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


Python QGraphicsItem.mouseReleaseEvent方法代码示例

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


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

示例1: mouseReleaseEvent

# 需要导入模块: from PyQt5.QtWidgets import QGraphicsItem [as 别名]
# 或者: from PyQt5.QtWidgets.QGraphicsItem import mouseReleaseEvent [as 别名]
 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,代码行数:35,代码来源:grabcorneritem.py

示例2: mouseReleaseEvent

# 需要导入模块: from PyQt5.QtWidgets import QGraphicsItem [as 别名]
# 或者: from PyQt5.QtWidgets.QGraphicsItem import mouseReleaseEvent [as 别名]
 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,代码行数:12,代码来源:grabcorneritem.py

示例3: mouseReleaseEvent

# 需要导入模块: from PyQt5.QtWidgets import QGraphicsItem [as 别名]
# 或者: from PyQt5.QtWidgets.QGraphicsItem import mouseReleaseEvent [as 别名]
    def mouseReleaseEvent(self, event):
        """Handle mouse release event.

        Argument(s):
        event (QGraphicsSceneMouseEvent): Graphics scene mouse event
        """
        QGraphicsItem.mouseReleaseEvent(self, event)

        # Construct edge if a semi edge is built
        if self.semiEdge is not None:
            # Remove the semi edge
            self.scene().removeItem(self.semiEdge)
            self.semiEdge = None

            # Filter item on the mouse and only get GraphicsNode
            items = [
                item for item in self.scene().items(event.scenePos()) if isinstance(item, GraphicsNode) and item != self
            ]
            if items:
                # Create edge
                self.graphicsGraphView.controller.onCreateEdge(self.id, items[0].id)
开发者ID:pydoted,项目名称:dotEd,代码行数:23,代码来源:GraphicsNode.py

示例4: mouseReleaseEvent

# 需要导入模块: from PyQt5.QtWidgets import QGraphicsItem [as 别名]
# 或者: from PyQt5.QtWidgets.QGraphicsItem import mouseReleaseEvent [as 别名]
 def mouseReleaseEvent(self, event: QGraphicsSceneMouseEvent):
     """Repeates mouseMove calculation in case any new movement.
     """
     self.setCursor(Qt.ArrowCursor)
     delta = int(floor((self.x()+event.pos().x()) / BASE_WIDTH)) - self._offset_idx
     delta = util.clamp(delta,
                        self._low_drag_bound-self._start_idx_low,
                        self._high_drag_bound-self._start_idx_high+self.width())
     if self._delta != delta:
         self._idx_low = int(self._start_idx_low + delta)
         self._idx_high = int(self._start_idx_high + delta)
         self._delta = delta
         self.reconfigureRect((), ())
     self._high_drag_bound = self._model_part.getProperty('max_vhelix_length')  # reset for handles
     return QGraphicsItem.mouseReleaseEvent(self, event)
开发者ID:cadnano,项目名称:cadnano2.5,代码行数:17,代码来源:pathextras.py

示例5: mouseReleaseEvent

# 需要导入模块: from PyQt5.QtWidgets import QGraphicsItem [as 别名]
# 或者: from PyQt5.QtWidgets.QGraphicsItem import mouseReleaseEvent [as 别名]
 def mouseReleaseEvent(self, event):
     if self.model_bounds:
         parent = self.parentItem()
         mTLx, mTLy, mBRx, mBRy = self.model_bounds
         poTL = parent.outline.rect().topLeft()
         poBR = parent.outline.rect().bottomRight()
         poTLx, poTLy = poTL.x(), poTL.y()
         poBRx, poBRy = poBR.x(), poBR.y()
         epos = event.scenePos()
         new_pos = self.item_start + epos - self.event_start_position
         h_w = self.half_width
         new_x = new_pos.x()+h_w
         new_y = new_pos.y()+h_w
         ht = self._handle_type
         if ht == HandleEnum.TOP_LEFT:
             new_x_TL = mTLx if new_x > mTLx else new_x
             new_y_TL = mTLy if new_y > mTLy else new_y
             r = parent.reconfigureRect((new_x_TL, new_y_TL), (), finish=True)
             self._group.alignHandles(r)
         elif ht == HandleEnum.TOP:
             new_y_TL = mTLy if new_y > mTLy else new_y
             r = parent.reconfigureRect((poTLx, new_y_TL), (), finish=True)
             self._group.alignHandles(r)
         elif ht == HandleEnum.TOP_RIGHT:
             new_y_TL = mTLy if new_y > mTLy else new_y
             new_x_BR = mBRx if new_x < mBRx else new_x
             r = parent.reconfigureRect((poTLx, new_y_TL), (new_x_BR, poBRy), finish=True)
             self._group.alignHandles(r)
         elif ht == HandleEnum.RIGHT:
             new_x_BR = mBRx if new_x < mBRx else new_x
             r = parent.reconfigureRect((), (new_x_BR, poBRy), finish=True)
             self._group.alignHandles(r)
         elif ht == HandleEnum.BOTTOM_RIGHT:
             new_x_BR = mBRx if new_x < mBRx else new_x
             new_y_BR = mBRy if new_y < mBRy else new_y
             r = parent.reconfigureRect((), (new_x_BR, new_y_BR), finish=True)
             self._group.alignHandles(r)
         elif ht == HandleEnum.BOTTOM:
             new_y_BR = mBRy if new_y < mBRy else new_y
             r = parent.reconfigureRect((), (poBRx, new_y_BR), finish=True)
             self._group.alignHandles(r)
         elif ht == HandleEnum.BOTTOM_LEFT:
             new_x_TL = mTLx if new_x > mTLx else new_x
             new_y_BR = mBRy if new_y < mBRy else new_y
             r = parent.reconfigureRect((new_x_TL, poTLy), (poBRx, new_y_BR), finish=True)
             self._group.alignHandles(r)
         elif ht == HandleEnum.LEFT:
             new_x_TL = mTLx if new_x > mTLx else new_x
             r = parent.reconfigureRect((new_x_TL, poTLy), (), finish=True)
             self._group.alignHandles(r)
         self.model_bounds = ()
         parent.showModelMinBoundsHint(self._handle_type, show=False)
     if self._group.is_dragging:
         self._group.is_dragging = False
         parent = self.parentItem()
         parent.setMovable(False)
         parent.finishDrag()
     self.setCursor(Qt.OpenHandCursor)
     # NOTE was QGraphicsItem.mouseReleaseEvent(parent, event) but that errored
     # NC 2018.01.29 so that seemd to fix the error
     return QGraphicsItem.mouseReleaseEvent(self, event)
开发者ID:cadnano,项目名称:cadnano2.5,代码行数:63,代码来源:resizehandles.py


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