コード例 #1
0
ファイル: widget_utils.py プロジェクト: natxo14/mxcube
    def __ledit_update_value(self, field_name, widget, new_value, type_fn,
                             validator):
        if not self.bindings[field_name][3]:
            origin_value = new_value
            if type_fn == float and validator:
                pattern = "%." + str(validator.decimals()) + "f"
                new_value = pattern % float(new_value)

            # fix validation if PyQt4 and sipapi 1 is used
            if isinstance(new_value, string_types):
                if "QString" in globals():
                    new_value = QtImport.QString(new_value)

            self.__validated(field_name, validator,
                             self.bindings[field_name][0], new_value)
            if isinstance(widget, QtImport.QLineEdit):
                if type_fn is float and validator:
                    widget.setText("{:g}".format(
                        round(float(origin_value), validator.decimals())))
            try:
                setattr(self.__model, field_name, type_fn(origin_value))
            except ValueError:
                if origin_value != "":
                    raise
            else:
                dispatcher.send("model_update", self.__model, field_name, self)
コード例 #2
0
    def _refresh_interface(self, field_name, data_binder):
        """Refresh interface when values change"""
        if field_name == "test_crystal":
            # Refresh crystal parameters label to reflect test_crystal pulldown
            test_crystal = self.get_parameter_value("test_crystal") or ""
            crystal_data = self.test_crystals.get(test_crystal)
            if crystal_data:
                label_str1 = "Spacegroup=%(space_group)s\n\n" % crystal_data._asdict(
                )
                label_str2 = (
                    "a=%(a)s   b=%(b)s   c=%(c)s\n" +
                    "alpha=%(alpha)s   beta=%(beta)s   gamma=%(gamma)s\n"
                ) % crystal_data._asdict()
            else:
                label_str1 = label_str2 = " "
            label = self._widget_data["test_crystal_spacegroup"][0]
            label.setText(QtImport.QString(label_str1))

            label = self._widget_data["test_crystal_parameters"][0]
            label.setText(QtImport.QString(label_str2))
コード例 #3
0
    def populate_widget(self, **kwargs):

        self._data_object = data_object = GphlAcquisitionData()
        self._parameter_mib.bindings.clear()
        # NB must be done here to set empty model, and also in subclasses:
        self._parameter_mib.set_model(data_object)
        for field_name, tags in self._pulldowns.items():
            widget = self._widget_data[field_name][0]
            widget.clear()
            widget.addItems(list(QtImport.QString(tag) for tag in tags))
            default_label = self._pulldown_defaults.get(field_name)
            if default_label is None:
                widget.setCurrentIndex(0)
                self._data_object.space_group = 0

            else:
                widget.setCurrentIndex(widget.findText(default_label))
コード例 #4
0
ファイル: SSXControlBrick.py プロジェクト: natxo14/mxcube
    def update_table(self):
        header = self.ssx_widget_layout.interlacings_tableWidget.horizontalHeader()
        self.ssx_widget_layout.quarter_density_checkbox.setEnabled(True)
        self.ssx_widget_layout.meandering_checkbox.setEnabled(True)
        # gets the list of interlacings

        interlacings_list = self.ssx_control_hwobj.get_interlacings_list()

        # update interlacings_textEdit
        self.ssx_widget_layout.interlacings_text_edit.setText(
            str(len(interlacings_list))
        )

        # set number of rows and columns
        self.ssx_widget_layout.interlacings_tableWidget.setRowCount(
            len(interlacings_list)
        )
        self.ssx_widget_layout.interlacings_tableWidget.setColumnCount(2)

        # resize columns respectively
        header.setResizeMode(QtImport.QHeaderView.Stretch)

        # headers names
        self.ssx_widget_layout.interlacings_tableWidget.setHorizontalHeaderLabels(
            QtImport.QString("interlace;est. delay (s)").split(";")
        )

        # set non editable
        self.ssx_widget_layout.interlacings_tableWidget.setEditTriggers(
            QtImport.QAbstractItemView.NoEditTriggers
        )

        # fill the table
        for element in range(0, len(interlacingsList)):
            self.ssx_widget_layout.interlacings_tableWidget.setItem(
                element, 0, QtImport.QTableWidgetItem(str(interlacingsList[element]))
            )
            self.ssx_widget_layout.interlacings_tableWidget.setItem(
                element,
                1,
                QtImport.QTableWidgetItem(
                    str(round(interlacingsList[element] / scan_rate, 3))
                ),
            )
コード例 #5
0
    def _refresh_interface(self, field_name, data_binder):
        """Refresh interface when values change"""
        if field_name == "crystal_system":
            # Refresh space_group pulldown to reflect crystal_system pulldown
            crystal_system = self.get_parameter_value("crystal_system") or ""
            data = self._CRYSTAL_SYSTEM_DATA[crystal_system]
            ll0 = self._pulldowns["space_group"] = []
            if data.crystal_system:
                ll0.append("")
                ll0.extend([
                    x.name for x in queue_model_enumerables.SPACEGROUP_DATA
                    if x.point_group in data.point_groups
                ])
            else:
                ll0.extend(queue_model_enumerables.XTAL_SPACEGROUPS)

            widget = self._widget_data["space_group"][0]
            widget.clear()
            widget.addItems(list(QtImport.QString(tag) for tag in ll0))
            self._data_object.space_group = 0
