Exemplo n.º 1
0
 def set_selections(self, selections: Sequence[int], key_detect: bool = False) -> None:
     """Auto select function, get the signal from canvas."""
     self.setFocus()
     keyboard_modifiers = QApplication.keyboardModifiers()
     if key_detect:
         if keyboard_modifiers == Qt.ShiftModifier:
             continue_select = True
             not_select = False
         elif keyboard_modifiers == Qt.ControlModifier:
             continue_select = True
             not_select = True
         else:
             continue_select = False
             not_select = False
         self.__set_selected_ranges(
             selections,
             is_continue=continue_select,
             un_select=not_select
         )
     else:
         self.__set_selected_ranges(
             selections,
             is_continue=(keyboard_modifiers == Qt.ShiftModifier),
             un_select=False
         )
Exemplo n.º 2
0
    def mouseReleaseEvent(self, event: QMouseEvent) -> None:
        """Release mouse button.

        + Alt & Left button: Add a point.
        + Left button: Select a point.
        + Free move mode: Edit the point(s) coordinate.
        """
        if self.selector.left_dragged:
            km = QApplication.keyboardModifiers()
            self.selector.selection_old = list(self.selections)
            if (self.select_mode == SelectMode.JOINT
                    and self.free_move != FreeMode.NO_FREE_MOVE):
                x, y = self.__mouse_pos(event)
                if self.selector.x != x and self.selector.y != y:
                    # Edit point coordinates.
                    self.__emit_free_move(self.selections)
                elif ((not self.selector.selection_rect)
                      and km != Qt.ControlModifier and km != Qt.ShiftModifier):
                    self.no_selected.emit()
            else:
                if km == Qt.AltModifier:
                    # Add Point
                    self.alt_add.emit(
                        self.__snap(self.selector.x, is_zoom=False),
                        self.__snap(self.selector.y, is_zoom=False))
                elif ((not self.selector.selection_rect)
                      and km != Qt.ControlModifier and km != Qt.ShiftModifier):
                    self.no_selected.emit()
        self.selected_tips_hide.emit()
        self.selector.release()
        self.update()
Exemplo n.º 3
0
    def eventFilter(self, watched, event):
        # check if mouse scroll.
        # Normal scroll is Y axis zoom
        # CTRL + scroll is X axis zoom
        mods = QApplication.keyboardModifiers()
        if event.type() == QEvent.GraphicsSceneWheel:
            # no CTRL, Y axis enabled, do not block
            if mods != Qt.ControlModifier and self.plot_config[
                    'mouse_enabled'][1]:
                self.plot.setMouseEnabled(x=False, y=True)
                return False
            elif mods != Qt.ControlModifier and not self.plot_config[
                    'mouse_enabled'][1]:
                self.plot.setMouseEnabled(
                    x=self.plot_config['mouse_enabled'][0],
                    y=self.plot_config['mouse_enabled'][1])
                return True
            elif mods == Qt.ControlModifier and self.plot_config[
                    'mouse_enabled'][0]:
                self.plot.setMouseEnabled(x=True, y=False)
                return False
            elif mods == Qt.ControlModifier and not self.plot_config[
                    'mouse_enabled'][0]:
                self.plot.setMouseEnabled(
                    x=self.plot_config['mouse_enabled'][0],
                    y=self.plot_config['mouse_enabled'][1])
                return True

        self.plot.setMouseEnabled(x=self.plot_config['mouse_enabled'][0],
                                  y=self.plot_config['mouse_enabled'][1])
        return False
