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


Python QPainterPath.lineTo方法代码示例

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


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

示例1: __init__

# 需要导入模块: from PySide.QtGui import QPainterPath [as 别名]
# 或者: from PySide.QtGui.QPainterPath import lineTo [as 别名]
    def __init__(self, parent, scene, view):
        super(QNodesEditor, self).__init__(parent)

        self.scene = scene
        self.scene.installEventFilter(self)

        gridSize = 25
        gridMap = QPixmap(gridSize,gridSize)
        gridPainter = QPainter(gridMap)
        gridPainter.fillRect(0,0,gridSize,gridSize, QApplication.palette().window().color().darker(103))
        gridPainter.fillRect(1,1,gridSize-2,gridSize-2, QApplication.palette().window())
        gridPainter.end()
        self.scene.setBackgroundBrush( QBrush(gridMap) )

        originSize = 50
        originItem = QGraphicsPathItem()
        path = QPainterPath()
        path.moveTo(0,-originSize)
        path.lineTo(0,originSize)
        path.moveTo(-originSize,0)
        path.lineTo(originSize,0)
        originItem.setPath(path)
        originItem.setPen(QPen(QApplication.palette().window().color().darker(110),2))
        originItem.setZValue(-2)
        self.scene.addItem(originItem)

        self.view = view
        self.view.setDragMode(QGraphicsView.RubberBandDrag)
        self.view.setRenderHint(QPainter.Antialiasing)

        self.connection = None
开发者ID:fieldOfView,项目名称:pyZNodeEditor,代码行数:33,代码来源:qnodeseditor.py

示例2: __init__

# 需要导入模块: from PySide.QtGui import QPainterPath [as 别名]
# 或者: from PySide.QtGui.QPainterPath import lineTo [as 别名]
class SelectedMineral:
    def __init__(self, parent, code, persistent = False):
        self.parent = parent
        self.persistent = persistent
        self.isActive = True # maybe to delete
        self.code = code
        self.name = self.parent.qtColorsNames[self.code][0]
        self.color = self.parent.qtColorsNames[self.code][1]
        self.painterPath = QPainterPath()
        self.verts, self.edges = parent.fetchMineral(self.code)
        if not self.verts:
            self.isActive = False
        

    # TODO: try to make it static or abstract in the future
    def project(self, projector, alef=19, bet=30):
        self.points = {}
        projector.setupProjectionMatrix(alef, bet)
        for k, v in self.verts.iteritems():
            self.points[k] = projector.project(v).tolist()
        for edge in self.edges.values():
            p1 = self.points[edge[0]]
            p2 = self.points[edge[1]]
            self.painterPath.moveTo(p1[0], p1[1])
            self.painterPath.lineTo(p2[0], p2[1])
开发者ID:ydanilin,项目名称:MinecraftMinerals2,代码行数:27,代码来源:selminerals.py

示例3: draw_ref

# 需要导入模块: from PySide.QtGui import QPainterPath [as 别名]
# 或者: from PySide.QtGui.QPainterPath import lineTo [as 别名]
    def draw_ref(self, painter, option, ref, repo, x):
        if repo.head_ref and posixpath.basename(ref) == 'HEAD':
            return x

        ref_text, ref_type = git_api.parse_ref(ref)
        if ref_type == git_api.REF_BRANCH:
            ref_color = self.ref_palette[ref_type, ref_text == repo.head_ref]
        else:
            ref_color = self.ref_palette.get(ref_type, self.ref_color_default)

        lane_size = option.rect.height()
        painter.setPen(QPen(Qt.black, self.ref_frame_thickness))
        painter.setBrush(QBrush(ref_color))
        painter.setFont(option.font)

        text_rect = painter.boundingRect(0, 0, 0, 0,
            Qt.AlignLeft | Qt.AlignTop, ref_text)
        text_rect.translate(-text_rect.x(), -text_rect.y())
        text_rect.setWidth(text_rect.width() + self.ref_padding_x)
        text_rect.setHeight(text_rect.height() + self.ref_padding_y)
        text_rect.translate(
            x + text_rect.height() * self.ref_arrow_ratio,
            (lane_size - text_rect.height()) / 2)
        path = QPainterPath()
        path.moveTo(x, lane_size / 2)
        path.lineTo(text_rect.left(), text_rect.top())
        path.lineTo(text_rect.right(), text_rect.top())
        path.lineTo(text_rect.right(), text_rect.bottom())
        path.lineTo(text_rect.left(), text_rect.bottom())
        path.lineTo(x, lane_size / 2)
        painter.drawPath(path)
        painter.drawText(text_rect, Qt.AlignLeft | Qt.AlignVCenter, ref_text)
        return text_rect.right() + self.ref_spacing
