Exemplo n.º 1
0
    def init_interface(self):
        """
        Build up GUI
        """

        tmp_dict = self.multipos_hwobj.get_positions()

        if tmp_dict:
            if not self.table_created:
                # create table items for first and only time
                self.ui_widgets_manager.beam_positions_table.setRowCount(
                    len(tmp_dict))

                for row in range(len(tmp_dict)):
                    for col in range(3):
                        tmp_item = qt_import.QTableWidgetItem()
                        tmp_item.setFlags(tmp_item.flags()
                                          ^ qt_import.Qt.ItemIsEditable)
                        self.ui_widgets_manager.beam_positions_table.setItem(
                            row, col, tmp_item)
                self.table_created = True

            table = self.ui_widgets_manager.beam_positions_table

            for i, (position, position_dict) in enumerate(tmp_dict.items()):
                beam_pos_x = position_dict["beam_pos_x"]
                beam_pos_y = position_dict["beam_pos_y"]

                table.item(i, 0).setText(str(position))
                table.item(i, 1).setText(str(beam_pos_x))
                table.item(i, 2).setText(str(beam_pos_y))
Exemplo n.º 2
0
    def init_plate_view(self):
        """Initalizes plate info
        """
        cell_width = 25
        cell_height = 23

        plate_info = HWR.beamline.plate_manipulator.get_plate_info()

        self.num_cols = plate_info.get("num_cols", 12)
        self.num_rows = plate_info.get("num_rows", 8)
        self.num_drops = plate_info.get("num_drops", 3)

        self.plate_navigator_table.setColumnCount(self.num_cols)
        self.plate_navigator_table.setRowCount(self.num_rows)

        for col in range(self.num_cols):
            temp_header_item = qt_import.QTableWidgetItem("%d" % (col + 1))
            self.plate_navigator_table.setHorizontalHeaderItem(
                col, temp_header_item)
            self.plate_navigator_table.setColumnWidth(col, cell_width)

        for row in range(self.num_rows):
            temp_header_item = qt_import.QTableWidgetItem(chr(65 + row))
            self.plate_navigator_table.setVerticalHeaderItem(
                row, temp_header_item)
            self.plate_navigator_table.setRowHeight(row, cell_height)

        for col in range(self.num_cols):
            for row in range(self.num_rows):
                temp_item = qt_import.QTableWidgetItem()
                self.plate_navigator_table.setItem(row, col, temp_item)

        table_width = cell_width * (self.num_cols + 1)
        table_height = (cell_height + 2) * (self.num_rows + 1)
        self.plate_navigator_table.setFixedWidth(table_width)
        self.plate_navigator_table.setFixedHeight(table_height)
        self.plate_navigator_cell.setFixedHeight(table_height)
        self.plate_navigator_cell.setFixedWidth(200)
        self.setFixedHeight(table_height + 2)
        self.navigation_graphicsscene.setSceneRect(0, 0, table_height, 200)

        self.navigation_item.set_size(200, table_height)
        self.navigation_item.set_num_drops_per_cell(plate_info['num_drops'])
        self.refresh_plate_location()
Exemplo n.º 3
0
    def refresh_plate_location(self):
        new_location = HWR.beamline.plate_manipulator.get_plate_location()
        self.plate_navigator_cell.setEnabled(True)

        if new_location:
            row = new_location[0]
            col = new_location[1]
            pos_x = new_location[2]
            pos_y = new_location[3]
            self.navigation_item.set_navigation_pos(pos_x, pos_y)
            self.plate_navigator_cell.update()
            if self.__current_location != new_location:
                empty_item = qt_import.QTableWidgetItem(qt_import.QIcon(), "")
                self.plate_navigator_table.setItem(self.__current_location[0],
                                                   self.__current_location[1],
                                                   empty_item)
                new_item = qt_import.QTableWidgetItem(
                    icons.load_icon("sample_axis"), "")
                self.plate_navigator_table.setItem(row, col, new_item)
                self.__current_location = new_location
