Exemplo n.º 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 = QtImport.QGroupBox("Transmission", self)
        current_label = QtImport.QLabel("Current:", self.group_box)
        current_label.setFixedWidth(75)
        self.transmission_ledit = QtImport.QLineEdit(self.group_box)
        self.transmission_ledit.setReadOnly(True)
        set_to_label = QtImport.QLabel("Set to:", self.group_box)
        self.new_value_ledit = QtImport.QLineEdit(self.group_box)

        # Layout --------------------------------------------------------------
        _group_box_gridlayout = QtImport.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 = QtImport.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 = QtImport.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()
Exemplo n.º 2
0
    def __init__(self, parent):

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

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

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

        self.grid_layout = QtImport.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 = QtImport.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(
            QtImport.QSizePolicy.Fixed, QtImport.QSizePolicy.Fixed
        )
        self.setSizePolicy(QtImport.QSizePolicy.Minimum, QtImport.QSizePolicy.Minimum)

        # Other ---------------------------------------------------------------
        self.setWindowTitle("Motor step editor")
        self.apply_button.setIcon(Icons.load_icon("Check"))
        self.close_button.setIcon(Icons.load_icon("Delete"))
Exemplo n.º 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 = QtImport.QGroupBox("Beamstop distance", self)
        current_label = QtImport.QLabel("Current:", self.group_box)
        current_label.setFixedWidth(75)
        self.beamstop_distance_ledit = QtImport.QLineEdit(self.group_box)
        self.beamstop_distance_ledit.setReadOnly(True)
        set_to_label = QtImport.QLabel("Set to:", self.group_box)
        self.new_value_ledit = QtImport.QLineEdit(self.group_box)

        # Layout --------------------------------------------------------------
        _group_box_gridlayout = QtImport.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 = QtImport.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,
                                QtImport.QPalette.Base)
        self.new_value_validator = QtImport.QDoubleValidator(
            0, 100, 2, self.new_value_ledit)
Exemplo n.º 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 = QtImport.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)
Exemplo n.º 5
0
    def __init__(self, parent=None, name="gphl_acquisition_widget"):
        GphlSetupWidget.__init__(self, parent=parent, name=name)

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

        _parameters_widget = self._parameters_widget

        row = 0
        field_name = "crystal_system"
        label_name = self._get_label_name(field_name)
        label_str = "Crystal system :"
        label = QtImport.QLabel(label_str, _parameters_widget)
        _parameters_widget.layout().addWidget(label, row, 0)
        self._widget_data[label_name] = (label, str, None, label_str)
        widget = QtImport.QComboBox()
        _parameters_widget.layout().addWidget(widget, row, 1)
        self._widget_data[field_name] = (widget, str, None, 0)
        self._pulldowns[field_name] = list(self._CRYSTAL_SYSTEM_DATA)

        row += 1
        field_name = "space_group"
        label_name = self._get_label_name(field_name)
        label_str = "Space group :"
        label = QtImport.QLabel(label_str, _parameters_widget)
        _parameters_widget.layout().addWidget(label, row, 0)
        self._widget_data[label_name] = (label, str, None, label_str)
        widget = QtImport.QComboBox()
        _parameters_widget.layout().addWidget(widget, row, 1)
        self._widget_data[field_name] = (widget, str, None, 0)

        row += 1
        field_name = "characterisation_strategy"
        label_name = self._get_label_name(field_name)
        label_str = "Characterisation strategy :"
        label = QtImport.QLabel(label_str, _parameters_widget)
        _parameters_widget.layout().addWidget(label, row, 0)
        self._widget_data[label_name] = (label, str, None, label_str)
        widget = QtImport.QComboBox()
        _parameters_widget.layout().addWidget(widget, row, 1)
        self._widget_data[field_name] = (widget, str, None, 0)
        strategy_names = HWR.beamline.gphl_workflow.get_property(
            "characterisation_strategies").split()
        self._pulldowns[field_name] = strategy_names

        row += 1
        field_name = "dose_budget"
        label_name = self._get_label_name(field_name)
        label_str = "Dose budget (MGy) :"
        label = QtImport.QLabel(label_str, _parameters_widget)
        _parameters_widget.layout().addWidget(label, row, 0)
        self._widget_data[label_name] = (label, str, None, label_str)
        widget = QtImport.QComboBox()
        _parameters_widget.layout().addWidget(widget, row, 1)
        self._widget_data[field_name] = (widget, str, None, 0)
        self._pulldowns[field_name] = list(
            HWR.beamline.gphl_workflow.dose_budgets)
        self._pulldown_defaults[
            field_name] = HWR.beamline.gphl_workflow.default_dose_budget_label
        indx = self._pulldowns[field_name].index(
            HWR.beamline.gphl_workflow.default_dose_budget_label)
        self._widget_data[field_name] = (widget, str, None, indx)

        row += 1
        field_name = "relative_rad_sensitivity"
        label_name = self._get_label_name(field_name)
        label_str = "Rel. radiation sensitivity"
        label = QtImport.QLabel(label_str, _parameters_widget)
        _parameters_widget.layout().addWidget(label, row, 0)
        self._widget_data[label_name] = (label, str, None, label_str)
        widget = QtImport.QLineEdit()
        _parameters_widget.layout().addWidget(widget, row, 1)
        validator = QtImport.QDoubleValidator(0, 100, 4, widget)
        self._widget_data[field_name] = (widget, float, validator, 1.0)