开发者ID:vstojkovic,项目名称:berk,代码行数:35,代码来源:__init__.py

示例4: objectSavePath

# 需要导入模块: from PySide.QtGui import QPainterPath [as 别名]
# 或者: from PySide.QtGui.QPainterPath import lineTo [as 别名]
    def objectSavePath(self):
        """
        TOWRITE

        :rtype: `QPainterPath`_
        """
        path = QPainterPath()
        path.lineTo(self.objectDeltaX(), self.objectDeltaY())
        return path
开发者ID:Allen76,项目名称:Embroidermodder,代码行数:11,代码来源:object_line.py

示例5: set_shape

# 需要导入模块: from PySide.QtGui import QPainterPath [as 别名]
# 或者: from PySide.QtGui.QPainterPath import lineTo [as 别名]
 def set_shape(self, width, height):
     ''' Compute the polygon to fit in width, height '''
     path = QPainterPath()
     path.addRoundedRect(0, 0, width, height, height / 2, height / 2)
     path.moveTo(min(width / 2, height / 2), 0)
     path.lineTo(min(width / 2, height / 2), height)
     path.moveTo(max(width / 2, width - height / 2), 0)
     path.lineTo(max(width / 2, width - height / 2), height)
     self.setPath(path)
     super(Start, self).set_shape(width, height)
开发者ID:Kampbell,项目名称:opengeode,代码行数:12,代码来源:sdlSymbols.py

示例6: setLineFromLine

# 需要导入模块: from PySide.QtGui import QPainterPath [as 别名]
# 或者: from PySide.QtGui.QPainterPath import lineTo [as 别名]
    def setLineFromLine(self, li):
        """
        TOWRITE

        :param `li`: TOWRITE
        :type `li`: QPointF
        """
        p = QPainterPath()
        p.moveTo(li.p1())
        p.lineTo(li.p2())
        self.setPath(p)
        self.objLine = li
开发者ID:Metallicow,项目名称:Embroidermodder,代码行数:14,代码来源:object_base.py

示例7: realRender

# 需要导入模块: from PySide.QtGui import QPainterPath [as 别名]
# 或者: from PySide.QtGui.QPainterPath import lineTo [as 别名]
    def realRender(self, painter, renderPath):  # TODO/PORT: Still needs work.
        """
        TOWRITE

        :param `painter`: TOWRITE
        :type `painter`: `QPainter`_
        :param `renderPath`: TOWRITE
        :type `renderPath`: `QPainterPath`_
        """
        color1 = self.objectColor()  #QColor  # lighter color
        color2 = color1.darker(150)  #QColor  # darker color

        # If we have a dark color, lighten it
        darkness = color1.lightness() #int
        threshold = 32 #int   #TODO: This number may need adjusted or maybe just add it to settings.
        if darkness < threshold:
            color2 = color1
            if not darkness:
                color1 = QColor(threshold, threshold, threshold)  # lighter() does not affect pure black
            else :
                color1 = color2.lighter(100 + threshold)

        count = renderPath.elementCount()  # int
        for i in range(0, count - 1):  # for(int i = 0; i < count-1; ++i);

            elem = renderPath.elementAt(i)      # QPainterPath::Element
            next = renderPath.elementAt(i + 1)  # QPainterPath::Element

            if next.isMoveTo():
                continue

            elemPath = QPainterPath()
            elemPath.moveTo(elem.x, elem.y)
            elemPath.lineTo(next.x, next.y)

            renderPen = QPen(QColor(0, 0, 0, 0))
            renderPen.setWidthF(0)
            painter.setPen(renderPen)
            stroker = QPainterPathStroker()
            stroker.setWidth(0.35)
            stroker.setCapStyle(Qt.RoundCap)
            stroker.setJoinStyle(Qt.RoundJoin)
            realPath = stroker.createStroke(elemPath)  # QPainterPath
            painter.drawPath(realPath)

            grad = QLinearGradient(elemPath.pointAtPercent(0.5), elemPath.pointAtPercent(0.0))
            grad.setColorAt(0, color1)
            grad.setColorAt(1, color2)
            grad.setSpread(QGradient.ReflectSpread)

            painter.fillPath(realPath, QBrush(grad))