Exemplo n.º 4
0
    def init_tables(self):
        """
        Inits table with status info
        :return:
        """
        self.status_str_desc = HWR.beamline.sample_changer.get_status_str_desc(
        )
        self.index_dict = {}
        self.status_table.setRowCount(len(self.status_str_desc))
        for row, key in enumerate(self.status_str_desc.keys()):
            temp_item = qt_import.QTableWidgetItem(key)
            self.status_table.setItem(row, 0, temp_item)
            temp_item = qt_import.QTableWidgetItem(self.status_str_desc[key])
            self.status_table.setItem(row, 1, temp_item)
            temp_item = qt_import.QTableWidgetItem("")
            self.status_table.setItem(row, 2, temp_item)
            self.index_dict[key] = row

        self.status_table.resizeColumnToContents(0)
        self.status_table.resizeColumnToContents(1)
Exemplo n.º 5
0
    def change_point_number(self, new_int_value):
        """
        Adapt
        """
        self.points_for_aligment = new_int_value

        # restart the table and populate with items
        table = self.ui_widgets_manager.aligment_table
        table.clearContents()
        table.setRowCount(self.points_for_aligment)

        for row in range(table.rowCount()):
            table.setItem(row, 0, qt_import.QTableWidgetItem(""))
            table.setItem(row, 1, qt_import.QTableWidgetItem(""))
            table.setItem(row, 2, qt_import.QTableWidgetItem(""))
        
        if HWR.beamline.diffractometer is not None:
            HWR.beamline.diffractometer.set_centring_parameters(
                self.points_for_aligment,
                self.delta_phi
            )
Exemplo n.º 6
0
    def fill_config_table(self):
        tmp_dict = self.multipos_hwobj.get_positions()
        if tmp_dict is not None:

            self.ui_widgets_manager.configuration_table.itemChanged.disconnect(
                self.configuration_table_item_changed)

            if not self.table_created:
                # create table items for first and only time

                self.ui_widgets_manager.configuration_table.setRowCount(
                    len(tmp_dict))

                for row in range(len(tmp_dict)):
                    for col in range(7):
                        tmp_item = qt_import.QTableWidgetItem()
                        if col == 0:
                            #zoom position name not editable
                            tmp_item.setFlags(tmp_item.flags()
                                              ^ qt_import.Qt.ItemIsEditable)
                        self.ui_widgets_manager.configuration_table.setItem(
                            row, col, tmp_item)
                self.table_created = True

            table = self.ui_widgets_manager.configuration_table
            for i, (position,
                    position_dict_elem) in enumerate(tmp_dict.items()):

                table.item(i, 0).setText(str(position))

                table.item(i, 1).setText(str(position_dict_elem["beam_pos_x"]))
                table.item(i, 2).setText(str(position_dict_elem["beam_pos_y"]))

                if position_dict_elem["cal_x"] == 1:
                    y_calib = "Not defined"
                else:
                    y_calib = str(abs(int(position_dict_elem["cal_x"])))
                if position_dict_elem["cal_y"] == 1:
                    z_calib = "Not defined"
                else:
                    z_calib = str(abs(int(position_dict_elem["cal_y"])))

                table.item(i, 3).setText(y_calib)
                table.item(i, 4).setText(z_calib)

                table.item(i, 5).setText(str(position_dict_elem['light']))
                table.item(i, 6).setText(str(position_dict_elem['zoom']))

            self.ui_widgets_manager.configuration_table.itemChanged.connect(
                self.configuration_table_item_changed)

            self.ui_widgets_manager.configuration_table.horizontalHeader(
            ).setSectionResizeMode(qt_import.QHeaderView.ResizeToContents)
Exemplo n.º 7
0
    def init_tables(self):
        client_info = self.exporter_client_hwobj.get_client_info()
        self.info_address_ledit.setText("%s:%d" %
                                        (client_info[0], client_info[1]))

        method_list = self.exporter_client_hwobj.get_method_list()
        self.method_table.setRowCount(len(method_list))

        for index, method in enumerate(method_list):
            string_list = method.split(" ")
            temp_item = qt_import.QTableWidgetItem(string_list[0])
            self.method_table.setItem(index, 0, temp_item)
            temp_item = qt_import.QTableWidgetItem(string_list[1])
            self.method_table.setItem(index, 1, temp_item)

        property_list = self.exporter_client_hwobj.get_property_list()
        self.property_table.setRowCount(len(property_list))

        for index, prop in enumerate(property_list):
            string_list = prop.split(" ")
            temp_item = qt_import.QTableWidgetItem(string_list[0])
            self.property_table.setItem(index, 0, temp_item)
            temp_item = qt_import.QTableWidgetItem(string_list[1])
            self.property_table.setItem(index, 1, temp_item)
            temp_item = qt_import.QTableWidgetItem(string_list[2])
            self.property_table.setItem(index, 2, temp_item)
            temp_item = qt_import.QTableWidgetItem()
            self.property_table.setItem(index, 3, temp_item)
        self.refresh_property_values()
