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


Python QtGui.QGraphicsPathItem类代码示例

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


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

示例1: __init__

    def __init__( self, edge, modObj, connObj ):
        QGraphicsPathItem.__init__( self )
        self.__edge = edge
        self.__modObj = modObj
        self.__connObj = connObj

        startPoint = QPointF( edge.points[ 0 ][ 0 ], edge.points[ 0 ][ 1 ] )
        painterPath = QPainterPath( startPoint )

        index = 1
        while index + 3 <= len( edge.points ):
            painterPath.cubicTo(edge.points[index][0],  edge.points[index][1],
                                edge.points[index+1][0],edge.points[index+1][1],
                                edge.points[index+2][0],edge.points[index+2][1])
            index = index + 3
        if index + 2 <= len( edge.points ):
            painterPath.quadTo(edge.points[index+1][0], edge.points[index+1][1],
                               edge.points[index+2][0], edge.points[index+2][1])
            index = index + 2

        if index + 1 <= len( edge.points ):
            painterPath.lineTo(edge.points[index+1][0], edge.points[index+1][1])

        lastIndex = len( edge.points ) - 1
        self.addArrow( painterPath,
                       edge.points[lastIndex-1][0],
                       edge.points[lastIndex-1][1],
                       edge.points[lastIndex][0],
                       edge.points[lastIndex][1] )

        self.setPath( painterPath )
        return
开发者ID:eaglexmw,项目名称:codimension,代码行数:32,代码来源:importsdgmgraphics.py

示例2: __init__

 def __init__(self, graphics, *args):
     QGraphicsPathItem.__init__(self, *args)
     path = path_from_graphics(graphics)
     self.setPath(path)
     self.setAcceptHoverEvents(True)
     self._actions = []
     self.link = None
开发者ID:nagyistoce,项目名称:orange-bio,代码行数:7,代码来源:OWKEGGPathwayBrowser.py

示例3: __init__

 def __init__(self, parent, pos, angle, pit=False):
     QGraphicsItemGroup.__init__(self, parent)
     AbstractSector.__init__(self, pos, angle)
     self.setZValue(3)
     self.black = QGraphicsPathItem(self)
     self.white = QGraphicsPathItem(self)
     start = 3 * (_trackWidth / 2)
     end = -start - abs(_pitDistance if pit else 0)
     rowdelta = _trackWidth / 4
     for item, y in [(self.black, -rowdelta),
                     (self.white, rowdelta)]:
         item.setCacheMode(QGraphicsPathItem.DeviceCoordinateCache)
         self.addToGroup(item)
         path = QPainterPath()
         path.moveTo(start, y)
         path.lineTo(end, y)
         path.moveTo(end, -y)
         path.lineTo(start, -y)
         item.setPath(path)
     pen = QPen(Qt.black, _trackWidth / 2)
     pen.setCapStyle(Qt.FlatCap)
     pen.setDashPattern([1, 1])
     self.black.setPen(QPen(pen))
     pen.setColor(Qt.white)
     self.white.setPen(pen)
开发者ID:Pesa,项目名称:forse,代码行数:25,代码来源:Track.py

示例4: __init__

    def __init__(self, radiusOut, raiusIn, angle, arcLen, parent=None):
        QGraphicsPathItem.__init__(self, parent=parent)
        self._radiusOut = radiusOut
        self._raiusIn = raiusIn
        self._angle = angle
        self._arcLen = arcLen

        self._pen = QPen(QColor('#000000'))
        self._pen.setWidth(1)
        self.setPen(self._pen)

        self._hoverPen = QPen(QColor('#000000'))
        self._hoverPen.setWidth(2)

        brush = QBrush(QColor('#FF9966'))
        self.setBrush(brush)

        rectOut = QRectF(-radiusOut, -radiusOut, radiusOut*2.0, radiusOut*2.0)
        rectIn = QRectF(-raiusIn, -raiusIn, raiusIn*2.0, raiusIn*2.0)

        startAngle = angle - arcLen/2.0
        endAngle = angle + arcLen/2.0

        path = QPainterPath()
        path.arcMoveTo(rectIn, startAngle)
        path.arcTo(rectOut, startAngle, arcLen)
        path.arcTo(rectIn, endAngle, 0)
        path.arcTo(rectIn, endAngle, -arcLen)

        self.setPath(path)

        self._isHover = False

        self._ioDragFirstPos = None