开发者ID:Metallicow,项目名称:Embroidermodder,代码行数:53,代码来源:object_base.py

示例8: subPathList

# 需要导入模块: from PySide.QtGui import QPainterPath [as 别名]
# 或者: from PySide.QtGui.QPainterPath import lineTo [as 别名]
    def subPathList(self):
        """
        TOWRITE

        :rtype: QList<QPainterPath>
        """
        s = self.scale()  # qreal
        trans = QTransform()
        trans.rotate(self.rotation())
        trans.scale(s, s)

        ## QList<QPainterPath> pathList;
        pathList = []
        path = self.objTextPath  # QPainterPath

        element = QPainterPath.Element
        pathMoves = []  # QList<int>
        numMoves = 0  # int

        for i in range(0, path.elementCount()):  # for(int i = 0; i < path.elementCount(); i++)

            element = path.elementAt(i)
            if element.isMoveTo():

                pathMoves.append(i)  # pathMoves << i;
                numMoves += 1  # numMoves++;

        pathMoves.append(path.elementCount())  # pathMoves << path.elementCount();

        for p in range(0, len(pathMoves) - 1):  #  for(int p = 0; p < pathMoves.size()-1 && p < numMoves; p++)
            if not (p < numMoves):
                break

            subPath = QPainterPath()
            for i in range(pathMoves[p], pathMoves[p + 1]):  # for(int i = pathMoves.value(p); i < pathMoves.value(p+1); i++)

                element = path.elementAt(i)
                if element.isMoveTo():
                    subPath.moveTo(element.x, element.y)

                elif element.isLineTo():
                    subPath.lineTo(element.x, element.y)

                elif element.isCurveTo():
                    subPath.cubicTo(path.elementAt(i).x, path.elementAt(i).y,          # control point 1
                                    path.elementAt(i + 1).x, path.elementAt(i + 1).y,  # control point 2
                                    path.elementAt(i + 2).x, path.elementAt(i + 2).y)  # end point

            pathList.append(trans.map(subPath))

        return pathList
开发者ID:Metallicow,项目名称:Embroidermodder,代码行数:53,代码来源:object_textsingle.py

示例9: reshape

# 需要导入模块: from PySide.QtGui import QPainterPath [as 别名]
# 或者: from PySide.QtGui.QPainterPath import lineTo [as 别名]
 def reshape(self):
     ''' Update the connection or arrow shape '''
     shape = QPainterPath()
     shape.moveTo(self.start_point)
     for point in self.middle_points:
         shape.lineTo(point)
     shape.lineTo(self.end_point)
     # If required draw an arrow head (e.g. in SDL NEXTSTATE and JOIN)
     if self.child.arrow_head:
         self.draw_arrow_head(shape, origin='head',
                              kind=self.child.arrow_head)
     if self.child.arrow_tail:
         shape.moveTo(shape.pointAtPercent(0))
         self.draw_arrow_head(shape, origin='tail',
                              kind=self.child.arrow_head)
     self.setPath(shape)
开发者ID:dbrabera,项目名称:opengeode,代码行数:18,代码来源:Connectors.py

示例10: setupPaint