Exemplo n.º 8
0
    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(qt_import.QHeaderView.Stretch)

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

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

        # fill the table
        for element in range(0, len(interlacingsList)):
            self.ssx_widget_layout.interlacings_tableWidget.setItem(
                element, 0,
                qt_import.QTableWidgetItem(str(interlacingsList[element])))
            self.ssx_widget_layout.interlacings_tableWidget.setItem(
                element,
                1,
                qt_import.QTableWidgetItem(
                    str(round(interlacingsList[element] / scan_rate, 3))),
            )
Exemplo n.º 9
0
    def set_widget_from_property(self, row, prop):
        """Adds new property to the propery table

        :param row: selected row
        :type row: int
        :param prop: property
        :type prop: dict
        """
        if prop.get_type() == "boolean":
            new_property_item = qt_import.QTableWidgetItem("")
            self.setItem(row, 1, new_property_item)
            if prop.get_user_value():
                self.item(row, 1).setCheckState(qt_import.Qt.Checked)
            else:
                self.item(row, 1).setCheckState(qt_import.Qt.Unchecked)
        elif prop.get_type() == "combo":
            choices_list = []
            choices = prop.get_choices()
            for choice in choices:
                choices_list.append(choice)
            new_property_item = ComboBoxTableItem(self, row, 1, choices_list)
            new_property_item.setCurrentIndex(
                new_property_item.findText(prop.get_user_value())
            )
            self.setCellWidget(row, 1, new_property_item)
        elif prop.get_type() == "file":
            new_property_item = FileTableItem(
                self, row, 1, prop.get_user_value(), prop.getFilter()
            )
            self.setCellWidget(row, 1, new_property_item)
        elif prop.get_type() == "color":
            new_property_item = ColorTableItem(self, row, 1, prop.get_user_value())
            self.setCellWidget(row, 1, new_property_item)
        else:
            if prop.get_user_value() is None:
                temp_table_item = qt_import.QTableWidgetItem("")
            else:
                temp_table_item = qt_import.QTableWidgetItem(str(prop.get_user_value()))
            self.setItem(row, 1, temp_table_item)
        self.resizeColumnsToContents()
Exemplo n.º 10
0
    def set_best_pos(self):
        """Displays 10 (if exists) best positions
        """

        return
        self._best_pos_table.setRowCount(
            len(self.__results_raw.get("best_positions", [])))
        for row, best_pos in enumerate(
                self.__results_raw.get("best_positions", [])):
            self._best_pos_table.setItem(
                row, 0,
                qt_import.QTableWidgetItem("%d" % (best_pos.get("index") + 1)))
            self._best_pos_table.setItem(
                row, 1,
                qt_import.QTableWidgetItem("%.2f" % (best_pos.get("score"))))
            self._best_pos_table.setItem(
                row, 2,
                qt_import.QTableWidgetItem("%d" % (best_pos.get("spots_num"))))
            self._best_pos_table.setItem(
                row,
                3,
                qt_import.QTableWidgetItem("%.2f" %
                                           (best_pos.get("spots_int_aver"))),
            )
            self._best_pos_table.setItem(
                row,
                4,
                qt_import.QTableWidgetItem("%.2f" %
                                           (best_pos.get("spots_resolution"))),
            )
            self._best_pos_table.setItem(
                row, 5,
                qt_import.QTableWidgetItem(str(best_pos.get("filename"))))
            self._best_pos_table.setItem(
                row, 6,
                qt_import.QTableWidgetItem("%d" % (best_pos.get("col"))))
            self._best_pos_table.setItem(
                row, 7,
                qt_import.QTableWidgetItem("%d" % (best_pos.get("row"))))
            if best_pos["cpos"]:
                self._best_pos_table.setItem(
                    row, 8, qt_import.QTableWidgetItem(str(best_pos["cpos"])))
        self._best_pos_table.setSortingEnabled(True)
