当前位置: 首页>>代码示例>>Python>>正文


Python QtWidgets.QGraphicsItem类代码示例

本文整理汇总了Python中PyQt5.QtWidgets.QGraphicsItem的典型用法代码示例。如果您正苦于以下问题:Python QGraphicsItem类的具体用法?Python QGraphicsItem怎么用?Python QGraphicsItem使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了QGraphicsItem类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: mouseMoveEvent

    def mouseMoveEvent(self, event):
        """
        All mouseMoveEvents are passed to the group if it's in a group

        Args:
            event (TYPE): Description
        """
        MOVE_THRESHOLD = 0.01   # ignore small moves
        selection_group = self.group()
        if selection_group is not None:
            selection_group.mousePressEvent(event)
        elif self._right_mouse_move:
            new_pos = event.scenePos()
            delta = new_pos - self.drag_last_position
            dx = int(floor(delta.x() / _BASE_WIDTH))*_BASE_WIDTH
            x = self.handle_start.x() + dx
            if abs(dx) > MOVE_THRESHOLD or dx == 0.0:
                old_x = self.x()
                self.setX(x)
                self._virtual_helix_item.setX(x + _VH_XOFFSET)
                self._part_item.updateXoverItems(self._virtual_helix_item)
                dz = self._part_item.convertToModelZ(x - old_x)
                self._model_part.translateVirtualHelices([self.idNum()],
                                                         0, 0, dz, False,
                                                         use_undostack=False)
        else:
            QGraphicsItem.mouseMoveEvent(self, event)
开发者ID:hadim,项目名称:cadnano2.5,代码行数:27,代码来源:virtualhelixhandleitem.py

示例2: mouseReleaseEvent

 def mouseReleaseEvent(self, event):
     if self.model_bounds:
         parent = self.parentItem()
         xTL, yTL, xBR, yBR = self.model_bounds
         ct = self.corner_type
         epos = event.scenePos()
         new_pos = self.item_start + epos - self.event_start_position
         new_x = new_pos.x()
         new_y = new_pos.y()
         hwidth = self.half_width
         if ct == TOP_LEFT:
             new_x_TL = xTL - hwidth if new_x + hwidth > xTL else new_x
             new_y_TL = yTL - hwidth if new_y + hwidth > yTL else new_y
             tl, _ = parent.reconfigureRect((new_x_TL + hwidth, new_y_TL + hwidth), (), do_grid=True)
             self.alignPos(*tl)
         elif ct == BOTTOM_RIGHT:
             new_x_BR = xBR + hwidth if new_x + hwidth < xBR else new_x
             new_y_BR = yBR + hwidth if new_y + hwidth < yBR else new_y
             _, br = parent.reconfigureRect((), (new_x_BR + hwidth, new_y_BR + hwidth), do_grid=True)
             self.alignPos(*br)
         elif ct == TOP_RIGHT:
             pass
         elif ct == BOTTOM_LEFT:
             pass
         else:
             raise NotImplementedError("corner_type %d not supported" % (ct))
         self.model_bounds = ()
     if self.is_grabbing:
         self.is_grabbing = False
         parent = self.parentItem()
         parent.setMovable(False)
         QGraphicsItem.mouseReleaseEvent(parent, event)
         parent.finishDrag()
开发者ID:cadnano,项目名称:cadnano2.5,代码行数:33,代码来源:grabcorneritem.py

示例3: mouseMoveEvent

    def mouseMoveEvent(self, event):
        #pos = self.mapFromGlobal(event.globalPos())
        if self.graphics_view == None:
            return
        self.graphics_view._is_cursor_moved = True
        QGraphicsItem.mouseMoveEvent(self, event)
        if event.buttons() == Qt.LeftButton:
            max_y_pos = self._minimap_height - self.height()
            # fix vertical
            self.setX(0)
            if self.y() < 0:
                self.setY(0)
            elif self.y() > max_y_pos and max_y_pos < 0:
                self.setY(0)
            elif self.y() > max_y_pos and max_y_pos > 0:
                self.setY(max_y_pos)

            # move textedit's scrollbar
            elif self.pos_ratio > 0:
                print("self.y()", self.y())
                print("self.pos_ratio", self.pos_ratio)
                print("/", int(self.y() / self.pos_ratio))
                cursor_ratio = self.y() / self._minimap_height
                print("cursor_ratio", cursor_ratio)
                r = self.y() + self.height() * cursor_ratio
                print("r", r)
                self.graphics_view._change_scrollbar_value(
                    int(r / self.pos_ratio))
开发者ID:ParaplegicRacehorse,项目名称:plume-creator,代码行数:28,代码来源:minimap_text_browser.py

