def __init__(self, parent=None, name=None, flags=0): QtImport.QDialog.__init__( self, parent, QtImport.Qt.WindowFlags(flags | QtImport.Qt.WindowStaysOnTopHint), ) # Internal variables -------------------------------------------------- self.camera_hwobj = None # Graphic elements ---------------------------------------------------- self.contrast_slider = QtImport.QSlider(QtImport.Qt.Horizontal, self) self.contrast_doublespinbox = QtImport.QDoubleSpinBox(self) self.contrast_checkbox = QtImport.QCheckBox("auto", self) self.brightness_slider = QtImport.QSlider(QtImport.Qt.Horizontal, self) self.brightness_doublespinbox = QtImport.QDoubleSpinBox(self) self.brightness_checkbox = QtImport.QCheckBox("auto", self) self.gain_slider = QtImport.QSlider(QtImport.Qt.Horizontal, self) self.gain_doublespinbox = QtImport.QDoubleSpinBox(self) self.gain_checkbox = QtImport.QCheckBox("auto", self) self.gamma_slider = QtImport.QSlider(QtImport.Qt.Horizontal, self) self.gamma_doublespinbox = QtImport.QDoubleSpinBox(self) self.gamma_checkbox = QtImport.QCheckBox("auto", self) self.exposure_time_slider = QtImport.QSlider(QtImport.Qt.Horizontal, self) self.exposure_time_doublespinbox = QtImport.QDoubleSpinBox(self) self.exposure_time_checkbox = QtImport.QCheckBox("auto", self) __close_button = QtImport.QPushButton("Close", self) # Layout -------------------------------------------------------------- __main_gridlayout = QtImport.QGridLayout(self) __main_gridlayout.addWidget(QtImport.QLabel("Contrast:", self), 0, 0) __main_gridlayout.addWidget(self.contrast_slider, 0, 1) __main_gridlayout.addWidget(self.contrast_doublespinbox, 0, 2) __main_gridlayout.addWidget(self.contrast_checkbox, 0, 3) __main_gridlayout.addWidget(QtImport.QLabel("Brightness:", self), 1, 0) __main_gridlayout.addWidget(self.brightness_slider, 1, 1) __main_gridlayout.addWidget(self.brightness_doublespinbox, 1, 2) __main_gridlayout.addWidget(self.brightness_checkbox, 1, 3) __main_gridlayout.addWidget(QtImport.QLabel("Gain:", self), 2, 0) __main_gridlayout.addWidget(self.gain_slider, 2, 1) __main_gridlayout.addWidget(self.gain_doublespinbox, 2, 2) __main_gridlayout.addWidget(self.gain_checkbox, 2, 3) __main_gridlayout.addWidget(QtImport.QLabel("Gamma:", self), 3, 0) __main_gridlayout.addWidget(self.gamma_slider, 3, 1) __main_gridlayout.addWidget(self.gamma_doublespinbox, 3, 2) __main_gridlayout.addWidget(self.gamma_checkbox, 3, 3) __main_gridlayout.addWidget( QtImport.QLabel("Exposure time (ms):", self), 4, 0) __main_gridlayout.addWidget(self.exposure_time_slider, 4, 1) __main_gridlayout.addWidget(self.exposure_time_doublespinbox, 4, 2) __main_gridlayout.addWidget(self.exposure_time_checkbox, 4, 3) __main_gridlayout.addWidget(__close_button, 6, 2) __main_gridlayout.setSpacing(2) __main_gridlayout.setContentsMargins(5, 5, 5, 5) __main_gridlayout.setSizeConstraint(QtImport.QLayout.SetFixedSize) # Qt signal/slot connections ------------------------------------------ self.contrast_slider.valueChanged.connect(self.set_contrast) self.contrast_doublespinbox.valueChanged.connect(self.set_contrast) self.contrast_checkbox.stateChanged.connect(self.set_contrast_auto) self.brightness_slider.valueChanged.connect(self.set_brightness) self.brightness_doublespinbox.valueChanged.connect(self.set_brightness) self.brightness_checkbox.stateChanged.connect(self.set_brightness_auto) self.gain_slider.valueChanged.connect(self.set_gain) self.gain_doublespinbox.valueChanged.connect(self.set_gain) self.gain_checkbox.stateChanged.connect(self.set_gain_auto) self.gamma_slider.valueChanged.connect(self.set_gamma) self.gamma_doublespinbox.valueChanged.connect(self.set_gamma) self.gamma_checkbox.stateChanged.connect(self.set_gamma_auto) self.exposure_time_slider.valueChanged.connect(self.set_exposure_time) self.exposure_time_doublespinbox.valueChanged.connect( self.set_exposure_time) self.exposure_time_checkbox.stateChanged.connect( self.set_exposure_time_auto) __close_button.clicked.connect(self.close) # SizePolicies -------------------------------------------------------- self.contrast_slider.setFixedWidth(200) self.brightness_slider.setFixedWidth(200) self.gain_slider.setFixedWidth(200) self.gamma_slider.setFixedWidth(200) self.exposure_time_slider.setFixedWidth(200) __close_button.setSizePolicy(QtImport.QSizePolicy.Fixed, QtImport.QSizePolicy.Fixed) # Other --------------------------------------------------------------- self.setModal(True) self.setWindowTitle("Camera controls")
def __init__(self, *args): BaseWidget.__init__(self, *args) # Hardware objects ---------------------------------------------------- self.motor_hwobj = None # Internal values ----------------------------------------------------- self.step_editor = None self.move_step = 1 self.demand_move = 0 self.in_expert_mode = None self.position_history = [] # Properties ---------------------------------------------------------- self.add_property("mnemonic", "string", "") self.add_property("formatString", "formatString", "+##.##") self.add_property("label", "string", "") self.add_property("showLabel", "boolean", True) self.add_property("showMoveButtons", "boolean", True) self.add_property("showSlider", "boolean", False) self.add_property("showStop", "boolean", True) self.add_property("showStep", "boolean", True) self.add_property("showStepList", "boolean", False) self.add_property("showPosition", "boolean", True) self.add_property("invertButtons", "boolean", False) self.add_property("oneClickPressButton", "boolean", False) self.add_property("delta", "string", "") self.add_property("decimals", "integer", 2) self.add_property("icons", "string", "") self.add_property("helpDecrease", "string", "") self.add_property("helpIncrease", "string", "") self.add_property("hideInUser", "boolean", False) self.add_property("defaultSteps", "string", "180 90 45 30 10") self.add_property("enableSliderTracking", "boolean", False) # Signals ------------------------------------------------------------ # Slots --------------------------------------------------------------- self.define_slot("toggle_enabled", ()) # Graphic elements----------------------------------------------------- self.main_gbox = QtImport.QGroupBox(self) self.motor_label = QtImport.QLabel(self.main_gbox) self.motor_label.setFixedHeight(27) # Main controls self.move_left_button = QtImport.QPushButton(self.main_gbox) self.move_left_button.setIcon(Icons.load_icon("Left2")) self.move_left_button.setToolTip("Moves the motor down (while pressed)") self.move_left_button.setFixedSize(27, 27) self.move_left_button.setAutoRepeatDelay(500) self.move_left_button.setAutoRepeatInterval(500) self.move_right_button = QtImport.QPushButton(self.main_gbox) self.move_right_button.setIcon(Icons.load_icon("Right2")) self.move_right_button.setToolTip("Moves the motor up (while pressed)") self.move_right_button.setFixedSize(27, 27) self.move_right_button.setAutoRepeatDelay(500) self.move_right_button.setAutoRepeatInterval(500) self.position_spinbox = QtImport.QDoubleSpinBox(self.main_gbox) self.position_spinbox.setMinimum(-10000) self.position_spinbox.setMaximum(10000) self.position_spinbox.setFixedSize(75, 27) self.position_spinbox.setDecimals(3) self.position_spinbox.setToolTip( "Moves the motor to a specific " + "position or step by step; right-click for motor history" ) self.position_spinbox.setContextMenuPolicy(QtImport.Qt.CustomContextMenu) # Extra controls self.stop_button = QtImport.QPushButton(self.main_gbox) self.stop_button.setIcon(Icons.load_icon("Stop2")) self.stop_button.setEnabled(False) self.stop_button.setToolTip("Stops the motor") self.stop_button.setFixedSize(27, 27) self.step_button = QtImport.QPushButton(self.main_gbox) self.step_button_icon = Icons.load_icon("TileCascade2") self.step_button.setIcon(self.step_button_icon) self.step_button.setToolTip("Changes the motor step") self.step_button.setFixedSize(27, 27) self.step_combo = QtImport.QComboBox(self.main_gbox) self.step_combo.setEditable(True) self.step_combo.setValidator( QtImport.QDoubleValidator(0, 360, 5, self.step_combo) ) self.step_combo.setDuplicatesEnabled(False) self.step_combo.setFixedHeight(27) self.position_slider = QtImport.QDoubleSlider( QtImport.Qt.Horizontal, self.main_gbox ) # Layout -------------------------------------------------------------- self._gbox_hbox_layout = QtImport.QHBoxLayout(self.main_gbox) self._gbox_hbox_layout.addWidget(self.motor_label) self._gbox_hbox_layout.addWidget(self.position_spinbox) self._gbox_hbox_layout.addWidget(self.move_left_button) self._gbox_hbox_layout.addWidget(self.move_right_button) self._gbox_hbox_layout.addWidget(self.position_slider) self._gbox_hbox_layout.addWidget(self.stop_button) self._gbox_hbox_layout.addWidget(self.step_button) self._gbox_hbox_layout.addWidget(self.step_combo) self._gbox_hbox_layout.setSpacing(2) self._gbox_hbox_layout.setContentsMargins(2, 2, 2, 2) self._main_hbox_layout = QtImport.QVBoxLayout(self) self._main_hbox_layout.addWidget(self.main_gbox) self._main_hbox_layout.setSpacing(0) self._main_hbox_layout.setContentsMargins(0, 0, 0, 0) # SizePolicy (horizontal, vertical) ----------------------------------- # self.setSizePolicy(QSizePolicy.Fixed, # QSizePolicy.Fixed) # Object events ------------------------------------------------------ spinbox_event = SpinBoxEvent(self.position_spinbox) self.position_spinbox.installEventFilter(spinbox_event) spinbox_event.returnPressedSignal.connect(self.change_position) spinbox_event.contextMenuSignal.connect(self.open_history_menu) self.position_spinbox.lineEdit().textEdited.connect(self.position_value_edited) self.step_combo.activated.connect(self.go_to_step) self.step_combo.activated.connect(self.step_changed) self.step_combo.editTextChanged.connect(self.step_edited) self.stop_button.clicked.connect(self.stop_motor) self.step_button.clicked.connect(self.open_step_editor) self.move_left_button.pressed.connect(self.move_down) self.move_left_button.released.connect(self.stop_moving) self.move_right_button.pressed.connect(self.move_up) self.move_right_button.released.connect(self.stop_moving) self.position_slider.doubleValueChanged.connect( self.position_slider_double_value_changed ) # Other --------------------------------------------------------------- self.instance_synchronize("position_spinbox", "step_combo")
def __init__(self, *args): BaseWidget.__init__(self, *args) # Hardware objects ---------------------------------------------------- # Internal values ----------------------------------------------------- # Properties ---------------------------------------------------------- self.add_property("label", "string", "") self.add_property("showStop", "boolean", True) self.add_property("defaultStep", "string", "10.0") # Signals ------------------------------------------------------------ # Slots --------------------------------------------------------------- # Graphic elements----------------------------------------------------- _main_gbox = QtImport.QGroupBox(self) self.kappa_dspinbox = QtImport.QDoubleSpinBox(_main_gbox) self.kappa_dspinbox.setRange(-360, 360) self.kappaphi_dspinbox = QtImport.QDoubleSpinBox(_main_gbox) self.kappaphi_dspinbox.setRange(-360, 360) self.step_cbox = QtImport.QComboBox(_main_gbox) self.step_button_icon = Icons.load_icon("TileCascade2") self.close_button = QtImport.QPushButton(_main_gbox) self.stop_button = QtImport.QPushButton(_main_gbox) # Layout -------------------------------------------------------------- _main_gbox_hlayout = QtImport.QHBoxLayout(_main_gbox) _main_gbox_hlayout.addWidget(QtImport.QLabel("Kappa:", _main_gbox)) _main_gbox_hlayout.addWidget(self.kappa_dspinbox) _main_gbox_hlayout.addWidget(QtImport.QLabel("Phi:", _main_gbox)) _main_gbox_hlayout.addWidget(self.kappaphi_dspinbox) _main_gbox_hlayout.addWidget(self.step_cbox) _main_gbox_hlayout.addWidget(self.close_button) _main_gbox_hlayout.addWidget(self.stop_button) _main_gbox_hlayout.setSpacing(2) _main_gbox_hlayout.setContentsMargins(2, 2, 2, 2) _main_hlayout = QtImport.QHBoxLayout(self) _main_hlayout.addWidget(_main_gbox) _main_hlayout.setSpacing(0) _main_hlayout.setContentsMargins(0, 0, 0, 0) # SizePolicies -------------------------------------------------------- # Qt signal/slot connections ------------------------------------------ kappa_dspinbox_event = SpinBoxEvent(self.kappa_dspinbox) kappaphi_dspinbox_event = SpinBoxEvent(self.kappaphi_dspinbox) self.kappa_dspinbox.installEventFilter(kappa_dspinbox_event) self.kappaphi_dspinbox.installEventFilter(kappaphi_dspinbox_event) kappa_dspinbox_event.returnPressedSignal.connect(self.change_position) kappaphi_dspinbox_event.returnPressedSignal.connect(self.change_position) self.kappa_dspinbox.lineEdit().textEdited.connect(self.kappa_value_edited) self.kappaphi_dspinbox.lineEdit().textEdited.connect(self.kappaphi_value_edited) self.step_cbox.activated.connect(self.go_to_step) self.step_cbox.activated.connect(self.step_changed) self.step_cbox.textChanged.connect(self.step_edited) self.close_button.clicked.connect(self.close_clicked) self.stop_button.clicked.connect(self.stop_clicked) # self.stop_button.setSizePolicy(qt.QSizePolicy.Fixed, qt.QSizePolicy.Minimum) # Other --------------------------------------------------------------- self.kappa_dspinbox.setAlignment(QtImport.Qt.AlignRight) self.kappa_dspinbox.setFixedWidth(75) self.kappaphi_dspinbox.setAlignment(QtImport.Qt.AlignRight) self.kappaphi_dspinbox.setFixedWidth(75) self.step_cbox.setEditable(True) self.step_cbox.setValidator( QtImport.QDoubleValidator(0, 360, 5, self.step_cbox) ) self.step_cbox.setDuplicatesEnabled(False) self.step_cbox.setFixedHeight(27) self.close_button.setIcon(Icons.load_icon("Home2")) self.close_button.setFixedSize(27, 27) self.stop_button.setIcon(Icons.load_icon("Stop2")) self.stop_button.setEnabled(False) self.stop_button.setFixedSize(27, 27) self.connect(HWR.beamline.diffractometer, "kappaMotorMoved", self.kappa_motor_moved) self.connect(HWR.beamline.diffractometer, "kappaPhiMotorMoved", self.kappaphi_motor_moved) self.connect(HWR.beamline.diffractometer, "minidiffStatusChanged", self.diffractometer_state_changed)