Esempio n. 1
0
    def go_back_clicked(self):
        """Act when 'go to old position' button clicked."""
        old_positions_menu = QtImport.QMenu(self)
        old_positions_menu.addSection(
            str("<nobr><b>Last positions :</b></nobr>"))

        old_positions_menu.addSeparator()

        for i in range(len(self.old_positions)):
            receiver = lambda i: self.go_to_old_position(i)
            position_action = old_positions_menu.addAction(
                self.old_positions[i])
            position_action.triggered.connect(receiver)

        old_positions_menu.exec_(QtImport.QCursor.pos())
Esempio n. 2
0
 def show_context_menu(self, context_menu_event):
     menu = QtImport.QMenu(self)
     menu.addAction("Clear", self.clear)
     menu.addAction("Copy", self.copy_log)
     menu.addAction("Save log", self.save_log)
     menu.popup(QtImport.QCursor.pos())
Esempio n. 3
0
 def open_history_menu(self):
     menu = QtImport.QMenu(self)
     for item in self.position_history:
         menu.addAction(item, self.go_to_history_pos)
     menu.popup(QtImport.QCursor.pos())
Esempio n. 4
0
 def show_shape_treewidget_popup(self, item, point, col):
     QtImport.QMenu(self.manager_widget.shapes_treewidget)