Exemplo n.º 4
0
    def keyPressEvent(self, ev):
        modifiers = QApplication.keyboardModifiers()
        key = ev.key()

        if key in (Qt.Key_Delete, Qt.Key_Backspace):
            self.onDeletePressed()
        elif key == Qt.Key_Escape:  #deselect all
            self.selectNode([])

        #copy&paste
        elif (key, modifiers) == (Qt.Key_C, Qt.ControlModifier):
            if self.onClipboardCopy(): return
        elif (key, modifiers) == (Qt.Key_X, Qt.ControlModifier):
            if self.onClipboardCut(): return
        elif (key, modifiers) == (Qt.Key_V, Qt.ControlModifier):
            if self.onClipboardPaste(): return

        #open
        elif key == Qt.Key_Down \
         and ( modifiers in ( Qt.ControlModifier, Qt.ControlModifier | Qt.KeypadModifier ) ):
            item = self.currentItem()
            if item:
                self.onItemActivated(item)
                return

        return super(GenericListWidget, self).keyPressEvent(ev)
Exemplo n.º 5
0
    def open_file(self, checked):
        modifiers = QApplication.keyboardModifiers()
        try:
            curr_file = self.current_file()
            folder = os.path.dirname(curr_file)
        except Exception:
            folder = os.getcwd()

        filename = QFileDialog.getOpenFileName(
            self, "Open File...", folder,
            "XML (*.xml);; ALH Config (*.alhConfig)")
        filename = filename[0] if isinstance(filename,
                                             (list, tuple)) else filename

        if filename:
            filename = str(filename)

            # if alh file selected, open conversion prompt
            if filename[-9:] == "alhConfig":
                self.legacy_window = LegacyWindow(filename)
                self.legacy_window.exec_()

                if self.legacy_window.converted_filename:
                    self.import_configuration(
                        self.legacy_window.converted_filename)

            else:
                self.import_configuration(filename)
Exemplo n.º 6
0
 def wheelEvent(self, event: QWheelEvent) -> None:
     super(_ScriptBrowser, self).wheelEvent(event)
     if QApplication.keyboardModifiers() != Qt.ControlModifier:
         return
     if event.angleDelta().y() > 0:
         self.zoomIn(1)
     else:
         self.zoomOut(1)
Exemplo n.º 7
0
    def __splitterMoved(self, pos, index):
        modifiers = QApplication.keyboardModifiers()

        if modifiers in [Qt.AltModifier]:
            return
        else:
            if not self.__splitter_event_is_paused:
                self.setAllHandlesToPos(pos)
Exemplo n.º 8
0
    def home(self):
        if self.home_file is None:
            return

        if QApplication.keyboardModifiers() == Qt.ShiftModifier:
            self.new_abs_window(filename=self.home_file[0], macros=self.home_file[1], command_line_args=self.home_file[2])
        else:
            self.go_abs(self.home_file[0], macros=self.home_file[1], command_line_args=self.home_file[2])
Exemplo n.º 9
0
 def forward(self):
     if len(self.forward_stack) > 0:
         if QApplication.keyboardModifiers() == Qt.ShiftModifier:
             stack_item = self.forward_stack[-1]
             self.new_abs_window(filename=stack_item[0], macros=stack_item[1], command_line_args=stack_item[2])
         else:
             stack_item = self.forward_stack.pop()
             self.open_abs_file(filename=stack_item[0], macros=stack_item[1], command_line_args=stack_item[2])
Exemplo n.º 10
0
 def onClipboardCopy(self):
     clip = QtWidgets.QApplication.clipboard()
     nameOnly = QApplication.keyboardModifiers() & Qt.ShiftModifier
     if nameOnly:
         clip.setText('\n'.join(
             [node.getName() for node in self.getSelection()]))
     else:
         clip.setMimeData(makeAssetListMimeData(self.getSelection()))
     return True
Exemplo n.º 11
0
 def go_button_pressed(self):
     filename = str(self.ui.panelSearchLineEdit.text())
     if not filename:
         return
     try:
         if QApplication.keyboardModifiers() == Qt.ShiftModifier:
             self.app.new_window(filename)
         else:
             self.go(filename)
     except (IOError, OSError, ValueError, ImportError) as e:
         self.handle_open_file_error(filename, e)