コード例 #6
0
ファイル: SSXControlBrick.py プロジェクト: natxo14/mxcube
    def __init__(self, *args):
        BaseWidget.__init__(self, *args)

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

        # Internal values -----------------------------------------------------
        self.current_chip_config = None
        self.chip_file_dir = ""
        self.chip_filenames_list = []
        self.shortlist_dir = ""

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

        # Properties to initialize hardware objects --------------------------
        self.add_property("hwobj_ssx_control", "string", "")

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

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

        # Graphic elements ----------------------------------------------------
        self.ssx_widget_layout = QtImport.load_ui_file("ssx_control_widget_layout.ui")

        # Layout --------------------------------------------------------------
        _main_layout = QtImport.QVBoxLayout(self)
        _main_layout.addWidget(self.ssx_widget_layout)

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

        # Qt signal/slot connections ------------------------------------------
        self.ssx_widget_layout.start_button.clicked.connect(self.start_experiment)
        self.ssx_widget_layout.chip_file_dir_browse_button.clicked.connect(
            self.get_chip_file_directory
        )
        self.ssx_widget_layout.shortlist_dir_browse_button.clicked.connect(
            self.get_shortlist_directory
        )
        self.ssx_widget_layout.save_chip_data_button.clicked.connect(
            self.save_chip_data
        )
        self.ssx_widget_layout.create_shortlist_button.clicked.connect(
            self.create_short_list
        )
        self.ssx_widget_layout.enable_all_button.clicked.connect(self.enable_all)
        self.ssx_widget_layout.disable_all_button.clicked.connect(self.disable_all)
        self.ssx_widget_layout.color_table.itemSelectionChanged.connect(
            self.change_cell_color
        )
        self.ssx_widget_layout.quarter_density_checkbox.stateChanged.connect(
            self.quarter_density_enabled
        )
        self.ssx_widget_layout.quarter_density_checkbox.setEnabled(False)
        self.ssx_widget_layout.meandering_checkbox.stateChanged.connect(
            self.meandering_enabled
        )

        # Other ---------------------------------------------------------------
        self.ssx_widget_layout.crystal_h_pitch_spinbox.valueChanged.connect(
            self.crystal_h_pitch_changed
        )
        self.ssx_widget_layout.crystal_v_pitch_spinbox.valueChanged.connect(
            self.crystal_v_pitch_changed
        )
        self.ssx_widget_layout.comp_h_pitch_spinbox.valueChanged.connect(
            self.comp_h_pitch_changed
        )
        self.ssx_widget_layout.comp_v_pitch_spinbox.valueChanged.connect(
            self.comp_v_pitch_changed
        )
        self.ssx_widget_layout.num_crystal_h_spinbox.valueChanged.connect(
            self.num_crystal_h_changed
        )
        self.ssx_widget_layout.num_crystal_v_spinbox.valueChanged.connect(
            self.num_crystal_v_changed
        )
        self.ssx_widget_layout.num_comp_h_spinbox.valueChanged.connect(
            self.num_comp_h_changed
        )
        self.ssx_widget_layout.num_comp_v_spinbox.valueChanged.connect(
            self.num_copm_v_changed
        )

        self.ssx_widget_layout.meandering_checkbox.setEnabled(False)

        # connect exposures per feature
        self.ssx_widget_layout.exp_per_feature_spinbox.valueChanged[unicode].connect(
            self.set_exposures_per_feature
        )
        # show names and one column at exposures per feature
        self.ssx_widget_layout.dg_channels_table.setRowCount(4)
        self.ssx_widget_layout.dg_channels_table.setColumnCount(1)
        # headers names
        self.ssx_widget_layout.dg_channels_table.setVerticalHeaderLabels(
            QtImport.QString("Detector;Excitation;Aux1;Aux2").split(";")
        )
        # set first column of checkboxes
        dg_channels_list = []

        for row in range(0, 4):
            checkbox_item = QtImport.QTableWidgetItem()
            checkbox_item.setFlags(
                QtImport.Qt.ItemIsUserCheckable | QtImport.Qt.ItemIsEnabled
            )
            checkbox_item.setCheckState(QtImport.Qt.Unchecked)
            dg_channels_list.append(checkbox_item)
            self.ssx_widget_layout.dg_channels_table.setItem(row, 0, checkbox_item)

        # set a color table with 3 by 3 cells
        self.ssx_widget_layout.color_table.setRowCount(3)
        self.ssx_widget_layout.color_table.setColumnCount(3)
        # set min size of cells
        self.ssx_widget_layout.color_table.horizontalHeader().setDefaultSectionSize(25)
        self.ssx_widget_layout.color_table.verticalHeader().setDefaultSectionSize(25)
        # table is non editable
        self.ssx_widget_layout.color_table.setEditTriggers(
            QtImport.QAbstractItemView.NoEditTriggers
        )
        # fill the table with empty items
        for row in range(0, 3):
            for column in range(0, 3):
                self.ssx_widget_layout.color_table.setItem(
                    row, column, QtImport.QTableWidgetItem()
                )
                self.ssx_widget_layout.color_table.item(row, column).setBackground(
                    Colors.GREEN
                )

        # connect scan rate
        self.ssx_widget_layout.scan_rate_ledit.textEdited.connect(
            self.scan_rate_text_changed
        )