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


Python QtGui.QPainterPath类代码示例

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


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

示例1: __init__

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,代码行数:25,代码来源:selminerals.py

示例2: addPort

    def addPort(self, name, isOutput = False, flags = 0, ptr = None):
        port = QNEPort(self)
        port.setName(name)
        port.setIsOutput(isOutput)
        port.setNEBlock(self)
        port.setPortFlags(flags)
        port.setPtr(ptr)

        fontmetrics = QFontMetrics(self.scene().font());
        width = fontmetrics.width(name)
        height = fontmetrics.height()
        if width > self.width - self.horzMargin:
            self.width = width + self.horzMargin
        self.height += height

        path = QPainterPath()
        path.addRoundedRect(-self.width/2, -self.height/2, self.width, self.height, 5, 5)
        self.setPath(path)

        y = -self.height / 2 + self.vertMargin + port.radius()
        for port_ in self.childItems():
            if port_.type() != QNEPort.Type:
                continue

            if port_.isOutput():
                port_.setPos(self.width/2 + port.radius(), y)
            else:
                port_.setPos(-self.width/2 - port.radius(), y)
            y += height;

        return port
开发者ID:fieldOfView,项目名称:pyQNodesEditor,代码行数:31,代码来源:qneblock.py

示例3: set_shape

 def set_shape(self, width, height):
     ''' Define the bouding rectangle of the JOIN symbol '''
     circ = min(width, height)
     path = QPainterPath()
     path.addEllipse(0, 0, circ, circ)
     self.setPath(path)
     super(Join, self).set_shape(width, height)
开发者ID:Kampbell,项目名称:opengeode,代码行数:7,代码来源:sdlSymbols.py

示例4: animate

 def animate(self, shapes):
     self.start_signal.emit()
     time.sleep(self.start_delay)
     self.running = True
     self.ended = False
     max_radius = []
     original_clips = []
     centers = []
     animating_radius = []
     inc_rate = []
     for s in shapes:
         # Setting max of width or height as radius, ergo "circular" reveal,
         # not "oval" reveal
         target = max(s.width, s.height)
         max_radius.append(target)
         # Starting from the zero reaching the max
         animating_radius.append(0)
         # Getting the original masks; Used in case of cancelation
         original_clips.append(s.clip)
         # Center of the shape, considering margin
         centers.append(QPoint((s.width / 2) + s.margin_start, (s.height / 2) + s.margin_top))
         # Calculating the increase rate using the good ol' formula
         inc_rate.append((target / self.fps) * (1000 / self.duration))
     while self.running or self.paused:
         if self.canceled:
             for i, s in enumerate(shapes):
                 s.clip = original_clips[i]
             self.cancel_signal.emit()
             return
         elif self.ended:
             self.end_signal.emit()
             return
         elif self.paused:
             # Handling the pause
             self.pause_signal.emit()
             while not self.paused:
                 pass
             self.resume_signal.emit()
         else:
             # Setting FPS from the animator
             time.sleep(1 / self.fps)
             completed = False
             for i, s in enumerate(shapes):
                 if animating_radius[i] < max_radius[i]:
                     path = QPainterPath()
                     path.addEllipse(centers[i], animating_radius[i], animating_radius[i])
                     s.clip = path
                     s.update()
                     QApplication.processEvents()
                     animating_radius[i] += inc_rate[i]
                 else:
                     completed = True
             # No need to check on every iteration, duration is same so
             # all objects are gonna end at the same time
             if completed:
                 self.end_signal.emit()
                 self.started = False
                 self.ended = True
                 return
开发者ID:nicolas-raoul,项目名称:PyMaterial,代码行数:59,代码来源:MCircularReveal.py