Exemplo n.º 12
0
    def keyPressEvent(self, ev):
        modifiers = QApplication.keyboardModifiers()
        key = ev.key()
        if key in (Qt.Key_Delete, Qt.Key_Backspace):
            self.onDeletePressed()
        elif key == Qt.Key_Left:  #move to parent node
            item = self.currentItem()
            if item and not item.isExpanded():
                pitem = item.parent()
                if pitem and not pitem.isHidden():
                    self.setCurrentItem(pitem)
                    return
        elif key == Qt.Key_Escape:  #deselect all
            self.selectNode([])
        #copy&paste
        elif key == Qt.Key_C and modifiers & Qt.ControlModifier:
            if self.onClipboardCopy(): return
        elif key == Qt.Key_X and modifiers & Qt.ControlModifier:
            if self.onClipboardCut(): return
        elif key == Qt.Key_V and modifiers & Qt.ControlModifier:
            if self.onClipboardPaste(): return
        #open
        elif key == Qt.Key_Down \
         and ( modifiers in ( Qt.ControlModifier, Qt.ControlModifier | Qt.KeypadModifier ) ):
            item = self.currentItem()
            if item:
                self.onItemActivated(item, 0)
                return

        elif key == Qt.Key_Down:
            if not self.currentItem():
                top = self.topLevelItem(0)
                self.setCurrentItem(top)
            else:
                item_below = self.itemBelow(self.currentItem())
                if item_below:
                    self.setCurrentItem(item_below)
            return

        elif key == Qt.Key_Up:
            if not self.currentItem():
                top = self.topLevelItem(0)
                self.setCurrentItem(top)
            item_below = self.itemAbove(self.currentItem())
            if item_below:
                self.setCurrentItem(item_below)
            return

        return super(GenericTreeWidget, self).keyPressEvent(ev)
Exemplo n.º 13
0
    def eventFilter(self, widget, event):
        """A filter to control the zooming and panning of the figure canvas."""

        # ---- Zooming
        if event.type() == QEvent.Wheel and not self.auto_fit_plotting:
            modifiers = QApplication.keyboardModifiers()
            if modifiers == Qt.ControlModifier:
                if event.angleDelta().y() > 0:
                    self.zoom_in()
                else:
                    self.zoom_out()
                return True
            else:
                return False

        # ---- Scaling
        elif event.type() == QEvent.Paint and self.auto_fit_plotting:
            self.scale_image()

        # ---- Panning
        # Set ClosedHandCursor:
        elif event.type() == QEvent.MouseButtonPress:
            if event.button() == Qt.LeftButton:
                QApplication.setOverrideCursor(Qt.ClosedHandCursor)
                self._ispanning = True
                self.xclick = event.globalX()
                self.yclick = event.globalY()

        # Reset Cursor:
        elif event.type() == QEvent.MouseButtonRelease:
            QApplication.restoreOverrideCursor()
            self._ispanning = False

        # Move  ScrollBar:
        elif event.type() == QEvent.MouseMove:
            if self._ispanning:
                dx = self.xclick - event.globalX()
                self.xclick = event.globalX()

                dy = self.yclick - event.globalY()
                self.yclick = event.globalY()

                scrollBarH = self.horizontalScrollBar()
                scrollBarH.setValue(scrollBarH.value() + dx)

                scrollBarV = self.verticalScrollBar()
                scrollBarV.setValue(scrollBarV.value() + dy)

        return QWidget.eventFilter(self, widget, event)
Exemplo n.º 14
0
 def onClipboardCopy(self):
     clip = QtWidgets.QApplication.clipboard()
     modifiers = QApplication.keyboardModifiers()
     out = None
     for node in self.getSelection():
         if out:
             out += "\n"
         else:
             out = ""
         if modifiers & Qt.ShiftModifier:
             out += node.getName()
         else:
             out += node.getNodePath()
     clip.setText(out)
     return True
