示例#1
0
    def __init__(self, *args):

        BaseWidget.__init__(self, *args)

        # Hardware objects ----------------------------------------------------

        # Internal variables --------------------------------------------------

        # Properties ----------------------------------------------------------
        self.add_property("formatString", "formatString", "###.##")

        # Signals ------------------------------------------------------------

        # Slots ---------------------------------------------------------------

        # Graphic elements ----------------------------------------------------
        self.group_box = qt_import.QGroupBox("Transmission", self)
        current_label = qt_import.QLabel("Current:", self.group_box)
        current_label.setFixedWidth(75)
        self.transmission_ledit = qt_import.QLineEdit(self.group_box)
        self.transmission_ledit.setReadOnly(True)
        set_to_label = qt_import.QLabel("Set to:", self.group_box)
        self.new_value_ledit = qt_import.QLineEdit(self.group_box)

        # Layout --------------------------------------------------------------
        _group_box_gridlayout = qt_import.QGridLayout(self.group_box)
        _group_box_gridlayout.addWidget(current_label, 0, 0)
        _group_box_gridlayout.addWidget(self.transmission_ledit, 0, 1)
        _group_box_gridlayout.addWidget(set_to_label, 1, 0)
        _group_box_gridlayout.addWidget(self.new_value_ledit, 1, 1)
        _group_box_gridlayout.setSpacing(0)
        _group_box_gridlayout.setContentsMargins(1, 1, 1, 1)

        _main_vlayout = qt_import.QVBoxLayout(self)
        _main_vlayout.setSpacing(0)
        _main_vlayout.setContentsMargins(0, 0, 2, 2)
        _main_vlayout.addWidget(self.group_box)

        # SizePolicies --------------------------------------------------------

        # Other ---------------------------------------------------------------
        self._update_ledit_color(colors.LIGHT_GREEN)
        self.validator = qt_import.QDoubleValidator(0, 100, 2, self.new_value_ledit)
        self.new_value_ledit.setToolTip("Transmission limits 0 : 100 %")
        self.instance_synchronize("transmission_ledit", "new_value_ledit")

        if HWR.beamline.transmission is not None:
            # Qt signal/slot connections ------------------------------------------
            self.new_value_ledit.returnPressed.connect(self.current_value_changed)
            self.new_value_ledit.textChanged.connect(self.input_field_changed)
            self.connect(HWR.beamline.transmission, "stateChanged", self._state_changed)
            self.connect(HWR.beamline.transmission, "valueChanged", self._value_changed)
            self.connected()
        else:
            self.disconnected()
示例#2
0
    def __init__(self, parent):

        qt_import.QDialog.__init__(self, parent)
        # Graphic elements-----------------------------------------------------
        # self.main_gbox = QtGui.QGroupBox('Motor step', self)
        # box2 = QtGui.QWidget(self)
        self.grid = qt_import.QWidget(self)
        label1 = qt_import.QLabel("Current:", self)
        self.current_step = qt_import.QLineEdit(self)
        self.current_step.setEnabled(False)
        label2 = qt_import.QLabel("Set to:", self)
        self.new_step = qt_import.QLineEdit(self)
        self.new_step.setAlignment(qt_import.Qt.AlignRight)
        self.new_step.setValidator(qt_import.QDoubleValidator(self))

        self.button_box = qt_import.QWidget(self)
        self.apply_button = qt_import.QPushButton("Apply", self.button_box)
        self.close_button = qt_import.QPushButton("Dismiss", self.button_box)

        # Layout --------------------------------------------------------------
        self.button_box_layout = qt_import.QHBoxLayout(self.button_box)
        self.button_box_layout.addWidget(self.apply_button)
        self.button_box_layout.addWidget(self.close_button)

        self.grid_layout = qt_import.QGridLayout(self.grid)
        self.grid_layout.addWidget(label1, 0, 0)
        self.grid_layout.addWidget(self.current_step, 0, 1)
        self.grid_layout.addWidget(label2, 1, 0)
        self.grid_layout.addWidget(self.new_step, 1, 1)

        self.main_layout = qt_import.QVBoxLayout(self)
        self.main_layout.addWidget(self.grid)
        self.main_layout.addWidget(self.button_box)
        self.main_layout.setSpacing(0)
        self.main_layout.setContentsMargins(0, 0, 0, 0)

        # Qt signal/slot connections -----------------------------------------
        self.new_step.returnPressed.connect(self.apply_clicked)
        self.apply_button.clicked.connect(self.apply_clicked)
        self.close_button.clicked.connect(self.accept)

        # SizePolicies --------------------------------------------------------
        self.close_button.setSizePolicy(qt_import.QSizePolicy.Fixed,
                                        qt_import.QSizePolicy.Fixed)
        self.setSizePolicy(qt_import.QSizePolicy.Minimum,
                           qt_import.QSizePolicy.Minimum)

        # Other ---------------------------------------------------------------
        self.setWindowTitle("Motor step editor")
        self.apply_button.setIcon(icons.load_icon("Check"))
        self.close_button.setIcon(icons.load_icon("Delete"))
示例#3
0
    def __init__(self, *args):

        BaseWidget.__init__(self, *args)

        # Hardware objects ----------------------------------------------------
        self.beamstop_hwobj = None

        # Internal variables --------------------------------------------------
        self.beamstop_limits = [0, 200]

        # Properties ----------------------------------------------------------
        self.add_property("mnemonic", "string", "")
        self.add_property("formatString", "formatString", "###.##")

        # Graphic elements ----------------------------------------------------
        self.group_box = qt_import.QGroupBox("Beamstop distance", self)
        current_label = qt_import.QLabel("Current:", self.group_box)
        current_label.setFixedWidth(75)
        self.beamstop_distance_ledit = qt_import.QLineEdit(self.group_box)
        self.beamstop_distance_ledit.setReadOnly(True)
        set_to_label = qt_import.QLabel("Set to:", self.group_box)
        self.new_value_ledit = qt_import.QLineEdit(self.group_box)

        # Layout --------------------------------------------------------------
        _group_box_gridlayout = qt_import.QGridLayout(self.group_box)
        _group_box_gridlayout.addWidget(current_label, 0, 0)
        _group_box_gridlayout.addWidget(self.beamstop_distance_ledit, 0, 1)
        _group_box_gridlayout.addWidget(set_to_label, 1, 0)
        _group_box_gridlayout.addWidget(self.new_value_ledit, 1, 1)
        _group_box_gridlayout.setSpacing(0)
        _group_box_gridlayout.setContentsMargins(1, 1, 1, 1)

        _main_vlayout = qt_import.QVBoxLayout(self)
        _main_vlayout.setSpacing(0)
        _main_vlayout.setContentsMargins(0, 0, 2, 2)
        _main_vlayout.addWidget(self.group_box)

        # SizePolicies --------------------------------------------------------

        # Qt signal/slot connections ------------------------------------------
        self.new_value_ledit.returnPressed.connect(self.current_value_changed)
        self.new_value_ledit.textChanged.connect(self.input_field_changed)

        # Other ---------------------------------------------------------------
        colors.set_widget_color(self.new_value_ledit, colors.LINE_EDIT_ACTIVE,
                                qt_import.QPalette.Base)
        self.new_value_validator = qt_import.QDoubleValidator(
            0, 100, 2, self.new_value_ledit)
示例#4
0
    def __init__(self, parent, options):
        decimals = options.get("decimals")
        # NB We do NOT enforce a maximum number of decimals in edited text,
        # Only in set values.
        if decimals is None:
            self.formatstr = "%s"
        else:
            self.formatstr = "%%.%sf" % decimals
        LineEdit.__init__(self, parent, options)
        self.validator = qt_import.QDoubleValidator(self)
        val = options.get("lowerBound")
        if val is not None:
            self.validator.setBottom(val)
        val = options.get("upperBound")
        if val is not None:
            self.validator.setTop(val)
        self.update_function = options.get("update_function")

        self.textChanged.connect(self.input_field_changed)