示例5: objectSavePath

    def objectSavePath(self):
        """
        TOWRITE

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

示例6: objectSavePath

    def objectSavePath(self):
        """
        TOWRITE

        :rtype: `QPainterPath`_
        """
        path = QPainterPath()
        path.addRect(-0.00000001, -0.00000001, 0.00000002, 0.00000002)
        return path
开发者ID:Drahflow,项目名称:Embroidermodder,代码行数:9,代码来源:object_point.py

示例7: __init__

 def __init__(self, pos, edge, symbol):
     ''' Create the point - as a small, lightblue box '''
     super(Connectionpoint, self).__init__(pos, edge=edge)
     path = QPainterPath()
     path.addRect(0, 0, 10, 10)
     self.setPath(path)
     self.setPos(pos.x() - 5, pos.y() - 5)
     # Symbol actually owning the connection point
     self.symbol = symbol
开发者ID:dbrabera,项目名称:opengeode,代码行数:9,代码来源:Connectors.py

示例8: setRectFromRect

    def setRectFromRect(self, r):
        """
        TOWRITE

        :param `r`: TOWRITE
        :type `r`: QPointF
        """
        p = QPainterPath()
        p.addRect(r)
        self.setPath(p)
开发者ID:Metallicow,项目名称:Embroidermodder,代码行数:10,代码来源:object_base.py

示例9: __init__

    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,代码行数:31,代码来源:qnodeseditor.py

示例10: fillEllipse

 def fillEllipse(
     self,
     painter,
     x,
     y,
     size,
     brush,
     ):
     path = QPainterPath()
     path.addEllipse(x, y, size, size)
     painter.fillPath(path, brush)
开发者ID:Jonney,项目名称:Khweeteur,代码行数:11,代码来源:qbadgebutton.py

示例11: setLineFromLine

    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,代码行数:12,代码来源:object_base.py

示例12: updatePath

    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,代码行数:12,代码来源:qneconnection.py

示例13: __init__

 def __init__(self, parent):
     super(QNEOutputPort, self).__init__(parent)
     self.parent = parent
     
     self.setPen(self.parent.pen())
     self.setBrush(self.parent.brush())
     
     radius_ = parent.radius_
     
     path = QPainterPath()
     path.addEllipse(0, -radius_, 2*radius_, 2*radius_)
     self.setPath(path)
开发者ID:fieldOfView,项目名称:pyZNodeEditor,代码行数:12,代码来源:qneport.py

示例14: paintEvent

    def paintEvent(self, event):
        cX = self.parent.leftMargin + self.scaleMarkLen
        cY = self.parent.topMargin + self.scaleMarkLen
        worldX = self.parent.chunkX*16
        worldZ = self.parent.chunkZ*16
        painter = QPainter()
        path = QPainterPath()
        painter.begin(self)
        painter.save()
        #painter.setFont(QFont('Arial Narrow', 8)) #QFont.Bold
        # draw scale
        x = cX
        y = cY
        painter.rotate(-90)
        for i in range(16):
            fr = QRectF(-y, x, self.scaleMarkLen, self.edgeLen)
            painter.drawText(fr, Qt.AlignHCenter | Qt.AlignVCenter, '-5555')
            painter.drawRect(fr)
            #fr = QRectF(-y - 16*self.edgeLen - self.scaleMarkLen, x, self.scaleMarkLen, self.edgeLen)
            #painter.drawText(fr, Qt.AlignHCenter | Qt.AlignVCenter, '-5555')
            #painter.drawRect(fr)
            x += self.edgeLen
        painter.rotate(90)

        x = self.parent.leftMargin
        y = cY
        for i in range(16):
            fr = QRectF(x, y, self.scaleMarkLen, self.edgeLen)
            painter.drawText(fr, Qt.AlignHCenter | Qt.AlignVCenter, '-5555')
            painter.drawRect(fr)
            #fr = QRectF(x + self.scaleMarkLen + 16*self.edgeLen, y, self.scaleMarkLen, self.edgeLen)
            #painter.drawText(fr, Qt.AlignHCenter | Qt.AlignVCenter, '-5555')
            #painter.drawRect(fr)
            y += self.edgeLen

        x = cX
        y = cY
        for i in range(16):
            for j in range(16):
                path.addRect(x, y, self.edgeLen, self.edgeLen)
                fr = QRectF(x, y, self.edgeLen, self.edgeLen)
                #painter.drawText(fr, Qt.AlignHCenter | Qt.AlignVCenter, '-5555')
                x += self.edgeLen
            x = cX
            y += self.edgeLen

        painter.drawPath(path)

        painter.restore()
        painter.end()
        del painter
开发者ID:ydanilin,项目名称:MinecraftMinerals,代码行数:51,代码来源:SliceTest01.py

示例15: paint

 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,代码行数:50,代码来源:segmentString.py


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