Exemplo n.º 15
0
    def save_configuration(self):
        modifiers = QApplication.keyboardModifiers()
        try:
            curr_file = self.current_file()
            folder = os.path.dirname(curr_file)
        except Exception:
            folder = os.getcwd()

        filename = QFileDialog.getSaveFileName(self, "Save File...", folder,
                                               "Configration files (*.xml)")
        filename = filename[0] if isinstance(filename,
                                             (list, tuple)) else filename

        self.config_tool.save_configuration(self.tree_view.model()._root_item,
                                            filename)
Exemplo n.º 16
0
    def line_clicked(self, plot_data_item):
        """line을 Shift키와 함께 click하면 marker를 표시한다."""
        modifiers = QApplication.keyboardModifiers()
        if modifiers == Qt.ShiftModifier:
            x = plot_data_item.xData
            y = plot_data_item.yData
            if isinstance(x, ndarray) and isinstance(y, ndarray):
                idx_near = (np.abs(x - self.mouse_pos_x)).argmin()

                # calc radius
                idx_prev = idx_near - 1
                if idx_near == 0:
                    idx_prev = 1

                radius = (min([
                    abs(x[idx_near] - x[idx_prev]),
                    abs(y[idx_near] - y[idx_prev])
                ]) / 2)

                roi = pg.CircleROI(
                    pos=(x[idx_near] - radius, y[idx_near] - radius),
                    radius=radius,
                    movable=False,
                    removable=True,
                )

                roi.setAcceptedMouseButtons(Qt.LeftButton)

                arrow = pg.ArrowItem(angle=90, pos=(radius, radius))
                arrow.setParentItem(roi)

                text = pg.TextItem(
                    html=('<span style="font-family: D2Conding ligature;">' +
                          f"x {x[idx_near]:g}<br>y {y[idx_near]:g}<br>" +
                          f"idx {idx_near}" + "</span>"),
                    border={
                        "color": "222222",
                        "width": 1
                    },
                    anchor=(0.5, -0.5),
                    fill=(250, 250, 255, 50),
                )
                text.setParentItem(roi)

                roi.sigClicked.connect(self.roi_click)
                roi.sigRemoveRequested.connect(self.roi_remove)

                self.addItem(roi)
Exemplo n.º 17
0
    def wheelEvent(self, event):

        try:
            delta = event.angleDelta().y()
        except AttributeError:
            delta = event.delta()

        slice_ = (self.currentSlice + int(delta / 120))\
            % self.numberOfSlices
        self.setSlice(slice_)

        self.signalSliceChanged.emit(slice_)

        modifiers = QApplication.keyboardModifiers()
        if modifiers == Qt.ControlModifier:
            self.signalSyncSlices.emit(slice_)
Exemplo n.º 18
0
    def _open_file_selection(self):
        modifiers = QApplication.keyboardModifiers()
        try:
            curr_file = self.current_file()
            folder = os.path.dirname(curr_file)
        except Exception:
            folder = os.getcwd()

        filename = QFileDialog.getSaveFileName(self, 'Save File...', folder,
                                               'Configration files (*.xml)')
        filename = filename[0] if isinstance(filename,
                                             (list, tuple)) else filename

        convert_alh_to_phoebus(self.legacy_filename, filename)
        self.converted_filename = filename
        self.accept()