示例4: __init__

    def __init__(self, axis, crop_extents_model, editable=True):

        self._cropColor = Qt.white

        QGraphicsItem.__init__(self)
        self.setFlag(QGraphicsItem.ItemHasNoContents)
        self.setAcceptHoverEvents(True)
        self.axis = axis
        self.crop_extents_model = crop_extents_model

        self._width = 0
        self._height = 0

        # Add shading item first so crop lines are drawn on top.
        self._shading_item = ExcludedRegionShading(self, self.crop_extents_model)

        self._horizontal0 = CropLine(self, "horizontal", 0)
        self._horizontal1 = CropLine(self, "horizontal", 1)
        self._vertical0 = CropLine(self, "vertical", 0)
        self._vertical1 = CropLine(self, "vertical", 1)

        self.crop_extents_model.changed.connect(self.onExtentsChanged)
        self.crop_extents_model.colorChanged.connect(self.onColorChanged)

        # keeping track which line started mouse move
        self._mouseMoveStartH = -1
        self._mouseMoveStartV = -1
        self._fractionOfDistance = 1
开发者ID:ilastik,项目名称:volumina,代码行数:28,代码来源:croppingMarkers.py

示例5: hoverEnterEvent

 def hoverEnterEvent(self, event: QGraphicsSceneHoverEvent):
     if event.modifiers() & Qt.ShiftModifier:
         self.setCursor(Qt.OpenHandCursor)
     else:
         self.setCursor(Qt.ArrowCursor)
     self._part_item.updateStatusBar("{}–{}".format(self._idx_low, self._idx_high))
     QGraphicsItem.hoverEnterEvent(self, event)
开发者ID:cadnano,项目名称:cadnano2.5,代码行数:7,代码来源:pathextras.py

示例6: append_item

    def append_item(self, item: QGraphicsItem) -> None:
        self.items.append(item)

        col = self.next_col
        row = self.next_row

        x = col * (self.style.tile_width + self.style.spacing_x) + self.style.padding_x
        y = row * (self.style.tile_height + self.style.spacing_y) + self.style.padding_y

        item.setPos(self.x + x + self.center_x_off,
                    self.y + y)

        bottom_y = y + self.style.tile_height + self.style.padding_y

        # calculate next items position
        if self.style.arrangement == TileStyle.Arrangement.ROWS:
            col += 1
            if col == self.columns:
                col = 0
                row += 1
        else:
            row += 1
            if row == self.rows:
                row = 0
                col += 1

        self.next_col = col
        self.next_row = row
        self.height = bottom_y
开发者ID:Grumbel,项目名称:dirtool,代码行数:29,代码来源:layout.py

示例7: mouseMoveEvent

 def mouseMoveEvent(self, event):
     """
     All mouseMoveEvents are passed to the group if it's in a group
     """
     selection_group = self.group()
     if selection_group != None:
         selection_group.mousePressEvent(event)
     else:
         QGraphicsItem.mouseMoveEvent(self, event)
开发者ID:Rebelofold,项目名称:cadnano2.5,代码行数:9,代码来源:virtualhelixhandleitem.py

示例8: itemChange

 def itemChange(self, change, value):
     return QGraphicsItem.itemChange(self, change, value)
     # for selection changes test against QGraphicsItem.ItemSelectedChange
     # intercept the change instead of the has changed to enable features.
     if change == QGraphicsItem.ItemSelectedChange and self.scene():
         active_tool = self._getActiveTool()
         if active_tool.methodPrefix() == "selectTool":
             viewroot = self._viewroot
             current_filter_dict = viewroot.selectionFilterDict()
             selection_group = viewroot.strandItemSelectionGroup()
     
             # only add if the selection_group is not locked out
             is_normal_select = selection_group.isNormalSelect()
             if value == True and (self._filter_name in current_filter_dict or not is_normal_select):
                 if self._strand_filter in current_filter_dict:
                     if self.group() != selection_group:
                         self.setSelectedColor(True)
                         # This should always be the case, but...
                         if is_normal_select:
                             selection_group.pendToAdd(self)
                             selection_group.setSelectionLock(selection_group)
                             selection_group.pendToAdd(self._low_cap)
                             selection_group.pendToAdd(self._high_cap)
                         # this else will capture the error.  Basically, the
                         # strandItem should be member of the group before this
                         # ever gets fired
                         else:
                             selection_group.addToGroup(self)
                     return True
                 else:
                     return False
             # end if
             elif value == True:
                 # Don't select
                 return False
             # end elif
             else:
                 # Deselect
                 # print "Deselecting strand"
                 selection_group.pendToRemove(self)
                 self.setSelectedColor(False)
                 selection_group.pendToRemove(self._low_cap)
                 selection_group.pendToRemove(self._high_cap)
                 return False
             # end else
         # end if
         elif active_tool.methodPrefix() == "paintTool":
             viewroot = self._viewroot
             current_filter_dict = viewroot.selectionFilterDict()
             if self._strand_filter in current_filter_dict:
                 if not active_tool.isMacrod():
                     active_tool.setMacrod()
                 self.paintToolMousePress(None, None)
         # end elif
         return False
     # end if
     return QGraphicsItem.itemChange(self, change, value)