# 需要导入模块: from PySide.QtGui import QPainterPath [as 别名]
# 或者: from PySide.QtGui.QPainterPath import lineTo [as 别名]
 def setupPaint(self):
     """Draw the wire segments and handle."""
     if not self.data['startIO'] or not self.data['endIO']:
         self.setPen(QPen(QBrush(QColor(QColor('black'))), 2))
     elif self.data['startIO'].value:
         self.setPen(QPen(QBrush(QColor(QColor('green'))), 2))
     else:
         self.setPen(QPen(QBrush(QColor(QColor('red'))), 2))
     path = QPainterPath()
     path.moveTo(self.data['points'][0])
     for p in self.data['points'][1:]:
         path.lineTo(p)
     if not self.complete:   # An incomplete wire needs a handle
         path.addEllipse(self.data['points'][-1], self.radius, self.radius)
     self.setPath(path)
     self.update()
开发者ID:pouzzler,项目名称:IED-Logic-Simulator,代码行数:18,代码来源:graphicitem.py

示例11: setLineFromXXYY

# 需要导入模块: from PySide.QtGui import QPainterPath [as 别名]
# 或者: from PySide.QtGui.QPainterPath import lineTo [as 别名]
    def setLineFromXXYY(self, x1, y1, x2, y2):
        """
        TOWRITE

        :param `x1`: TOWRITE
        :type `x1`: qreal
        :param `y1`: TOWRITE
        :type `y1`: qreal
        :param `x2`: TOWRITE
        :type `x2`: qreal
        :param `y2`: TOWRITE
        :type `y2`: qreal
        """
        p = QPainterPath()
        p.moveTo(x1, y1)
        p.lineTo(x2, y2)
        self.setPath(p)
        self.objLine.setLine(x1, y1, x2, y2)
开发者ID:Metallicow,项目名称:Embroidermodder,代码行数:20,代码来源:object_base.py

示例12: reshape

# 需要导入模块: from PySide.QtGui import QPainterPath [as 别名]
# 或者: from PySide.QtGui.QPainterPath import lineTo [as 别名]
    def reshape(self):
        ''' Update the shape of the edge (redefined function) '''
        path = QPainterPath()
        # If there is a starting point, draw a line to the first curve point
        if self.start_point:
            path.moveTo(self.source_connection.center)
            path.lineTo(self.bezier[0])
        else:
            path.moveTo(self.source_connection.center)
        # Loop over the curve points:
        for group in self.bezier[1:]:
            path.cubicTo(*[point.center for point in group])

        # If there is an ending point, draw a line to it
        if self.end_point:
            path.lineTo(self.end_connection.center)

        end_point = path.currentPosition()
        arrowhead = self.angle_arrow(path)
        path.lineTo(arrowhead[0])
        path.moveTo(end_point)
        path.lineTo(arrowhead[1])
        path.moveTo(end_point)
        try:
            # Add the transition label, if any (none for the START edge)
            font = QFont('arial', pointSize=8)
            metrics = QFontMetrics(font)
            label = self.edge.get('label', '') or ''
            lines = label.split('\n')
            width = metrics.width(max(lines)) # longest line
            height = metrics.height() * len(lines)
            # lp is the position of the center of the text
            pos = self.mapFromScene(*self.edge['lp'])
            if not self.text_label:
                self.text_label = QGraphicsTextItem(
                                 self.edge.get('label', ''), parent=self)
                self.text_label.setX(pos.x() - width / 2)
                self.text_label.setY(pos.y() - height / 2)
                self.text_label.setFont(font)
                # Make horizontal center alignment, as dot does
                self.text_label.setTextWidth(
                        self.text_label.boundingRect().width())
                fmt = QTextBlockFormat()
                fmt.setAlignment(Qt.AlignHCenter)
                cursor = self.text_label.textCursor()
                cursor.select(QTextCursor.Document)
                cursor.mergeBlockFormat(fmt)
                cursor.clearSelection()
                self.text_label.setTextCursor(cursor)
                self.text_label.show()
        except KeyError:
            # no label
            pass
        self.setPath(path)
开发者ID:afesteves,项目名称:opengeode,代码行数:56,代码来源:Connectors.py

示例13: _setupPainterPath