示例#5
0
    def __init__(self, *args):

        BaseWidget.__init__(self, *args)

        # Internal values -----------------------------------------------------
        self.resolution_limits = None
        self.detector_distance_limits = None
        self.door_interlocked = True

        # Properties ----------------------------------------------------------
        self.add_property("defaultMode", "combo", ("Ang", "mm"), "Ang")
        self.add_property("mmFormatString", "formatString", "###.##")
        self.add_property("angFormatString", "formatString", "##.###")

        self.group_box = qt_import.QGroupBox("Resolution", self)
        current_label = qt_import.QLabel("Current:", self.group_box)
        current_label.setFixedWidth(75)

        self.resolution_ledit = qt_import.QLineEdit(self.group_box)
        self.resolution_ledit.setReadOnly(True)
        self.detector_distance_ledit = qt_import.QLineEdit(self.group_box)
        self.detector_distance_ledit.setReadOnly(True)

        _new_value_widget = qt_import.QWidget(self)
        set_to_label = qt_import.QLabel("Set to:", self.group_box)
        self.new_value_ledit = qt_import.QLineEdit(self.group_box)
        self.units_combobox = qt_import.QComboBox(_new_value_widget)
        self.stop_button = qt_import.QPushButton(_new_value_widget)
        self.stop_button.setIcon(icons.load_icon("Stop2"))
        self.stop_button.setEnabled(False)
        self.stop_button.setFixedWidth(25)

        # Layout --------------------------------------------------------------
        _new_value_widget_hlayout = qt_import.QHBoxLayout(_new_value_widget)
        _new_value_widget_hlayout.addWidget(self.new_value_ledit)
        _new_value_widget_hlayout.addWidget(self.units_combobox)
        _new_value_widget_hlayout.addWidget(self.stop_button)
        _new_value_widget_hlayout.setSpacing(0)
        _new_value_widget_hlayout.setContentsMargins(0, 0, 0, 0)

        _group_box_gridlayout = qt_import.QGridLayout(self.group_box)
        _group_box_gridlayout.addWidget(current_label, 0, 0, 2, 1)
        _group_box_gridlayout.addWidget(self.resolution_ledit, 0, 1)
        _group_box_gridlayout.addWidget(self.detector_distance_ledit, 1, 1)
        _group_box_gridlayout.addWidget(set_to_label, 2, 0)
        _group_box_gridlayout.addWidget(_new_value_widget, 2, 1)
        _group_box_gridlayout.setSpacing(0)
        _group_box_gridlayout.setContentsMargins(1, 1, 1, 1)

        _main_vlayout = qt_import.QVBoxLayout(self)
        _main_vlayout.setSpacing(0)
        _main_vlayout.setContentsMargins(0, 0, 2, 2)
        _main_vlayout.addWidget(self.group_box)

        # SizePolicies --------------------------------------------------------

        # Qt signal/slot connections ------------------------------------------
        self.new_value_ledit.returnPressed.connect(self.current_value_changed)
        self.new_value_ledit.textChanged.connect(self.input_field_changed)
        self.units_combobox.activated.connect(self.unit_changed)
        self.stop_button.clicked.connect(self.stop_clicked)

        # Other ---------------------------------------------------------------
        colors.set_widget_color(self.new_value_ledit, colors.LINE_EDIT_ACTIVE,
                                qt_import.QPalette.Base)
        self.new_value_validator = qt_import.QDoubleValidator(
            0, 15, 4, self.new_value_ledit)

        self.units_combobox.addItem(chr(197))
        self.units_combobox.addItem("mm")
        self.instance_synchronize(
            "group_box",
            "resolution_ledit",
            "detector_distance_ledit",
            "new_value_ledit",
            "units_combobox",
        )
示例#6
0
    def __init__(self, *args):

        BaseWidget.__init__(self, *args)

        # Properties ----------------------------------------------------------
        self.add_property("defaultMode", "combo", ("keV", "Ang"), "keV")
        self.add_property("kevFormatString", "formatString", "##.####")
        self.add_property("angFormatString", "formatString", "##.####")
        self.add_property("displayStatus", "boolean", False)
        self.add_property("doBeamAlignment", "boolean", False)

        # Signals ------------------------------------------------------------

        # Slots ---------------------------------------------------------------

        # Hardware objects ----------------------------------------------------

        # Internal values -----------------------------------------------------

        # Graphic elements ----------------------------------------------------
        self.group_box = qt_import.QGroupBox("Energy", self)
        energy_label = qt_import.QLabel("Current:", self.group_box)
        energy_label.setFixedWidth(75)
        wavelength_label = qt_import.QLabel("Wavelength: ", self.group_box)
        self.energy_ledit = qt_import.QLineEdit(self.group_box)
        self.energy_ledit.setReadOnly(True)
        self.wavelength_ledit = qt_import.QLineEdit(self.group_box)
        self.wavelength_ledit.setReadOnly(True)

        self.status_label = qt_import.QLabel("Status:", self.group_box)
        self.status_label.setEnabled(False)
        self.status_ledit = qt_import.QLineEdit(self.group_box)
        self.status_ledit.setEnabled(False)

        self.new_value_widget = qt_import.QWidget(self)
        self.set_to_label = qt_import.QLabel("Set to: ", self)
        self.new_value_ledit = qt_import.QLineEdit(self.new_value_widget)
        # self.new_value_ledit.setMaximumWidth(60)
        self.units_combobox = qt_import.QComboBox(self.new_value_widget)
        self.units_combobox.addItems(["keV", u"\u212B"])
        self.stop_button = qt_import.QPushButton(self.new_value_widget)
        self.stop_button.setIcon(icons.load_icon("Stop2"))
        self.stop_button.setEnabled(False)
        self.stop_button.setFixedWidth(25)

        self.beam_align_cbox = qt_import.QCheckBox(
            "Center beam after energy change", self)

        # Layout --------------------------------------------------------------
        _new_value_widget_hlayout = qt_import.QHBoxLayout(
            self.new_value_widget)
        _new_value_widget_hlayout.addWidget(self.new_value_ledit)
        _new_value_widget_hlayout.addWidget(self.units_combobox)
        _new_value_widget_hlayout.addWidget(self.stop_button)
        _new_value_widget_hlayout.setSpacing(0)
        _new_value_widget_hlayout.setContentsMargins(0, 0, 0, 0)

        _group_box_gridlayout = qt_import.QGridLayout(self.group_box)
        _group_box_gridlayout.addWidget(energy_label, 0, 0)
        _group_box_gridlayout.addWidget(self.energy_ledit, 0, 1)
        _group_box_gridlayout.addWidget(wavelength_label, 1, 0)
        _group_box_gridlayout.addWidget(self.wavelength_ledit, 1, 1)
        _group_box_gridlayout.addWidget(self.status_label, 2, 0)
        _group_box_gridlayout.addWidget(self.status_ledit, 2, 1)
        _group_box_gridlayout.addWidget(self.set_to_label, 3, 0)
        _group_box_gridlayout.addWidget(self.new_value_widget, 3, 1)
        _group_box_gridlayout.addWidget(self.beam_align_cbox, 4, 0, 1, 2)

        _group_box_gridlayout.setSpacing(0)
        _group_box_gridlayout.setContentsMargins(1, 1, 1, 1)

        _main_vlayout = qt_import.QVBoxLayout(self)
        _main_vlayout.setSpacing(0)
        _main_vlayout.setContentsMargins(0, 0, 2, 2)
        _main_vlayout.addWidget(self.group_box)

        # SizePolicies --------------------------------------------------------

        # Qt signal/slot connections ------------------------------------------
        self.new_value_ledit.returnPressed.connect(self.current_value_changed)
        self.new_value_ledit.textChanged.connect(self.input_field_changed)
        self.units_combobox.activated.connect(self.units_changed)
        self.stop_button.clicked.connect(self.stop_clicked)
        self.beam_align_cbox.stateChanged.connect(self.do_beam_align_changed)

        # Other ---------------------------------------------------------------
        # self.group_box.setCheckable(True)
        # self.group_box.setChecked(True)
        self.new_value_validator = qt_import.QDoubleValidator(
            0, 15, 4, self.new_value_ledit)
        self.status_ledit.setEnabled(False)

        self.set_new_value_limits()
        self.connect(HWR.beamline.energy, "energyChanged", self.energy_changed)
        self.connect(HWR.beamline.energy, "stateChanged", self.state_changed)
        self.connect(HWR.beamline.energy, "statusInfoChanged",
                     self.status_info_changed)

        if hasattr(HWR.beamline.energy, "set_do_beam_alignment"):
            HWR.beamline.energy.set_do_beam_alignment(self["doBeamAlignment"])

        if HWR.beamline.energy.is_ready():
            tunable_energy = HWR.beamline.energy.is_tunable
            if tunable_energy is None:
                tunable_energy = False
            self.set_to_label.setEnabled(tunable_energy)
            self.new_value_ledit.setEnabled(tunable_energy)
            self.units_combobox.setEnabled(tunable_energy)
            if tunable_energy:
                colors.set_widget_color(self.new_value_ledit,
                                        colors.LINE_EDIT_ACTIVE,
                                        qt_import.QPalette.Base)
        else:
            self.setEnabled(False)

        self.instance_synchronize("energy_ledit", "new_value_ledit")