Exemplo n.º 11
0
    def chip_selected(self):
        self.file_name = self.chip_files_listwidget.currentItem().text()
        self.fill_chip_data(self.file_name)

        # creates the corresponding color table
        self.ssx_widget_layout.color_table.setRowCount(
            self.template.num_comp_h_spinbox.value())
        self.ssx_widget_layout.color_table.setColumnCount(
            self.template.num_comp_v_spinbox.value())
        # fill the table with empty items
        for row in range(0, self.ssx_widget_layout.color_table.rowCount()):
            for col in range(0,
                             self.ssx_widget_layout.color_table.columnCount()):
                self.ssx_widget_layout.color_table.setItem(
                    row, col, qt_import.QTableWidgetItem())
                self.ssx_widget_layout.color_table.item(
                    row, col).setBackground(colors.GREEN)
Exemplo n.º 12
0
    def init_com_table(self):
        try:
            self.com_device_list = self.beamline_test_hwobj.get_device_list()
        except BaseException:
            self.com_device_list = None

        if self.com_device_list:
            row = 0
            self.com_device_table.setRowCount(len(self.com_device_list))
            for device in self.com_device_list:
                row += 1
                for info_index, info in enumerate(device):
                    temp_table_item = qt_import.QTableWidgetItem(info)
                    self.com_device_table.setItem(row - 1, info_index, temp_table_item)
            # for col in range(self.com_device_table.columnCount()):
            #     self.com_device_table.adjustColumn(col)
            # self.com_device_table.adjustSize()
            self.beamline_test_widget.progress_bar.setMaximum(len(self.com_device_list))
        else:
            self.test_com_page.setEnabled(False)
Exemplo n.º 13
0
    def property_changed(self, property_name, old_value, new_value):
        """Defines gui and connects to hwobj based on the user defined properties"""
        if property_name == "mnemonic":
            if self.crl_hwobj:
                self.disconnect(self.crl_hwobj, "crlModeChanged", self.crl_mode_changed)
                self.disconnect(
                    self.crl_hwobj, "crlValueChanged", self.crl_value_changed
                )

            self.crl_hwobj = self.get_hardware_object(new_value)

            if self.crl_hwobj:
                crl_modes = self.crl_hwobj.get_modes()
                for crl_mode in crl_modes:
                    self.mode_combo.addItem(crl_mode)
                self.connect(self.crl_hwobj, "crlModeChanged", self.crl_mode_changed)
                self.connect(self.crl_hwobj, "crlValueChanged", self.crl_value_changed)
                self.crl_hwobj.force_emit_signals()
        elif property_name == "lenseCount":
            self.crl_value_table.setColumnCount(new_value)
            for col_index in range(new_value):
                temp_item = qt_import.QTableWidgetItem("")
                temp_item.setFlags(qt_import.Qt.ItemIsEnabled)
                temp_item.setBackground(colors.LIGHT_GRAY)
                self.crl_value_table.setItem(0, col_index, temp_item)
                self.crl_value_table.setColumnWidth(col_index, 20)
                self.crl_value.append(0)
            self.crl_value_table.setFixedWidth(20 * new_value + 6)
            self.crl_lense_spinbox.setMaximum(new_value - 1)
        elif property_name == "caption":
            if new_value:
                self.main_gbox.setTitle(new_value)
        elif property_name == "style":
            self.crl_value_table.setVisible(new_value == "table")
            self.mode_combo.setEnabled(new_value == "table")
            self.set_according_to_energy_button.setEnabled(new_value == "table")
            self.crl_lense_spinbox.setVisible(new_value != "table")
            self.crl_lense_in_button.setVisible(new_value != "table")
            self.crl_lense_out_button.setVisible(new_value != "table")
        else:
            BaseWidget.property_changed(self, property_name, old_value, new_value)
Exemplo n.º 14
0
    def update_gui(self):

        tmp_dict = self.multipos_hwobj.get_positions()
        if tmp_dict:

            if not self.table_created:
                # create table items for first and only time

                self.ui_widgets_manager.calibration_table.setRowCount(
                    len(tmp_dict))

                for row in range(len(tmp_dict)):
                    for col in range(3):
                        tmp_item = qt_import.QTableWidgetItem()
                        tmp_item.setFlags(tmp_item.flags()
                                          ^ qt_import.Qt.ItemIsEditable)
                        self.ui_widgets_manager.calibration_table.setItem(
                            row, col, tmp_item)
                self.table_created = True

            table = self.ui_widgets_manager.calibration_table
            for i, (position, position_dict) in enumerate(tmp_dict.items()):

                if position_dict["cal_x"] == 1:
                    y_calib = "Not defined"
                else:
                    y_calib = str(abs(int(position_dict["cal_x"])))
                if position_dict["cal_y"] == 1:
                    z_calib = "Not defined"
                else:
                    z_calib = str(abs(int(position_dict["cal_y"])))
                """
                resolution are displayed in nanometer/pixel and saved in metre/pixel
                """
                table.item(i, 0).setText(str(position))
                table.item(i, 1).setText(y_calib)
                table.item(i, 2).setText(z_calib)