Esempio n. 5
0
    def __init__(self, *args):
        BaseWidget.__init__(self, *args)

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

        # Internal values -----------------------------------------------------
        self.graphics_scene_size = None
        self.graphics_scene_fixed_size = None
        self.graphics_view = None
        # self.graphics_camera_frame = None
        self.fixed_size = None
        self.display_beam = None
        self.display_scale = None
        self.image_scale_list = []

        # Properties ----------------------------------------------------------
        self.add_property("mnemonic", "string", "/graphics")
        self.add_property("fixedSize", "string", "")
        self.add_property("displayBeam", "boolean", True)
        self.add_property("displayScale", "boolean", True)
        self.add_property("displayOmegaAxis", "boolean", True)
        self.add_property("beamDefiner", "boolean", False)
        self.add_property("cameraControls", "boolean", False)

        # Graphic elements-----------------------------------------------------
        self.info_widget = QtImport.QWidget(self)
        self.display_beam_size_cbox = QtImport.QCheckBox(
            "Display beam size", self)
        self.display_beam_size_cbox.setHidden(True)
        self.coord_label = QtImport.QLabel(":", self)
        self.info_label = QtImport.QLabel(self)
        self.camera_control_dialog = CameraControlDialog(self)

        self.popup_menu = QtImport.QMenu(self)
        self.popup_menu.menuAction().setIconVisibleInMenu(True)
        create_menu = self.popup_menu.addMenu("Create")
        create_menu.menuAction().setIconVisibleInMenu(True)
        temp_action = create_menu.addAction(
            Icons.load_icon("VCRPlay2"),
            "Centring point with 3 clicks",
            self.create_point_click_clicked,
        )
        temp_action.setShortcut("Ctrl+1")
        temp_action = create_menu.addAction(
            Icons.load_icon("ThumbUp"),
            "Centring point on current position",
            self.create_point_current_clicked,
        )
        temp_action.setShortcut("Ctrl+2")
        temp_action.setIcon(Icons.load_icon("ThumbUp"))
        create_menu.addAction(
            Icons.load_icon("ThumbUp"),
            "Centring points with one click",
            self.create_points_one_click_clicked,
        )
        temp_action = create_menu.addAction(Icons.load_icon("Line.png"),
                                            "Helical line",
                                            self.create_line_clicked)
        temp_action.setShortcut("Ctrl+3")
        temp_action = create_menu.addAction(
            Icons.load_icon("Line.png"),
            "Automatic helical line",
            self.create_auto_line_clicked,
        )
        temp_action = create_menu.addAction(Icons.load_icon("Grid"), "Grid",
                                            self.create_grid)
        temp_action.setShortcut("Ctrl+4")
        temp_action = create_menu.addAction(Icons.load_icon("AutoGrid"),
                                            "Auto Grid", self.create_auto_grid)

        measure_menu = self.popup_menu.addMenu("Measure")
        self.measure_distance_action = measure_menu.addAction(
            Icons.load_icon("measure_distance"),
            "Distance",
            self.measure_distance_clicked,
        )
        self.measure_angle_action = measure_menu.addAction(
            Icons.load_icon("measure_angle"), "Angle",
            self.measure_angle_clicked)
        self.measure_area_action = measure_menu.addAction(
            Icons.load_icon("measure_area"), "Area", self.measure_area_clicked)

        beam_mark_menu = self.popup_menu.addMenu("Beam mark")
        self.move_beam_mark_manual_action = beam_mark_menu.addAction(
            "Set position manually", self.move_beam_mark_manual)
        # self.move_beam_mark_manual_action.setEnabled(False)
        self.move_beam_mark_auto_action = beam_mark_menu.addAction(
            "Set position automaticaly", self.move_beam_mark_auto)
        # self.move_beam_mark_auto_action.setEnabled(False)
        self.display_beam_size_action = beam_mark_menu.addAction(
            "Display size", self.display_beam_size_toggled)
        self.display_beam_size_action.setCheckable(True)

        self.define_beam_action = self.popup_menu.addAction(
            Icons.load_icon("Draw"),
            "Define beam size with slits",
            self.define_beam_size,
        )
        self.define_beam_action.setEnabled(False)
        self.popup_menu.addSeparator()

        temp_action = self.popup_menu.addAction("Select all centring points",
                                                self.select_all_points_clicked)
        temp_action.setShortcut("Ctrl+A")
        temp_action = self.popup_menu.addAction(
            "Deselect all items", self.deselect_all_items_clicked)
        temp_action.setShortcut("Ctrl+D")
        temp_action = self.popup_menu.addAction(Icons.load_icon("Delete"),
                                                "Clear all items",
                                                self.clear_all_items_clicked)
        temp_action.setShortcut("Ctrl+X")
        self.popup_menu.addSeparator()

        tools_menu = self.popup_menu.addMenu("Tools")
        self.display_grid_action = tools_menu.addAction(
            Icons.load_icon("Grid"), "Display grid", self.display_grid_toggled)
        self.display_grid_action.setCheckable(True)
        self.display_histogram_action = tools_menu.addAction(
            Icons.load_icon("Grid"),
            "Display historgram",
            self.display_histogram_toggled,
        )
        self.display_histogram_action.setCheckable(True)
        self.magnification_action = tools_menu.addAction(
            Icons.load_icon("Magnify2"),
            "Magnification tool",
            self.start_magnification_tool,
        )
        # self.magnification_action.setCheckable(True)

        # self.display_histogram_action = self.popup_menu.addAction(\
        #     "Display histogram", self.display_histogram_toggled)
        # self.define_histogram_action = self.popup_menu.addAction(\
        #     "Define histogram", self.define_histogram_clicked)

        # self.display_histogram_action.setEnabled(False)
        # self.define_histogram_action.setEnabled(False)

        self.image_scale_menu = self.popup_menu.addMenu(
            Icons.load_icon("DocumentMag2"), "Image scale")
        self.image_scale_menu.setEnabled(False)
        self.image_scale_menu.triggered.connect(self.image_scale_triggered)
        self.camera_control_action = self.popup_menu.addAction(
            "Camera control", self.open_camera_control_dialog)
        self.camera_control_action.setEnabled(False)

        # Layout --------------------------------------------------------------
        _info_widget_hlayout = QtImport.QHBoxLayout(self.info_widget)
        _info_widget_hlayout.addWidget(self.display_beam_size_cbox)
        _info_widget_hlayout.addWidget(self.coord_label)
        _info_widget_hlayout.addStretch(0)
        _info_widget_hlayout.addWidget(self.info_label)
        _info_widget_hlayout.setSpacing(0)
        _info_widget_hlayout.setContentsMargins(0, 0, 0, 0)
        self.info_widget.setLayout(_info_widget_hlayout)

        self.main_layout = QtImport.QVBoxLayout(self)
        self.main_layout.setSpacing(0)
        self.main_layout.setContentsMargins(0, 0, 0, 0)

        # Qt signal/slot connections -----------------------------------------
        self.display_beam_size_cbox.stateChanged.connect(
            self.display_beam_size_toggled)

        # SizePolicies --------------------------------------------------------
        self.info_widget.setSizePolicy(QtImport.QSizePolicy.Expanding,
                                       QtImport.QSizePolicy.Fixed)

        # Scene elements ------------------------------------------------------
        self.setMouseTracking(True)