开发者ID:amylittleyang,项目名称:OtraCAD,代码行数:57,代码来源:stranditem.py

示例9: mouseReleaseEvent

 def mouseReleaseEvent(self, event):
     if self.model_bounds:
         self.model_bounds = ()
     if self.is_grabbing:
         # print("I am released")
         self.is_grabbing = False
         parent = self.parentItem()
         parent.setMovable(False)
         QGraphicsItem.mouseReleaseEvent(parent, event)
         parent.finishDrag()
开发者ID:hadim,项目名称:cadnano2.5,代码行数:10,代码来源:grabcorneritem.py

示例10: mousePressEvent

    def mousePressEvent(self, event):
        '''Handle mouse press event.

        Argument(s):
        event (QGraphicsSceneMouseEvent): Graphics scene mouse event
        '''
        QGraphicsItem.mousePressEvent(self, event)

        # Get the focus
        if event.buttons() == Qt.LeftButton:
            self.getFocus(self.id)
开发者ID:pydoted,项目名称:dotEd,代码行数:11,代码来源:GraphicsEdge.py

示例11: __init__

    def __init__(self, nr, closed, parentEntity):
        QGraphicsItem.__init__(self)
        Shape.__init__(self, nr, closed, parentEntity)

        self.setFlag(QGraphicsItem.ItemIsSelectable, True)
        self.setAcceptedMouseButtons(QtCore.Qt.NoButton)

        self.selectionChangedCallback = None
        self.enableDisableCallback = None

        self.starrow = None
        self.enarrow = None
开发者ID:opme,项目名称:dxf2gcode,代码行数:12,代码来源:canvas2d.py

示例12: mouseMoveEvent

    def mouseMoveEvent(self, event):
        """Handle mouse move event.

        Argument(s):
        event (QGraphicsSceneMouseEvent): Graphics scene mouse event
        """
        # Only move the node if CTRL button pressed
        if event.modifiers() == Qt.ControlModifier:
            QGraphicsItem.mouseMoveEvent(self, event)

        # Update coordinates of the line
        elif self.semiEdge is not None:
            self.semiEdge.update(event.scenePos())
开发者ID:pydoted,项目名称:dotEd,代码行数:13,代码来源:GraphicsNode.py

示例13: setSelected

    def setSelected(self, flag=True, blockSignals=True):
        """
        Override inherited function to turn off selection of Arrows.
        @param flag: The flag to enable or disable Selection
        """
        self.starrow.setSelected(flag)
        self.enarrow.setSelected(flag)
        self.stmove.setSelected(flag)

        QGraphicsItem.setSelected(self, flag)
        Shape.setSelected(self, flag)

        if self.selectionChangedCallback and not blockSignals:
            self.selectionChangedCallback(self, flag)
开发者ID:opme,项目名称:dxf2gcode,代码行数:14,代码来源:canvas2d.py

示例14: hoverMoveEvent

    def hoverMoveEvent(self, event: QGraphicsSceneHoverEvent):
        """Summary

        Args:
            event: Description
        """

        tool = self._getActiveTool()
        tool_method_name = tool.methodPrefix() + "HoverMove"
        if hasattr(self, tool_method_name):
            getattr(self, tool_method_name)(tool, event)
        else:
            event.setAccepted(False)
            QGraphicsItem.hoverMoveEvent(self, event)
开发者ID:cadnano,项目名称:cadnano2.5,代码行数:14,代码来源:nucleicacidpartitem.py

示例15: mousePressEvent

 def mousePressEvent(self, event):
     """
     Parses a mousePressEvent, calling the approproate tool method as
     necessary. Stores _move_idx for future comparison.
     """
     if event.button() != Qt.LeftButton:
         event.ignore()
         QGraphicsItem.mousePressEvent(self, event)
         return
     self.scene().views()[0].addToPressList(self)
     self._move_idx = int(floor((self.x() + event.pos().x()) / _BASE_WIDTH))
     tool_method_name = self._getActiveTool().methodPrefix() + "MousePress"
     if hasattr(self, tool_method_name):  # if the tool method exists
         modifiers = event.modifiers()
         getattr(self, tool_method_name)(modifiers)  # call tool method
开发者ID:Rebelofold,项目名称:cadnano2.5,代码行数:15,代码来源:activesliceitem.py


注:本文中的PyQt5.QtWidgets.QGraphicsItem类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。