Exemplo n.º 19
0
    def eventFilter(self, widget, event):
        """A filter to control the zooming and panning of the figure canvas."""

        # ---- Zooming
        if event.type() == QEvent.Wheel:
            modifiers = QApplication.keyboardModifiers()
            if modifiers == Qt.ControlModifier:
                if event.angleDelta().y() > 0:
                    self.zoom_in()
                else:
                    self.zoom_out()
                return True
            else:
                return False

        # ---- Panning
        # Set ClosedHandCursor:
        elif event.type() == QEvent.MouseButtonPress:
            if event.button() == Qt.LeftButton:
                QApplication.setOverrideCursor(Qt.ClosedHandCursor)
                self._ispanning = True
                self.xclick = event.globalX()
                self.yclick = event.globalY()

        # Reset Cursor:
        elif event.type() == QEvent.MouseButtonRelease:
            QApplication.restoreOverrideCursor()
            self._ispanning = False

        # Move  ScrollBar:
        elif event.type() == QEvent.MouseMove:
            if self._ispanning:
                dx = self.xclick - event.globalX()
                self.xclick = event.globalX()

                dy = self.yclick - event.globalY()
                self.yclick = event.globalY()

                scrollBarH = self.horizontalScrollBar()
                scrollBarH.setValue(scrollBarH.value() + dx)

                scrollBarV = self.verticalScrollBar()
                scrollBarV.setValue(scrollBarV.value() + dy)

        return QWidget.eventFilter(self, widget, event)
Exemplo n.º 20
0
    def keyPressEvent(self, event):
        key = event.key()
        modifiers = QApplication.keyboardModifiers()

        if key == Qt.Key_Delete:
            if modifiers == Qt.ShiftModifier:
                self._delete_selected()
            elif modifiers == Qt.NoModifier:
                self._trash_selected()
        # TODO:
        # elif key == Qt.Key_X:
            # if modifiers == Qt.ControlModifier:
                # self._cut()
        elif key == Qt.Key_C:
            if modifiers == Qt.ControlModifier:
                self._copy()
        elif key == Qt.Key_V:
            if modifiers == Qt.ControlModifier:
                self._paste()
Exemplo n.º 21
0
    def _handle_activated_index(self, index):
        '''
        This slot handles the activation of items in the view. If the activated item is a directory,
        then the view will change to that directory. If ctrl is held, then the directory will open in
        a new root. If the item is a file, the item will be opened.
        '''
        if self._model.isDir(index):
            modifiers = QApplication.keyboardModifiers()
            if modifiers == Qt.ControlModifier:
                # Send a request for opening a new root.
                self.open_request.emit(self._model.filePath(index))
                return

            # Change the root directory.
            self._move_root_index(index)
            path = self._model.filePath(self._view.rootIndex())
            self._root_edit.update(path)
        else:
            self._open_index(index)
Exemplo n.º 22
0
    def open_file_action(self, checked):
        modifiers = QApplication.keyboardModifiers()
        try:
            curr_file = self.current_file()
            folder = os.path.dirname(curr_file)
        except IndexError:
            folder = os.getcwd()

        filename = QFileDialog.getOpenFileName(self, 'Open File...', folder, 'PyDM Display Files (*.ui *.py)')
        filename = filename[0] if isinstance(filename, (list, tuple)) else filename

        if filename:
            filename = str(filename)
            try:
                if modifiers == Qt.ShiftModifier:
                    self.app.new_window(filename)
                else:
                    self.open_file(filename)
            except (IOError, OSError, ValueError, ImportError) as e:
                self.handle_open_file_error(filename, e)
Exemplo n.º 23
0
    def contextMenuEvent(self, event):
        """
        Handle context menu events.

        This overrides WebView.contextMenuEvent() in order to add the
        actions in `self.actions` and remove the Back and Forward actions
        which have no meaning for the notebook widget.

        If Shift is pressed, then instead display the standard Qt context menu,
        per gh:spyder-ide/spyder-notebook#279

        Parameters
        ----------
        event : QContextMenuEvent
            The context menu event that needs to be handled.
        """
        if QApplication.keyboardModifiers() & Qt.ShiftModifier:
            return QWebEngineView.contextMenuEvent(self, event)

        if self.actions is None:
            actions = []
        else:
            actions = self.actions + [None]

        actions += [
            self.pageAction(QWebEnginePage.SelectAll),
            self.pageAction(QWebEnginePage.Copy),
            None,
            self.zoom_in_action,
            self.zoom_out_action]

        if not WEBENGINE:
            settings = self.page().settings()
            settings.setAttribute(QWebEngineSettings.DeveloperExtrasEnabled,
                                  True)
            actions += [None, self.pageAction(QWebEnginePage.InspectElement)]

        menu = QMenu(self)
        add_actions(menu, actions)
        menu.popup(event.globalPos())
        event.accept()