Esempio n. 6
0
    def __init__(self, parent=None, show_aligned_results=False):

        QtImport.QWidget.__init__(self, parent)

        self.setObjectName("hit_map_widget")

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

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

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

        # Internal values -----------------------------------------------------
        self.__plot_type = "1D"
        self.__result_types = []
        self.__results_raw = None
        self.__results_aligned = None
        self.__first_result = True
        self.__associated_grid = None
        self.__associated_data_collection = None
        self.__selected_col = 0
        self.__selected_row = 0
        self.__score_key = None
        self.__max_value = 0
        self.__filter_min_value = 0
        self.__best_pos_list = None
        self.__hit_map_max_size = []
        self.__hitmap_clicked = False
        self.__enable_continues_image_display = False
        #self.__tooltip_text = None
        self.selected_image_serial = None

        # Graphic elements ----------------------------------------------------
        self._hit_map_gbox = QtImport.QGroupBox("Hit map", self)
        self._hit_map_plot = PlotWidget(self._hit_map_gbox)
        self._hit_map_popup_menu = QtImport.QMenu(self._hit_map_gbox)

        hit_map_info_widget = QtImport.QWidget(self._hit_map_gbox)
        score_type_label = QtImport.QLabel("Result: ", hit_map_info_widget)
        self._score_type_cbox = QtImport.QComboBox(hit_map_info_widget)
        self._autoscale_button = QtImport.QPushButton("Auto scale",
                                                      hit_map_info_widget)
        image_display_cbox = QtImport.QCheckBox("Display image in ADxV",
                                                hit_map_info_widget)
        self._image_info_label = QtImport.QLabel("Image: #, value #",
                                                 hit_map_info_widget)

        self._hit_map_tools_widget = QtImport.QWidget(self._hit_map_gbox)

        _threshold_label = QtImport.QLabel("Threshold: ",
                                           self._hit_map_tools_widget)
        self._threshold_slider = QtImport.QSlider(QtImport.Qt.Horizontal,
                                                  self._hit_map_tools_widget)
        self._relaunch_processing_button = QtImport.QPushButton(
            "Relaunch processing", self._hit_map_tools_widget)
        self._create_points_button = QtImport.QPushButton(
            "Create centring points", self._hit_map_tools_widget)

        self._summary_gbox = QtImport.QGroupBox("Summary", self)
        self._summary_textbrowser = QtImport.QTextBrowser(self._summary_gbox)
        self._best_pos_gbox = QtImport.QGroupBox("Best positions", self)
        self._best_pos_table = QtImport.QTableWidget(self._best_pos_gbox)
        self._best_pos_popup_menu = QtImport.QMenu(self._hit_map_gbox)
        self._best_pos_gbox.setHidden(True)

        # Layout --------------------------------------------------------------
        _hit_map_info_hlayout = QtImport.QHBoxLayout(hit_map_info_widget)
        _hit_map_info_hlayout.addWidget(score_type_label)
        _hit_map_info_hlayout.addWidget(self._score_type_cbox)
        _hit_map_info_hlayout.addWidget(self._autoscale_button)
        _hit_map_info_hlayout.addWidget(image_display_cbox)
        _hit_map_info_hlayout.addStretch(0)
        _hit_map_info_hlayout.addWidget(self._image_info_label)
        _hit_map_info_hlayout.setSpacing(2)
        _hit_map_info_hlayout.setContentsMargins(0, 0, 0, 0)

        _hit_map_tools_hlayout = QtImport.QHBoxLayout(
            self._hit_map_tools_widget)
        _hit_map_tools_hlayout.addWidget(_threshold_label)
        _hit_map_tools_hlayout.addWidget(self._threshold_slider)
        _hit_map_tools_hlayout.addStretch(0)
        _hit_map_tools_hlayout.addWidget(self._relaunch_processing_button)
        _hit_map_tools_hlayout.addWidget(self._create_points_button)
        _hit_map_tools_hlayout.setSpacing(2)
        _hit_map_tools_hlayout.setContentsMargins(0, 0, 0, 0)

        _hit_map_gbox_vlayout = QtImport.QVBoxLayout(self._hit_map_gbox)
        _hit_map_gbox_vlayout.addWidget(self._hit_map_plot)
        _hit_map_gbox_vlayout.addWidget(hit_map_info_widget)
        _hit_map_gbox_vlayout.addWidget(self._hit_map_tools_widget)
        _hit_map_gbox_vlayout.setSpacing(2)
        _hit_map_gbox_vlayout.setContentsMargins(0, 0, 0, 0)

        _summary_gbox_vlayout = QtImport.QVBoxLayout(self._summary_gbox)
        _summary_gbox_vlayout.addWidget(self._summary_textbrowser)
        _summary_gbox_vlayout.setSpacing(2)
        _summary_gbox_vlayout.setContentsMargins(0, 0, 0, 0)

        _best_postition_gbox_vlayout = QtImport.QVBoxLayout(
            self._best_pos_gbox)
        _best_postition_gbox_vlayout.addWidget(self._best_pos_table)
        _best_postition_gbox_vlayout.setSpacing(2)
        _best_postition_gbox_vlayout.setContentsMargins(0, 0, 0, 0)

        _main_hlayout = QtImport.QVBoxLayout(self)
        _main_hlayout.addWidget(self._hit_map_gbox)
        _main_hlayout.addWidget(self._summary_gbox)
        _main_hlayout.addWidget(self._best_pos_gbox)
        _main_hlayout.setSpacing(2)
        _main_hlayout.setContentsMargins(2, 2, 2, 2)

        # SizePolicies --------------------------------------------------------
        #self._image_info_label.setAlignment(QtImport.Qt.AlignLeft)
        #self._image_info_label.setSizePolicy(
        #    QtImport.QSizePolicy.Expanding, QtImport.QSizePolicy.Fixed
        #)

        # Qt signals and slots ------------------------------------------------
        image_display_cbox.stateChanged.connect(
            self.enable_image_display_state_changed)
        self._score_type_cbox.activated.connect(self.score_type_changed)
        self._threshold_slider.valueChanged.connect(
            self.filter_min_slider_changed)
        self._relaunch_processing_button.clicked.connect(
            self.relaunch_processing_clicked)
        self._create_points_button.clicked.connect(self.create_points_clicked)
        self._hit_map_plot.mouseMovedSignal.connect(self.mouse_moved)
        self._hit_map_plot.mouseClickedSignal.connect(self.mouse_clicked)
        self._hit_map_plot.mouseDoubleClickedSignal.connect(
            self.move_to_position_clicked)
        self._hit_map_plot.mouseLeftSignal.connect(self.mouse_left_plot)
        self._autoscale_button.clicked.connect(self.autoscale_pressed)

        # Other ---------------------------------------------------------------
        #self.__tooltip_text = (
        #    "Double click to move to the position. " + "Right click to open menu."
        #)
        #self._hit_map_plot.setToolTip(self.__tooltip_text)
        self._hit_map_popup_menu.addSeparator()
        self._hit_map_popup_menu.addAction("Move to position",
                                           self.move_to_position_clicked)
        self._hit_map_popup_menu.addAction("Create centring point",
                                           self.create_centring_point_clicked)

        self._hit_map_popup_menu.addAction("Create helical line",
                                           self.create_helical_line_clicked)
        self._hit_map_popup_menu.addAction(
            "Rotate 90 degrees and create helical line",
            self.rotate_and_create_helical_line_clicked,
        )

        self._hit_map_popup_menu.addSeparator()
        self._hit_map_popup_menu.addAction("Open image in ADXV",
                                           self.display_image_clicked)
        self._hit_map_popup_menu.addSeparator()

        #self._hit_map_plot.contextMenuEvent = self.open_hit_map_popup_menu

        if HWR.beamline.online_processing is not None:
            self.__result_types = HWR.beamline.online_processing.get_result_types(
            )
        for result in self.__result_types:
            self._score_type_cbox.addItem(result["descr"])
        self._score_type_cbox.setMaximumWidth(200)
        self.__score_key = "spots_resolution"

        self._threshold_slider.setRange(0, 100)
        self._threshold_slider.setTickInterval(5)
        self._threshold_slider.setFixedWidth(200)
        self._threshold_slider.setTracking(False)

        #font = self._best_pos_table.font()
        #font.setPointSize(8)
        #self._best_pos_table.setFont(font)
        self._best_pos_table.setEditTriggers(
            QtImport.QAbstractItemView.NoEditTriggers)
        self._best_pos_table.setColumnCount(9)
        self._best_pos_table.setAlternatingRowColors(True)
        self._best_pos_table.setWordWrap(False)
        self._best_pos_table.horizontalHeader().setSortIndicatorShown(True)
        self._best_pos_table.setHorizontalHeaderItem(
            0, QtImport.QTableWidgetItem("No."))
        for index, result_type in enumerate(self.__result_types):
            self._best_pos_table.setHorizontalHeaderItem(
                index + 1, QtImport.QTableWidgetItem(result_type["descr"]))

        for index, header_text in enumerate(
            ("Path", "Col", "Row", "Motor positions")):
            self._best_pos_table.setHorizontalHeaderItem(
                5 + index, QtImport.QTableWidgetItem(header_text))

        self._best_pos_popup_menu.addAction("Move to position",
                                            self.move_to_best_position_clicked)
        self._best_pos_table.contextMenuEvent = self.open_best_pos_popup_menu

        screen_shape = QtImport.QDesktopWidget().screenGeometry()
        self.__hit_map_max_size = (screen_shape.width() / 2,
                                   screen_shape.height() / 2)