示例#7
0
    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 = []
        self.editing = False
        self.units = None
        self.show_units = None

        # 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)
        self.add_property("show_units", "boolean", False)
        self.add_property("unit", "string", "mm")

        # Signals ------------------------------------------------------------

        # Slots ---------------------------------------------------------------
        self.define_slot("toggle_enabled", ())

        # Graphic elements-----------------------------------------------------
        self.main_gbox = qt_import.QGroupBox(self)
        self.motor_label = qt_import.QLabel(self.main_gbox)
        self.motor_label.setFixedHeight(27)

        # Main controls
        self.move_left_button = qt_import.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 = qt_import.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 = qt_import.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(
            qt_import.Qt.CustomContextMenu)

        # Extra controls
        self.stop_button = qt_import.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 = qt_import.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 = qt_import.QComboBox(self.main_gbox)
        self.step_combo.setEditable(True)
        self.step_combo.setValidator(
            qt_import.QDoubleValidator(0, 360, 5, self.step_combo))
        self.step_combo.setDuplicatesEnabled(False)
        self.step_combo.setFixedHeight(27)

        self.position_slider = qt_import.QDoubleSlider(qt_import.Qt.Horizontal,
                                                       self.main_gbox)

        # Layout --------------------------------------------------------------
        self._gbox_hbox_layout = qt_import.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 = qt_import.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")
示例#8
0
    def __init__(
        self,
        parent=None,
        name=None,
        fl=0,
        acq_params=None,
        path_template=None,
        layout="vertical",
    ):
        """
        Loads ui file that defines the gui layout.
        Initiates QLineEdits by adding limits, precision
        Connects to qt signals to update acquisition parameters
        :param parent:
        :param name:
        :param fl:
        :param acq_params:
        :param path_template:
        :param layout:
        """

        qt_import.QWidget.__init__(self, parent, qt_import.Qt.WindowFlags(fl))

        if name is not None:
            self.setObjectName(name)

        # Internal variables --------------------------------------------------
        self.value_changed_list = []

        # Properties ----------------------------------------------------------

        # Signals -------------------------------------------------------------

        # Slots ---------------------------------------------------------------

        # Graphic elements ----------------------------------------------------
        if acq_params is None:
            self._acquisition_parameters = queue_model_objects.AcquisitionParameters(
            )
        else:
            self._acquisition_parameters = acq_params

        if path_template is None:
            self._path_template = queue_model_objects.PathTemplate()
        else:
            self._path_template = path_template

        self._acquisition_mib = DataModelInputBinder(
            self._acquisition_parameters)

        self.acq_widget_layout = qt_import.load_ui_file(
            "acquisition_widget_vertical_ssx_layout.ui")
        # Layout --------------------------------------------------------------
        __main_vlayout = qt_import.QVBoxLayout(self)
        __main_vlayout.addWidget(self.acq_widget_layout)
        __main_vlayout.setSpacing(0)
        __main_vlayout.setContentsMargins(0, 0, 0, 0)

        # SizePolicies --------------------------------------------------------

        # Qt signal/slot connections ------------------------------------------
        self.acq_widget_layout.num_triggers_ledit.textChanged.connect(
            self.num_triggers_ledit_changed)
        self.acq_widget_layout.num_images_per_trigger_ledit.textChanged.connect(
            self.num_images_per_trigger_ledit_changed)

        self.acq_widget_layout.exp_time_ledit.textChanged.connect(
            self.exposure_time_ledit_changed)
        self.acq_widget_layout.detector_roi_mode_combo.activated.connect(
            self.detector_roi_mode_changed)
        self.acq_widget_layout.energy_ledit.textEdited.connect(
            self.energy_ledit_changed)
        self.acq_widget_layout.transmission_ledit.textEdited.connect(
            self.transmission_ledit_changed)
        self.acq_widget_layout.resolution_ledit.textEdited.connect(
            self.resolution_ledit_changed)

        # Other ---------------------------------------------------------------
        self.energy_validator = qt_import.QDoubleValidator(
            4, 25, 4, self.acq_widget_layout.energy_ledit)
        self.resolution_validator = qt_import.QDoubleValidator(
            0, 15, 3, self.acq_widget_layout.resolution_ledit)
        self.transmission_validator = qt_import.QDoubleValidator(
            0, 100, 3, self.acq_widget_layout.transmission_ledit)
        self.exp_time_validator = qt_import.QDoubleValidator(
            0.0001, 10000, 7, self.acq_widget_layout.exp_time_ledit)
        self.num_triggers_validator = qt_import.QIntValidator(
            1, 9999999, self.acq_widget_layout.num_triggers_ledit)
        self.num_images_per_trigger_validator = qt_import.QIntValidator(
            1, 9999999, self.acq_widget_layout.num_images_per_trigger_ledit)
        self.num_img_validator = qt_import.QIntValidator(
            1, 9999999, self.acq_widget_layout.num_images_ledit)
        self.hare_num_validator = qt_import.QIntValidator(
            1, 9999999, self.acq_widget_layout.hare_num_ledit)

        limits_dict = HWR.beamline.acquisition_limit_values

        tpl = limits_dict.get("exposure_time")
        if tpl:
            self.exp_time_validator.setRange(tpl[0], tpl[1], 6)

        self._acquisition_mib.bind_value_update(
            "exp_time",
            self.acq_widget_layout.exp_time_ledit,
            float,
            self.exp_time_validator,
        )

        self._acquisition_mib.bind_value_update(
            "num_triggers",
            self.acq_widget_layout.num_triggers_ledit,
            int,
            self.num_triggers_validator,
        )

        self._acquisition_mib.bind_value_update(
            "num_images_per_trigger",
            self.acq_widget_layout.num_images_per_trigger_ledit,
            int,
            self.num_images_per_trigger_validator,
        )

        self._acquisition_mib.bind_value_update(
            "hare_num",
            self.acq_widget_layout.hare_num_ledit,
            int,
            self.hare_num_validator,
        )

        tpl = limits_dict.get("number_of_images")
        if tpl:
            self.num_img_validator.setRange(tpl[0], tpl[1])

        self._acquisition_mib.bind_value_update(
            "num_images",
            self.acq_widget_layout.num_images_ledit,
            int,
            self.num_img_validator,
        )

        self._acquisition_mib.bind_value_update(
            "energy", self.acq_widget_layout.energy_ledit, float,
            self.energy_validator)
        self.update_energy_limits(
            (self.energy_validator.bottom(), self.energy_validator.top()))

        self._acquisition_mib.bind_value_update(
            "transmission",
            self.acq_widget_layout.transmission_ledit,
            float,
            self.transmission_validator,
        )
        self.update_transmission_limits((self.transmission_validator.bottom(),
                                         self.transmission_validator.top()))

        self._acquisition_mib.bind_value_update(
            "resolution",
            self.acq_widget_layout.resolution_ledit,
            float,
            self.resolution_validator,
        )

        self.init_detector_roi_modes()
        self.acq_widget_layout.detector_roi_mode_label.setEnabled(False)
        self.acq_widget_layout.detector_roi_mode_combo.setEnabled(False)
        self.update_exp_time_limits()
