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


Python QtCore.QPointF方法代码示例

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


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

示例1: mouseMoveEvent

# 需要导入模块: from qtpy import QtCore [as 别名]
# 或者: from qtpy.QtCore import QPointF [as 别名]
def mouseMoveEvent(self, event):
        if self.__dragging:
            newPos = self.mapToScene(event.pos())

            graph = self.getGraph()
            if graph.getSnapToGrid() is True:
                gridSize = graph.getGridSize()

                newNodePos = newPos - self._mouseDelta

                snapPosX = math.floor(newNodePos.x() / gridSize) * gridSize;
                snapPosY = math.floor(newNodePos.y() / gridSize) * gridSize;
                snapPos = QtCore.QPointF(snapPosX, snapPosY)

                newPosOffset = snapPos - newNodePos

                newPos = newPos + newPosOffset

            delta = newPos - self._lastDragPoint
            self.__graph.moveSelectedNodes(delta)
            self._lastDragPoint = newPos
            self._nodesMoved = True
        else:
            super(Node, self).mouseMoveEvent(event) 
开发者ID:EricTRocks,项目名称:pyflowgraph,代码行数:26,代码来源:node.py

示例2: generateNodes

# 需要导入模块: from qtpy import QtCore [as 别名]
# 或者: from qtpy.QtCore import QPointF [as 别名]
def generateNodes(count, offset, depth):
    for i in range(count):
        node1 = Node(graph, 'node' + str(depth) + str(i))
        node1.addPort(InputPort(node1, graph, 'InPort', QtGui.QColor(128, 170, 170, 255), 'MyDataX'))
        node1.addPort(OutputPort(node1, graph, 'OutPort', QtGui.QColor(32, 255, 32, 255), 'MyDataX'))
        node1.setGraphPos(QtCore.QPointF(offset, i * 80 ))

        graph.addNode(node1)

        global totalCount
        totalCount += 1

    if depth < 6:
        generateNodes( count * 2, offset+160, depth+1)

        for i in range(count):
            graph.connectPorts('node' + str(depth) + str(i), 'OutPort', 'node' + str(depth+1) + str(i*2), 'InPort')
            graph.connectPorts('node' + str(depth) + str(i), 'OutPort', 'node' + str(depth+1) + str(i*2+1), 'InPort')
    elif depth < 12:
        generateNodes( int(count / 2), offset+160, depth+1)

        for i in range(count//2):
            graph.connectPorts('node' + str(depth) + str(i), 'OutPort', 'node' + str(depth+1) + str(int(i)), 'InPort') 
开发者ID:EricTRocks,项目名称:pyflowgraph,代码行数:25,代码来源:bigGraph.py

示例3: draw_ranges

# 需要导入模块: from qtpy import QtCore [as 别名]
# 或者: from qtpy.QtCore import QPointF [as 别名]
def draw_ranges(self) -> None:
        """Draw rectangle ranges."""
        pen = QPen()
        pen.setWidth(5)
        for i, (tag, rect) in enumerate(self.ranges.items()):
            range_color = QColor(color_num(i + 1))
            range_color.setAlpha(30)
            self.painter.setBrush(range_color)
            range_color.setAlpha(255)
            pen.setColor(range_color)
            self.painter.setPen(pen)
            cx = rect.x() * self.zoom
            cy = rect.y() * -self.zoom
            if rect.width():
                self.painter.drawRect(QRectF(
                    QPointF(cx, cy),
                    QSizeF(rect.width(), rect.height()) * self.zoom
                ))
            else:
                self.draw_circle(QPointF(cx, cy), 3)
            range_color.setAlpha(255)
            pen.setColor(range_color)
            self.painter.setPen(pen)
            self.painter.drawText(QPointF(cx, cy) + QPointF(6, -6), tag)
            self.painter.setBrush(Qt.NoBrush) 
开发者ID:KmolYuan,项目名称:Pyslvs-UI,代码行数:27,代码来源:canvas.py

示例4: draw_curve

# 需要导入模块: from qtpy import QtCore [as 别名]
# 或者: from qtpy.QtCore import QPointF [as 别名]
def draw_curve(self, path: Sequence[_Coord]) -> None:
        """Draw path as curve."""
        if len(set(path)) < 2:
            return
        painter_path = QPainterPath()
        error = False
        for i, (x, y) in enumerate(path):
            if isnan(x):
                error = True
                self.painter.drawPath(painter_path)
                painter_path = QPainterPath()
            else:
                p = QPointF(x, -y) * self.zoom
                if i == 0:
                    painter_path.moveTo(p)
                    self.draw_circle(p, 2)
                    continue
                if error:
                    painter_path.moveTo(p)
                    error = False
                else:
                    painter_path.lineTo(p)
        self.painter.drawPath(painter_path) 
开发者ID:KmolYuan,项目名称:Pyslvs-UI,代码行数:25,代码来源:canvas.py

示例5: paint

# 需要导入模块: from qtpy import QtCore [as 别名]
# 或者: from qtpy.QtCore import QPointF [as 别名]
def paint(self, painter, option, widget):
        srcPoint = self.mapFromScene(self.__srcPortCircle.centerInSceneCoords())
        dstPoint = self.mapFromScene(self.__dstPortCircle.centerInSceneCoords())

        dist_between = dstPoint - srcPoint

        self.__path = QtGui.QPainterPath()
        self.__path.moveTo(srcPoint)
        self.__path.cubicTo(
            srcPoint + QtCore.QPointF(dist_between.x() * 0.4, 0),
            dstPoint - QtCore.QPointF(dist_between.x() * 0.4, 0),
            dstPoint
            )
        self.setPath(self.__path)
        super(Connection, self).paint(painter, option, widget) 
开发者ID:EricTRocks,项目名称:pyflowgraph,代码行数:17,代码来源:connection.py

示例6: setDragPoint

# 需要导入模块: from qtpy import QtCore [as 别名]
# 或者: from qtpy.QtCore import QPointF [as 别名]
def setDragPoint(self, dragPoint):
        topLeft = QtCore.QPointF(self.__mouseDownPos)
        bottomRight = QtCore.QPointF(dragPoint)
        if dragPoint.x() < self.__mouseDownPos.x():
            topLeft.setX(dragPoint.x())
            bottomRight.setX(self.__mouseDownPos.x())
        if dragPoint.y() < self.__mouseDownPos.y():
            topLeft.setY(dragPoint.y())
            bottomRight.setY(self.__mouseDownPos.y())
        self.setPos(topLeft)
        self.resize(bottomRight.x() - topLeft.x(), bottomRight.y() - topLeft.y()) 
开发者ID:EricTRocks,项目名称:pyflowgraph,代码行数:13,代码来源:selection_rect.py

示例7: getGraphPos

# 需要导入模块: from qtpy import QtCore [as 别名]
# 或者: from qtpy.QtCore import QPointF [as 别名]
def getGraphPos(self):
        transform = self.transform()
        size = self.size()
        return QtCore.QPointF(transform.dx()+(size.width()*0.5), transform.dy()+(size.height()*0.5)) 
开发者ID:EricTRocks,项目名称:pyflowgraph,代码行数:6,代码来源:node.py

示例8: generatePicture

# 需要导入模块: from qtpy import QtCore [as 别名]
# 或者: from qtpy.QtCore import QPointF [as 别名]
def generatePicture(self,data=None,redraw=False):
        """重新生成图形对象"""
        # 重画或者只更新最后一个K线
        if redraw:
            self.pictures = []
        elif self.pictures:
            self.pictures.pop()
        w = 0.4
        bPen   = self.bPen
        bBrush = self.bBrush
        rPen   = self.rPen
        rBrush = self.rBrush
        self.low,self.high = (np.min(data['low']),np.max(data['high'])) if len(data)>0 else (0,1)
        npic = len(self.pictures)
        for (t, open0, close0, low0, high0) in data:
            if t >= npic:
                picture = QtGui.QPicture()
                p = QtGui.QPainter(picture)
                # 下跌蓝色(实心), 上涨红色(空心)
                pen,brush,pmin,pmax = (bPen,bBrush,close0,open0)\
                    if open0 > close0 else (rPen,rBrush,open0,close0)
                p.setPen(pen)  
                p.setBrush(brush)
                # 画K线方块和上下影线
                if open0 == close0:
                    p.drawLine(QtCore.QPointF(t-w,open0), QtCore.QPointF(t+w, close0))
                else:
                    p.drawRect(QtCore.QRectF(t-w, open0, w*2, close0-open0))
                if pmin  > low0:
                    p.drawLine(QtCore.QPointF(t,low0), QtCore.QPointF(t, pmin))
                if high0 > pmax:
                    p.drawLine(QtCore.QPointF(t,pmax), QtCore.QPointF(t, high0))
                p.end()
                self.pictures.append(picture)

    # 手动重画
    #---------------------------------------------------------------------- 
开发者ID:rjj510,项目名称:uiKLine,代码行数:39,代码来源:uiKLine.py

示例9: convex_hull

# 需要导入模块: from qtpy import QtCore [as 别名]
# 或者: from qtpy.QtCore import QPointF [as 别名]
def convex_hull(points: List[_Coord], *, as_qpoint: bool) -> List[QPointF]:
    ... 
开发者ID:KmolYuan,项目名称:Pyslvs-UI,代码行数:4,代码来源:canvas.py

示例10: __init__

# 需要导入模块: from qtpy import QtCore [as 别名]
# 或者: from qtpy.QtCore import QPointF [as 别名]
def __init__(self, parent: QWidget):
        """Set the parameters for drawing."""
        super(BaseCanvas, self).__init__(parent)
        self.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)
        self.setFocusPolicy(Qt.StrongFocus)
        self.setMouseTracking(True)
        self.painter = QPainter()
        # Origin coordinate
        self.ox = self.width() / 2
        self.oy = self.height() / 2
        # Canvas zoom rate
        self.zoom = 1.
        # Joint size
        self.joint_size = 5
        # Canvas line width
        self.link_width = 3
        self.path_width = 3
        # Font size
        self.font_size = 15
        # Show point mark or dimension
        self.show_ticks = _TickMark.SHOW
        self.show_point_mark = True
        self.show_dimension = True
        # Path track
        self.path = _PathOption()
        # Path solving
        self.ranges = {}
        self.target_path = {}
        self.show_target_path = False
        # Background
        self.background = QImage()
        self.background_opacity = 1.
        self.background_scale = 1.
        self.background_offset = QPointF(0, 0)
        # Monochrome mode
        self.monochrome = False
        # Grab mode
        self.__grab_mode = False 