开发者ID:allebacco,项目名称:PyNodeGraph,代码行数:34,代码来源:connector_item.py

示例5: __init__

    def __init__(self, longitudes, latitudes, scene, parent=None):
        QGraphicsPathItem.__init__(self, parent=parent, scene=scene)

        assert len(longitudes) == len(latitudes)

        self._longitudes = np.array(longitudes, dtype=np.float32)
        self._latitudes = np.array(latitudes, dtype=np.float32)

        self.updatePosition(scene)
开发者ID:rugolotti,项目名称:PyTileMap,代码行数:9,代码来源:mapitems.py

示例6: paint

    def paint( self, painter, option, widget ):
        """ Draws a curve and then adds an arrow """

        pen = QPen( QColor( 0, 0, 0) )
        pen.setWidth( 2 )
        pen.setStyle( Qt.DotLine )
        self.setPen( pen )

        QGraphicsPathItem.paint( self, painter, option, widget )
        return
开发者ID:eaglexmw,项目名称:codimension,代码行数:10,代码来源:importsdgmgraphics.py

示例7: __init__

    def __init__(self, parent=None):
        QGraphicsPathItem.__init__(self, parent=parent)

        self._startName = None
        self._endName = None
        self._path = None

        self._startPos = None
        self._endPos = None

        pen = QPen(QBrush(QColor(Qt.black)), 2.0)
        self.setPen(pen)
开发者ID:allebacco,项目名称:PyNodeGraph,代码行数:12,代码来源:connection_item.py

示例8: __init__

    def __init__( self, settings, x1, y1, x2, y2 ):
        QGraphicsPathItem.__init__( self )
        self.__settings = settings

        path = QPainterPath()
        path.moveTo( x1, y1 )
        path.lineTo( x2, y2 )
        self.setPath( path )

        self.penStyle = None
        self.penColor = None
        self.penWidth = None
        return
开发者ID:fukanchik,项目名称:codimension,代码行数:13,代码来源:auxitems.py

示例9: ParallelCoordinatesCurve

class ParallelCoordinatesCurve(OWCurve):
    def __init__(self, n_attributes, y_values, color, name=""):
        OWCurve.__init__(self, tooltip=name)
        self._item = QGraphicsPathItem(self)
        self.path = QPainterPath()
        self.fitted = False

        self.n_attributes = n_attributes
        self.n_rows = int(len(y_values) / n_attributes)

        self.set_style(OWCurve.Lines)
        if isinstance(color, tuple):
            self.set_pen(QPen(QColor(*color)))
        else:
            self.set_pen(QPen(QColor(color)))

        x_values = list(range(n_attributes)) * self.n_rows
        self.set_data(x_values, y_values)

    def update_properties(self):
        self.redraw_path()

    def redraw_path(self):
        self.path = QPainterPath()
        for segment in self.segment(self.data()):
            if self.fitted:
                self.draw_cubic_path(segment)
            else:
                self.draw_normal_path(segment)
        self._item.setPath(self.graph_transform().map(self.path))
        self._item.setPen(self.pen())

    def segment(self, data):
        for i in range(self.n_rows):
            yield data[i * self.n_attributes:(i + 1) * self.n_attributes]

    def draw_cubic_path(self, segment):
        for (x1, y1), (x2, y2) in zip(segment, segment[1:]):
            self.path.moveTo(x1, y1)
            self.path.cubicTo(QPointF(x1 + 0.5, y1),
                              QPointF(x2 - 0.5, y2), QPointF(x2, y2))

    def draw_normal_path(self, segment):
        if not segment:
            return

        x, y = segment[0]
        self.path.moveTo(x, y)
        for x, y in segment[1:]:
            self.path.lineTo(x, y)
开发者ID:r0k3,项目名称:orange3,代码行数:50,代码来源:owparallelgraph.py