示例#9
0
    def init_view(self):
        self.chan_config = HWR.beamline.ssx_setup.get_config()

        self.chan_table.blockSignals(True)
        self.chan_table.setColumnCount(3)
        for index, header_text in enumerate(("Name", "Delay", "Length")):
            self.chan_table.setHorizontalHeaderItem(
                index, qt_import.QTableWidgetItem(header_text))
            if index > 0:
                self.chan_table.resizeColumnToContents(index)

        self.chan_table.setRowCount(self.chan_config["num_channels"])
        self.chan_seq = [None] * self.chan_config["num_channels"]
        self.chan_table.verticalHeader().setDefaultSectionSize(20)
        self.chan_table.setFixedHeight(20 *
                                       (self.chan_config["num_channels"] + 2) +
                                       10)

        for index in range(self.chan_config["num_channels"]):
            combo = qt_import.QComboBox()
            combo.activated.connect(self.chan_seq_combo_activated)

            for chan_name in self.chan_config["channels"].keys():
                combo.addItem(chan_name)
            combo.addItem("")

            combo.setCurrentIndex(-1)
            self.chan_table.setCellWidget(index, 0, combo)
            self.chan_combo_items.append(combo)

            for col in (1, 2):
                self.chan_table.setItem(index, col,
                                        qt_import.QTableWidgetItem(""))

            if index < len(self.chan_config["default_seq"]):
                def_chan_item_name = self.chan_config["default_seq"][index]
                combo.setCurrentIndex(combo.findText(def_chan_item_name))
                self.chan_table.setItem(
                    index, 1,
                    qt_import.QTableWidgetItem(
                        str(self.chan_config["channels"][def_chan_item_name]
                            [0])))
                self.chan_table.setItem(
                    index, 2,
                    qt_import.QTableWidgetItem(
                        str(self.chan_config["channels"][def_chan_item_name]
                            [1])))

        self.chan_table.blockSignals(False)
        self.refresh_chan_sequence()

        self.metadata_dict = HWR.beamline.ssx_setup.get_metadata_dict()

        for index, key in enumerate(self.metadata_dict.keys()):
            row = index // 2
            value = self.metadata_dict[key]
            metadata_title_ledit = qt_import.QLabel(value["descr"] + ":  ")
            self.metadata_gbox_glayout.addWidget(metadata_title_ledit, row,
                                                 index % 2 * 2)

            metadata_value_ledit = qt_import.QLineEdit(str(value["value"]))
            metadata_value_ledit.setObjectName(key)
            if value.get("limits"):
                limits = value.get("limits")
                metadata_value_ledit.setValidator(
                    qt_import.QDoubleValidator(limits[0], limits[1], 2,
                                               metadata_value_ledit))
                tooltip = "%s limits: %s - %s" % (value["descr"], str(
                    limits[0]), str(limits[1]))
                metadata_value_ledit.setToolTip(tooltip)
            metadata_value_ledit.textChanged.connect(
                self.metadata_value_changed)
            self.metadata_gbox_glayout.addWidget(metadata_value_ledit, row,
                                                 index % 2 * 2 + 1)
            metadata_title_ledit.setDisabled(value.get("read_only", False))
            metadata_value_ledit.setDisabled(value.get("read_only", False))
示例#10
0
    def __init__(
        self,
        parent=None,
        name=None,
        fl=0,
        acq_params=None,
        path_template=None,
        layout=None,
    ):

        qt_import.QWidget.__init__(self, parent, qt_import.Qt.WindowFlags(fl))
        if name is not None:
            self.setObjectName(name)

        # Internal variables --------------------------------------------------
        self.value_changed_list = []

        # Properties ----------------------------------------------------------

        # Signals -------------------------------------------------------------

        # Slots ---------------------------------------------------------------

        # Graphic elements ----------------------------------------------------
        if acq_params is None:
            self._acquisition_parameters = queue_model_objects.AcquisitionParameters(
            )
        else:
            self._acquisition_parameters = acq_params
        if path_template is None:
            self._path_template = queue_model_objects.PathTemplate()
        else:
            self._path_template = path_template

        self._acquisition_mib = DataModelInputBinder(
            self._acquisition_parameters)
        self.acq_widget_layout = qt_import.load_ui_file(
            "acquisition_widget_vertical_simple_layout.ui")

        # Layout --------------------------------------------------------------
        main_layout = qt_import.QVBoxLayout(self)
        main_layout.addWidget(self.acq_widget_layout)
        main_layout.setSpacing(0)
        main_layout.setContentsMargins(0, 0, 0, 0)

        # SizePolicies --------------------------------------------------------

        # Qt signal/slot connections ------------------------------------------
        self.acq_widget_layout.osc_start_cbox.stateChanged.connect(
            self.use_osc_start)
        self.acq_widget_layout.num_images_cbox.activated.connect(
            self.update_num_images)
        self.acq_widget_layout.detector_roi_mode_combo.activated.connect(
            self.detector_roi_mode_changed)

        # Other ---------------------------------------------------------------
        self.osc_start_validator = qt_import.QDoubleValidator(
            -10000, 10000, 4, self.acq_widget_layout.osc_start_ledit)
        self.osc_range_validator = qt_import.QDoubleValidator(
            -10000, 10000, 4, self.acq_widget_layout.osc_range_ledit)
        self.kappa_validator = qt_import.QDoubleValidator(
            0, 360, 4, self.acq_widget_layout.kappa_ledit)
        self.kappa_phi_validator = qt_import.QDoubleValidator(
            0, 360, 4, self.acq_widget_layout.kappa_phi_ledit)
        self.energy_validator = qt_import.QDoubleValidator(
            0, 25, 5, self.acq_widget_layout.energy_ledit)
        self.resolution_validator = qt_import.QDoubleValidator(
            0, 15, 3, self.acq_widget_layout.resolution_ledit)
        self.transmission_validator = qt_import.QDoubleValidator(
            0, 100, 3, self.acq_widget_layout.transmission_ledit)
        self.exp_time_validator = qt_import.QDoubleValidator(
            0, 10000, 6, self.acq_widget_layout.exp_time_ledit)
        self.acq_widget_layout.num_images_cbox.setCurrentIndex(1)

        self.acq_widget_layout.detector_roi_mode_label.setEnabled(False)
        self.acq_widget_layout.detector_roi_mode_combo.setEnabled(False)

        self.set_tunable_energy(HWR.beamline.tunable_wavelength)

        if HWR.beamline.diffractometer.in_plate_mode():
            self.acq_widget_layout.num_images_cbox.clear()
            self.acq_widget_layout.num_images_cbox.addItem("1")
            self.acq_widget_layout.num_images_cbox.setCurrentIndex(0)

        self.init_detector_roi_modes()
        self.init_limits()