Exemplo n.º 6
0
    def __init__(self, parent=None, name="gphl_acquisition_widget"):
        GphlSetupWidget.__init__(self, parent=parent, name=name)

        _parameters_widget = self._parameters_widget

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

        # Get test crystal data
        self.test_crystals = OrderedDict()
        xx0 = next(HWR.beamline.gphl_workflow.get_objects("test_crystals"))
        for test_crystal in xx0.get_objects("test_crystal"):
            dd0 = test_crystal.get_properties()
            self.test_crystals[dd0["name"]] = CrystalData(**dd0)

        row = 0
        field_name = "test_crystal"
        label_name = self._get_label_name(field_name)
        label_str = "Test Crystal :"
        label = QtImport.QLabel(label_str, _parameters_widget)
        _parameters_widget.layout().addWidget(label, row, 0)
        self._widget_data[label_name] = (label, str, None, label_str)
        widget = QtImport.QComboBox()
        _parameters_widget.layout().addWidget(widget, row, 1)
        self._widget_data[field_name] = (widget, str, None, 0)
        self._pulldowns[field_name] = list(self.test_crystals)

        row += 1
        label_name = "test_crystal_spacegroup"
        label_str = " "
        label = QtImport.QLabel(label_str, _parameters_widget)
        _parameters_widget.layout().addWidget(label, row, 0)
        self._widget_data[label_name] = (label, str, None, label_str)
        label_name = "test_crystal_parameters"
        label_str = " "
        label = QtImport.QLabel(label_str, _parameters_widget)
        _parameters_widget.layout().addWidget(label, row, 1)
        self._widget_data[label_name] = (label, str, None, label_str)

        row += 1
        field_name = "dose_budget"
        label_name = self._get_label_name(field_name)
        label_str = "Dose budget (MGy) :"
        label = QtImport.QLabel(label_str, _parameters_widget)
        _parameters_widget.layout().addWidget(label, row, 0)
        self._widget_data[label_name] = (label, str, None, label_str)
        widget = QtImport.QComboBox()
        _parameters_widget.layout().addWidget(widget, row, 1)
        self._pulldowns[field_name] = list(
            HWR.beamline.gphl_workflow.dose_budgets)
        self._pulldown_defaults[
            field_name] = HWR.beamline.gphl_workflow.default_dose_budget_label
        indx = self._pulldowns[field_name].index(
            HWR.beamline.gphl_workflow.default_dose_budget_label)
        self._widget_data[field_name] = (widget, str, None, indx)

        row += 1
        field_name = "relative_rad_sensitivity"
        label_name = self._get_label_name(field_name)
        label_str = "Rel. radiation sensitivity"
        label = QtImport.QLabel(label_str, _parameters_widget)
        _parameters_widget.layout().addWidget(label, row, 0)
        self._widget_data[label_name] = (label, str, None, label_str)
        widget = QtImport.QLineEdit()
        _parameters_widget.layout().addWidget(widget, row, 1)
        validator = QtImport.QDoubleValidator(0, 100, 4, widget)
        self._widget_data[field_name] = (widget, float, validator, 1.0)
