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


Python QGraphicsItem.mouseMoveEvent方法代码示例

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


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

示例1: mouseMoveEvent

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

示例2: mouseMoveEvent

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

示例3: mouseMoveEvent

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

示例4: mouseMoveEvent

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

示例5: mouseMoveEvent

# 需要导入模块: from PyQt5.QtWidgets import QGraphicsItem [as 别名]
# 或者: from PyQt5.QtWidgets.QGraphicsItem import mouseMoveEvent [as 别名]
 def mouseMoveEvent(self, event):
     parent = self.parentItem()
     if self.model_bounds:
         xTL, yTL, xBR, yBR = self.model_bounds
         ct = self.corner_type
         epos = event.scenePos()
         # print(epos, self.item_start)
         # print(xTL, self.item_start.x())
         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))
     else:
         res = QGraphicsItem.mouseMoveEvent(parent, event)
         return res
开发者ID:cadnano,项目名称:cadnano2.5,代码行数:33,代码来源:grabcorneritem.py

示例6: mouseMoveEvent

# 需要导入模块: from PyQt5.QtWidgets import QGraphicsItem [as 别名]
# 或者: from PyQt5.QtWidgets.QGraphicsItem import mouseMoveEvent [as 别名]
    def mouseMoveEvent(self, event):
        parent = self.parentItem()
        epos = event.scenePos()
        h_w = self.half_width

        if self.model_bounds:
            mTLx, mTLy, mBRx, mBRy = self.model_bounds
            po_rect = parent.outline.rect()
            poTL = po_rect.topLeft()
            poBR = po_rect.bottomRight()
            poTLx, poTLy = poTL.x(), poTL.y()
            poBRx, poBRy = poBR.x(), poBR.y()
            new_pos = self.item_start + epos - self.event_start_position
            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), ())
                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), ())
                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))
                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))
                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))
                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))
                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))
                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), ())
                self._group.alignHandles(r)
            else:
                raise NotImplementedError("handle_type %d not supported" % (ht))
            event.setAccepted(True)
        else:
            res = QGraphicsItem.mouseMoveEvent(parent, event)
            return res
开发者ID:cadnano,项目名称:cadnano2.5,代码行数:60,代码来源:resizehandles.py

示例7: mouseMoveEvent

# 需要导入模块: from PyQt5.QtWidgets import QGraphicsItem [as 别名]
# 或者: from PyQt5.QtWidgets.QGraphicsItem import mouseMoveEvent [as 别名]
 def mouseMoveEvent(self, event: QGraphicsSceneMouseEvent):
     """Converts event coords into an idx delta and updates if changed.
     """
     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.resize_handle_group.updateText(HandleEnum.LEFT, self._idx_low)
         self.resize_handle_group.updateText(HandleEnum.RIGHT, self._idx_high)
     return QGraphicsItem.mouseMoveEvent(self, event)
开发者ID:cadnano,项目名称:cadnano2.5,代码行数:17,代码来源:pathextras.py


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