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


Python QPainterPath.moveTo方法代码示例

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


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

示例1: __init__

# 需要导入模块: from PySide.QtGui import QPainterPath [as 别名]
# 或者: from PySide.QtGui.QPainterPath import moveTo [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

示例2: draw_ref

# 需要导入模块: from PySide.QtGui import QPainterPath [as 别名]
# 或者: from PySide.QtGui.QPainterPath import moveTo [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

示例3: __init__

# 需要导入模块: from PySide.QtGui import QPainterPath [as 别名]
# 或者: from PySide.QtGui.QPainterPath import moveTo [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

示例4: set_shape

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

示例5: _setupPainterPath

# 需要导入模块: from PySide.QtGui import QPainterPath [as 别名]
# 或者: from PySide.QtGui.QPainterPath import moveTo [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

示例6: updatePath

# 需要导入模块: from PySide.QtGui import QPainterPath [as 别名]
# 或者: from PySide.QtGui.QPainterPath import moveTo [as 别名]
    def updatePath(self):
        path = QPainterPath()
        path.moveTo(self.pos1)

        dx = self.pos2.x() - self.pos1.x()
        dy = self.pos2.y() - self.pos1.y()

        ctr1 = QPointF(self.pos1.x() + dx * 0.25, self.pos1.y() + dy * 0.1)
        ctr2 = QPointF(self.pos1.x() + dx * 0.75, self.pos1.y() + dy * 0.9)

        path.cubicTo(ctr1, ctr2, self.pos2)
        self.setPath(path)
开发者ID:fieldOfView,项目名称:pyZNodeEditor,代码行数:14,代码来源:qneconnection.py

示例7: setLineFromLine

# 需要导入模块: from PySide.QtGui import QPainterPath [as 别名]
# 或者: from PySide.QtGui.QPainterPath import moveTo [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

示例8: subPathList

# 需要导入模块: from PySide.QtGui import QPainterPath [as 别名]
# 或者: from PySide.QtGui.QPainterPath import moveTo [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: realRender

# 需要导入模块: from PySide.QtGui import QPainterPath [as 别名]
# 或者: from PySide.QtGui.QPainterPath import moveTo [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

示例10: paint

# 需要导入模块: from PySide.QtGui import QPainterPath [as 别名]
# 或者: from PySide.QtGui.QPainterPath import moveTo [as 别名]
 def paint(self, painter, styleOption, widget):
   ''' Reimplemented to paint elements in alternating colors '''
   path = self.path()  # alias
   pathEnd = None
   i = 0
   while True:
     try:
       element = path.elementAt(i)
       # print type(element), element.type
       if element.isMoveTo():
         pathEnd = QPointF(element.x, element.y)
         i+=1
       elif element.isCurveTo():
         # Gather curve data, since is spread across elements of type curveElementData
         cp1 = QPointF(element.x, element.y)
         element = path.elementAt(i+1)
         cp2 = QPointF(element.x, element.y)
         element = path.elementAt(i+2)
         newEnd = QPointF(element.x, element.y)
         # create a subpath, since painter has no drawCubic method
         subpath=QPainterPath()
         subpath.moveTo(pathEnd)
         subpath.cubicTo(cp1, cp2, newEnd)
         painter.drawPath(subpath)
         
         pathEnd = newEnd
         i+=3
       else:
         print "unhandled path element", element.type
         i+=1
         """
         TODO: if SegmentStringss contain lines (w/o Direction ControlPoints)
         !!! We don't use QPathElements of type Line
         elif element.isLineTo():
           newEnd = QPointF(element.x, element.y)
           painter.drawLine(pathEnd, newEnd)
           pathEnd = newEnd
           i+=1
         """
       if i >= path.elementCount():
         break
     except Exception as inst:
       print inst
       break
       
     # Alternate colors
     if i%2 == 1:
       painter.setPen(Qt.blue)
     else:
       painter.setPen(Qt.red)
开发者ID:skadge,项目名称:freehandTool,代码行数:52,代码来源:segmentString.py

示例11: setupPaint

# 需要导入模块: from PySide.QtGui import QPainterPath [as 别名]
# 或者: from PySide.QtGui.QPainterPath import moveTo [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

示例12: reshape

# 需要导入模块: from PySide.QtGui import QPainterPath [as 别名]
# 或者: from PySide.QtGui.QPainterPath import moveTo [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

示例13: draw_edge

# 需要导入模块: from PySide.QtGui import QPainterPath [as 别名]
# 或者: from PySide.QtGui.QPainterPath import moveTo [as 别名]
 def draw_edge(self, painter, option, edge, lane_offset):
     from_y = 0.5 + lane_offset
     to_y = 1 + from_y
     pen = QPen(self.edge_color(edge.color), self.edge_thickness,
         Qt.SolidLine, Qt.FlatCap, Qt.RoundJoin)
     painter.setPen(pen)
     if edge.from_lane == edge.to_lane:
         line_x = edge.from_lane + 0.5
         painter.drawLine(QPointF(line_x, from_y), QPointF(line_x, to_y))
     else:
         from_x = edge.from_lane + 0.5
         to_x = edge.to_lane + 0.5
         path = QPainterPath()
         path.moveTo(QPointF(from_x, from_y))
         path.cubicTo(from_x, from_y + 0.5, to_x, to_y - 0.5, to_x, to_y)
         painter.drawPath(path)
开发者ID:vstojkovic,项目名称:berk,代码行数:18,代码来源:__init__.py

示例14: updatePath

# 需要导入模块: from PySide.QtGui import QPainterPath [as 别名]
# 或者: from PySide.QtGui.QPainterPath import moveTo [as 别名]
 def updatePath(self):
     """
     TOWRITE
     """
     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())
     # NOTE: Reverse the path so that the inside area isn't considered part of the rectangle
     path.lineTo(r.topLeft())
     path.lineTo(r.topRight())
     path.lineTo(r.bottomRight())
     path.moveTo(r.bottomLeft())
     self.setObjectPath(path)
开发者ID:Metallicow,项目名称:Embroidermodder,代码行数:19,代码来源:object_rect.py

示例15: setLineFromXXYY

# 需要导入模块: from PySide.QtGui import QPainterPath [as 别名]
# 或者: from PySide.QtGui.QPainterPath import moveTo [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


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