开发者ID:KmolYuan,项目名称:Pyslvs-UI,代码行数:40,代码来源:canvas.py

示例11: draw_circle

# 需要导入模块: from qtpy import QtCore [as 别名]
# 或者: from qtpy.QtCore import QPointF [as 别名]
def draw_circle(self, p: QPointF, r: float) -> None:
        """Draw circle."""
        self.painter.drawEllipse(p, r, r) 
开发者ID:KmolYuan,项目名称:Pyslvs-UI,代码行数:5,代码来源:canvas.py

示例12: draw_target_path

# 需要导入模块: from qtpy import QtCore [as 别名]
# 或者: from qtpy.QtCore import QPointF [as 别名]
def draw_target_path(self) -> None:
        """Draw solving path."""
        pen = QPen()
        pen.setWidth(self.path_width)
        for i, n in enumerate(sorted(self.target_path)):
            path = self.target_path[n]
            if self.monochrome:
                line, dot = target_path_style(0)
            else:
                line, dot = target_path_style(i + 1)
            pen.setColor(line)
            self.painter.setPen(pen)
            if len(path) == 1:
                x, y = path[0]
                p = QPointF(x, -y) * self.zoom
                self.painter.drawText(p + QPointF(6, -6), f"P{n}")
                pen.setColor(dot)
                self.painter.setPen(pen)
                self.draw_circle(p, self.joint_size)
            else:
                painter_path = QPainterPath()
                for j, (x, y) in enumerate(path):
                    p = QPointF(x, -y) * self.zoom
                    self.draw_circle(p, self.joint_size)
                    if j == 0:
                        self.painter.drawText(p + QPointF(6, -6), f"P{n}")
                        painter_path.moveTo(p)
                    else:
                        xb, yb = path[j - 1]
                        self.draw_arrow(xb, yb, x, y, line=False)
                        painter_path.lineTo(p)
                pen.setColor(line)
                self.painter.setPen(pen)
                self.painter.drawPath(painter_path)
                for x, y in path:
                    pen.setColor(dot)
                    self.painter.setPen(pen)
                    self.draw_circle(QPointF(x, -y) * self.zoom,
                                     self.joint_size)
        self.painter.setBrush(Qt.NoBrush) 