Exemplo n.º 15
0
    def init_gui(self):
        """
        Inits gui
        :return: None
        """
        self.image_tracking_cbox.setChecked(True)
        self.inverted_rows_cbox.setChecked(
            self.current_chip_config["inverted_rows"])
        self.grid_table.setColumnCount(self.current_chip_config["num_comp_h"])
        self.grid_table.setRowCount(self.current_chip_config["num_comp_v"])

        for col in range(self.current_chip_config["num_comp_h"]):
            temp_header_item = qt_import.QTableWidgetItem("%d" % (col + 1))
            self.grid_table.setHorizontalHeaderItem(col, temp_header_item)
            self.grid_table.setColumnWidth(col, self["cell_size"])

        for row in range(self.current_chip_config["num_comp_v"]):
            temp_header_item = qt_import.QTableWidgetItem(chr(65 + row))
            self.grid_table.setVerticalHeaderItem(row, temp_header_item)
            self.grid_table.setRowHeight(row, self["cell_size"])

        for col in range(self.current_chip_config["num_comp_h"]):
            for row in range(self.current_chip_config["num_comp_v"]):
                temp_item = qt_import.QTableWidgetItem()
                self.grid_table.setItem(row, col, temp_item)

        table_width = (self["cell_size"] *
                       (self.current_chip_config["num_comp_h"] + 1) + 4)
        table_height = (self["cell_size"] *
                        (self.current_chip_config["num_comp_v"] + 1) + 4)
        self.grid_table.setFixedWidth(table_width)
        self.grid_table.setFixedHeight(table_height)

        self.comp_table.setColumnCount(
            self.current_chip_config["num_crystal_h"])
        self.comp_table.setRowCount(self.current_chip_config["num_crystal_v"])

        for col in range(self.current_chip_config["num_crystal_h"]):
            temp_header_item = qt_import.QTableWidgetItem("%d" % (col + 1))
            self.comp_table.setHorizontalHeaderItem(col, temp_header_item)
            self.comp_table.setColumnWidth(col, self["cell_size"])

        for row in range(self.current_chip_config["num_crystal_v"]):
            temp_header_item = qt_import.QTableWidgetItem(chr(65 + row))
            self.comp_table.setVerticalHeaderItem(row, temp_header_item)
            self.comp_table.setRowHeight(row, self["cell_size"])

        for col in range(self.current_chip_config["num_crystal_h"]):
            for row in range(self.current_chip_config["num_crystal_v"]):
                temp_item = qt_import.QTableWidgetItem()
                self.comp_table.setItem(row, col, temp_item)

        table_width = (self["cell_size"] *
                       (self.current_chip_config["num_crystal_h"] + 1) + 7)
        table_height = (self["cell_size"] *
                        (self.current_chip_config["num_crystal_v"] + 1) + 7)
        self.comp_table.setFixedWidth(table_width + 10)
        self.comp_table.setFixedHeight(table_height)

        self.hit_map_plot.setFixedWidth(table_width)
        self.hit_map_plot.setFixedHeight(200)

        for score_type in self.score_type_list:
            self.hit_map_plot.add_curve(
                score_type,
                np.array([]),
                np.array([]),
                linestyle="None",
                label=score_type,
                color="m",
                marker="s",
            )
        self.hit_map_plot.hide_all_curves()
        self.hit_map_plot.show_curve(self.score_type)
