def __init__(self, value, parent=None): QtWidgets.QGridLayout.__init__(self) font = tuple_to_qfont(value) assert font is not None # Font family self.family = QtWidgets.QFontComboBox(parent) self.family.setCurrentFont(font) self.addWidget(self.family, 0, 0, 1, -1) # Font size self.size = QtWidgets.QComboBox(parent) self.size.setEditable(True) sizelist = [*range(6, 12), *range(12, 30, 2), 36, 48, 72] size = font.pointSize() if size not in sizelist: sizelist.append(size) sizelist.sort() self.size.addItems([str(s) for s in sizelist]) self.size.setCurrentIndex(sizelist.index(size)) self.addWidget(self.size, 1, 0) # Italic or not self.italic = QtWidgets.QCheckBox(self.tr("Italic"), parent) self.italic.setChecked(font.italic()) self.addWidget(self.italic, 1, 1) # Bold or not self.bold = QtWidgets.QCheckBox(self.tr("Bold"), parent) self.bold.setChecked(font.bold()) self.addWidget(self.bold, 1, 2)
def get_Galtemplate_layout(self): self.Galtemplate = QtWidgets.QGroupBox('Galaxy Template') self.Galplot = QtWidgets.QCheckBox('Plot template', self) self.Galz_label = QtWidgets.QLabel('z = ', self) self.Galz = QtWidgets.QLineEdit('{:5.4f}'.format(self.z[1]), self) self.Galcolor_label = QtWidgets.QLabel('Color: ', self) self.Galcolor = QtWidgets.QLineEdit(self.linecolor[1], self) self.Galscale_label = QtWidgets.QLabel('Scale factor: ', self) self.Galscale = QtWidgets.QLineEdit('{:5.2f}'.format( self.linescale[1], self)) self.Gallabels = QtWidgets.QCheckBox('Plot labels', self) self.Galplot.stateChanged.connect(self.update_figures) self.Galz.returnPressed.connect(self.update_redshifts) self.Galcolor.returnPressed.connect(self.update_linecolors) self.Galscale.returnPressed.connect(self.update_linescales) self.Gallabels.stateChanged.connect(self.update_figures) # the layout layout = QtWidgets.QGridLayout() layout.addWidget(self.Galplot, 0, 0, 1, 2) layout.addWidget(self.Gallabels, 0, 2, 1, 2) layout.addWidget(self.Galz_label, 1, 0, 1, 1) layout.addWidget(self.Galz, 1, 1, 1, 1) layout.addWidget(self.Galscale_label, 1, 2, 1, 1) layout.addWidget(self.Galscale, 1, 3, 1, 1) layout.addWidget(self.Galcolor_label, 2, 0, 1, 1) layout.addWidget(self.Galcolor, 2, 1, 1, 1) self.Galtemplate.setLayout(layout)
def setup_figure(self): self.ui.start_pushButton.clicked.connect(self.start) self.ui.interrupt_pushButton.clicked.connect(self.interrupt) self.settings.x_axis.connect_to_widget(self.ui.x_axis_comboBox) self.settings.x_axis.add_listener(self.update_display) self.acq_mode.connect_to_widget(self.ui.acq_mode_comboBox) if hasattr(self, 'shutter_open'): CB_widget = QtWidgets.QCheckBox('use shutter') self.settings.use_shutter.connect_to_widget(CB_widget) self.ui.power_scan_GroupBox.layout().addWidget(CB_widget) else: self.settings['use_shutter'] = False self.settings.use_shutter.change_readonly(True) self.settings.manual_acq_times.connect_to_widget(self.ui.manual_acq_times_lineEdit) self.ui.manual_acq_times_lineEdit.setVisible(False) self.settings.acq_mode.add_listener(self.on_change_acq_mode) self.power_wheel_range.min.connect_to_widget(self.ui.power_wheel_min_doubleSpinBox) self.power_wheel_range.max.connect_to_widget(self.ui.power_wheel_max_doubleSpinBox) self.power_wheel_range.num.connect_to_widget(self.ui.power_wheel_num_doubleSpinBox) self.power_wheel_range.step.connect_to_widget(self.ui.power_wheel_step_doubleSpinBox) self.power_wheel_range.sweep_type.connect_to_widget(self.ui.sweep_type_comboBox) # Hardware connections layout = self.ui.collect_groupBox.layout() hw_list = self.app.hardware.keys() self.installed_hw = {} for key in self.hws.keys(): if key in hw_list: CB_widget = QtWidgets.QCheckBox(key) lq = getattr(self.settings, 'collect_{}'.format(key)) lq.connect_to_widget(CB_widget) SP_widget = QtWidgets.QDoubleSpinBox() Tacq_lq = getattr(self.app.hardware[key].settings, self.hws[key]) Tacq_lq.connect_to_widget(SP_widget) layout.addRow(CB_widget, SP_widget) self.installed_hw.update({key: Tacq_lq}) # Plot if hasattr(self, 'graph_layout'): self.graph_layout.deleteLater() # see http://stackoverflow.com/questions/9899409/pyside-removing-a-widget-from-a-layout del self.graph_layout self.graph_layout=pg.GraphicsLayoutWidget() self.ui.plot_groupBox.layout().addWidget(self.graph_layout) self.power_plot = self.graph_layout.addPlot(title="Power Scan") self.display_ready = False self.status = {'title':'starting power scan', 'color':'y'}
def get_print_layout(self): self.print = QtWidgets.QGroupBox('Save figure') self.savefile_label = QtWidgets.QLabel('File:', self) self.savefile = QtWidgets.QLineEdit('./JWSTfilter.pdf', self) self.savec1 = QtWidgets.QCheckBox('Canvas 1', self) self.savec2 = QtWidgets.QCheckBox('Canvas 2', self) self.save = QtWidgets.QPushButton('Save', self) self.save.clicked.connect(self.save_figures) layout = QtWidgets.QGridLayout() layout.addWidget(self.savefile_label, 0, 0) layout.addWidget(self.savefile, 0, 1, 1, 2) layout.addWidget(self.savec1, 1, 0, 1, 1) layout.addWidget(self.savec2, 1, 1, 1, 1) layout.addWidget(self.save, 1, 2, 1, 1) self.print.setLayout(layout)
def __init__(self, name, label, cmap, parent=None): super().__init__(parent) self.setObjectName(name) self.layout = QtWidgets.QVBoxLayout(self) self.layout.setAlignment(Qt.AlignLeft) self.label = QtWidgets.QLabel(label) self.label.setStyleSheet("QLabel { font-size: 10px; }") self.b = QtWidgets.QCheckBox("Add opacity point: ", self) self.b.stateChanged.connect(self.clickBox) self.b.setLayoutDirection(Qt.RightToLeft) nF = QtWidgets.QFrame() layout1 = QtWidgets.QHBoxLayout(nF) layout1.setContentsMargins(0, 0, 0, 0) layout1.setAlignment(Qt.AlignLeft) layout1.addWidget(self.b) layout1.addWidget(self.setup_cmap_frame(cmap)) self.layout.addWidget(self.label) self.layout.addWidget(nF) # Set shape of this QWidget self.setFrameShape(QtWidgets.QFrame.StyledPanel) self.setFrameShadow(QtWidgets.QFrame.Raised)
def setup_figure(self): hh_hw = self.hydraharp_hw HS = hh_hw.settings ui_filename = sibling_path(__file__, "hydraharp_channel_optimizer.ui") self.ui = load_qt_ui_file(ui_filename) #Connect hardware settings spinboxes = ['DeviceIndex', 'HistogramBins', 'Tacq', 'Resolution', 'StopCount', 'SyncOffset', 'CFDLevelSync', 'CFDZeroCrossSync', 'SyncRate', 'SyncPeriod',] for spinbox in spinboxes: widget = getattr(self.ui, '{}_doubleSpinBox'.format(spinbox)) getattr(HS, spinbox).connect_to_widget(widget) HS.SyncDivider.connect_to_widget(self.ui.SyncDivider_comboBox) HS.connected.connect_to_widget(self.ui.connected_checkBox) HS.Mode.connect_to_widget(self.ui.Mode_comboBox) HS.RefSource.connect_to_widget(self.ui.RefSource_comboBox) HS.StopOnOverflow.connect_to_widget(self.ui.StopOnOverflow_checkBox) HS.Binning.connect_to_widget(self.ui.Binning_comboBox) #settings for each channel: for i in range(self.n_channels): if i%2==0: q = int(i/2) self.add_timing_module(channels=np.arange(q,q+2)) #Channel optimizer self.settings.activation.connect_to_widget(self.ui.run_checkBox) self.settings.SyncRate_visible.connect_to_widget(self.ui.SyncRate_visible_checkBox) self.settings.history_len.connect_to_widget(self.ui.history_len_doubleSpinBox) self.settings.avg_len.connect_to_widget(self.ui.avg_len_doubleSpinBox) for i in range(self.n_channels): checkBox = QtWidgets.QCheckBox('show CountRate{}'.format(i)) if i%2 == 0: VLayout = QtWidgets.QVBoxLayout() self.ui.optimizer_layout.addLayout(VLayout) VLayout.addWidget(checkBox) self.settings.get_lq('CountRate{}_visible'.format(i)).connect_to_widget(checkBox) self.graph_layout=pg.GraphicsLayoutWidget() self.ui.channel_optimizer_GroupBox.layout().addWidget(self.graph_layout) self.plot = self.graph_layout.addPlot(title="Hydraharp Channel Optimizer") self.plotlines = {} self.avglines = {} colors = ['y','r','g','b'] for i,rate in enumerate(self.rates): self.plotlines.update({rate:self.plot.plot(pen=colors[i])}) avg_line = pg.InfiniteLine(angle=0, movable=False, pen=colors[i%len(colors)]) self.plot.addItem(avg_line) self.avglines.update({rate:avg_line})
def get_moment_layout(self): self.moment = QtWidgets.QGroupBox('Moment') # The moment range boxes self.mr = [] self.mr.append(QtWidgets.QLabel('Channel:', self)) self.mr.append( QtWidgets.QLineEdit('{:4d}'.format(self.range[2][0]), self)) self.mr.append(QtWidgets.QLabel(' to ', self)) self.mr.append( QtWidgets.QLineEdit('{:4d}'.format(self.range[2][1]), self)) # The mask buttons self.momentmask = [] masklabel = [ 'Use mask for moment-0 with values above RMS of: ', 'Use mask for moment-1 with values above RMS of: ', 'Use mask for moment-2 with values above RMS of: ' ] for label in masklabel: self.momentmask.append(QtWidgets.QCheckBox(label)) self.momentmaskvalue = [] for mmval in self.mmaskval: self.momentmaskvalue.append( QtWidgets.QLineEdit('{:10.7f}'.format(mmval), self)) # Gaussian moment plot self.gaussianmoment = QtWidgets.QCheckBox('Gaussian moment') self.gaussianmoment.setChecked(False) # update moment button self.momentbutton = QtWidgets.QPushButton('Calculate Moments', self) self.momentbutton.clicked.connect(self.get_moments) # create layout layout = QtWidgets.QGridLayout() for idx in np.arange(4): layout.addWidget(self.mr[idx], 0, idx) for idx in np.arange(3): layout.addWidget(self.momentmask[idx], idx + 1, 0, 1, 3) layout.addWidget(self.momentmaskvalue[idx], idx + 1, 3) layout.addWidget(self.gaussianmoment, 4, 0, 1, 4) layout.addWidget(self.momentbutton, 5, 0, 1, 4) self.moment.setLayout(layout)
def __init__(self,parent=None,selected=None,raw_adc=False,raw_time=False,pedestal=None,distribute=None,fft=False,**ignored): super().__init__(parent) self._layout = QtWidgets.QVBoxLayout(self) self.set_selected(selected) self.fft_checkbox = QtWidgets.QCheckBox('Plot FFT') self.fft_checkbox.setCheckState(QtCore.Qt.Checked if fft else QtCore.Qt.Unchecked) self._layout.addWidget(self.fft_checkbox) self.raw_checkbox = QtWidgets.QCheckBox('Plot raw ADC counts') self.raw_checkbox.setCheckState(QtCore.Qt.Checked if raw_adc else QtCore.Qt.Unchecked) self._layout.addWidget(self.raw_checkbox) self.raw_time_checkbox = QtWidgets.QCheckBox('Plot sample index') self.raw_time_checkbox.setCheckState(QtCore.Qt.Checked if raw_time else QtCore.Qt.Unchecked) self._layout.addWidget(self.raw_time_checkbox) redist_layout = QtWidgets.QHBoxLayout() self.redist_checkbox = QtWidgets.QCheckBox('Redistribute signals') self.redist_checkbox.setCheckState(QtCore.Qt.Checked if distribute else QtCore.Qt.Unchecked) redist_layout.addWidget(self.redist_checkbox) self.redist_amount = QtWidgets.QLineEdit('0' if distribute is None else str(distribute)) redist_layout.addWidget(self.redist_amount) self._layout.addLayout(redist_layout) ped_layout = QtWidgets.QHBoxLayout() self.baseline_checkbox = QtWidgets.QCheckBox('Correct baselines') self.baseline_checkbox.setCheckState(QtCore.Qt.Checked if pedestal else QtCore.Qt.Unchecked) ped_layout.addWidget(self.baseline_checkbox) self.ped_min = QtWidgets.QLineEdit('0' if pedestal is None else str(pedestal[0])) self.ped_min.setFixedWidth(100) ped_layout.addWidget(self.ped_min) self.ped_max = QtWidgets.QLineEdit('50' if pedestal is None else str(pedestal[1])) self.ped_max.setFixedWidth(100) ped_layout.addWidget(self.ped_max) self._layout.addLayout(ped_layout) buttons = QtWidgets.QDialogButtonBox(QtWidgets.QDialogButtonBox.Ok | QtWidgets.QDialogButtonBox.Cancel, QtCore.Qt.Horizontal, self) buttons.accepted.connect(self.accept) buttons.rejected.connect(self.reject) self._layout.addWidget(buttons)
def __init__(self, parent=None): super(StartP, self).__init__(parent) integerValidator = QtGui.QIntValidator(0, 300, self) dataLabel = QtWidgets.QLabel('Data Directory:') self.dataLine = QtWidgets.QLineEdit() dataBtn = QtWidgets.QPushButton('File', self) dataBtn.clicked.connect(self.getDir) self.registerField('dataDir*', self.dataLine) allelesLabel = QtWidgets.QLabel('Number of alleles:') self.allelesLine = QtWidgets.QLineEdit() self.allelesLine.setValidator(integerValidator) self.registerField('alleleCount*', self.allelesLine) groupsLabel = QtWidgets.QLabel('Number of Groups:') self.groupsLine = QtWidgets.QLineEdit() self.groupsLine.setValidator(integerValidator) self.registerField('groupCount*', self.groupsLine) self.b1 = QtWidgets.QCheckBox("Females") self.b1.setChecked(False) self.registerField('females', self.b1) comboLabel = QtWidgets.QLabel('Graphic Type:') self.combo = QtWidgets.QComboBox(self) self.combo.addItem('Allele Counts') self.combo.addItem('Allele Heatmap') self.combo.addItem('Allele Stack') self.combo.addItem('Allele Geo-Map') self.registerField('graphic', self.combo) grid = QtWidgets.QGridLayout() grid.setSpacing(10) grid.addWidget(dataLabel, 1, 0) grid.addWidget(self.dataLine, 1, 1) grid.addWidget(dataBtn, 1, 2) grid.addWidget(allelesLabel, 2, 0) grid.addWidget(self.allelesLine, 2, 1) grid.addWidget(groupsLabel, 3, 0) grid.addWidget(self.groupsLine, 3, 1) grid.addWidget(self.b1, 5, 1) grid.addWidget(comboLabel, 4, 0) grid.addWidget(self.combo, 4, 1) self.setLayout(grid)
def _add_figure(self, name): tab = QtWidgets.QWidget() overplot = QtWidgets.QCheckBox("Allow overplotting") overplot.setChecked(False) self._overplot[name] = overplot fig = Figure((5.0, 4.0), dpi=100) canvas = self.FigureCanvas(fig) canvas.setMinimumWidth(640) canvas.setParent(tab) toolbar = self.NavigationToolbar(canvas, tab) tab_label = QtWidgets.QLabel(name) tab_label.setMaximumHeight(20) layout = QtWidgets.QVBoxLayout() layout.addWidget(overplot) layout.addWidget(tab_label) layout.addWidget(canvas) layout.addWidget(toolbar) tab.setLayout(layout) self._tabs.addTab(tab, '{:.8}'.format(name)) return fig
def __init__(self, name, label, parent=None): super().__init__(parent) self.setObjectName(name) if self.objectName() == '3D_Int': self.b = QtWidgets.QCheckBox("Add opacity point?", self) self.b.stateChanged.connect(self.clickBox) self.layout = QtWidgets.QVBoxLayout(self) self.label = QtWidgets.QLabel(label) self.label.setStyleSheet("QLabel { font-size: 10px; }") self.slider = QRangeSlider(self) self.slider.setCallback(self.get_range) self.layout.addWidget(self.label) self.layout.addWidget(self.slider) # Set shape of this QWidget self.setFrameShape(QtWidgets.QFrame.StyledPanel) self.setFrameShadow(QtWidgets.QFrame.Raised)
def get_NIRSpec_layout(self): self.NIRSpec = QtWidgets.QGroupBox('NIRSpec spectral ranges') self.Nspec = [] for idx, filt in enumerate(self.Nsmodes): self.Nspec.append(QtWidgets.QCheckBox(filt, self)) self.Nspec.append(QtWidgets.QLabel('Color: ', self)) self.Nspec.append( QtWidgets.QLineEdit('{:6.4f}'.format(self.Nscolors[idx]), self)) for idx in np.arange(len(self.Nsmodes)): self.Nspec[3 * idx].stateChanged.connect(self.update_figures) self.Nspec[3 * idx + 2].returnPressed.connect( self.update_Nspeccolor) self.Nsselectall = QtWidgets.QPushButton('Select all', self) self.Nsselectall.clicked.connect(self.update_Nsselectall) # the layout layout = QtWidgets.QGridLayout() for idx in np.arange(len(self.Nsmodes)): for idx2 in np.arange(3): layout.addWidget(self.Nspec[3 * idx + idx2], idx, idx2) layout.addWidget(self.Nsselectall, 3 * idx + 1, 0, 1, 2) self.NIRSpec.setLayout(layout)
def get_MIRIfilters_layout(self): self.MIRIfilter = QtWidgets.QGroupBox('MIRI filters') self.Mfilter = [] for idx, filt in enumerate(self.Mfilters): self.Mfilter.append(QtWidgets.QCheckBox(filt, self)) self.Mfilter.append(QtWidgets.QLabel('Color: ', self)) self.Mfilter.append( QtWidgets.QLineEdit('{:6.4f}'.format(self.Mfcolors[idx]), self)) for idx in np.arange(len(self.Mfilters)): self.Mfilter[3 * idx].stateChanged.connect(self.update_figures) self.Mfilter[3 * idx + 2].returnPressed.connect( self.update_Mfiltercolor) self.Mfselectall = QtWidgets.QPushButton('Select all', self) self.Mfselectall.clicked.connect(self.update_Mfselectall) # the layout layout = QtWidgets.QGridLayout() for idx in np.arange(len(self.Mfilters)): for idx2 in np.arange(3): layout.addWidget(self.Mfilter[3 * idx + idx2], idx, idx2) layout.addWidget(self.Mfselectall, 3 * idx + 1, 0, 1, 2) self.MIRIfilter.setLayout(layout)
def __init__(self, parent=None): super(Page4, self).__init__(parent) integerValidator = QtGui.QIntValidator(0, 10, self) comboLabel = QtWidgets.QLabel('Graphic Type:') dataLabel = QtWidgets.QLabel('Data Directory:') self.dataLine = QtWidgets.QLineEdit() dataBtn = QtWidgets.QPushButton('File', self) dataBtn.clicked.connect(self.getDir) self.registerField('popDir*', self.dataLine) allelesLabel = QtWidgets.QLabel('Number of alleles:') self.allelesLine = QtWidgets.QLineEdit() self.allelesLine.setValidator(integerValidator) self.registerField('alleleCount2*', self.allelesLine) groupsLabel = QtWidgets.QLabel('Number of Groups:') self.groupsLine = QtWidgets.QLineEdit() self.groupsLine.setValidator(integerValidator) self.registerField('groupCount2*', self.groupsLine) self.b1 = QtWidgets.QCheckBox("Females") self.b1.setChecked(False) self.registerField('females', self.b1) grid = QtWidgets.QGridLayout() grid.setSpacing(10) grid.addWidget(dataLabel, 1, 0) grid.addWidget(self.dataLine, 1, 1) grid.addWidget(dataBtn, 1, 2) grid.addWidget(allelesLabel, 2, 0) grid.addWidget(self.allelesLine, 2, 1) grid.addWidget(groupsLabel, 3, 0) grid.addWidget(self.groupsLine, 3, 1) grid.addWidget(self.b1, 4, 1) self.setLayout(grid)
def __init__(self): self.running: bool = False self.beta: float = 0 self.range_alpha: List = [] self.hide_alpha_zero: bool = False self.need_to_remake: bool = True self.ready_to_go = False self.logarithmic = False self.simulations_per_tick: int = 0 super().__init__() self._main = QtWidgets.QWidget() self.setCentralWidget(self._main) # layout = QtWidgets.QVBoxLayout(self._main) layout = QtWidgets.QGridLayout(self._main) self.setWindowTitle("Caching Algorithm Simulation") self.static_canvas = FigureCanvas(Figure(figsize=(6, 4))) layout.addWidget(self.static_canvas, 0, 0) # self.addToolBar(NavigationToolbar(static_canvas, self)) self.dynamic_canvas = FigureCanvas(Figure(figsize=(6, 4))) layout.addWidget(self.dynamic_canvas, 1, 0) # self.addToolBar(QtCore.Qt.BottomToolBarArea, # NavigationToolbar(dynamic_canvas, self)) self.file_distribution = FigureCanvas(Figure(figsize=(6, 4))) layout.addWidget(self.file_distribution, 0, 1) self._file_dist = self.file_distribution.figure.subplots() # mini UI layout for button input entry_corner = QtWidgets.QGridLayout(self._main) layout.addLayout(entry_corner, 1, 1) miniui = QtWidgets.QGridLayout(self._main) entry_corner.addLayout(miniui, 0, 0) start_stop = QtWidgets.QGridLayout(self._main) miniui.addLayout(start_stop, 0, 0) entry_text = QtWidgets.QGridLayout(self._main) entry_corner.addLayout(entry_text, 0, 1) self.toggle_button = QtWidgets.QPushButton("Run") self.toggle_button.setCheckable(True) self.toggle_button.setFixedWidth(80) self.toggle_button.toggled.connect(self.toggle_run) self.restart_button = QtWidgets.QPushButton("Restart") self.restart_button.setFixedWidth(80) self.restart_button.clicked.connect(self._flag_for_restart) start_stop.addWidget(self.toggle_button, 0, 0) start_stop.addWidget(self.restart_button, 1, 0) # checkboxes self.toggle_buttons = QtWidgets.QGridLayout(self._main) miniui.addLayout(self.toggle_buttons, 1, 0) self.box_hide_alpha_zero = QtWidgets.QCheckBox( "Hide \\alpha=0/Show \\alpha=1", self ) self.box_hide_alpha_zero.stateChanged.connect(self.clicked_hide_a) self.toggle_buttons.addWidget(self.box_hide_alpha_zero, 0, 0) # needs_restart_label = QtWidgets.QLabel("Requires Restart") # self.toggle_buttons.addWidget(needs_restart_label, 1, 0) self.is_logarithmic = QtWidgets.QCheckBox("Logarithmic \\alpha") self.is_logarithmic.stateChanged.connect(self.clicked_logarithmic) self.toggle_buttons.addWidget(self.is_logarithmic, 2, 0) # entries user_num_label = QtWidgets.QLabel("Number of Users") entry_text.addWidget(user_num_label, 0, 0) self.user_num_entry = QtWidgets.QLineEdit(self) self.user_num_entry.setFixedWidth(80) entry_text.addWidget(self.user_num_entry, 1, 0) file_num_label = QtWidgets.QLabel("Number of Files") entry_text.addWidget(file_num_label, 2, 0) self.file_num_entry = QtWidgets.QLineEdit(self) self.file_num_entry.setFixedWidth(80) entry_text.addWidget(self.file_num_entry, 3, 0) cache_size_label = QtWidgets.QLabel("Cached Files / User") entry_text.addWidget(cache_size_label, 4, 0) self.cache_size_entry = QtWidgets.QLineEdit(self) self.cache_size_entry.setFixedWidth(80) entry_text.addWidget(self.cache_size_entry, 5, 0) requested_size_label = QtWidgets.QLabel("Requested Files / User") entry_text.addWidget(requested_size_label, 6, 0) self.requested_size_entry = QtWidgets.QLineEdit(self) self.requested_size_entry.setFixedWidth(80) entry_text.addWidget(self.requested_size_entry, 7, 0) alpha_start_label = QtWidgets.QLabel("\\alpha Start") entry_text.addWidget(alpha_start_label, 0, 1) self.alpha_start_entry = QtWidgets.QLineEdit(self) self.alpha_start_entry.setFixedWidth(80) entry_text.addWidget(self.alpha_start_entry, 1, 1) alpha_end_label = QtWidgets.QLabel("\\alpha End") entry_text.addWidget(alpha_end_label, 2, 1) self.alpha_end_entry = QtWidgets.QLineEdit(self) self.alpha_end_entry.setFixedWidth(80) entry_text.addWidget(self.alpha_end_entry, 3, 1) num_of_alpha_label = QtWidgets.QLabel("# d\\alpha Simulations") entry_text.addWidget(num_of_alpha_label, 4, 1) self.num_of_alpha_entry = QtWidgets.QLineEdit(self) self.num_of_alpha_entry.setFixedWidth(80) entry_text.addWidget(self.num_of_alpha_entry, 5, 1) zipf_label = QtWidgets.QLabel("Zipf constant a") entry_text.addWidget(zipf_label, 6, 1) self.zipf_entry = QtWidgets.QLineEdit(self) self.zipf_entry.setFixedWidth(80) entry_text.addWidget(self.zipf_entry, 7, 1) simulation_ptick_label = QtWidgets.QLabel("Simulations per tick") entry_text.addWidget(simulation_ptick_label, 8, 0) self.simulation_ptick_entry = QtWidgets.QLineEdit(self) self.simulation_ptick_entry.setFixedWidth(80) entry_text.addWidget(self.simulation_ptick_entry, 9, 0) self._static_ax = self.static_canvas.figure.subplots() self._dynamic_ax = self.dynamic_canvas.figure.subplots() self._timer = self.dynamic_canvas.new_timer( 100, [(self._update_canvas, (), {})] ) # set box data manually self.user_num_entry.setText(str(DEFAULT_USER_NUM)) self.file_num_entry.setText(str(DEFAULT_NUM_OF_FILES)) self.cache_size_entry.setText(str(DEFAULT_CACHE_SIZE)) self.requested_size_entry.setText(str(DEFAULT_REQUEST_NUM)) self.alpha_start_entry.setText(str(DEFAULT_ALPHA_START)) self.alpha_end_entry.setText(str(DEFAULT_ALPHA_END)) self.num_of_alpha_entry.setText(str(DEFAULT_NUMBER_OF_ALPHA)) self.zipf_entry.setText(str(DEFAULT_ZIPF)) self.simulation_ptick_entry.setText(str(DEFAULT_SIMULATIONS_PER_TICK))
def initManualtab(self): self._manu.gridlayout = QtWidgets.QGridLayout() self._manu.setLayout(self._manu.gridlayout) measurebutton = QtWidgets.QPushButton('Start measurement', self) measurebutton.setToolTip("Start a measurement") self._manu.gridlayout.addWidget(measurebutton, 0, 0, 1, 1, QtCore.Qt.AlignLeft) measurebutton.clicked.connect(self.start_measure) # stopmeasurebutton = QtWidgets.QPushButton('Stop measurement', self) stopmeasurebutton.setToolTip("Stop a measurement") self._manu.gridlayout.addWidget(stopmeasurebutton, 0, 1, 1, 1, QtCore.Qt.AlignLeft) stopmeasurebutton.clicked.connect(self.stop_measure) # savemeasurebutton = QtWidgets.QPushButton('Save measurement', self) savemeasurebutton.setToolTip("Save the last measurement") self._manu.gridlayout.addWidget(savemeasurebutton, 0, 2, 1, 1, QtCore.Qt.AlignLeft) savemeasurebutton.clicked.connect(self.save_measurement) # self.setsr80textbox = QtWidgets.QLineEdit(self) self.setsr80textbox.setText('20') self._manu.gridlayout.addWidget(self.setsr80textbox, 1, 0, 1, 1, QtCore.Qt.AlignLeft) setsr80button = QtWidgets.QPushButton('Set SR80 temperature', self) self._manu.gridlayout.addWidget(setsr80button, 1, 1, 1, 1, QtCore.Qt.AlignLeft) setsr80button.clicked.connect(self.set_sr80temp) # self.setsr800textbox = QtWidgets.QLineEdit(self) self.setsr800textbox.setText('20') self._manu.gridlayout.addWidget(self.setsr800textbox, 2, 0, 1, 1, QtCore.Qt.AlignLeft) setsr800button = QtWidgets.QPushButton('Set SR800 temperature', self) self._manu.gridlayout.addWidget(setsr800button, 2, 1, 1, 1, QtCore.Qt.AlignLeft) setsr800button.clicked.connect(self.set_sr800temp) # reinitmotorbutton = QtWidgets.QPushButton('Reinit motor', self) reinitmotorbutton.setToolTip("Re-Initialize Mirror") self._manu.gridlayout.addWidget(reinitmotorbutton, 3, 0, 1, 1, QtCore.Qt.AlignLeft) reinitmotorbutton.clicked.connect(self.reinitmotor) # roofbutton = QtWidgets.QPushButton('Point to roof', self) roofbutton.setToolTip("Point mirror to roof") self._manu.gridlayout.addWidget(roofbutton, 4, 0, 1, 1, QtCore.Qt.AlignLeft) roofbutton.clicked.connect(self.motor_roof) # sr80button = QtWidgets.QPushButton('Point to SR80', self) sr80button.setToolTip("Point mirror to SR80 black body") self._manu.gridlayout.addWidget(sr80button, 5, 0, 1, 1, QtCore.Qt.AlignLeft) sr80button.clicked.connect(self.motor_sr80) # sr800button = QtWidgets.QPushButton('Point to SR800', self) sr800button.setToolTip("Point mirror to SR800 black body") self._manu.gridlayout.addWidget(sr800button, 6, 0, 1, 1, QtCore.Qt.AlignLeft) sr800button.clicked.connect(self.motor_sr800) # ht1button = QtWidgets.QPushButton('Point to ht1', self) ht1button.setToolTip("Point mirror to self build heat bed black body") self._manu.gridlayout.addWidget(ht1button, 7, 0, 1, 1, QtCore.Qt.AlignLeft) ht1button.clicked.connect(self.motor_ht1) # rtbutton = QtWidgets.QPushButton('Point to rt', self) rtbutton.setToolTip( "Point mirror to self built room temperature black body") self._manu.gridlayout.addWidget(rtbutton, 8, 0, 1, 1, QtCore.Qt.AlignLeft) rtbutton.clicked.connect(self.motor_rt) # ir301button = QtWidgets.QPushButton('Point to IR301', self) ir301button.setToolTip("Point mirror to IR301 black body") self._manu.gridlayout.addWidget(ir301button, 9, 0, 1, 1, QtCore.Qt.AlignLeft) ir301button.clicked.connect(self.motor_ir301) # parkbutton = QtWidgets.QPushButton('Park mirror', self) parkbutton.setToolTip("Point mirror to park position") self._manu.gridlayout.addWidget(parkbutton, 10, 0, 1, 1, QtCore.Qt.AlignLeft) parkbutton.clicked.connect(self.motor_park) # sr800onbutton = QtWidgets.QPushButton('Switch SR800 on', self) sr800onbutton.setToolTip("Switch SR800 on") self._manu.gridlayout.addWidget(sr800onbutton, 3, 1, 1, 1, QtCore.Qt.AlignLeft) sr800onbutton.clicked.connect(self.switch_sr800_on) # sr800offbutton = QtWidgets.QPushButton('Switch SR800 off', self) sr800offbutton.setToolTip("Switch SR800 off") self._manu.gridlayout.addWidget(sr800offbutton, 4, 1, 1, 1, QtCore.Qt.AlignLeft) sr800offbutton.clicked.connect(self.switch_sr800_off) # # ir301onbutton = QtWidgets.QPushButton('Switch IR301 on', self) ir301onbutton.setToolTip("Switch IR301 on") self._manu.gridlayout.addWidget(ir301onbutton, 5, 1, 1, 1, QtCore.Qt.AlignLeft) ir301onbutton.clicked.connect(self.switch_ir301_on) # ir301offbutton = QtWidgets.QPushButton('Switch IR301 off', self) ir301offbutton.setToolTip("Switch IR301 off") self._manu.gridlayout.addWidget(ir301offbutton, 6, 1, 1, 1, QtCore.Qt.AlignLeft) ir301offbutton.clicked.connect(self.switch_ir301_off) # emailbutton = QtWidgets.QPushButton('Send diagnostics email', self) emailbutton.setToolTip("Send diagnostics emai") self._manu.gridlayout.addWidget(emailbutton, 7, 1, 1, 1, QtCore.Qt.AlignLeft) emailbutton.clicked.connect(self.send_diag_email) # self.paramtextbox = QtWidgets.QLineEdit(self) self.paramtextbox.setText(' | '.join( [k + ':' + str(j) for k, j in self.v80.meas_params.items()])) self._manu.gridlayout.addWidget(self.paramtextbox, 0, 3, 1, 4) parambutton = QtWidgets.QPushButton('Update params', self) parambutton.setToolTip("Set Vertex80 measurement parameters") self._manu.gridlayout.addWidget(parambutton, 1, 5, 1, 1, QtCore.Qt.AlignRight) parambutton.clicked.connect(self.setv80param) # self.v80commcheckbox = QtWidgets.QCheckBox( 'Block Vertex80 communications') self.v80commcheckbox.stateChanged.connect(self.set_blockv80comm) self._manu.gridlayout.addWidget(self.v80commcheckbox, 2, 3, 1, 1, QtCore.Qt.AlignLeft) # self.sr80commcheckbox = QtWidgets.QCheckBox( 'Block SR80 communications') self.sr80commcheckbox.stateChanged.connect(self.set_blocksr80comm) self._manu.gridlayout.addWidget(self.sr80commcheckbox, 3, 3, 1, 1, QtCore.Qt.AlignLeft) # # # self.dirlistwidget = QtWidgets.QListWidget() # self.make_listwidget() ##import ipdb; ipdb.set_trace() # self.dirlistwidget.itemClicked.connect(self.listclick) # self.gridlayout.addWidget(self.dirlistwidget, 1,3,3,2, QtCore.Qt.AlignRight) # # self.show_seq = QtWidgets.QTextEdit(self._main) # self._main.gridlayout.addWidget(self.show_seq) # Status Box self.Init_StatusBox()
def setup(self): for label, value in self.data: if DEBUG: print("value:", value) if label is None and value is None: # Separator: (None, None) self.formlayout.addRow(QtWidgets.QLabel(" "), QtWidgets.QLabel(" ")) self.widgets.append(None) continue elif label is None: # Comment self.formlayout.addRow(QtWidgets.QLabel(value)) self.widgets.append(None) continue elif tuple_to_qfont(value) is not None: field = FontLayout(value, self) elif label.lower() not in BLACKLIST and is_color_like(value): field = ColorLayout(to_qcolor(value), self) elif isinstance(value, six.string_types): field = QtWidgets.QLineEdit(value, self) elif isinstance(value, (list, tuple)): if isinstance(value, tuple): value = list(value) selindex = value.pop(0) field = QtWidgets.QComboBox(self) if isinstance(value[0], (list, tuple)): keys = [key for key, _val in value] value = [val for _key, val in value] else: keys = value field.addItems(value) if selindex in value: selindex = value.index(selindex) elif selindex in keys: selindex = keys.index(selindex) elif not isinstance(selindex, int): print("Warning: '%s' index is invalid (label: " "%s, value: %s)" % (selindex, label, value), file=STDERR) selindex = 0 field.setCurrentIndex(selindex) elif isinstance(value, bool): field = QtWidgets.QCheckBox(self) if value: field.setCheckState(QtCore.Qt.Checked) else: field.setCheckState(QtCore.Qt.Unchecked) elif isinstance(value, float): field = QtWidgets.QLineEdit(repr(value), self) field.setCursorPosition(0) field.setValidator(QtGui.QDoubleValidator(field)) field.validator().setLocale(QtCore.QLocale("C")) dialog = self.get_dialog() dialog.register_float_field(field) field.textChanged.connect(lambda text: dialog.update_buttons()) elif isinstance(value, int): field = QtWidgets.QSpinBox(self) field.setRange(-1e9, 1e9) field.setValue(value) elif isinstance(value, datetime.datetime): field = QtWidgets.QDateTimeEdit(self) field.setDateTime(value) elif isinstance(value, datetime.date): field = QtWidgets.QDateEdit(self) field.setDate(value) else: field = QtWidgets.QLineEdit(repr(value), self) self.formlayout.addRow(label, field) self.widgets.append(field)
def get_controls_layout(self): self.controls = QtWidgets.QGroupBox('Image controls') # min and max values self.min_label = QtWidgets.QLabel(self) self.min_label.setText('Min: ') self.min = QtWidgets.QLineEdit('{:10.7f}'.format(self.vmin), self) self.min.setToolTip('The minimum value to display') self.min.returnPressed.connect(self.update_min) self.max_label = QtWidgets.QLabel(self) self.max_label.setText('Max: ') self.max = QtWidgets.QLineEdit('{:10.7f}'.format(self.vmax), self) self.max.setToolTip('The maxmimum value to display.') self.max.returnPressed.connect(self.update_max) # RMS value self.rms = QtWidgets.QLabel(self) strrms = np.nanmedian(np.sqrt(self.qube.variance[self.channel])) self.rms.setText('RMS value: {:10.7f}'.format(strrms)) # Contour levels self.levels_label = QtWidgets.QLabel(self) self.levels_label.setText('Contour levels: ') self.levels = QtWidgets.QLineEdit(__arrtostr__(self.contours), self) self.levels.setToolTip('Contours levels to display ' + '(in terms of RMS). Should be a list of ' + 'floats separated by commas.') self.levels.returnPressed.connect(self.update_contours) # color map self.colormap_label = QtWidgets.QLabel(self) self.colormap_label.setText('Colormap: ') self.colormap = QtWidgets.QLineEdit('{}'.format(self.cmap), self) self.colormap.setToolTip('The color map to use for the display') self.colormap.returnPressed.connect(self.update_cmap) # Contour colors self.levelcolor_label = QtWidgets.QLabel(self) self.levelcolor_label.setText('Contour Color: ') self.levelcolor = QtWidgets.QLineEdit('{}'.format(self.ccolor), self) self.levelcolor.setToolTip('The color of the contours') self.levelcolor.returnPressed.connect(self.update_levelcolor) # plot mask button self.mask = QtWidgets.QCheckBox('Plot mask') self.mask.setToolTip('Plot the mask used for the fitting.') self.mask.clicked.connect(self.update_figures) # plot chi squared value self.chisq = QtWidgets.QLabel(self) self.chisq.setText('Red. Chi-Squared: ' + '{:10.7f}'.format(self.chisquared)) # create layout layout = QtWidgets.QGridLayout() layout.addWidget(self.min_label, 0, 0) layout.addWidget(self.min, 0, 1) layout.addWidget(self.max_label, 1, 0) layout.addWidget(self.max, 1, 1) layout.addWidget(self.rms, 0, 2, 1, 2) layout.addWidget(self.levels_label, 1, 2) layout.addWidget(self.levels, 1, 3) layout.addWidget(self.colormap_label, 0, 4) layout.addWidget(self.colormap, 0, 5) layout.addWidget(self.levelcolor_label, 1, 4) layout.addWidget(self.levelcolor, 1, 5) layout.addWidget(self.mask, 0, 6) layout.addWidget(self.chisq, 1, 6) self.controls.setLayout(layout)
def make_sensor_buttons(self, sensors): # Remove all sensor checkbox widgets from the layout # every time new data is loaded for i in range(self.ui.verticalLayout_left_top.count()): item = self.ui.verticalLayout_left_top.itemAt(i) # self.verticalLayout_left_top.removeWidget(item.widget()) widget = item.widget() if widget is not None: widget.deleteLater() for i in range(self.ui.verticalLayout_bottom.count()): item = self.ui.verticalLayout_bottom.itemAt(i) # self.verticalLayout_left_top.removeWidget(item.widget()) widget = item.widget() if widget is not None: widget.deleteLater() # sensors' keys are names of all sensors which carry # all of the data associated with it # Make copy of it so we can use its keys and assign radio buttons to it # If we do not make a copy then the sensors values would get # overwritten by radio button objects self.sensor_dict = dict(sensors) self.sensor_dict2 = dict(sensors) # Counter added to figure out when the last item was added # Set alignment of the last item to push all the radio buttons up counter = len(sensors.items()) for key, value in sensors.items(): counter -= 1 self.sensor_radio_btns = QtWidgets.QRadioButton(key, self) self.sensor_check_btns = QtWidgets.QCheckBox(key, self) self.sensor_dict[key] = self.sensor_radio_btns self.sensor_dict2[key] = self.sensor_check_btns self.ui.buttonGroup_data.addButton(self.sensor_dict[key]) self.ui.buttonGroup_residual.addButton(self.sensor_dict2[key]) if (counter > 0): self.ui.verticalLayout_left_top.addWidget( self.sensor_dict[key]) self.ui.verticalLayout_bottom.addWidget(self.sensor_dict2[key]) else: self.ui.verticalLayout_left_top.addWidget( self.sensor_dict[key], 0, QtCore.Qt.AlignTop) self.ui.verticalLayout_bottom.addWidget( self.sensor_dict2[key], 0, QtCore.Qt.AlignTop) self.sensor_dict[key].setText(key) # radio_btn_HF = QtWidgets.QRadioButton("Minute", self) # radio_btn_HF.setChecked(True) self.mode = self.ui.radioButton_Minute.text() self.sensor_dict["PRD"].setChecked(True) self.sens_str = "PRD" # self.sensor_dict2["PRD"].setEnabled(False) self.sensor_dict2["ALL"].setEnabled(False) self.plot(all=False) self.ui.buttonGroup_data.buttonClicked.connect(self.on_sensor_changed) self.ui.buttonGroup_residual.buttonClicked.connect( self.on_residual_sensor_changed) self.ui.buttonGroup_resolution.buttonClicked.connect( self.on_frequency_changed)
def setup(self): for label, value in self.data: if label is None and value is None: # Separator: (None, None) self.formlayout.addRow(QtWidgets.QLabel(" "), QtWidgets.QLabel(" ")) self.widgets.append(None) continue elif label is None: # Comment self.formlayout.addRow(QtWidgets.QLabel(value)) self.widgets.append(None) continue elif tuple_to_qfont(value) is not None: field = FontLayout(value, self) elif (label.lower() not in BLACKLIST and mcolors.is_color_like(value)): field = ColorLayout(to_qcolor(value), self) elif isinstance(value, str): field = QtWidgets.QLineEdit(value, self) elif isinstance(value, (list, tuple)): if isinstance(value, tuple): value = list(value) # Note: get() below checks the type of value[0] in self.data so # it is essential that value gets modified in-place. # This means that the code is actually broken in the case where # value is a tuple, but fortunately we always pass a list... selindex = value.pop(0) field = QtWidgets.QComboBox(self) if isinstance(value[0], (list, tuple)): keys = [key for key, _val in value] value = [val for _key, val in value] else: keys = value field.addItems(value) if selindex in value: selindex = value.index(selindex) elif selindex in keys: selindex = keys.index(selindex) elif not isinstance(selindex, Integral): _log.warning( "index '%s' is invalid (label: %s, value: %s)", selindex, label, value) selindex = 0 field.setCurrentIndex(selindex) elif isinstance(value, bool): field = QtWidgets.QCheckBox(self) if value: field.setCheckState(QtCore.Qt.Checked) else: field.setCheckState(QtCore.Qt.Unchecked) elif isinstance(value, Integral): field = QtWidgets.QSpinBox(self) field.setRange(-10**9, 10**9) field.setValue(value) elif isinstance(value, Real): field = QtWidgets.QLineEdit(repr(value), self) field.setCursorPosition(0) field.setValidator(QtGui.QDoubleValidator(field)) field.validator().setLocale(QtCore.QLocale("C")) dialog = self.get_dialog() dialog.register_float_field(field) field.textChanged.connect(lambda text: dialog.update_buttons()) elif isinstance(value, datetime.datetime): field = QtWidgets.QDateTimeEdit(self) field.setDateTime(value) elif isinstance(value, datetime.date): field = QtWidgets.QDateEdit(self) field.setDate(value) else: field = QtWidgets.QLineEdit(repr(value), self) self.formlayout.addRow(label, field) self.widgets.append(field)
def create_main_frame(self): self.main_frame = QtWidgets.QWidget() plot_frame = QtWidgets.QWidget() self.dpi = 100 self.fig = Figure((6.0, 4.0), dpi=self.dpi) self.canvas = FigureCanvas(self.fig) self.canvas.setParent(self.main_frame) self.axes = self.fig.add_subplot(111, projection='3d') self.mpl_toolbar = NavigationToolbar(self.canvas, self.main_frame) log_label = QtWidgets.QLabel("Data series:") self.series_list_view = QtWidgets.QListView() self.series_list_view.setModel(self.series_list_model) spin_label1 = QtWidgets.QLabel('X from') self.from_spin = QtWidgets.QSpinBox() spin_label2 = QtWidgets.QLabel('to') self.to_spin = QtWidgets.QSpinBox() spins_hbox = QtWidgets.QHBoxLayout() spins_hbox.addWidget(spin_label1) spins_hbox.addWidget(self.from_spin) spins_hbox.addWidget(spin_label2) spins_hbox.addWidget(self.to_spin) spins_hbox.addStretch(1) self.legend_cb = QtWidgets.QCheckBox("Show L&egend") self.legend_cb.setChecked(False) self.legend_pp = QtWidgets.QCheckBox("P-polarization") self.legend_pp.setChecked(False) self.legend_sp = QtWidgets.QCheckBox("S-polarization") self.legend_sp.setChecked(False) self.show_button = QtWidgets.QPushButton("&Show") #self.connect(self.show_button, SIGNAL('clicked()'), self.on_show) self.show_button.clicked.connect(self.on_show) left_vbox = QtWidgets.QVBoxLayout() left_vbox.addWidget(self.canvas) left_vbox.addWidget(self.mpl_toolbar) right_vbox = QtWidgets.QVBoxLayout() right_vbox.addWidget(log_label) right_vbox.addWidget(self.series_list_view) right_vbox.addLayout(spins_hbox) right_vbox.addWidget(self.legend_cb) right_vbox.addWidget(self.legend_pp) right_vbox.addWidget(self.legend_sp) right_vbox.addWidget(self.show_button) right_vbox.addStretch(1) hbox = QtWidgets.QHBoxLayout() hbox.addLayout(left_vbox) hbox.addLayout(right_vbox) self.main_frame.setLayout(hbox) self.setCentralWidget(self.main_frame)
def show(time, data, com, com_dot, com_ddot, com_i, grf, angles, stick): qapp = QtWidgets.QApplication(sys.argv) app = QtWidgets.QMainWindow() app.setWindowTitle("Analyse biomécanique de Kinovea") _main = QtWidgets.QWidget() app.setCentralWidget(_main) main_layout = QtWidgets.QHBoxLayout(_main) # Body position column body_position_layout = QtWidgets.QVBoxLayout() main_layout.addLayout(body_position_layout) # Show model body_position_canvas = FigureCanvas(Figure(figsize=(5, 3))) body_position_layout.addWidget(body_position_canvas) body_position_ax = body_position_canvas.figure.subplots() time_idx = 0 body_position_ax.set_ylabel("Axe vertical (m)") body_position_ax.set_xlabel("Axe frontal (m)") body_position_text = body_position_ax.text( 0.5, 0.99, "", fontsize=12, horizontalalignment='center', verticalalignment='top', transform=body_position_ax.transAxes ) kino_n_image = 5 kino_pre_plot = [] kino_post_plot = [] kino_colors = np.linspace(0.88, 0, kino_n_image) for i in range(kino_n_image): i2 = kino_n_image - 1 - i kino_pre_plot.append( body_position_ax.plot(np.nan, np.nan, color=[kino_colors[i2], kino_colors[i2], kino_colors[i2]]) ) kino_post_plot.append( body_position_ax.plot(np.nan, np.nan, color=[kino_colors[i2], kino_colors[i2], kino_colors[i2]]) ) stick_plot = body_position_ax.plot(np.nan, np.nan, 'r') comi_plot = body_position_ax.plot(np.nan, np.nan, 'k.') com_plot = body_position_ax.plot(np.nan, np.nan, 'k.', markersize=20) def move_stick_figure(time_idx): body_position_ax.set_title(f"Position du corps à l'instant {time[time_idx]:.2f} s") body_position_text.set_text(f"CoM = [{str(np.round(com[0, 0, time_idx], 2))}; {str(np.round(com[1, 0, time_idx], 2))}]") for i in range(kino_n_image): if time_idx - i - 1 >= 0 and kino_pre_check.isChecked(): kino_pre_plot[i][0].set_data(data[0, stick, time_idx - i - 1], data[1, stick, time_idx - i - 1]) else: kino_pre_plot[i][0].set_data(np.nan, np.nan) if time_idx + i + 1 < data.shape[2] and kino_post_check.isChecked(): kino_post_plot[i][0].set_data(data[0, stick, time_idx + i + 1], data[1, stick, time_idx + i + 1]) else: kino_post_plot[i][0].set_data(np.nan, np.nan) stick_plot[0].set_data(data[0, stick, time_idx], data[1, stick, time_idx]) comi_plot[0].set_data(com_i[0, :, time_idx], com_i[1, :, time_idx]) com_plot[0].set_data(com[0, 0, time_idx], com[1, 0, time_idx]) # Force axis equal with min and max data body_position_ax.plot( [np.min(data[0, :, :]), np.max(data[0, :, :])], [np.min(data[1, :, :]) - (np.max(data[1, :, :]) - np.min(data[1, :, :]))*0.1 , np.max(data[1, :, :]) + (np.max(data[1, :, :]) - np.min(data[1, :, :]))*0.1 ], 'w.' ) body_position_ax.axis('equal') time_slider = QtWidgets.QSlider(QtCore.Qt.Horizontal) body_position_layout.addWidget(time_slider) kinogram_layout = QtWidgets.QHBoxLayout() body_position_layout.addLayout(kinogram_layout) kino_pre_check = QtWidgets.QCheckBox() kino_pre_check.setText("Kinogramme pre") kinogram_layout.addWidget(kino_pre_check) kino_post_check = QtWidgets.QCheckBox() kino_post_check.setText("Kinogramme post") kinogram_layout.addWidget(kino_post_check) # Trajectory column trajectory_canvas = FigureCanvas(Figure(figsize=(5, 3))) main_layout.addWidget(trajectory_canvas) buffer = (time[-1]-time[0])*0.005 xlim = (time[0]-buffer, time[-1]+buffer) ax_height = trajectory_canvas.figure.add_subplot(411) ax_height.set_title("Hauteur du CoM") ax_height.set_ylabel("Hauteur (m)") ax_height.tick_params(axis='x', which='both', bottom=False, top=False, labelbottom=False) ax_height.plot(time, com[1, 0, :]) ylim = ax_height.get_ylim() height_vbar = ax_height.plot((np.nan, np.nan), ylim, 'r') ax_height.set_xlim(xlim) ax_height.set_ylim(ylim) ax_velocity = trajectory_canvas.figure.add_subplot(412) ax_velocity.set_title("Vitesse verticale") ax_velocity.set_ylabel("Vitesse (m/s)") ax_velocity.tick_params(axis='x', which='both', bottom=False, top=False, labelbottom=False) ax_velocity.plot(time, com_dot[1, 0, :]) ylim = ax_velocity.get_ylim() velocity_vbar = ax_velocity.plot((np.nan, np.nan), ylim, 'r') ax_velocity.set_xlim(xlim) ax_velocity.set_ylim(ylim) ax_acceleration = trajectory_canvas.figure.add_subplot(413) ax_acceleration.set_title("Accélération verticale") ax_acceleration.set_ylabel("Accélération (m/s²)") ax_acceleration.tick_params(axis='x', which='both', bottom=False, top=False, labelbottom=False) ax_acceleration.plot(time, com_ddot[1, 0, :]) ylim = ax_acceleration.get_ylim() acceleration_vbar = ax_acceleration.plot((np.nan, np.nan), ylim, 'r') ax_acceleration.set_xlim(xlim) ax_acceleration.set_ylim(ylim) ax_grf = trajectory_canvas.figure.add_subplot(414) ax_grf.set_title("GRF") ax_grf.set_ylabel("GRF (N)") ax_grf.set_xlabel("Temps (s)") ax_grf.plot(time, grf[1, 0, :]) ylim = ax_grf.get_ylim() grf_vbar = ax_grf.plot((np.nan, np.nan), ylim, 'r') ax_grf.set_xlim(xlim) ax_grf.set_ylim(ylim) trajectory_canvas.figure.tight_layout(h_pad=-0.5, w_pad=-6) # Angles column angles_canvas = FigureCanvas(Figure(figsize=(5, 3))) main_layout.addWidget(angles_canvas) ax_angles = angles_canvas.figure.subplots() ax_angles.set_title("Angles articulaire au cours du temps") ax_angles.set_ylabel("Angle (°)") ax_angles.set_xlabel("Temps (s)") for joint in angles.values(): ax_angles.plot(time, KinoveaReader.to_degree(joint)) ylim = ax_angles.get_ylim() angles_vbar = ax_angles.plot((np.nan, np.nan), ylim, 'r') ax_angles.set_xlim(xlim) ax_angles.set_ylim(ylim) ax_angles.legend(angles.keys()) def change_time(): time_idx = time_slider.value() move_stick_figure(time_idx) body_position_canvas.draw() height_vbar[0].set_xdata([time[time_idx], time[time_idx]]) velocity_vbar[0].set_xdata([time[time_idx], time[time_idx]]) acceleration_vbar[0].set_xdata([time[time_idx], time[time_idx]]) grf_vbar[0].set_xdata([time[time_idx], time[time_idx]]) trajectory_canvas.draw() angles_vbar[0].set_xdata([time[time_idx], time[time_idx]]) angles_canvas.draw() time_slider.setMinimum(0) time_slider.setMaximum(time.shape[0] - 1) time_slider.setPageStep(1) time_slider.setValue(0) time_slider.valueChanged.connect(change_time) body_position_canvas.mpl_connect(body_position_canvas.resize_event, change_time) kino_pre_check.stateChanged.connect(change_time) kino_post_check.stateChanged.connect(change_time) # app.showMaximized() change_time() app.show() qapp.exec_()
def create_main_frame(self): self.main_frame = QtWidgets.QWidget() plot_frame = QtWidgets.QWidget() self.index = 1 self.dpi = 100 self.fig = Figure((6.0, 4.0), dpi=self.dpi) self.canvas = FigureCanvas(self.fig) self.canvas.setParent(self.main_frame) self.axes = self.fig.add_subplot(111, projection='3d') self.mpl_toolbar = NavigationToolbar(self.canvas, self.main_frame) log_label = QtWidgets.QLabel("Data series:") self.series_list_view = QtWidgets.QListView() self.series_list_view.setModel(self.series_list_model_1) spin_label1 = QtWidgets.QLabel('X from') self.from_spin = QtWidgets.QSpinBox() spin_label2 = QtWidgets.QLabel('to') self.to_spin = QtWidgets.QSpinBox() spins_hbox = QtWidgets.QHBoxLayout() spins_hbox.addWidget(spin_label1) spins_hbox.addWidget(self.from_spin) spins_hbox.addWidget(spin_label2) spins_hbox.addWidget(self.to_spin) spins_hbox.addStretch(1) self.legend_cb = QtWidgets.QCheckBox("Show Legend") self.legend_cb.setChecked(False) self.legend_pp = QtWidgets.QCheckBox("P-polarization") self.legend_pp.setChecked(False) self.legend_sp = QtWidgets.QCheckBox("S-polarization") self.legend_sp.setChecked(False) self.show_button = QtWidgets.QPushButton("&Show") self.show_button.clicked.connect(lambda: self.on_show(self.index)) self.load_button = QtWidgets.QPushButton("&Load file") self.load_button.clicked.connect(lambda: self.load_file(self.index)) self.series_list_view2 = QtWidgets.QListView() self.series_list_view2.setModel(self.series_list_model_2) log_label_2 = QtWidgets.QLabel("Data series:") spin_label1_2 = QtWidgets.QLabel('X from') self.from_spin_2 = QtWidgets.QSpinBox() spin_label2_2 = QtWidgets.QLabel('to') self.to_spin_2 = QtWidgets.QSpinBox() spins_hbox_2 = QtWidgets.QHBoxLayout() spins_hbox_2.addWidget(spin_label1_2) spins_hbox_2.addWidget(self.from_spin_2) spins_hbox_2.addWidget(spin_label2_2) spins_hbox_2.addWidget(self.to_spin_2) spins_hbox_2.addStretch(1) self.legend_cb_2 = QtWidgets.QCheckBox("Show Legend") self.legend_cb_2.setChecked(False) self.legend_pp_2 = QtWidgets.QCheckBox("P-polarization") self.legend_pp_2.setChecked(False) self.legend_sp_2 = QtWidgets.QCheckBox("S-polarization") self.legend_sp_2.setChecked(False) self.show_button_2 = QtWidgets.QPushButton("&Show") self.show_button_2.clicked.connect(lambda: self.on_show(self.index)) self.load_button_2 = QtWidgets.QPushButton("&Load file") self.load_button_2.clicked.connect(lambda: self.load_file(self.index)) self.series_list_view3 = QtWidgets.QListView() self.series_list_view3.setModel(self.series_list_model_3) self.show_button_3 = QtWidgets.QPushButton("&Show Comparison") self.show_button_3.clicked.connect( lambda: self.on_show_comparison(self.index)) self.series_list_view4 = QtWidgets.QListView() self.series_list_view4.setModel(self.series_list_model_4) left_vbox = QtWidgets.QVBoxLayout() left_vbox.addWidget(self.canvas) left_vbox.addWidget(self.mpl_toolbar) self.tabs = QtWidgets.QTabWidget() self.tab1 = QtWidgets.QWidget() self.tab2 = QtWidgets.QWidget() self.tab3 = QtWidgets.QWidget() self.tabs.addTab(self.tab1, "Tab 1") self.tabs.addTab(self.tab2, "Tab 2") self.tabs.addTab(self.tab3, "Tab 3") self.tab1.layout = QtWidgets.QVBoxLayout(self) self.tab1.layout.addWidget(log_label) self.tab1.layout.addWidget(self.series_list_view) self.tab1.layout.addLayout(spins_hbox) self.tab1.layout.addWidget(self.legend_cb) self.tab1.layout.addWidget(self.legend_pp) self.tab1.layout.addWidget(self.legend_sp) self.tab1.layout.addWidget(self.show_button) self.tab1.layout.addWidget(self.load_button) self.tab1.layout.addStretch(1) self.tab1.setLayout(self.tab1.layout) self.tab2.layout = QtWidgets.QVBoxLayout(self) self.tab2.layout.addWidget(log_label_2) self.tab2.layout.addWidget(self.series_list_view2) self.tab2.layout.addLayout(spins_hbox_2) self.tab2.layout.addWidget(self.legend_cb_2) self.tab2.layout.addWidget(self.legend_pp_2) self.tab2.layout.addWidget(self.legend_sp_2) self.tab2.layout.addWidget(self.show_button_2) self.tab2.layout.addWidget(self.load_button_2) self.tab2.layout.addStretch(1) self.tab2.setLayout(self.tab2.layout) self.tab3.layout = QtWidgets.QVBoxLayout(self) self.tab3.layout.addWidget(self.series_list_view3) self.tab3.layout.addWidget(self.series_list_view4) self.tab3.layout.addWidget(self.show_button_3) self.tab3.setLayout(self.tab3.layout) right_vbox = QtWidgets.QVBoxLayout() right_vbox.addWidget(self.tabs) self.tabs.currentChanged.connect(self.on_change) hbox = QtWidgets.QHBoxLayout() hbox.addLayout(left_vbox) hbox.addLayout(right_vbox) self.main_frame.setLayout(hbox) self.setCentralWidget(self.main_frame)