开发者ID:KmolYuan,项目名称:Pyslvs-UI,代码行数:42,代码来源:canvas.py

示例13: draw_dot

# 需要导入模块: from qtpy import QtCore [as 别名]
# 或者: from qtpy.QtCore import QPointF [as 别名]
def draw_dot(self, path: Sequence[_Coord]) -> None:
        """Draw path as dots."""
        if len(set(path)) < 2:
            return
        for i, (x, y) in enumerate(path):
            if isnan(x):
                continue
            p = QPointF(x, -y) * self.zoom
            if i == 0:
                self.draw_circle(p, 2)
            else:
                self.painter.drawPoint(p) 
开发者ID:KmolYuan,项目名称:Pyslvs-UI,代码行数:14,代码来源:canvas.py

示例14: to_rect

# 需要导入模块: from qtpy import QtCore [as 别名]
# 或者: from qtpy.QtCore import QPointF [as 别名]
def to_rect(self, zoom: float) -> QRectF:
        """Return limit as QRectF type."""
        return QRectF(
            QPointF(self.x, -self.y) * zoom,
            QPointF(self.sx, -self.sy) * zoom
        ) 
开发者ID:KmolYuan,项目名称:Pyslvs-UI,代码行数:8,代码来源:canvas_base.py

示例15: __draw_frame

# 需要导入模块: from qtpy import QtCore [as 别名]
# 或者: from qtpy.QtCore import QPointF [as 别名]
def __draw_frame(self) -> None:
        """Draw a external frame."""
        pos_x = self.width() - self.ox
        pos_y = -self.oy
        neg_x = -self.ox
        neg_y = self.height() - self.oy
        self.painter.drawLine(QPointF(neg_x, pos_y), QPointF(pos_x, pos_y))
        self.painter.drawLine(QPointF(neg_x, neg_y), QPointF(pos_x, neg_y))
        self.painter.drawLine(QPointF(neg_x, pos_y), QPointF(neg_x, neg_y))
        self.painter.drawLine(QPointF(pos_x, pos_y), QPointF(pos_x, neg_y)) 
开发者ID:KmolYuan,项目名称:Pyslvs-UI,代码行数:12,代码来源:canvas_base.py


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