Esempio n. 7
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)

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

        # Internal variables --------------------------------------------------
        self.current_image_num = 0
        self.total_image_num = 0

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

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

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

        # Graphic elements ----------------------------------------------------
        results_gbox = QtImport.QGroupBox("Results", self)

        self.graphics_view_widget = QtImport.QWidget(results_gbox)
        self.results_widget = QtImport.load_ui_file(
            "xray_imaging_results_widget_layout.ui")
        tools_widget = QtImport.QGroupBox(self)
        button_widget = QtImport.QWidget(self)
        self.start_centering_button = QtImport.QPushButton(
            Icons.load_icon("VCRPlay2"), "3 Click", tools_widget)
        self.start_n_centering_button = QtImport.QPushButton(
            Icons.load_icon("VCRPlay"), "n Click", tools_widget)
        self.accept_centering_button = QtImport.QPushButton(
            Icons.load_icon("ThumbUp"), "Save", tools_widget)
        self.histogram_plot = PlotWidget(self)

        self.popup_menu = QtImport.QMenu(self)
        self.popup_menu.menuAction().setIconVisibleInMenu(True)

        self.popup_menu.addAction(
            Icons.load_icon("VCRPlay2"),
            "Start 3-click centering",
            start_centering_clicked,
        )
        self.popup_menu.addAction(
            Icons.load_icon("VCRPlay"),
            "Start n-click centering",
            start_n_centering_clicked,
        )
        self.popup_menu.addAction(
            Icons.load_icon("ThumbUp"),
            "Create centering point",
            self.accept_centering_clicked,
        )

        self.popup_menu.addSeparator()
        self.measure_distance_action = self.popup_menu.addAction(
            Icons.load_icon("measure_distance"),
            "Distance and histogram",
            measure_distance_clicked,
        )

        # Layout --------------------------------------------------------------
        self._graphics_view_widget_vlayout = QtImport.QVBoxLayout(
            self.graphics_view_widget)
        self._graphics_view_widget_vlayout.setSpacing(0)
        self._graphics_view_widget_vlayout.setContentsMargins(0, 0, 0, 0)

        __button_widget_hlayout = QtImport.QHBoxLayout(button_widget)
        __button_widget_hlayout.addWidget(self.start_centering_button)
        __button_widget_hlayout.addWidget(self.start_n_centering_button)
        __button_widget_hlayout.addWidget(self.accept_centering_button)
        __button_widget_hlayout.addStretch()
        __button_widget_hlayout.setSpacing(2)
        __button_widget_hlayout.setContentsMargins(2, 2, 2, 2)

        __tools_widget_vlayout = QtImport.QVBoxLayout(tools_widget)
        __tools_widget_vlayout.addWidget(button_widget)
        __tools_widget_vlayout.addWidget(self.results_widget)
        __tools_widget_vlayout.addWidget(self.histogram_plot)
        __tools_widget_vlayout.addStretch()
        __tools_widget_vlayout.setSpacing(2)
        __tools_widget_vlayout.setContentsMargins(2, 2, 2, 2)

        __main_hlayout = QtImport.QHBoxLayout(self)
        __main_hlayout.addWidget(self.graphics_view_widget)
        __main_hlayout.addWidget(tools_widget)
        __main_hlayout.setSpacing(0)
        __main_hlayout.setContentsMargins(0, 0, 0, 0)

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

        # Qt signal/slot connections ------------------------------------------
        self.results_widget.data_browse_button.clicked.connect(
            self.data_browse_button_clicked)
        self.results_widget.ff_browse_button.clicked.connect(
            self.ff_browse_button_clicked)
        self.results_widget.config_browse_button.clicked.connect(
            self.config_browse_button_clicked)
        self.results_widget.load_button.clicked.connect(
            self.load_button_clicked)
        self.results_widget.first_image_button.clicked.connect(
            first_image_button_clicked)
        self.results_widget.prev_image_button.clicked.connect(
            self.prev_image_button_clicked)
        self.results_widget.next_image_button.clicked.connect(
            self.next_image_button_clicked)
        self.results_widget.last_image_button.clicked.connect(
            self.last_image_button_clicked)
        self.results_widget.minus_quarter_button.clicked.connect(
            self.minus_quater_button_clicked)
        self.results_widget.plus_quarter_button.clicked.connect(
            plus_quater_button_clicked)

        self.results_widget.image_dial.valueChanged.connect(dial_value_changed)

        self.results_widget.image_spinbox.valueChanged.connect(
            spinbox_value_changed)

        self.results_widget.play_button.clicked.connect(
            self.play_button_clicked)
        self.results_widget.stop_button.clicked.connect(stop_button_clicked)
        self.results_widget.repeat_cbox.stateChanged.connect(
            repeat_state_changed)
        self.results_widget.ff_apply_cbox.stateChanged.connect(
            ff_apply_state_changed)

        self.start_centering_button.clicked.connect(start_centering_clicked)
        self.accept_centering_button.clicked.connect(accept_centering_clicked)

        # Other ---------------------------------------------------------------
        self.results_widget.first_image_button.setIcon(
            Icons.load_icon("VCRRewind"))
        self.results_widget.prev_image_button.setIcon(
            Icons.load_icon("VCRPlay4"))
        self.results_widget.next_image_button.setIcon(
            Icons.load_icon("VCRPlay2"))
        self.results_widget.last_image_button.setIcon(
            Icons.load_icon("VCRFastForward2"))
        self.results_widget.play_button.setIcon(Icons.load_icon("VCRPlay"))
        self.results_widget.stop_button.setIcon(Icons.load_icon("Stop2"))

        self.start_centering_button.setFixedSize(70, 50)
        self.start_n_centering_button.setFixedSize(70, 50)
        self.accept_centering_button.setFixedSize(70, 50)

        if HWR.beamline.imaging is not None:
            HWR.beamline.imaging.connect("imageInit", self.image_init)
            HWR.beamline.imaging.connect("imageLoaded", self.image_loaded)
            HWR.beamline.imaging.connect("measureItemChanged",
                                         self.measure_item_changed)

            self.graphics_view = HWR.beamline.imaging.get_graphics_view()
            self._graphics_view_widget_vlayout.addWidget(self.graphics_view)
            self.graphics_view_widget.setFixedSize(
                self.graphics_view.scene().width(),
                self.graphics_view.scene().height())

            self.setDisabled(False)
        else:
            self.setDisabled(True)