Exemplo n.º 16
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))
Exemplo n.º 17
0
    def __init__(self, parent=None, name="dc_group_widget"):

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

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

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

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

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

        # Internal variables --------------------------------------------------
        self._data_collection = None
        self.add_dc_cb = None
        self._tree_view_item = None

        _subwedge_widget = qt_import.QGroupBox("Summary", self)
        self.polar_scater_widget = PolarScaterWidget()
        self.subwedge_table = qt_import.QTableWidget(_subwedge_widget)
        self.position_widget = qt_import.load_ui_file("snapshot_widget_layout.ui")

        # Layout --------------------------------------------------------------
        _subwedge_widget_vlayout = qt_import.QVBoxLayout(_subwedge_widget)
        _subwedge_widget_vlayout.addWidget(self.polar_scater_widget)
        _subwedge_widget_vlayout.addWidget(self.subwedge_table)
        _subwedge_widget_vlayout.setContentsMargins(0, 4, 0, 0)
        _subwedge_widget_vlayout.setSpacing(6)
        _subwedge_widget_vlayout.addStretch(0)

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

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

        # Qt signal/slot connections ------------------------------------------

        # Other ---------------------------------------------------------------
        # self.polar_scater_widget.setFixedSize(600, 600)
        font = self.subwedge_table.font()
        font.setPointSize(8)
        self.subwedge_table.setFont(font)
        self.subwedge_table.setEditTriggers(qt_import.QAbstractItemView.NoEditTriggers)
        self.subwedge_table.setColumnCount(7)
        self.subwedge_table.horizontalHeader().setStretchLastSection(False)

        horizontal_headers = [
            "Osc start",
            "Osc range",
            "Images",
            "Exposure time",
            "Energy",
            "Transmission",
            "Resolution",
        ]
        for index, header in enumerate(horizontal_headers):
            self.subwedge_table.setHorizontalHeaderItem(
                index, qt_import.QTableWidgetItem(header)
            )