示例#11
0
    def __init__(
        self,
        parent=None,
        name=None,
        fl=0,
        acq_params=None,
        path_template=None,
        layout="horizontal",
    ):

        qt_import.QWidget.__init__(self, parent, qt_import.Qt.WindowFlags(fl))

        if name is not None:
            self.setObjectName(name)

        # Hardware objects ----------------------------------------------------

        # Internal variables --------------------------------------------------
        self.previous_energy = 0

        # If the acq. widget is used with grids then total osc range is not
        # equal to num_images * osc_range, but num_images_per_line * osc_range
        # For grids the osc total range is updated when a grid is selected

        self.grid_mode = False

        # Properties ----------------------------------------------------------

        # Signals -------------------------------------------------------------

        # Slots ---------------------------------------------------------------

        # Graphic elements ----------------------------------------------------
        if acq_params is None:
            self._acquisition_parameters = queue_model_objects.AcquisitionParameters()
        else:
            self._acquisition_parameters = acq_params

        if path_template is None:
            self._path_template = queue_model_objects.PathTemplate()
        else:
            self._path_template = path_template

        self._acquisition_mib = DataModelInputBinder(self._acquisition_parameters)

        if layout == "horizontal":
            self.acq_widget_layout = qt_import.load_ui_file(
                "acquisition_widget_horizontal_layout.ui"
            )
            self.use_osc_start(False)
        else:
            self.acq_widget_layout = qt_import.load_ui_file(
                "acquisition_widget_vertical_layout.ui"
            )

        # Layout --------------------------------------------------------------
        __main_vlayout = qt_import.QVBoxLayout(self)
        __main_vlayout.addWidget(self.acq_widget_layout)
        __main_vlayout.setSpacing(0)
        __main_vlayout.setContentsMargins(0, 0, 0, 0)

        # SizePolicies --------------------------------------------------------

        # Qt signal/slot connections ------------------------------------------
        self.acq_widget_layout.osc_start_cbox.stateChanged.connect(self.fix_osc_start)
        self.acq_widget_layout.exp_time_ledit.textChanged.connect(
            self.exposure_time_ledit_changed
        )
        self.acq_widget_layout.exp_time_total_ledit.textEdited.connect(
            self.exp_time_total_ledit_changed
        )
        self.acq_widget_layout.first_image_ledit.textChanged.connect(
            self.first_image_ledit_change
        )
        self.acq_widget_layout.num_images_ledit.textChanged.connect(
            self.num_images_ledit_change
        )
        self.acq_widget_layout.detector_roi_mode_combo.activated.connect(
            self.detector_roi_mode_changed
        )
        self.acq_widget_layout.energies_combo.activated.connect(self.energy_selected)
        self.acq_widget_layout.mad_cbox.toggled.connect(self.use_mad)
        self.acq_widget_layout.osc_start_ledit.textEdited.connect(
            self.osc_start_ledit_changed
        )
        self.acq_widget_layout.osc_range_ledit.textEdited.connect(
            self.osc_range_per_frame_ledit_changed
        )
        self.acq_widget_layout.osc_total_range_ledit.textEdited.connect(
            self.osc_total_range_ledit_changed
        )
        self.acq_widget_layout.energy_ledit.textEdited.connect(
            self.energy_ledit_changed
        )
        self.acq_widget_layout.transmission_ledit.textEdited.connect(
            self.transmission_ledit_changed
        )
        self.acq_widget_layout.resolution_ledit.textEdited.connect(
            self.resolution_ledit_changed
        )
        self.acq_widget_layout.kappa_ledit.textEdited.connect(self.kappa_ledit_changed)
        self.acq_widget_layout.kappa_phi_ledit.textEdited.connect(
            self.kappa_phi_ledit_changed
        )

        if self.acq_widget_layout.findChild(qt_import.QLineEdit, "overlap_ledit"):
            self.acq_widget_layout.overlap_ledit.textChanged.connect(
                self.overlap_changed
            )
        if self.acq_widget_layout.findChild(qt_import.QCheckBox, "max_osc_range_cbx"):
            self.acq_widget_layout.max_osc_range_cbx.toggled.connect(
                self.max_osc_range_toggled
            )

        # Other ---------------------------------------------------------------
        self.value_changed_list = []

        self.acq_widget_layout.energies_combo.setDisabled(True)
        self.acq_widget_layout.energies_combo.addItems(
            ["ip: -", "pk: -", "rm1: -", "rm2: -"]
        )

        self.osc_start_validator = qt_import.QDoubleValidator(
            -10000, 10000, 4, self.acq_widget_layout.osc_start_ledit
        )
        self.osc_range_per_frame_validator = qt_import.QDoubleValidator(
            0, 10000, 4, self.acq_widget_layout.osc_range_ledit
        )
        self.osc_total_range_validator = qt_import.QDoubleValidator(
            0, 10000, 4, self.acq_widget_layout.osc_total_range_ledit
        )
        self.kappa_validator = qt_import.QDoubleValidator(
            -0.01, 360, 4, self.acq_widget_layout.kappa_ledit
        )
        self.kappa_phi_validator = qt_import.QDoubleValidator(
            -360, 360, 4, self.acq_widget_layout.kappa_phi_ledit
        )
        self.energy_validator = qt_import.QDoubleValidator(
            4, 25, 5, self.acq_widget_layout.energy_ledit
        )
        self.resolution_validator = qt_import.QDoubleValidator(
            0, 15, 3, self.acq_widget_layout.resolution_ledit
        )
        self.transmission_validator = qt_import.QDoubleValidator(
            0, 100, 3, self.acq_widget_layout.transmission_ledit
        )
        self.exp_time_validator = qt_import.QDoubleValidator(
            0.0001, 10000, 7, self.acq_widget_layout.exp_time_ledit
        )
        self.first_img_validator = qt_import.QIntValidator(
            0, 99999, self.acq_widget_layout.first_image_ledit
        )
        self.num_img_validator = qt_import.QIntValidator(
            1, 9999999, self.acq_widget_layout.num_images_ledit
        )
        self.acq_widget_layout.detector_roi_mode_label.setEnabled(False)
        self.acq_widget_layout.detector_roi_mode_combo.setEnabled(False)

        self.init_limits()
示例#12
0
    def init_limits(self):
        limits_dict = HWR.beamline.acquisition_limit_values

        tpl = limits_dict.get("osc_range")
        if tpl:
            self.osc_start_validator.setRange(tpl[0], tpl[1], 4)
            self.osc_range_per_frame_validator.setRange(tpl[0], tpl[1], 4)
            self.osc_total_range_validator.setRange(tpl[0], tpl[1], 4)

        self._acquisition_mib.bind_value_update(
            "osc_start",
            self.acq_widget_layout.osc_start_ledit,
            float,
            self.osc_start_validator,
        )

        self._acquisition_mib.bind_value_update(
            "osc_range",
            self.acq_widget_layout.osc_range_ledit,
            float,
            self.osc_range_per_frame_validator,
        )

        self._acquisition_mib.bind_value_update(
            "osc_total_range",
            self.acq_widget_layout.osc_total_range_ledit,
            float,
            self.osc_total_range_validator,
        )

        tpl = limits_dict.get("kappa")
        if tpl:
            self.kappa_validator.setRange(tpl[0], tpl[1], 4)
        self._acquisition_mib.bind_value_update(
            "kappa", self.acq_widget_layout.kappa_ledit, float, self.kappa_validator
        )

        tpl = limits_dict.get("kappa_phi")
        if tpl:
            self.kappa_phi_validator.setRange(tpl[0], tpl[1], 4)
        self._acquisition_mib.bind_value_update(
            "kappa_phi",
            self.acq_widget_layout.kappa_phi_ledit,
            float,
            self.kappa_phi_validator,
        )

        tpl = limits_dict.get("exposure_time")
        if tpl:
            self.exp_time_validator.setRange(tpl[0], tpl[1], 6)

        self._acquisition_mib.bind_value_update(
            "exp_time",
            self.acq_widget_layout.exp_time_ledit,
            float,
            self.exp_time_validator,
        )

        tpl = limits_dict.get("number_of_images")
        if tpl:
            self.num_img_validator.setRange(tpl[0], tpl[1])
            self.first_img_validator.setRange(tpl[0], tpl[1])

        self._acquisition_mib.bind_value_update(
            "first_image",
            self.acq_widget_layout.first_image_ledit,
            int,
            self.first_img_validator,
        )

        self._acquisition_mib.bind_value_update(
            "num_images",
            self.acq_widget_layout.num_images_ledit,
            int,
            self.num_img_validator,
        )

        num_passes = self.acq_widget_layout.findChild(
            qt_import.QLineEdit, "num_passes_ledit"
        )

        if num_passes:
            self._acquisition_mib.bind_value_update(
                "num_passes", num_passes, int, qt_import.QIntValidator(1, 1000, self)
            )

        overlap_ledit = self.acq_widget_layout.findChild(
            qt_import.QLineEdit, "overlap_ledit"
        )

        if overlap_ledit:
            self._acquisition_mib.bind_value_update(
                "overlap",
                overlap_ledit,
                float,
                qt_import.QDoubleValidator(-1000, 1000, 2, self),
            )

        self._acquisition_mib.bind_value_update(
            "energy", self.acq_widget_layout.energy_ledit, float, self.energy_validator
        )
        self.update_energy_limits(
            (self.energy_validator.bottom(), self.energy_validator.top())
        )

        self._acquisition_mib.bind_value_update(
            "transmission",
            self.acq_widget_layout.transmission_ledit,
            float,
            self.transmission_validator,
        )
        self.update_transmission_limits(
            (self.transmission_validator.bottom(), self.transmission_validator.top())
        )

        self._acquisition_mib.bind_value_update(
            "resolution",
            self.acq_widget_layout.resolution_ledit,
            float,
            self.resolution_validator,
        )
        # self.update_resolution_limits((self.resolution_validator.bottom(),
        #                               self.resolution_validator.top()))

        self._acquisition_mib.bind_value_update(
            "shutterless", self.acq_widget_layout.shutterless_cbx, bool, None
        )

        self.set_tunable_energy(HWR.beamline.tunable_wavelength)

        has_shutter_less = HWR.beamline.detector.has_shutterless()
        self.acq_widget_layout.shutterless_cbx.setEnabled(has_shutter_less)
        self.acq_widget_layout.shutterless_cbx.setChecked(has_shutter_less)

        if HWR.beamline.disable_num_passes:
            num_passes = self.acq_widget_layout.findChild(
                qt_import.QLineEdit, "num_passes_ledit"
            )
            if num_passes:
                num_passes.setDisabled(True)

        self.init_detector_roi_modes()
