예제 #1
0
    def drawRoi(self, qp):
        pensolid = QtGui.QPen(self.solidColor, 1, QtCore.Qt.SolidLine)
        pendash = QtGui.QPen(self.dashColor, 1, QtCore.Qt.CustomDashLine)
        ##        pendash.setDashPattern([3, 3, 1, 5, 3, 3, 5, 1])
        pendash.setDashPattern([4, 4])

        x0 = self.overscan
        y0 = self.overscan
        #max-> keep is visible even if it is smaller then 1x1
        x1 = max(self.size().width() - 1 - self.overscan, x0 + 1)
        y1 = max(self.size().height() - 1 - self.overscan, y0 + 1)

        pendash.setDashOffset(8 - self.phase)

        polygonRect = QtGui.QPolygon()
        polygonNe = QtGui.QPolygon()
        polygonSw = QtGui.QPolygon()

        polygonRect << QtCore.QPoint(x0, y0) << QtCore.QPoint(x1, y0)\
            << QtCore.QPoint(x1, y1) << QtCore.QPoint(x0, y1)
        polygonNe << QtCore.QPoint(x0, y0) << QtCore.QPoint(x1, y0)\
            << QtCore.QPoint(x1, y1)
        polygonSw << QtCore.QPoint(x0, y0)  << QtCore.QPoint(x0, y1)\
            << QtCore.QPoint(x1, y1)

        if self.createState:
            self.setAttribute(QtCore.Qt.WA_OpaquePaintEvent, False)
            qp.setOpacity(0.25)
            qp.fillRect(x0, y0, x1 - x0 + 1, y1 - y0 + 1, self.fillColor)
            qp.setOpacity(0.5)
        else:
            qp.setOpacity(1.0)
            self.timer.start(100)

        qp.setPen(pensolid)
        qp.drawPolygon(polygonRect)
        qp.setPen(pendash)
        qp.drawPolyline(polygonNe)
        qp.drawPolyline(polygonSw)
예제 #2
0
 def __init__(self, *args, **kwargs):
     self.epsilon = kwargs.pop('epsilon', 10.0)
     super(Canvas, self).__init__(*args, **kwargs)
     # Initialise local state.
     self.mode = self.EDIT
     self.shapes = []
     self.shapesBackups = []
     self.current = None
     self.selectedShapes = []  # save the selected shapes here
     self.selectedShapesCopy = []
     self.lineColor = QtGui.QColor(0, 0, 255)
     # self.line represents:
     #   - createMode == 'polygon': edge from last point to current
     #   - createMode == 'rectangle': diagonal line of the rectangle
     #   - createMode == 'line': the line
     #   - createMode == 'point': the point
     self.line = Shape(line_color=self.lineColor)
     self.prevPoint = QtCore.QPoint()
     self.prevMovePoint = QtCore.QPoint()
     self.offsets = QtCore.QPoint(), QtCore.QPoint()
     self.scale = 1.0
     self.pixmap = QtGui.QPixmap()
     self.visible = {}
     self._hideBackround = False
     self.hideBackround = False
     self.hShape = None
     self.hVertex = None
     self.hEdge = None
     self.movingShape = False
     self._painter = QtGui.QPainter()
     self._cursor = CURSOR_DEFAULT
     # Menus:
     # 0: right-click without selection and dragging of shapes
     # 1: right-click with selection and dragging of shapes
     self.menus = (QtWidgets.QMenu(), QtWidgets.QMenu())
     # Set widget options.
     self.setMouseTracking(True)
     self.setFocusPolicy(QtCore.Qt.WheelFocus)