Exemplo n.º 24
0
    def wheelEvent(self, event: QWheelEvent) -> None:
        """Switch function by mouse wheel.

        + Set zoom bar value.
        + Set select mode.
        """
        p = event.angleDelta()
        if QApplication.keyboardModifiers() == Qt.ShiftModifier:
            value = p.y()
        elif p.x() != 0:
            value = p.x()
        elif p.y() != 0:
            value = self.prefer.scale_factor_option * (1 if p.y() > 0 else -1)
            value += self.zoom_value()
            self.set_zoom_bar(value)
            return
        else:
            return
        tags = ("Points", "Links")
        mode = (self.selection_mode() + (-1 if value > 0 else 1)) % len(tags)
        self.selection_mode_wheel(mode)
        QToolTip.showText(event.globalPos(), f"Selection mode: {tags[mode]}", self)
        event.accept()
Exemplo n.º 25
0
 def current_selection(self) -> Tuple[int, ...]:
     km = QApplication.keyboardModifiers()
     if km == Qt.ControlModifier or km == Qt.ShiftModifier:
         return tuple(set(self.selection_old + self.selection_rect))
     else:
         return tuple(self.selection_rect)
Exemplo n.º 26
0
 def home_triggered(self):
     new_process = QApplication.keyboardModifiers() == Qt.ShiftModifier
     self.home(open_in_new_process=new_process)
Exemplo n.º 27
0
 def forward_triggered(self):
     new_process = QApplication.keyboardModifiers() == Qt.ShiftModifier
     self.forward(open_in_new_process=new_process)
Exemplo n.º 28
0
    def mousePressEvent(self, event, *args, **kwargs):
        """
        Attrs:
            _picking (bool): tells the widget that the user is now attempting
                to pick a value
            _in_gradient_widget (bool) tells the widget that the cursor is
                in the gradient widget
        """
        modifiers = QApplication.keyboardModifiers()
        button = event.button()
        if button in [Qt.LeftButton, Qt.RightButton, Qt.MiddleButton]:
            # move rgba

            # HSV
            self._picking = True
            self._black_select = False
            self._in_gradient_widget = True
            self._orig_pos = QCursor.pos()
            # setup default crosshair
            self.__hideRGBACrosshair(True)
            self.__hideLinearCrosshair(False)

            # RGB
            main_widget = getWidgetAncestor(self, ColorGradientDelegate)
            color = main_widget.color()
            pos = QPoint(0, 0)

            # TODO Check hack after upgrading to 5.15
            # katana is not registering the alt + mmb?
            if modifiers in [Qt.AltModifier, Qt.ControlModifier]:
                # RED
                if button == Qt.LeftButton:
                    pos = QPoint(color.redF() * self.width(), color.redF() * self.height())
                    self.scene().gradient_type = attrs.RED
                # GREEN
                elif button == Qt.MiddleButton:
                    pos = QPoint(color.greenF() * self.width(), color.greenF() * self.height())
                    self.scene().gradient_type = attrs.GREEN
                # BLUE
                elif button == Qt.RightButton:
                    pos = QPoint(color.blueF() * self.width(), color.blueF() * self.height())
                    self.scene().gradient_type = attrs.BLUE

            # HSV
            else:
                if button == Qt.LeftButton:
                    self.__hideRGBACrosshair(False)
                    self.__hideLinearCrosshair(True)
                    self.scene().gradient_type = attrs.RGBA
                # VALUE
                elif button == Qt.MiddleButton:
                    pos = QPoint(color.valueF() * self.width(), color.valueF() * self.height())
                    self.scene().gradient_type = attrs.VALUE
                # SATURATION
                elif button == Qt.RightButton:
                    pos = QPoint(color.saturationF() * self.width(), color.saturationF() * self.height())
                    self.scene().gradient_type = attrs.SATURATION

            # update display label to show selected value
            color_gradient_widget = getWidgetAncestor(self, ColorGradientDelegate)
            color_arg_widgets_dict = color_gradient_widget.header_widget.getWidgetDict()
            if self.scene().gradient_type != attrs.RGBA:
                color_arg_widgets_dict[self.scene().gradient_type].setSelected(True)

            # draw gradient / hide cursor
            self.scene().drawGradient()

            # set up cursor
            self.setCursor(Qt.BlankCursor)
            if pos:
                self.scene().linear_crosshair_item.setCrosshairPos(pos)
                QCursor.setPos(self.mapToGlobal(pos))

        return QGraphicsView.mousePressEvent(self, event, *args, **kwargs)