Exemplo n.º 18
0
    def __init__(self, *args):
        """
        Main init
        :param args:
        """

        BaseWidget.__init__(self, *args)

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

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

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

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

        # Graphic elements ----------------------------------------------------
        self.status_gbox = qt_import.QGroupBox("Status", self)
        self.mounted_sample_ledit = qt_import.QLineEdit("", self)
        self.sample_detected_ledit = qt_import.QLineEdit("", self)
        self.focus_mode_ledit = qt_import.QLineEdit("", self)

        self.puck_switches_gbox = qt_import.QGroupBox("Puck switches", self)
        self.puck_switches_table = qt_import.QTableWidget(
            self.puck_switches_gbox)
        self.central_puck_ledit = qt_import.QLineEdit("No center puck",
                                                      self.puck_switches_gbox)

        self.control_gbox = qt_import.QGroupBox("Control", self)
        self.open_lid_button = qt_import.QPushButton("Open lid",
                                                     self.control_gbox)
        self.close_lid_button = qt_import.QPushButton("Close lid",
                                                      self.control_gbox)
        self.base_to_center_button = qt_import.QPushButton(
            "Base to center", self.control_gbox)
        self.center_to_base_button = qt_import.QPushButton(
            "Center to base", self.control_gbox)
        self.dry_gripper_button = qt_import.QPushButton(
            "Dry gripper", self.control_gbox)

        self.status_list_gbox = qt_import.QGroupBox("Status list", self)
        self.status_table = qt_import.QTableWidget(self)

        # Layout --------------------------------------------------------------
        _status_gbox_gridlayout = qt_import.QGridLayout(self.status_gbox)
        _status_gbox_gridlayout.addWidget(
            qt_import.QLabel("Mounted sample", self.status_list_gbox), 0, 0)
        _status_gbox_gridlayout.addWidget(
            qt_import.QLabel("Sample detected", self.status_list_gbox), 1, 0)
        _status_gbox_gridlayout.addWidget(
            qt_import.QLabel("Focus mode", self.status_list_gbox), 2, 0)
        _status_gbox_gridlayout.addWidget(self.mounted_sample_ledit, 0, 1)
        _status_gbox_gridlayout.addWidget(self.sample_detected_ledit, 1, 1)
        _status_gbox_gridlayout.addWidget(self.focus_mode_ledit, 2, 1)
        _status_gbox_gridlayout.setSpacing(2)
        _status_gbox_gridlayout.setContentsMargins(0, 0, 0, 0)
        _status_gbox_gridlayout.setColumnStretch(2, 10)

        _puck_switches_gbox_vlayout = qt_import.QHBoxLayout(
            self.puck_switches_gbox)
        _puck_switches_gbox_vlayout.addWidget(self.puck_switches_table)
        _puck_switches_gbox_vlayout.addWidget(self.central_puck_ledit)
        _puck_switches_gbox_vlayout.setSpacing(2)
        _puck_switches_gbox_vlayout.setContentsMargins(0, 0, 0, 0)

        _status_vbox_layout = qt_import.QVBoxLayout(self.status_list_gbox)
        _status_vbox_layout.addWidget(self.status_table)
        _status_vbox_layout.setSpacing(2)
        _status_vbox_layout.setContentsMargins(0, 0, 0, 0)

        _control_gbox_hlayout = qt_import.QHBoxLayout(self.control_gbox)
        _control_gbox_hlayout.addWidget(self.open_lid_button)
        _control_gbox_hlayout.addWidget(self.close_lid_button)
        _control_gbox_hlayout.addWidget(self.base_to_center_button)
        _control_gbox_hlayout.addWidget(self.center_to_base_button)
        _control_gbox_hlayout.addWidget(self.dry_gripper_button)
        _control_gbox_hlayout.setSpacing(2)
        _control_gbox_hlayout.setContentsMargins(0, 0, 0, 0)

        _main_vlayout = qt_import.QVBoxLayout(self)
        _main_vlayout.addWidget(self.status_gbox)
        _main_vlayout.addWidget(self.puck_switches_gbox)
        _main_vlayout.addWidget(self.control_gbox)
        _main_vlayout.addWidget(self.status_list_gbox)
        _main_vlayout.setSpacing(2)
        _main_vlayout.setContentsMargins(2, 2, 2, 2)

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

        # Qt signal/slot connections ------------------------------------------
        self.open_lid_button.clicked.connect(open_lid_clicked)
        self.close_lid_button.clicked.connect(close_lid_clicked)
        self.base_to_center_button.clicked.connect(base_to_center_clicked)
        self.center_to_base_button.clicked.connect(center_to_base_clicked)
        self.dry_gripper_button.clicked.connect(dry_gripper_clicked)

        # Other ---------------------------------------------------------------
        self.mounted_sample_ledit.setFixedWidth(80)
        self.sample_detected_ledit.setFixedWidth(80)
        self.focus_mode_ledit.setFixedWidth(80)

        self.puck_switches_table.setRowCount(1)
        self.puck_switches_table.setColumnCount(PUCK_COUNT)
        self.puck_switches_table.verticalHeader().hide()
        self.puck_switches_table.horizontalHeader().hide()
        self.puck_switches_table.setRowHeight(0, 28)
        self.puck_switches_table.setFixedHeight(28)
        self.puck_switches_table.setShowGrid(True)
        self.puck_switches_table.setFixedWidth(33 * PUCK_COUNT + 4)

        for col_index in range(PUCK_COUNT):
            temp_item = qt_import.QTableWidgetItem(str(col_index + 1))
            temp_item.setFlags(qt_import.Qt.ItemIsEnabled)
            temp_item.setBackground(colors.WHITE)
            self.puck_switches_table.setItem(0, col_index, temp_item)
            self.puck_switches_table.setColumnWidth(col_index, 33)

        self.status_table.setColumnCount(3)
        self.status_table.setHorizontalHeaderLabels(
            ["Property", "Description", "Value"])

        self.puck_switches_gbox.setSizePolicy(qt_import.QSizePolicy.Preferred,
                                              qt_import.QSizePolicy.Fixed)
        self.init_tables()
        self.connect(HWR.beamline.sample_changer, "statusListChanged",
                     self.status_list_changed)
        self.connect(HWR.beamline.sample_changer, "infoDictChanged",
                     self.info_dict_changed)

        HWR.beamline.sample_changer.re_emit_values()
Exemplo n.º 19
0
    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 = qt_import.load_ui_file(
            "ssx_control_widget_layout.ui")

        # Layout --------------------------------------------------------------
        _main_layout = qt_import.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(
            qt_import.QString("Detector;Excitation;Aux1;Aux2").split(";"))
        # set first column of checkboxes
        dg_channels_list = []

        for row in range(0, 4):
            checkbox_item = qt_import.QTableWidgetItem()
            checkbox_item.setFlags(qt_import.Qt.ItemIsUserCheckable
                                   | qt_import.Qt.ItemIsEnabled)
            checkbox_item.setCheckState(qt_import.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(
            qt_import.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, qt_import.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)