예제 #3
0
    def column_name_changed(self, name):
        # Determine the position of the tooltip
        pos = self.name_box.mapToGlobal(
            QC.QPoint(self.name_box.rect().left(),
                      self.name_box.height() // 2))

        # If this name is not valid, show tooltip with error
        if not self.check_column_name(name):
            err_msg = "This name is either invalid or already taken!"
            GW.QToolTip.showText(pos, err_msg, self.name_box)

        # If it is valid, disable any previous tooltip
        else:
            GW.QToolTip.hideText()
예제 #4
0
 def test_close_dialog(self, qtbot):
     assert not self.window.channels_window_is_open
     qtbot.mouseClick(self.window.channels_button, QtCore.Qt.LeftButton)
     assert self.window.channels_window_is_open
     pos = self.dialog.pos()
     x, y = pos.x(), pos.y()
     new_pos = QtCore.QPoint(x + 5, y - 10)
     self.dialog.move(new_pos)
     qtbot.mouseClick(self.dialog.close_button, QtCore.Qt.LeftButton)
     assert not self.window.channels_window_is_open
     assert self.window.channels_window_pos == new_pos
     qtbot.mouseClick(self.window.channels_button, QtCore.Qt.LeftButton)
     assert self.window.channels_window_is_open
     assert self.dialog.pos() == new_pos
예제 #5
0
    def rotateBy(self, angle):
        c = self.centroid()

        tpoints = []
        for p in self.points:
            rp = p - c
            _x = rp.x() * np.cos(angle) - rp.y() * np.sin(angle) + c.x()
            _x = np.rint(_x)
            _y = rp.x() * np.sin(angle) + rp.y() * np.cos(angle) + c.y()
            _y = np.rint(_y)
            tp = QtCore.QPoint(_x, _y)
            tpoints.append(tp)

        self.points = tpoints
예제 #6
0
    def paint(self, painter, option, index):
        """Overloaded Qt method for custom painting of a model index"""
        if not self.highlight_text:
            QtWidgets.QStyledItemDelegate.paint(self, painter, option, index)
            return
        text = index.data()
        if self.case_sensitive:
            html = text.replace(
                self.highlight_text, '<strong>%s</strong>' % self.highlight_text
            )
        else:
            match = re.match(
                r'(.*)(%s)(.*)' % re.escape(self.highlight_text), text, re.IGNORECASE
            )
            if match:
                start = match.group(1) or ''
                middle = match.group(2) or ''
                end = match.group(3) or ''
                html = start + ('<strong>%s</strong>' % middle) + end
            else:
                html = text
        self.doc.setHtml(html)

        # Painting item without text, Text Document will paint the text
        params = QtWidgets.QStyleOptionViewItem(option)
        self.initStyleOption(params, index)
        params.text = ''

        style = QtWidgets.QApplication.style()
        style.drawControl(QtWidgets.QStyle.CE_ItemViewItem, params, painter)
        ctx = QtGui.QAbstractTextDocumentLayout.PaintContext()

        # Highlighting text if item is selected
        if params.state & QtWidgets.QStyle.State_Selected:
            color = params.palette.color(
                QtGui.QPalette.Active, QtGui.QPalette.HighlightedText
            )
            ctx.palette.setColor(QtGui.QPalette.Text, color)

        # translate the painter to where the text is drawn
        item_text = QtWidgets.QStyle.SE_ItemViewItemText
        rect = style.subElementRect(item_text, params, self.widget)
        painter.save()

        start = rect.topLeft() + QtCore.QPoint(defs.margin, 0)
        painter.translate(start)

        # tell the text document to draw the html for us
        self.doc.documentLayout().draw(painter, ctx)
        painter.restore()
예제 #7
0
    def __init__(self, parent=None):
        super(ImageView, self).__init__(parent)

        scene = QtWidgets.QGraphicsScene(self)
        self.graphics_pixmap = QtWidgets.QGraphicsPixmapItem()
        scene.addItem(self.graphics_pixmap)
        self.setScene(scene)

        self.zoom_factor = 1.125
        self.rubberband = None
        self.panning = False
        self.first_show_occured = False
        self.last_scene_roi = None
        self.start_drag = QtCore.QPoint()
예제 #8
0
    def GetQtPixmap(self, clip_rect=None, target_resolution=None):

        # colourspace conversions seem to be exclusively QImage territory
        if self._icc_profile_bytes is not None:

            qt_image = self.GetQtImage(clip_rect=clip_rect,
                                       target_resolution=target_resolution)

            return QG.QPixmap.fromImage(qt_image)

        (my_width, my_height) = self._resolution

        if clip_rect is None:

            clip_rect = QC.QRect(QC.QPoint(0, 0),
                                 QC.QSize(my_width, my_height))

        if target_resolution is None:

            target_resolution = clip_rect.size()

        my_full_rect = QC.QRect(0, 0, my_width, my_height)

        if my_full_rect.contains(clip_rect):

            try:

                numpy_image = self._GetNumPyImage(clip_rect, target_resolution)

                (height, width, depth) = numpy_image.shape

                data = numpy_image.data

                return HG.client_controller.bitmap_manager.GetQtPixmapFromBuffer(
                    width, height, depth * 8, data)

            except Exception as e:

                HydrusData.PrintException(e, do_wait=False)

        HydrusData.Print(
            'Failed to produce a tile! Info is: {}, {}, {}, {}'.format(
                self._hash.hex(), (my_width, my_height), clip_rect,
                target_resolution))

        pixmap = QG.QPixmap(target_resolution)

        pixmap.fill(QC.Qt.black)

        return pixmap
예제 #9
0
 def OnDrop( self, x, y ):
     
     screen_position = ClientGUIFunctions.ClientToScreen( self._parent, QC.QPoint( x, y ) )
     
     drop_tlw = QW.QApplication.topLevelAt( screen_position )
     my_tlw = self._parent.window()
     
     if drop_tlw == my_tlw:
         
         return True
         
     else:
         
         return False
예제 #10
0
 def intersectionPoint(self, p1, p2):
     # Cycle through each image edge in clockwise fashion,
     # and find the one intersecting the current line segment.
     # http://paulbourke.net/geometry/lineline2d/
     size = self.pixmap.size()
     points = [(0, 0),
               (size.width() - 1, 0),
               (size.width() - 1, size.height() - 1),
               (0, size.height() - 1)]
     # x1, y1 should be in the pixmap, x2, y2 should be out of the pixmap
     x1 = min(max(p1.x(), 0), size.width() - 1)
     y1 = min(max(p1.y(), 0), size.height() - 1)
     x2, y2 = p2.x(), p2.y()
     d, i, (x, y) = min(self.intersectingEdges((x1, y1), (x2, y2), points))
     x3, y3 = points[i]
     x4, y4 = points[(i + 1) % 4]
     if (x, y) == (x1, y1):
         # Handle cases where previous point is on one of the edges.
         if x3 == x4:
             return QtCore.QPoint(x3, min(max(0, y2), max(y3, y4)))
         else:  # y3 == y4
             return QtCore.QPoint(min(max(0, x2), max(x3, x4)), y3)
     return QtCore.QPoint(x, y)
예제 #11
0
 def boundedMoveShape(self, shape, pos):
     if self.outOfPixmap(pos):
         return False  # No need to move
     o1 = pos + self.offsets[0]
     if self.outOfPixmap(o1):
         pos -= QtCore.QPoint(min(0, o1.x()), min(0, o1.y()))
     o2 = pos + self.offsets[1]
     if self.outOfPixmap(o2):
         pos += QtCore.QPoint(min(0,
                                  self.pixmap.width() - o2.x()),
                              min(0,
                                  self.pixmap.height() - o2.y()))
     # XXX: The next line tracks the new position of the cursor
     # relative to the shape, but also results in making it
     # a bit "shaky" when nearing the border and allows it to
     # go outside of the shape's area for some reason.
     # self.calculateOffsets(self.selectedShape, pos)
     dp = pos - self.prevPoint
     if dp:
         shape.moveBy(dp)
         self.prevPoint = pos
         return True
     return False
예제 #12
0
    def __init__(self, *args, **kwargs):
        super(IntegrationWidget, self).__init__(*args, **kwargs)

        self.integration_image_widget = IntegrationImgDisplayWidget()
        self.integration_control_widget = IntegrationControlWidget()
        self.integration_pattern_widget = IntegrationPatternWidget()
        self.integration_status_widget = IntegrationStatusWidget()

        self._layout = QtWidgets.QVBoxLayout()
        self._layout.setSpacing(6)
        self._layout.setContentsMargins(0, 0, 0, 0)

        self.vertical_splitter = QtWidgets.QSplitter(self)
        self.vertical_splitter.setOrientation(QtCore.Qt.Vertical)
        self.vertical_splitter.addWidget(self.integration_control_widget)
        self.vertical_splitter.addWidget(self.integration_pattern_widget)
        self.vertical_splitter.setStretchFactor(1, 99999)


        self.vertical_splitter_left = QtWidgets.QSplitter(self)
        self.vertical_splitter_left.setOrientation(QtCore.Qt.Vertical)
        self.vertical_splitter_left.addWidget(self.integration_image_widget)

        self.horizontal_splitter = QtWidgets.QSplitter()
        self.horizontal_splitter.setOrientation(QtCore.Qt.Horizontal)
        self.horizontal_splitter.addWidget(self.vertical_splitter_left)
        self.horizontal_splitter.addWidget(self.vertical_splitter)
        self.horizontal_splitter.addWidget(self.vertical_splitter)

        self._layout.addWidget(self.horizontal_splitter, 10)
        self._layout.addWidget(self.integration_status_widget, 0)
        self.setLayout(self._layout)

        self.create_shortcuts()

        self.bkg_image_scale_sb.setKeyboardTracking(False)
        self.bkg_image_offset_sb.setKeyboardTracking(False)

        self.qa_bkg_pattern_inspect_btn.setVisible(False)

        self.mask_transparent_cb.setVisible(False)

        self.file_info_widget = FileInfoWidget(self)
        self.move_widget = MoveStageWidget(self)

        self.img_frame_size = QtCore.QSize(400, 500)
        self.img_frame_position = QtCore.QPoint(0, 0)

        self.img_mode = 'Image'
예제 #13
0
    def GetQtImage(self, clip_rect=None, target_resolution=None):

        if clip_rect is None:

            (width, height) = self._resolution

            clip_rect = QC.QRect(QC.QPoint(0, 0), QC.QSize(width, height))

        if target_resolution is None:

            target_resolution = clip_rect.size()

        numpy_image = self._GetNumPyImage(clip_rect, target_resolution)

        (height, width, depth) = numpy_image.shape

        data = numpy_image.data

        qt_image = HG.client_controller.bitmap_manager.GetQtImageFromBuffer(
            width, height, depth * 8, data)

        # ok this stuff was originally for image ICC, as loaded using PIL's image.info dict
        # ultimately I figured out how to do the conversion with PIL itself, which was more universal
        # however if we end up pulling display ICC or taking user-set ICC, we may want this qt code somewhere

        if self._icc_profile_bytes is not None:

            try:

                if self._qt_colourspace is None:

                    self._qt_colourspace = QG.QColorSpace.fromIccProfile(
                        self._icc_profile_bytes)

                # originally this was converting image ICC to sRGB, but I think in the 'display' sense, we'd be setting sRGB and then converting to the user-set ICC
                # 'hey, Qt, this QImage is in sRGB (I already normalised it), now convert it to xxx, thanks!'

                qt_image.setColorSpace(self._qt_colourspace)
                qt_image.convertToColorSpace(QG.QColorSpace.SRgb)

            except:

                HydrusData.Print(
                    'Failed to load the ICC Profile for {} into a Qt Colourspace!'
                    .format(self._path))

                self._icc_profile_bytes = None

        return qt_image
예제 #14
0
def test_style_dialog():

    # This is in part a regression test for a bug in Python 3. It is not a
    # full test of StyleDialog.

    session = simple_session()
    hub = session.hub
    collect = session.data_collection

    image = Data(label='im',
                 x=[[1, 2], [3, 4]],
                 y=[[2, 3], [4, 5]])

    pos = QtCore.QPoint(10, 10)
    st = NonBlockingStyleDialog.dropdown_editor(image, pos)
예제 #15
0
 def mouseMoveEvent(self, event):
     dx = event.x() - self.lastPos.x()
     dy = event.y() - self.lastPos.y()
     if self.do_rotate:
         self._settings.rotateCamera(dx, dy)
     if self.do_translate:
         self._settings.moveCamera(dx, dy)
     if self.do_zoom:
         self._settings.zoom += dy
     if self.do_move_clippingplane:
         s = 200.0 * exp(-self._settings.zoom / 100)
         self._settings.moveClippingPoint(-dy / s)
     if self.do_rotate_clippingplane:
         self._settings.rotateClippingNormal(dx, dy, self._settings.rotmat)
     self.lastPos = QtCore.QPoint(event.pos())
     self.updateGL()
예제 #16
0
    def getBackgroundRect(self):
        """Return the background rectangel container."""
        width = self.width()
        height = self.height()

        radius = min(width / 2, height / 2)
        center = QtCore.QPoint(width / 2, height / 2)
        back_r = radius - radius / 50
        rect_back = self.rect()

        # Set the LED
        rect_back.setWidth(back_r)
        rect_back.setHeight(back_r)
        rect_back.moveCenter(center)

        return rect_back
 def fitInView(self):
     # Reset View
     width, height = self.view_rect
     scale = min(
         (self.size().width() / width, self.size().height() / height))
     if self.rotation == 90 or self.rotation == 270:
         scale = min(
             (self.size().width() / height, self.size().height() / width))
     self.scaler.setTransform(QtGui.QTransform(scale, 0, 0, scale, 0, 0))
     xoff = self.size().width() - width * scale
     yoff = self.size().height() - height * scale
     self.translater.setTransform(
         QtGui.QTransform(1, 0, 0, 1, xoff * 0.5 / scale,
                          yoff * 0.5 / scale))
     self.panEvent(xoff, yoff)
     self.zoomEvent(scale, QtCore.QPoint(0, 0))
     self.fitted = 1
예제 #18
0
 def mousePressEvent(self, event):
     self.lastPos = QtCore.QPoint(event.pos())
     self.lastFastmode = self._settings.fastmode
     self._settings.fastmode = True
     if event.modifiers() == QtCore.Qt.ControlModifier:
         if event.button() == QtCore.Qt.RightButton:
             self.do_move_clippingplane = True
         if event.button() == QtCore.Qt.LeftButton:
             self.do_rotate_clippingplane = True
     else:
         if event.button() == QtCore.Qt.LeftButton:
             if self._rotation_enabled:
                 self.do_rotate = True
         if event.button() == QtCore.Qt.MidButton:
             self.do_translate = True
         if event.button() == QtCore.Qt.RightButton:
             self.do_zoom = True
예제 #19
0
def _click_area(qobj,
                pos=None,
                offset=None,
                modifier=QtCore.Qt.NoModifier,
                timeout=100):
    geom = qobj.geometry()
    if pos is None:
        x = int(
            geom.width() *
            random.uniform(0.2, 0.8))  # avid to click on the edge of widgets
        y = int(geom.height() * random.uniform(0.2, 0.8))
        pos = QtCore.QPoint(x, y)
    if offset is not None:
        pos += offset
    QTest.mouseClick(qobj, QtCore.Qt.LeftButton, modifier=modifier, pos=pos)
    # print(pos.x(), pos.y())
    QTest.qWait(timeout)  # wait for things to happen on gui
예제 #20
0
    def getValueRect(self):
        """Return the value rectangel container."""
        width = self.width()
        height = self.height()

        radius = min(width / 2, height / 2)
        center = QtCore.QPoint(width / 2, height / 2)
        back_r = radius - radius / 50
        led_r = back_r - back_r / 10
        rect_val = self.rect()

        # Set the LED
        rect_val.setWidth(led_r)
        rect_val.setHeight(led_r)
        rect_val.moveCenter(center)

        return rect_val
예제 #21
0
    def __init__(self):
        super(Canvas, self).__init__()
        self.image_wapper = None
        self.epsilon = 10.0
        self._curCursor = CURSOR_DEFAULT
        self._cursor = CURSOR_DEFAULT
        self.shapes = []
        self.shapesBackups = []
        self.selectedShapes = []
        self.selectedShapesCopy = []

        self.visible = {}
        self.current = None
        self.hShape = None
        self.hVertex = None
        self.hEdge = None
        self._hideBackround = False
        self.hideBackround = False
        self.movingShape = False
        self._fill_drawing = True
        self.isEnter = False

        self._Painter = QtGui.QPainter()
        self.lineColor = Shape.line_color
        self.line = Shape(line_color=self.lineColor,
                          slice_type=None,
                          slice_index=0)

        self.menu = QtWidgets.QMenu()

        self.setMouseTracking(True)
        self.setFocusPolicy(QtCore.Qt.WheelFocus)

        self._label = QtWidgets.QLabel("", self)
        self._label.setStyleSheet("color: #45804b")
        self._label.move(10, 10)

        self._tag_label = QtWidgets.QLabel("", self)
        self._tag_label.setStyleSheet("color: #FF0000")
        self._tag_label.move(10, 40)
        self._slider = FrameSlider(self)
        self._slider.setVisible(False)
        self._slider.valueChanged.connect(self.setSliceIndex)

        self._focus_delta = QtCore.QPoint(0, 0)
예제 #22
0
def drawBarb(qp,
             origin_x,
             origin_y,
             wdir,
             wspd,
             color='#FFFFFF',
             shemis=False):
    pen = QtGui.QPen(QtGui.QColor(color), 1, QtCore.Qt.SolidLine)
    pen.setWidthF(1.)
    qp.setPen(pen)
    qp.setBrush(QtCore.Qt.NoBrush)

    try:
        wspd = int(round(wspd / 5.) * 5)  # Round to the nearest 5
    except ValueError:
        return

    qp.translate(origin_x, origin_y)

    if wspd > 0:
        qp.rotate(wdir - 90)

        path = QtGui.QPainterPath()
        path.moveTo(0, 0)
        path.lineTo(25, 0)

        while wspd >= 50:
            drawFlag(path, shemis=shemis)
            wspd -= 50

        while wspd >= 10:
            drawFullBarb(path, shemis=shemis)
            wspd -= 10

        while wspd >= 5:
            drawHalfBarb(path, shemis=shemis)
            wspd -= 5

        qp.drawPath(path)
        qp.rotate(90 - wdir)
    else:
        qp.drawEllipse(QtCore.QPoint(0, 0), 3, 3)
    qp.translate(-origin_x, -origin_y)
예제 #23
0
 def test_channels_dialog(self, qtbot):
     assert self.viewer.channels_window is None
     assert not self.viewer.channels_window_is_open
     assert self.viewer.channels_window_pos is None
     qtbot.add_widget(self.viewer)
     qtbot.mouseClick(self.viewer.channels_button, QtCore.Qt.LeftButton)
     assert self.viewer.channels_window is not None
     assert self.viewer.channels_window_is_open
     assert isinstance(self.viewer.channels_window, ChannelsDialog)
     assert self.viewer.channels_window_pos is None
     qtbot.add_widget(self.viewer.channels_window)
     new_pos = QtCore.QPoint(42, 24)
     self.viewer.channels_window.move(new_pos)
     qtbot.mouseClick(self.viewer.channels_window.close_button,
                      QtCore.Qt.LeftButton)
     assert self.viewer.channels_window_pos is not None
     assert self.viewer.channels_window_pos == new_pos
     qtbot.mouseClick(self.viewer.channels_button, QtCore.Qt.LeftButton)
     self.viewer.channels_window.pos() == new_pos
예제 #24
0
def GetSafePosition(position: QC.QPoint, frame_key):

    # some window managers size the windows just off screen to cut off borders
    # so choose a test position that's a little more lenient

    fuzzy_point = QC.QPoint(FUZZY_PADDING, FUZZY_PADDING)

    test_position = position + fuzzy_point

    screen = QW.QApplication.screenAt(test_position)

    if screen is None:

        try:

            first_display = QW.QApplication.screens()[0]

            rescue_position = first_display.availableGeometry().topLeft(
            ) + fuzzy_point

            rescue_screen = QW.QApplication.screenAt(rescue_position)

            if rescue_screen == first_display:

                message = 'A window with frame key "{}" that wanted to display at "{}" was rescued from apparent off-screen to the new location at "{}".'.format(
                    frame_key, position, rescue_position)

                return (rescue_position, message)

        except Exception as e:

            # user is using IceMongo Linux, a Free Libre Open Source derivation of WeasleBlue Linux, with the iJ4 5-D inverted Window Managing system, which has a holographically virtualised desktop system

            HydrusData.PrintException(e)

        message = 'A window with frame key "{}" that wanted to display at "{}" could not be rescued from off-screen! Please let hydrus dev know!'.format(
            frame_key, position)

        return (None, message)

    else:

        return (position, None)
예제 #25
0
    def list_context_menu(self, pos):
        self.listMenu = QMenu()
        current_index = self.list_view.currentIndex()
        select = self.listMenu.addAction("Select")
        select.triggered.connect(
            lambda: self.list_view.selectionModel().select(current_index, QtCore.QItemSelectionModel.Select)
        )

        deselect = self.listMenu.addAction("Deselect")
        deselect.triggered.connect(
            lambda: self.list_view.selectionModel().select(current_index, QtCore.QItemSelectionModel.Deselect)
        )
        delete = self.listMenu.addAction("Delete")
        delete.setDisabled(current_index.data() not in self.new_teams)
        delete.triggered.connect(lambda: self.model.delete_team(current_index.row()))

        parentPosition = self.list_view.mapToGlobal(QtCore.QPoint(0, 0))
        self.listMenu.move(parentPosition + pos)
        self.listMenu.show()
예제 #26
0
    def __call__(self):
        # Show it
        self.show()

        # Determine the position of the top left corner of the figure dock
        dock_pos = self.figure_widget.rect().topLeft()

        # Determine the size of this dialog
        size = self.size()
        size = QC.QPoint(size.width(), 0)

        # Determine position of top left corner
        dialog_pos = self.figure_widget.mapToGlobal(dock_pos - size)

        # Move it slightly to give some spacing
        dialog_pos.setX(dialog_pos.x() - 12)

        # Move the dialog there
        self.move(dialog_pos)
예제 #27
0
    def __init__(self, parent: Optional[QtWidgets.QWidget] = None) -> None:
        super(BaseViewWidget, self).__init__(parent)
        if hasattr(QtOpenGL.QGLFormat, 'setVersion'):
            f = QtOpenGL.QGLFormat()
            f.setVersion(3, 2)
            f.setProfile(QtOpenGL.QGLFormat.CoreProfile)
            c = QtOpenGL.QGLContext(f)
            QtOpenGL.QGLWidget.__init__(self, c, parent)
        else:
            QtOpenGL.QGLWidget.__init__(self, parent)

        self.__gl_initialized = False

        self.viewState = ViewPort(self.width(), self.height())
        self.viewState.changed.connect(self.update)

        self.lastPoint = QtCore.QPoint(0, 0)
        # Nav Handling
        self.active_drag = None

        self.mouse_wheel_emu = None

        self.action_log_cb: 'Optional[Callable[[VarArg(Any)], None]]' = None
        self.interactionDelegate = None
        self.setMouseTracking(True)

        # TODO refine type
        self.selectionList: Set[Any] = set()

        self.open_time = time.time()

        # OpenGL shared resources object. Initialized during initializeGL
        self.gls = GLShared()

        #
        self.local_actions_map = {
            (EventID.Mouse_B2_DragStart, Modifier(0)): EVT_START_FIELD_DRAG,
            (EventID.Mouse_B2, Modifier(0)): EVT_STOP_FIELD_DRAG,
        }

        self.id_actions_map = {}
        self.notify_changed_actions = []
예제 #28
0
파일: multipoint.py 프로젝트: pcbre/pcbre
    def make_active(self, world_to_point=False):
        self.__saved_point = self.current_point.save()

        if not world_to_point:
            pt = self.view.viewState.tfW2V(self.current_point.get())

            bounds = Rect.from_points(
                Point2(0, 0), Point2(self.view.width(), self.view.height()))
            pt_clipped = clip_point_to_rect(pt, bounds)

            screen_pt = self.view.mapToGlobal(
                QtCore.QPoint(*pt_clipped.to_int_tuple()))

            QtGui.QCursor.setPos(screen_pt)
        else:
            rect_pt = Point2(self.view.mapFromGlobal(QtGui.QCursor.pos()))
            world_pt = self.view.viewState.tfV2W(rect_pt)
            self.current_point.set(world_pt)

        self.__point_active = True
예제 #29
0
def guirestore(widget, qsettings, default):
    logger.info("Restoring settings: {}".format(qsettings.fileName()))
    # Restore geometry
    selfName = widget.objectName()
    qsettings.beginGroup("mainwindow")
    try:
        widget.resize(
            qsettings.value(selfName + "_size", QtCore.QSize(500, 500)))
        widget.move(qsettings.value(selfName + "_pos", QtCore.QPoint(60, 60)))
    except Exception:
        pass
    for name, obj in inspect.getmembers(widget):
        try:
            _, setter, _ = getter_setter_onchange(obj)
            value = qsettings.value(name, default.value(name))
            setter(value) if value not in (None, "") else None
        except Exception:
            logger.warn(
                "Unable to restore settings for object: {}".format(name))
    qsettings.endGroup()
예제 #30
0
    def mouseMoveEvent(self, event):

        if (event.buttons()
                & QC.Qt.LeftButton) and self._drag_last_pos is not None:

            mouse_pos = QG.QCursor.pos()

            delta = mouse_pos - self._drag_last_pos

            win = self.window()

            win.move(win.pos() + delta)

            self._drag_last_pos = QC.QPoint(mouse_pos)

            event.accept()

            return

        QW.QWidget.mouseMoveEvent(self, event)