Esempio n. 8
0
 def run(self):
     """Adds menu to the tool bar"""
     self.tools_menu = QtImport.QMenu("Tools", self)
     self.tools_menu.addSeparator()
     BaseWidget._menubar.insert_menu(self.tools_menu, 2)
     self.init_tools()
Esempio n. 9
0
    def run(self):
        self.tools_menu = QtImport.QMenu("Graphics", self)

        _create_menu = self.tools_menu.addMenu("Create")
        temp_action = _create_menu.addAction(
            Icons.load_icon("VCRPlay2"),
            "Centring point with 3 clicks",
            self.create_point_click_clicked,
        )
        temp_action.setShortcut("Ctrl+1")
        temp_action = _create_menu.addAction(
            Icons.load_icon("ThumbUp"),
            "Centring point on current position",
            self.create_point_current_clicked,
        )
        temp_action.setShortcut("Ctrl+2")
        temp_action = _create_menu.addAction(Icons.load_icon("Line.png"),
                                             "Helical line",
                                             self.create_line_clicked)
        temp_action.setShortcut("Ctrl+3")
        temp_action = _create_menu.addAction(
            Icons.load_icon("Line.png"),
            "Automatic helical line",
            self.create_auto_line_clicked,
        )
        temp_action = _create_menu.addAction(Icons.load_icon("Grid"), "Grid",
                                             self.create_grid_clicked)
        temp_action.setShortcut("Ctrl+G")

        _measure_menu = self.tools_menu.addMenu("Measure")
        self.measure_distance_action = _measure_menu.addAction(
            Icons.load_icon("measure_distance"),
            "Distance",
            self.measure_distance_clicked,
        )
        self.measure_angle_action = _measure_menu.addAction(
            Icons.load_icon("measure_angle"), "Angle",
            self.measure_angle_clicked)
        self.measure_area_action = _measure_menu.addAction(
            Icons.load_icon("measure_area"), "Area", self.measure_area_clicked)

        _beam_mark_menu = self.tools_menu.addMenu("Beam mark")
        self.move_beam_mark_manual_action = _beam_mark_menu.addAction(
            "Set position manualy", self.move_beam_mark_manual)
        self.move_beam_mark_manual_action.setEnabled(False)
        self.move_beam_mark_auto_action = _beam_mark_menu.addAction(
            "Set position automaticaly", self.move_beam_mark_auto)
        self.move_beam_mark_auto_action.setEnabled(False)
        self.display_beam_size_action = _beam_mark_menu.addAction(
            "Display size", self.display_beam_size_toggled)
        self.display_beam_size_action.setCheckable(True)
        self.define_beam_action = _beam_mark_menu.addAction(
            "Define size with slits", self.define_beam_size)
        self.define_beam_action.setEnabled(self["beamDefiner"])

        self.tools_menu.addSeparator()

        temp_action = self.tools_menu.addAction("Select all centring points",
                                                self.select_all_points_clicked)
        temp_action.setShortcut("Ctrl+A")
        temp_action = self.tools_menu.addAction(
            "Deselect all items", self.deselect_all_items_clicked)
        temp_action.setShortcut("Ctrl+D")
        temp_action = self.tools_menu.addAction(Icons.load_icon("Delete"),
                                                "Clear all items",
                                                self.clear_all_items_clicked)
        temp_action.setShortcut("Ctrl+X")

        self.tools_menu.addSeparator()

        self.display_grid_action = self.tools_menu.addAction(
            "Display grid", self.display_grid_toggled)
        self.display_grid_action.setCheckable(True)
        self.magnification_action = self.tools_menu.addAction(
            Icons.load_icon("Magnify2"),
            "Magnification tool",
            self.start_magnification_tool,
        )

        self.image_scale_menu = self.tools_menu.addMenu(
            Icons.load_icon("DocumentMag2"), "Image scale")
        self.image_scale_menu.setEnabled(False)
        self.init_image_scale_list()
        self.image_scale_menu.triggered.connect(self.image_scale_triggered)

        # self.camera_control_action = self.tools_menu.addAction(\
        #     "Camera control", self.open_camera_control_dialog)
        # self.camera_control_action.setEnabled(False)

        if self.target_menu == "menuBar":
            if BaseWidget._menubar is not None:
                BaseWidget._menubar.insert_menu(self.tools_menu, 3)
        elif self.target_menu == "toolBar":
            if BaseWidget._toolbar is not None:
                for action in self.tools_menu.actions():
                    BaseWidget._toolbar.addAction(action)
        else:
            if BaseWidget._menubar is not None:
                BaseWidget._menubar.insert_menu(self.tools_menu, 2)

            if BaseWidget._toolbar is not None:
                for action in self.tools_menu.actions():
                    BaseWidget._toolbar.addAction(action)