示例10: _addPath

 def _addPath(self):
   iNode = 2 * model._nodes.index(self.__node)
   x0,y0 = record.states[0][iNode:iNode+2]
   path = QPainterPath()
   path.moveTo(x0,-y0)
   item = QGraphicsPathItem()
   item.setPen( QPen( QColor(0,0,255), 0 ) )
   item.setPath(path)
   self._path = item
   for state in record.states[1:]:
     self._addPoint(state)
   if hasattr(record,'changeListeners'):
     record.changeListeners.append(self._addPoint)
   groupCurves.addToGroup(item)
开发者ID:DirkToewe,项目名称:strandbeest_sim,代码行数:14,代码来源:Strandbeest.py

示例11: __init__

    def __init__(self, parent=None, **kwargs):
        Annotation.__init__(self, parent, **kwargs)
        self.setFlag(QGraphicsItem.ItemIsMovable)
        self.setFlag(QGraphicsItem.ItemIsSelectable)

        self.setFocusPolicy(Qt.ClickFocus)

        self.__textMargins = (2, 2, 2, 2)

        rect = self.geometry().translated(-self.pos())
        self.__framePathItem = QGraphicsPathItem(self)
        self.__framePathItem.setPen(QPen(Qt.NoPen))

        self.__textItem = GraphicsTextEdit(self)
        self.__textItem.setPlaceholderText(self.tr("Enter text here"))
        self.__textItem.setPos(2, 2)
        self.__textItem.setTextWidth(rect.width() - 4)
        self.__textItem.setTabChangesFocus(True)
        self.__textItem.setTextInteractionFlags(Qt.NoTextInteraction)
        self.__textItem.setFont(self.font())
        self.__textInteractionFlags = Qt.NoTextInteraction

        layout = self.__textItem.document().documentLayout()
        layout.documentSizeChanged.connect(self.__onDocumentSizeChanged)

        self.__updateFrame()
开发者ID:CHANAYA,项目名称:orange3,代码行数:26,代码来源:annotationitem.py

示例12: paint

    def paint( self, painter, option, widget ):
        color = self.__settings.lineColor
        if self.penColor:
            color = self.penColor
        width = self.__settings.lineWidth
        if self.penWidth:
            width = self.penWidth

        pen = QPen( color )
        pen.setWidth( width )
        pen.setCapStyle( Qt.FlatCap )
        pen.setJoinStyle( Qt.RoundJoin )
        if self.penStyle:
            pen.setStyle( self.penStyle )
        self.setPen( pen )
        QGraphicsPathItem.paint( self, painter, option, widget )
        return
开发者ID:fukanchik,项目名称:codimension,代码行数:17,代码来源:auxitems.py

示例13: itemChange

    def itemChange(self, change, value):
        if change == QGraphicsPathItem.ItemSelectedHasChanged:
            if value.toBool():
                self.setZValue(self.zValue() + 1)
            else:
                self.setZValue(self.zValue() - 1)

        return QGraphicsPathItem.itemChange(self, change, value)
开发者ID:AutumnLight,项目名称:orange,代码行数:8,代码来源:OWVennDiagram.py

示例14: __init__

    def __init__(self, p0, p1, parent=None):
        QGraphicsPathItem.__init__(self, parent=parent)

        self._p0 = p0
        self._p1 = p1

        self._startPoint = QGraphicsEllipseItem(-3, -3, 6, 6, parent=self)
        self._startPoint.setPos(p0)
        self._endPoint = QGraphicsEllipseItem(-3, -3, 6, 6, parent=self)
        self._endPoint.setVisible(False)

        brush = QBrush(QColor(Qt.black))
        self._startPoint.setBrush(brush)
        self._endPoint.setBrush(brush)

        pen = QPen(brush, 2.0)
        self.setPen(pen)
开发者ID:sonictk,项目名称:PyNodeGraph,代码行数:17,代码来源:dragged_line_item.py

示例15: __init__

 def __init__(self, plot=None):
     orangeqt.PlotItem.__init__(self)
     self._x_enabled = True
     self._y_enabled = True
     self._path_item = QGraphicsPathItem(self)
     self.set_in_background(True)
     if plot:
         self.attach(plot)
         self._path_item.setPen(plot.color(OWPalette.Grid))
开发者ID:kereturn,项目名称:orange3,代码行数:9,代码来源:owtools.py


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