Exemplo n.º 29
0
 def keyPressEvent(self, event):
     if QApplication.keyboardModifiers() & Qt.ControlModifier and (
             event.key() == Qt.Key_Equal):
         self.change_font_size(1)
Exemplo n.º 30
0
    def func_shift_left_click(self, event):
        """Shift를 누르고 마우스 왼쪽을 클릭하면 Data Marker를 표시한다.

        Args:
          event: Event.

        """
        modifiers = QApplication.keyboardModifiers()
        if event.button() == Qt.LeftButton and modifiers == Qt.ShiftModifier:
            pos = event.scenePos()
            data_point = self.getImageItem().mapFromScene(pos)

            data_point_x = int(data_point.x())
            data_point_y = int(data_point.y())

            # view_rect = self.getImageItem().viewRect()
            # text_size = self.size_text(view_rect.width(), view_rect.height())
            if self.image.ndim > 2:
                val_point = f"{self.image[data_point_y, data_point_x, :]}"
            else:
                val_point = f"{self.image[data_point_y, data_point_x]}"

            rgb_hex = hex(self.getImageItem().getPixmap().toImage().pixel(
                data_point_x, data_point_y))
            rgb = (f"[{int(rgb_hex[4:6], 16)} {int(rgb_hex[6:8], 16)}"
                   f" {int(rgb_hex[8:], 16)}]")

            roi = pg.ROI(
                pos=self.pos_of_roi(data_point_x, data_point_y),
                pen=self.contrast_color(rgb_hex),
                size=self.size_of_roi(),
                movable=False,
                removable=True,
            )
            roi.setPen(color=self.contrast_color(rgb_hex), width=4.5)

            roi.setAcceptedMouseButtons(Qt.LeftButton)
            text = PgTextItem(
                html=(f'<span style="font-family: {self.font_family};">' +
                      self.html_of_data_marker_name("PIXEL[X,Y]") +
                      self.html_of_data_marker_value(
                          f"[{data_point_x} {data_point_y}]") + "<br>" +
                      self.html_of_data_marker_name("AXIS [X,Y]") +
                      self.html_of_data_marker_value(
                          f"[{self.axis_x[data_point_x]:6g}"
                          f" {self.axis_y[data_point_y]:6g}]") + "<br>" +
                      self.html_of_data_marker_name("Value") +
                      self.html_of_data_marker_value(val_point) + "<br>" +
                      self.html_of_data_marker_name("[R,G,B]") +
                      self.html_of_data_marker_value(rgb) + "</span>"),
                border={
                    "color": "000000",
                    "width": 1
                },
                anchor=(0, 1),
                fill=(250, 250, 255, 255),
            )
            text.sig_change_font_size.connect(self.change_roi_font_size)
            text.setParentItem(roi)
            roi.sigClicked.connect(self.roi_click)
            roi.sigRemoveRequested.connect(self.roi_remove)

            self.addItem(roi)
            event.accept()
        else:
            event.ignore()