# 需要导入模块: from PySide.QtGui import QPainterPath [as 别名]
# 或者: from PySide.QtGui.QPainterPath import lineTo [as 别名]
 def _setupPainterPath(self):
   painter_path = QPainterPath()
   painter_path.moveTo(0, 15) #left
   painter_path.lineTo(0, 0) #up
   painter_path.lineTo(self.width() - 1, 0) # right
   painter_path.lineTo(self.width() - 1, 15) # down
   painter_path.arcTo(QRect(self.width() - 6, 15, 5, 4), 0, -90) # control point1, cp2, destPoint
   painter_path.lineTo(5, 19) # left
   painter_path.arcTo(QRect(1, 15, 5, 4), 270, -90) #arc left up
   painter_path.closeSubpath()
   self._painter_path = painter_path
开发者ID:github-account-because-they-want-it,项目名称:VisualScrape,代码行数:13,代码来源:ui_common.py

示例14: objectSavePath

# 需要导入模块: from PySide.QtGui import QPainterPath [as 别名]
# 或者: from PySide.QtGui.QPainterPath import lineTo [as 别名]
    def objectSavePath(self):
        """
        TOWRITE

        :rtype: `QPainterPath`_
        """
        path = QPainterPath()
        r = self.rect()  # QRectF
        path.moveTo(r.bottomLeft())
        path.lineTo(r.bottomRight())
        path.lineTo(r.topRight())
        path.lineTo(r.topLeft())
        path.lineTo(r.bottomLeft())

        s = self.scale()  # qreal
        trans = QTransform()
        trans.rotate(self.rotation())
        trans.scale(s, s)
        return trans.map(path)
开发者ID:Metallicow,项目名称:Embroidermodder,代码行数:21,代码来源:object_rect.py

示例15: __init__

# 需要导入模块: from PySide.QtGui import QPainterPath [as 别名]
# 或者: from PySide.QtGui.QPainterPath import lineTo [as 别名]
    def __init__(self, scene):
        ''' Initialize the game '''
        self.scene = scene
        scene.scene_left.connect(self.quit_scene)
        self.rocket = Rocket()
        self.width = self.scene.sceneRect().width()
        self.height = self.scene.sceneRect().height()

        self.screen_bottom = self.height - self.rocket.boundingRect().height()
        scene.addItem(self.rocket)

        # Compute random land points
        random.seed()
        p1 = QPointF(0.0, random.uniform(0.0, self.height))
        p2 = QPointF(random.uniform(0.0, self.width / 4.0),
                    random.uniform(0.0, self.height))
        p3 = QPointF(random.uniform(p2.x(), 2 * self.width / 3.0), self.height)
        p4 = QPointF(p3.x() + 40.0, self.height)
        p5 = QPointF(self.width, random.uniform(0.0, self.height))
        path = QPainterPath(p1)
        slope = (p2.y() - p1.y()) / (p2.x() - p1.x())
        sign = 3
        for point in range(int((p2.x() - p1.x()) / 5)):
            sign = -sign
            x = p1.x() + point * 5
            path.lineTo(x, slope * x + sign)
        path.lineTo(p2)
        path.lineTo(p3)
        path.lineTo(p4)
        path.lineTo(p5)
        scene.addPath(path)

        # Initialize the music
        try:
            self.music = phonon.Phonon.createPlayer(
                    phonon.Phonon.MusicCategory,
                    phonon.Phonon.MediaSource(':/lander.mp3'))
        except NameError:
            LOG.warning('Could not initialise phonon')
        # Initialize the animation for the translation of the rocket
        self.animation = QtCore.QPropertyAnimation(self.rocket, "position")
        self.rocket_position = None
        # Initialize the animation for the rotation of the rocket
        self.rotation = QtCore.QPropertyAnimation(self.rocket, "angle")

        # Catch the key events to add user interaction:
        self.scene.keyPressEvent = lambda x: self.key(x)

        # updateCurrentTime is called by Qt when time changes
        self.animation.updateCurrentTime = lambda x: self.time_progress(x)
        # Connect signal sent at end of animation
        self.animation.finished.connect(self.animation_finished)
开发者ID:Kampbell,项目名称:opengeode,代码行数:54,代码来源:Lander.py


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