示例#13
0
    def __init__(self, parent=None, name="char_parameter_widget"):

        qt_import.QWidget.__init__(self, parent)

        if name is not None:
            self.setObjectName(name)

        # Hardware objects ----------------------------------------------------

        # Internal variables --------------------------------------------------
        self._char = None
        self._char_params = queue_model_objects.CharacterisationParameters()
        self._char_params_mib = DataModelInputBinder(self._char_params)
        self._tree_view_item = None
        self.previous_energy = None

        self.add_dc_cb = None

        # Graphic elements ----------------------------------------------------
        main_widget = qt_import.QWidget(self)
        rone_widget = qt_import.QWidget(main_widget)
        self.reference_img_widget = ReferenceImageWidget(rone_widget)
        self.acq_widget = self.reference_img_widget.acq_widget
        self.path_widget = self.reference_img_widget.path_widget
        self.position_widget = qt_import.load_ui_file(
            "snapshot_widget_layout.ui")
        self.position_widget.setMinimumSize(450, 340)

        rtwo_widget = qt_import.QWidget(main_widget)
        self.char_type_widget = CharTypeWidget(rtwo_widget)
        self.routine_dc_widget = self.char_type_widget.routine_dc_page
        self.sad_widget = self.char_type_widget.sad_page
        self.rad_dmg_char_widget = self.char_type_widget.rad_damage_page
        self.opt_parameters_widget = OptimisationParametersWidgetLayout(self)

        rtree_widget = qt_import.QWidget(main_widget)
        self.rad_dmg_widget = qt_import.load_ui_file(
            "radiation_damage_model_widget_layout.ui")
        self.vertical_dimension_widget = qt_import.load_ui_file(
            "vertical_crystal_dimension_widget_layout.ui")

        # Layout --------------------------------------------------------------
        rone_widget_layout = qt_import.QHBoxLayout(rone_widget)
        rone_widget_layout.addWidget(self.reference_img_widget)
        rone_widget_layout.addWidget(self.position_widget)
        # rone_widget_layout.addStretch(0)
        rone_widget_layout.setSpacing(2)
        rone_widget_layout.setContentsMargins(0, 0, 0, 0)

        rtwo_widget_layout = qt_import.QHBoxLayout(rtwo_widget)
        rtwo_widget_layout.addWidget(self.char_type_widget)
        rtwo_widget_layout.addWidget(self.opt_parameters_widget)
        rtwo_widget_layout.addStretch(0)
        rtwo_widget_layout.setSpacing(2)
        rtwo_widget_layout.setContentsMargins(0, 0, 0, 0)

        rtree_widget_layout = qt_import.QHBoxLayout(rtree_widget)
        rtree_widget_layout.addWidget(self.rad_dmg_widget)
        rtree_widget_layout.addWidget(self.vertical_dimension_widget)
        rtree_widget_layout.addStretch(10)
        rtree_widget_layout.setSpacing(2)
        rtree_widget_layout.setContentsMargins(0, 0, 0, 0)

        _main_widget_vlayout = qt_import.QVBoxLayout(main_widget)
        _main_widget_vlayout.addWidget(rone_widget)
        _main_widget_vlayout.addWidget(rtwo_widget)
        _main_widget_vlayout.addWidget(rtree_widget)
        _main_widget_vlayout.addStretch(10)
        _main_widget_vlayout.setSpacing(2)
        _main_widget_vlayout.setContentsMargins(0, 0, 0, 0)

        _main_hlayout = qt_import.QHBoxLayout(self)
        _main_hlayout.addWidget(main_widget)
        _main_hlayout.setSpacing(0)
        _main_hlayout.addStretch(0)
        _main_hlayout.setContentsMargins(0, 0, 0, 0)

        # SizePolicies -------------------------------------------------------

        # Qt signal/slot connections ------------------------------------------
        self.toggle_permitted_range(
            self.opt_parameters_widget.opt_param_widget.permitted_range_cbx.
            isChecked())

        self.opt_parameters_widget.opt_param_widget.permitted_range_cbx.toggled.connect(
            self.toggle_permitted_range)

        # Other ---------------------------------------------------------------
        self._char_params_mib.bind_value_update(
            "min_dose",
            self.routine_dc_widget.dose_ledit,
            float,
            qt_import.QDoubleValidator(0.0, 1000, 2, self),
        )

        self._char_params_mib.bind_value_update(
            "min_time",
            self.routine_dc_widget.time_ledit,
            float,
            qt_import.QDoubleValidator(0.0, 1000, 2, self),
        )

        self._char_params_mib.bind_value_update(
            "use_min_dose", self.routine_dc_widget.min_dose_radio, bool, None)

        self._char_params_mib.bind_value_update(
            "use_min_time", self.routine_dc_widget.min_time_radio, bool, None)

        self._char_params_mib.bind_value_update(
            "account_rad_damage",
            self.routine_dc_widget.radiation_damage_cbx,
            bool,
            None,
        )

        self._char_params_mib.bind_value_update(
            "auto_res", self.sad_widget.automatic_resolution_radio, bool, None)

        self._char_params_mib.bind_value_update(
            "sad_res",
            self.sad_widget.sad_resolution_ledit,
            float,
            qt_import.QDoubleValidator(0.5, 20, 3, self),
        )

        self._char_params_mib.bind_value_update(
            "opt_sad", self.sad_widget.optimised_sad_cbx, bool, None)

        self._char_params_mib.bind_value_update(
            "determine_rad_params", self.rad_dmg_char_widget.rad_damage_cbx,
            bool, None)

        self._char_params_mib.bind_value_update(
            "burn_osc_start",
            self.rad_dmg_char_widget.burn_osc_start_ledit,
            float,
            qt_import.QDoubleValidator(0.0, 1000, 2, self),
        )

        self._char_params_mib.bind_value_update(
            "burn_osc_interval",
            self.rad_dmg_char_widget.burn_osc_interval_ledit,
            float,
            qt_import.QDoubleValidator(0.0, 1000, 2, self),
        )

        self._char_params_mib.bind_value_update(
            "use_aimed_resolution",
            self.opt_parameters_widget.opt_param_widget.maximum_res_cbx,
            bool,
            None,
        )

        self._char_params_mib.bind_value_update(
            "use_aimed_multiplicity",
            self.opt_parameters_widget.opt_param_widget.aimed_mult_cbx,
            bool,
            None,
        )

        self._char_params_mib.bind_value_update(
            "aimed_resolution",
            self.opt_parameters_widget.opt_param_widget.maximum_res_ledit,
            float,
            qt_import.QDoubleValidator(0.01, 1000, 2, self),
        )

        self._char_params_mib.bind_value_update(
            "aimed_multiplicity",
            self.opt_parameters_widget.opt_param_widget.aimed_mult_ledit,
            float,
            qt_import.QDoubleValidator(0.01, 1000, 2, self),
        )

        self._char_params_mib.bind_value_update(
            "aimed_i_sigma",
            self.opt_parameters_widget.opt_param_widget.i_over_sigma_ledit,
            float,
            qt_import.QDoubleValidator(0.01, 1000, 2, self),
        )

        self._char_params_mib.bind_value_update(
            "aimed_completness",
            self.opt_parameters_widget.opt_param_widget.aimed_comp_ledit,
            float,
            qt_import.QDoubleValidator(0.01, 1000, 2, self),
        )

        self._char_params_mib.bind_value_update(
            "strategy_complexity",
            self.opt_parameters_widget.opt_param_widget.start_comp_cbox,
            int,
            None,
        )

        self._char_params_mib.bind_value_update(
            "use_permitted_rotation",
            self.opt_parameters_widget.opt_param_widget.permitted_range_cbx,
            bool,
            None,
        )

        self._char_params_mib.bind_value_update(
            "permitted_phi_start",
            self.opt_parameters_widget.opt_param_widget.phi_start_ledit,
            float,
            qt_import.QDoubleValidator(0.0, 1000, 2, self),
        )

        self._char_params_mib.bind_value_update(
            "permitted_phi_end",
            self.opt_parameters_widget.opt_param_widget.phi_end_ledit,
            float,
            qt_import.QDoubleValidator(0.0, 1000, 2, self),
        )

        self._char_params_mib.bind_value_update(
            "low_res_pass_strat",
            self.opt_parameters_widget.opt_param_widget.low_res_pass_cbx,
            bool,
            None,
        )

        self._char_params_mib.bind_value_update(
            "rad_suscept",
            self.rad_dmg_widget.sensetivity_ledit,
            float,
            qt_import.QDoubleValidator(0.0, 1000, 2, self),
        )

        self._char_params_mib.bind_value_update(
            "beta",
            self.rad_dmg_widget.beta_over_gray_ledit,
            float,
            qt_import.QDoubleValidator(0.0, 1000, 2, self),
        )

        self._char_params_mib.bind_value_update(
            "gamma",
            self.rad_dmg_widget.gamma_over_gray_ledit,
            float,
            qt_import.QDoubleValidator(0.0, 1000, 2, self),
        )

        self._char_params_mib.bind_value_update(
            "max_crystal_vdim",
            self.vertical_dimension_widget.max_vdim_ledit,
            float,
            qt_import.QDoubleValidator(0.0, 1000, 2, self),
        )

        self._char_params_mib.bind_value_update(
            "min_crystal_vdim",
            self.vertical_dimension_widget.min_vdim_ledit,
            float,
            qt_import.QDoubleValidator(0.0, 1000, 2, self),
        )

        self._char_params_mib.bind_value_update(
            "min_crystal_vphi",
            self.vertical_dimension_widget.min_vphi_ledit,
            float,
            qt_import.QDoubleValidator(0.0, 1000, 2, self),
        )

        self._char_params_mib.bind_value_update(
            "max_crystal_vphi",
            self.vertical_dimension_widget.max_vphi_ledit,
            float,
            qt_import.QDoubleValidator(0.0, 1000, 2, self),
        )

        # self._char_params_mib.bind_value_update('space_group',
        #                                        self.vertical_dimension_widget.space_group_ledit,
        #                                        str,
        #                                        None)

        self.vertical_dimension_widget.space_group_ledit.addItems(
            queue_model_enumerables.XTAL_SPACEGROUPS)

        self.char_type_widget.charact_type_tbox.currentChanged.connect(
            self.update_char_type)
        self.rad_dmg_char_widget.rad_damage_cbx.toggled.connect(
            self.enable_opt_parameters_widget)
        self.opt_parameters_widget.opt_param_widget.maximum_res_cbx.toggled.connect(
            self.enable_maximum_res_ledit)
        self.opt_parameters_widget.opt_param_widget.aimed_mult_cbx.toggled.connect(
            self.enable_aimed_mult_ledit)
        self.path_widget.data_path_layout.prefix_ledit.textChanged.connect(
            self._prefix_ledit_change)
        self.path_widget.data_path_layout.run_number_ledit.textChanged.connect(
            self._run_number_ledit_change)
        self.vertical_dimension_widget.space_group_ledit.activated.connect(
            self._space_group_change)