Exemplo n.º 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 = []

        # 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")
Exemplo n.º 8
0
    def __init__(
        self,
        parent=None,
        name=None,
        fl=0,
        acq_params=None,
        path_template=None,
        layout=None,
    ):

        QtImport.QWidget.__init__(self, parent, QtImport.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 = QtImport.load_ui_file(
            "acquisition_widget_vertical_simple_layout.ui")

        # Layout --------------------------------------------------------------
        main_layout = QtImport.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 = QtImport.QDoubleValidator(
            -10000, 10000, 4, self.acq_widget_layout.osc_start_ledit)
        self.osc_range_validator = QtImport.QDoubleValidator(
            -10000, 10000, 4, self.acq_widget_layout.osc_range_ledit)
        self.kappa_validator = QtImport.QDoubleValidator(
            0, 360, 4, self.acq_widget_layout.kappa_ledit)
        self.kappa_phi_validator = QtImport.QDoubleValidator(
            0, 360, 4, self.acq_widget_layout.kappa_phi_ledit)
        self.energy_validator = QtImport.QDoubleValidator(
            0, 25, 5, self.acq_widget_layout.energy_ledit)
        self.resolution_validator = QtImport.QDoubleValidator(
            0, 15, 3, self.acq_widget_layout.resolution_ledit)
        self.transmission_validator = QtImport.QDoubleValidator(
            0, 100, 3, self.acq_widget_layout.transmission_ledit)
        self.exp_time_validator = QtImport.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()
Exemplo n.º 9
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:
        """

        QtImport.QWidget.__init__(self, parent, QtImport.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 = QtImport.load_ui_file(
            "acquisition_widget_vertical_still_layout.ui")
        # Layout --------------------------------------------------------------
        __main_vlayout = QtImport.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 = QtImport.QDoubleValidator(
            4, 25, 4, self.acq_widget_layout.energy_ledit)
        self.resolution_validator = QtImport.QDoubleValidator(
            0, 15, 3, self.acq_widget_layout.resolution_ledit)
        self.transmission_validator = QtImport.QDoubleValidator(
            0, 100, 3, self.acq_widget_layout.transmission_ledit)
        self.exp_time_validator = QtImport.QDoubleValidator(
            0.0001, 10000, 7, self.acq_widget_layout.exp_time_ledit)
        self.num_triggers_validator = QtImport.QIntValidator(
            1, 9999999, self.acq_widget_layout.num_triggers_ledit)
        self.num_images_per_trigger_validator = QtImport.QIntValidator(
            1, 9999999, self.acq_widget_layout.num_images_per_trigger_ledit)
        self.num_img_validator = QtImport.QIntValidator(
            1, 9999999, self.acq_widget_layout.num_images_ledit)
        self.hare_num_validator = QtImport.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()
Exemplo n.º 10
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 = 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)
Exemplo n.º 11
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 = QtImport.QLabel(title)
        self.selection_box = QtImport.QFrame()
        self.edition_box = QtImport.QFrame()

        self.txt_new_value = QtImport.QLineEdit()
        self.cmd_ok = QtImport.QPushButton()
        self.cmd_ok.setIcon(Icons.load_icon("button_ok_small"))
        self.cmd_ok.setFixedWidth(20)

        self.cmd_cancel = QtImport.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(QtImport.QSizePolicy.Fixed,
                                       QtImport.QSizePolicy.Fixed)

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

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

        self.main_vertical_layout = QtImport.QVBoxLayout()
        self.selection_box_layout = QtImport.QHBoxLayout()
        self.edition_box_layout = QtImport.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 = QtImport.QPushButton(prefix +
                                                         str(initial_value))
            self.cmd_edit_value = QtImport.QPushButton("...")
            self.selection_box_layout.addWidget(self.cmd_select_value)
            self.selection_box_layout.addWidget(self.cmd_edit_value)

        else:
            self.cmd_edit_value = QtImport.QPushButton("...")
            self.cmd_select_value = QtImport.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)
Exemplo n.º 12
0
    def __init__(
        self,
        parent=None,
        name=None,
        fl=0,
        acq_params=None,
        path_template=None,
        layout="horizontal",
    ):

        QtImport.QWidget.__init__(self, parent, QtImport.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 = QtImport.load_ui_file(
                "acquisition_widget_horizontal_layout.ui"
            )
            self.use_osc_start(False)
        else:
            self.acq_widget_layout = QtImport.load_ui_file(
                "acquisition_widget_vertical_layout.ui"
            )

        # Layout --------------------------------------------------------------
        __main_vlayout = QtImport.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(QtImport.QLineEdit, "overlap_ledit"):
            self.acq_widget_layout.overlap_ledit.textChanged.connect(
                self.overlap_changed
            )
        if self.acq_widget_layout.findChild(QtImport.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 = QtImport.QDoubleValidator(
            -10000, 10000, 4, self.acq_widget_layout.osc_start_ledit
        )
        self.osc_range_per_frame_validator = QtImport.QDoubleValidator(
            0, 10000, 4, self.acq_widget_layout.osc_range_ledit
        )
        self.osc_total_range_validator = QtImport.QDoubleValidator(
            0, 10000, 4, self.acq_widget_layout.osc_total_range_ledit
        )
        self.kappa_validator = QtImport.QDoubleValidator(
            -0.01, 360, 4, self.acq_widget_layout.kappa_ledit
        )
        self.kappa_phi_validator = QtImport.QDoubleValidator(
            -360, 360, 4, self.acq_widget_layout.kappa_phi_ledit
        )
        self.energy_validator = QtImport.QDoubleValidator(
            4, 25, 5, self.acq_widget_layout.energy_ledit
        )
        self.resolution_validator = QtImport.QDoubleValidator(
            0, 15, 3, self.acq_widget_layout.resolution_ledit
        )
        self.transmission_validator = QtImport.QDoubleValidator(
            0, 100, 3, self.acq_widget_layout.transmission_ledit
        )
        self.exp_time_validator = QtImport.QDoubleValidator(
            0.0001, 10000, 7, self.acq_widget_layout.exp_time_ledit
        )
        self.first_img_validator = QtImport.QIntValidator(
            0, 99999, self.acq_widget_layout.first_image_ledit
        )
        self.num_img_validator = QtImport.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()
Exemplo n.º 13
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(
            QtImport.QLineEdit, "num_passes_ledit"
        )

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

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

        if overlap_ledit:
            self._acquisition_mib.bind_value_update(
                "overlap",
                overlap_ledit,
                float,
                QtImport.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(
                QtImport.QLineEdit, "num_passes_ledit"
            )
            if num_passes:
                num_passes.setDisabled(True)

        self.init_detector_roi_modes()
Exemplo n.º 14
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 -----------------------------------------------------
        self.energy_limits = None
        self.wavelength_limits = None

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

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

        self.new_value_widget = QtImport.QWidget(self)
        self.set_to_label = QtImport.QLabel("Set to: ", self)
        self.new_value_ledit = QtImport.QLineEdit(self.new_value_widget)
        # self.new_value_ledit.setMaximumWidth(60)
        self.units_combobox = QtImport.QComboBox(self.new_value_widget)
        self.units_combobox.addItems(["keV", u"\u212B"])
        self.stop_button = QtImport.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 = QtImport.QCheckBox(
            "Center beam after energy change", self)

        # Layout --------------------------------------------------------------
        _new_value_widget_hlayout = QtImport.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 = QtImport.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 = QtImport.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 = QtImport.QDoubleValidator(
            0, 15, 4, self.new_value_ledit)
        self.status_ledit.setEnabled(False)

        self.instance_synchronize("energy_ledit", "new_value_ledit")
Exemplo n.º 15
0
    def __init__(self, parent=None, name=None, fl=0, xray_imaging_params=None):

        QtImport.QWidget.__init__(self, parent, QtImport.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 = QtImport.load_ui_file(
            "xray_imaging_parameters_widget_layout.ui")
        # Layout --------------------------------------------------------------
        __main_vlayout = QtImport.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 = QtImport.QIntValidator(
        #     0, 99999, self._parameters_widget.detector_distance_ledit
        # )
        self.detector_distance_validator = QtImport.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,
        )
Exemplo n.º 16
0
    def __init__(self, parent=None, name="char_parameter_widget"):

        QtImport.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 = QtImport.QWidget(self)
        rone_widget = QtImport.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 = QtImport.load_ui_file(
            "snapshot_widget_layout.ui")
        self.position_widget.setMinimumSize(450, 340)

        rtwo_widget = QtImport.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 = QtImport.QWidget(main_widget)
        self.rad_dmg_widget = QtImport.load_ui_file(
            "radiation_damage_model_widget_layout.ui")
        self.vertical_dimension_widget = QtImport.load_ui_file(
            "vertical_crystal_dimension_widget_layout.ui")

        # Layout --------------------------------------------------------------
        rone_widget_layout = QtImport.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 = QtImport.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 = QtImport.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 = QtImport.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 = QtImport.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,
            QtImport.QDoubleValidator(0.0, 1000, 2, self),
        )

        self._char_params_mib.bind_value_update(
            "min_time",
            self.routine_dc_widget.time_ledit,
            float,
            QtImport.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,
            QtImport.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,
            QtImport.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,
            QtImport.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,
            QtImport.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,
            QtImport.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,
            QtImport.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,
            QtImport.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,
            QtImport.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,
            QtImport.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,
            QtImport.QDoubleValidator(0.0, 1000, 2, self),
        )

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

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

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

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

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

        self._char_params_mib.bind_value_update(
            "max_crystal_vphi",
            self.vertical_dimension_widget.max_vphi_ledit,
            float,
            QtImport.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)
Exemplo n.º 17
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 = QtImport.QGroupBox("Resolution", self)
        current_label = QtImport.QLabel("Current:", self.group_box)
        current_label.setFixedWidth(75)

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

        _new_value_widget = QtImport.QWidget(self)
        set_to_label = QtImport.QLabel("Set to:", self.group_box)
        self.new_value_ledit = QtImport.QLineEdit(self.group_box)
        self.units_combobox = QtImport.QComboBox(_new_value_widget)
        self.stop_button = QtImport.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 = QtImport.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 = QtImport.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 = QtImport.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, QtImport.QPalette.Base
        )
        self.new_value_validator = QtImport.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",
        )
Exemplo n.º 18
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 = QtImport.load_ui_file(
            "vertical_crystal_dimension_widget_layout.ui")

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

        self._comments_widget = CommentsWidget(self)

        # Layout --------------------------------------------------------------
        _main_vlayout = QtImport.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.addWidget(self._comments_widget)
        _main_vlayout.setContentsMargins(2, 2, 2, 2)
        _main_vlayout.setSpacing(6)
        _main_vlayout.addStretch(0)

        # SizePolicies --------------------------------------------------------
        self._comments_widget.setFixedHeight(100)

        # 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 False:
            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,
                QtImport.QDoubleValidator(0.0, 1000, 2, self),
            )

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

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

            self._char_params_mib.bind_value_update(
                "max_crystal_vphi",
                self._vertical_dimension_widget.max_vphi_ledit,
                float,
                QtImport.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)