示例#14
0
    def __init__(self, parent=None, name=None, fl=0):

        CreateTaskBase.__init__(self, parent, name, fl, "Characterisation")
        self.setObjectName("create_char_widget")

        # Hardware objects ----------------------------------------------------

        # Internal variables --------------------------------------------------
        self._vertical_dimension_widget = None
        self._current_selected_item = None
        self._char = None
        self._char_params = None

        self.init_models()
        self._char_params_mib = DataModelInputBinder(self._char_params)

        # Graphic elements ----------------------------------------------------
        self._acq_widget = AcquisitionWidgetSimple(
            self,
            acq_params=self._acquisition_parameters,
            path_template=self._path_template,
        )

        self._data_path_widget = DataPathWidget(self,
                                                data_model=self._path_template,
                                                layout="vertical")

        self._vertical_dimension_widget = qt_import.load_ui_file(
            "vertical_crystal_dimension_widget_layout.ui")

        self._char_widget = qt_import.load_ui_file(
            "characterise_simple_widget_vertical_layout.ui")

        # Layout --------------------------------------------------------------
        _main_vlayout = qt_import.QVBoxLayout(self)
        _main_vlayout.addWidget(self._acq_widget)
        _main_vlayout.addWidget(self._data_path_widget)
        _main_vlayout.addWidget(self._char_widget)
        _main_vlayout.addWidget(self._vertical_dimension_widget)
        _main_vlayout.setContentsMargins(2, 2, 2, 2)
        _main_vlayout.setSpacing(6)
        _main_vlayout.addStretch(0)

        # SizePolicies --------------------------------------------------------

        # Qt signal/slot connections ------------------------------------------
        self._data_path_widget.pathTemplateChangedSignal.connect(
            self.path_template_changed)
        self._acq_widget.acqParametersChangedSignal.connect(
            self.acq_parameters_changed)

        self._vertical_dimension_widget.space_group_ledit.activated.connect(
            self._space_group_change)

        self._char_widget.characterisation_gbox.toggled.connect(
            self.characterisation_gbox_toggled)
        self._char_widget.wait_result_cbx.toggled.connect(
            self.wait_results_cbx_toggled)
        self._char_widget.execute_plan_cbx.toggled.connect(
            self.run_diffraction_plan_cbx_toggled)

        # Other ---------------------------------------------------------------
        if True:
            self._char_params_mib.bind_value_update(
                "opt_sad", self._char_widget.optimised_sad_cbx, bool, None)

            self._char_params_mib.bind_value_update(
                "account_rad_damage", self._char_widget.account_rad_dmg_cbx,
                bool, None)

            self._char_params_mib.bind_value_update(
                "strategy_complexity", self._char_widget.start_comp_cbox, int,
                None)

            self._char_params_mib.bind_value_update(
                "max_crystal_vdim",
                self._vertical_dimension_widget.max_vdim_ledit,
                float,
                qt_import.QDoubleValidator(0.0, 1000, 2, self),
            )

            self._char_params_mib.bind_value_update(
                "min_crystal_vdim",
                self._vertical_dimension_widget.min_vdim_ledit,
                float,
                qt_import.QDoubleValidator(0.0, 1000, 2, self),
            )

            self._char_params_mib.bind_value_update(
                "min_crystal_vphi",
                self._vertical_dimension_widget.min_vphi_ledit,
                float,
                qt_import.QDoubleValidator(0.0, 1000, 2, self),
            )

            self._char_params_mib.bind_value_update(
                "max_crystal_vphi",
                self._vertical_dimension_widget.max_vphi_ledit,
                float,
                qt_import.QDoubleValidator(0.0, 1000, 2, self),
            )

        self._vertical_dimension_widget.space_group_ledit.addItems(
            XTAL_SPACEGROUPS)

        self._data_path_widget.data_path_layout.compression_cbox.setVisible(
            False)
示例#15
0
    def __init__(self,
                 layout,
                 initial_value,
                 parent=None,
                 title="",
                 prefix=""):
        """"
        Constructor of StepEditor

        :param layout: select step value edit widget position
        :param initial_value: set motor initial position
        :param parent: parent widget
        :param title: step value edit widget's title
        :param prefix: + / - symbol fordward/backward step buttons
        """
        super(StepEditor, self).__init__(parent)

        self.prefix = prefix
        self.value = initial_value

        # Graphic elements-----------------------------------------------------

        self.title_label = qt_import.QLabel(title)
        self.selection_box = qt_import.QFrame()
        self.edition_box = qt_import.QFrame()

        self.txt_new_value = qt_import.QLineEdit()
        self.cmd_ok = qt_import.QPushButton()
        self.cmd_ok.setIcon(icons.load_icon("button_ok_small"))
        self.cmd_ok.setFixedWidth(20)

        self.cmd_cancel = qt_import.QPushButton()
        self.cmd_cancel.setIcon(icons.load_icon("button_cancel_small"))
        self.cmd_cancel.setFixedWidth(20)

        self.edition_box.hide()
        self.title_label.hide()
        self.edition_box.setSizePolicy(qt_import.QSizePolicy.Fixed,
                                       qt_import.QSizePolicy.Fixed)

        self.double_validator = qt_import.QDoubleValidator(self.txt_new_value)
        self.double_validator.setNotation(
            qt_import.QDoubleValidator.StandardNotation)
        self.txt_new_value.setValidator(self.double_validator)

        # Layout --------------------------------------------------------------

        self.main_vertical_layout = qt_import.QVBoxLayout()
        self.selection_box_layout = qt_import.QHBoxLayout()
        self.edition_box_layout = qt_import.QHBoxLayout()

        # widget's addition order defines their position

        self.edition_box_layout.addWidget(self.txt_new_value)
        self.edition_box_layout.addWidget(self.cmd_ok)
        self.edition_box_layout.addWidget(self.cmd_cancel)
        self.edition_box.setLayout(self.edition_box_layout)

        self.selection_box_layout.addWidget(self.edition_box)

        if layout == StepEditor.RIGHT_LAYOUT:
            self.cmd_select_value = qt_import.QPushButton(prefix +
                                                          str(initial_value))
            self.cmd_edit_value = qt_import.QPushButton("...")
            self.selection_box_layout.addWidget(self.cmd_select_value)
            self.selection_box_layout.addWidget(self.cmd_edit_value)

        else:
            self.cmd_edit_value = qt_import.QPushButton("...")
            self.cmd_select_value = qt_import.QPushButton(prefix +
                                                          str(initial_value))
            self.selection_box_layout.addWidget(self.cmd_edit_value)
            self.selection_box_layout.addWidget(self.cmd_select_value)

        self.selection_box.setLayout(self.selection_box_layout)

        self.main_vertical_layout.addWidget(self.title_label)
        self.main_vertical_layout.addWidget(self.selection_box)

        self.setLayout(self.main_vertical_layout)

        self.cmd_select_value.setAutoDefault(False)

        # Qt signal/slot connections -----------------------------------------
        self.cmd_select_value.clicked.connect(self.cmd_select_value_clicked)
        self.cmd_edit_value.clicked.connect(self.cmd_edit_values_clicked)
        self.txt_new_value.returnPressed.connect(self.validate_new_value)
        self.cmd_ok.clicked.connect(self.validate_new_value)
        self.cmd_cancel.clicked.connect(self.end_edit)
示例#16
0
    def __init__(self, parent=None, name=None, fl=0, xray_imaging_params=None):

        qt_import.QWidget.__init__(self, parent, qt_import.Qt.WindowFlags(fl))

        if name is not None:
            self.setObjectName(name)

        # Internal variables --------------------------------------------------

        # Properties ----------------------------------------------------------

        # Signals -------------------------------------------------------------

        # Slots ---------------------------------------------------------------

        # Graphic elements ----------------------------------------------------
        self._xray_imaging_parameters = xray_imaging_params
        self._xray_imaging_mib = DataModelInputBinder(
            self._xray_imaging_parameters)

        self._parameters_widget = qt_import.load_ui_file(
            "xray_imaging_parameters_widget_layout.ui")
        # Layout --------------------------------------------------------------
        __main_vlayout = qt_import.QVBoxLayout(self)
        __main_vlayout.addWidget(self._parameters_widget)
        __main_vlayout.setSpacing(0)
        __main_vlayout.setContentsMargins(0, 0, 0, 0)

        # SizePolicies --------------------------------------------------------

        # Qt signal/slot connections ------------------------------------------
        self._parameters_widget.ff_pre_cbox.toggled.connect(
            self.ff_pre_toggled)
        self._parameters_widget.ff_post_cbox.toggled.connect(
            self.ff_post_toggled)
        self._parameters_widget.add_button.pressed.connect(
            self.add_distance_pressed)
        self._parameters_widget.remove_button.pressed.connect(
            self.remove_distance_pressed)

        # Other ---------------------------------------------------------------
        # self.detector_distance_validator = qt_import.QIntValidator(
        #     0, 99999, self._parameters_widget.detector_distance_ledit
        # )
        self.detector_distance_validator = qt_import.QDoubleValidator(
            0, 99999, 2, self._parameters_widget.detector_distance_ledit)

        self._xray_imaging_mib.bind_value_update(
            "camera_write_data", self._parameters_widget.store_data_cbox, bool,
            None)

        self._xray_imaging_mib.bind_value_update(
            "ff_pre", self._parameters_widget.ff_pre_cbox, bool, None)

        self._xray_imaging_mib.bind_value_update(
            "ff_post", self._parameters_widget.ff_post_cbox, bool, None)

        self._xray_imaging_mib.bind_value_update(
            "ff_apply", self._parameters_widget.ff_apply_cbox, bool, None)

        self._xray_imaging_mib.bind_value_update(
            "ff_ssim_enabled", self._parameters_widget.ff_ssim_cbox, bool,
            None)

        self._xray_imaging_mib.bind_value_update(
            "ff_num_images", self._parameters_widget.ff_num_images_ledit, int,
            None)

        self._xray_imaging_mib.bind_value_update(
            "sample_offset_a",
            self._parameters_widget.ff_offset_a_ledit,
            float,
            None,
        )

        self._xray_imaging_mib.bind_value_update(
            "sample_offset_b",
            self._parameters_widget.ff_offset_b_ledit,
            float,
            None,
        )

        self._xray_imaging_mib.bind_value_update(
            "sample_offset_c",
            self._parameters_widget.ff_offset_c_ledit,
            float,
            None,
        )

        self._xray_imaging_mib.bind_value_update(
            "detector_distance",
            self._parameters_widget.detector_distance_ledit,
            float,
            self.detector_distance_validator,
        )
示例#17
0
    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 = qt_import.QGroupBox(self)

        self.kappa_dspinbox = qt_import.QDoubleSpinBox(_main_gbox)
        self.kappa_dspinbox.setRange(-360, 360)
        self.kappaphi_dspinbox = qt_import.QDoubleSpinBox(_main_gbox)
        self.kappaphi_dspinbox.setRange(-360, 360)
        self.step_cbox = qt_import.QComboBox(_main_gbox)
        self.step_button_icon = icons.load_icon("TileCascade2")
        self.close_button = qt_import.QPushButton(_main_gbox)
        self.stop_button = qt_import.QPushButton(_main_gbox)

        # Layout --------------------------------------------------------------
        _main_gbox_hlayout = qt_import.QHBoxLayout(_main_gbox)
        _main_gbox_hlayout.addWidget(qt_import.QLabel("Kappa:", _main_gbox))
        _main_gbox_hlayout.addWidget(self.kappa_dspinbox)
        _main_gbox_hlayout.addWidget(qt_import.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 = qt_import.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.editTextChanged.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(qt_import.Qt.AlignRight)
        self.kappa_dspinbox.setFixedWidth(75)
        self.kappaphi_dspinbox.setAlignment(qt_import.Qt.AlignRight)
        self.kappaphi_dspinbox.setFixedWidth(75)

        self.step_cbox.setEditable(True)
        self.step_cbox.setValidator(
            qt_import.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)