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


Python QtGui.QGraphicsLineItem类代码示例

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


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

示例1: __init__

    def __init__(self, parent, fromView, toView, distributedObjects):
        """ Constructor
        @param parent                parent for the QGraphicsPolygonItem-Constructor
        @param fromView              datagraph.htmlvariableview.HtmlVariableView, starting point of the Pointer
        @param toView                datagraph.htmlvariableview.HtmlVariableView, end point of the Pointer
        @param distributedObjects    distributedobjects.DistributedObjects, the DistributedObjects-Instance
        fromView and toView are QGraphicsWebViews
        """
        QGraphicsLineItem.__init__(self, parent)
        self.fromView = fromView
        fromView.addOutgoingPointer(self)
        self.toView = toView
        toView.addIncomingPointer(self)
        #self.setBrush( QBrush( self.bgcolor  ) )
        self.setPen(QPen(self.fgcolor, 1))

        self.distributedObjects = distributedObjects

        QObject.connect(self.fromView, SIGNAL('geometryChanged()'), self.updatePosition)
        QObject.connect(self.toView, SIGNAL('geometryChanged()'), self.updatePosition)
        QObject.connect(self.fromView, SIGNAL('xChanged()'), self.updatePosition)
        QObject.connect(self.fromView, SIGNAL('yChanged()'), self.updatePosition)
        QObject.connect(self.toView, SIGNAL('xChanged()'), self.updatePosition)
        QObject.connect(self.toView, SIGNAL('yChanged()'), self.updatePosition)
        QObject.connect(self.fromView, SIGNAL('removing()'), self.delete)
        QObject.connect(self.toView, SIGNAL('removing()'), self.delete)

        self.arrowhead = QPolygonF()
        self.arrowSize = 20
        self.setZValue(-1)  # paint the arrows behind (lower z-value) everything else
开发者ID:gledr,项目名称:ricodebug,代码行数:30,代码来源:pointer.py

示例2: __init__

 def __init__(self, w, h, fgcolor):
     QGraphicsLineItem.__init__(self)
     self.setLine(w / 2., 0, w / 2., h)
     if fgcolor:
         self.setPen(QPen(QColor(fgcolor)))
     else:
         self.setPen(QPen(QColor('#000000')))
开发者ID:UdeM-LBIT,项目名称:CoreTracker,代码行数:7,代码来源:Faces.py

示例3: draw_y_axis

 def draw_y_axis(self):
     lineItem = QGraphicsLineItem(0, self.coordY(self.ylim[0]),
                                  0, self.coordY(self.ylim[1]),
                                  parent=self.item)
     lineItem.setPen(QPen(QColor('black')))
     lineItem.setZValue(10)
     max_w = 0
     for y in set(self.hlines + list(self.ylim)):
         lineItem = QGraphicsLineItem(0, self.coordY(y),
                                            -5, self.coordY(y),
                                            parent=self.item)
         lineItem.setPen(QPen(QColor('black')))
         lineItem.setZValue(10)
         text = QGraphicsSimpleTextItem(str(y))
         text.setFont(QFont("Arial", self.fsize-2))
         text.setParentItem(self.item)
         tw = text.boundingRect().width()
         max_w = tw if tw > max_w else max_w
         th = text.boundingRect().height()
         # Center text according to masterItem size
         text.setPos(-tw - 5, self.coordY(y)-th/2)
     if self.ylabel:
         text = QGraphicsSimpleTextItem(self.ylabel)
         text.setFont(QFont("Arial", self.fsize-1))
         text.setParentItem(self.item)
         text.rotate(-90)
         tw = text.boundingRect().width()
         th = text.boundingRect().height()
         # Center text according to masterItem size
         text.setPos(-th -5-max_w, tw/2+self.coordY(sum(self.ylim)/2))
开发者ID:meren,项目名称:ebov,代码行数:30,代码来源:rulerface.py

示例4: GPendulum

class GPendulum(Graphics.Items.ItemGroupBase):
    def _setup(self):
        self.rod = QGraphicsLineItem(QLineF(0, 0, 0, 100))
        p = QPen(QColor(100, 100, 100))
        p.setWidth(5)
        self.rod.setPen(p)
        self.rod.setToolTip('This is the rod of the pendulum')
        self.ball = QGraphicsEllipseItem(QRectF(-20, 80, 40, 40))
        b = QBrush(Qt.SolidPattern)
        b.setColor(QColor(0, 255, 0))
        self.ball.setBrush(b)
        self.ball.setToolTip('This is the ball of the pendulum where the mass is concentrated')
        self.addToGroup(self.rod)
        self.addToGroup(self.ball)
        self.setFlags(QGraphicsItem.ItemIsSelectable)

    def setProperties(self, q):
        self.properties = q

    def contextMenuEvent(self, e):
        e.accept()
        m = QMenu()
        p = m.addAction("Properties")
        a = m.exec_(e.screenPos())
        if a == p:
            dlg = SimTools.RichTypes.Qt4Widgets.SimpleRichTypesDialog(mainWin, 'Pendulum properties',
                text='Change physical properties', scrolling=False)
            dlg.addRichTypes(self.properties)
            dlg.exec_()
开发者ID:BackupTheBerlios,项目名称:simuvis4-svn,代码行数:29,代码来源:pendulum.py

示例5: __init__

 def __init__ (self, s_in, s_out ,parent=None, scene=None):
     
     QGraphicsLineItem.__init__ (self)
     
     self.s_in  = s_in
     self.s_out = s_out
     
     self.comm = c0.Comm0 ()
     
     self.xo = self.s_in.getAbsPos().x()
     self.yo = self.s_in.getAbsPos().y()
     self.xf = self.s_out.getAbsPos().x()
     self.yf = self.s_out.getAbsPos().y()
     
     self.color  = QColor (Qt.green).dark(120)
     
     #self.setFlags (QGraphicsItem.ItemIsSelectable | QGraphicsItem.ItemIsMovable)
     #self.setAcceptsHoverEvents (True)
     
     self.setZValue (-1)
     
     self.arrowSize = 5
     self.arrowHead = QPolygonF()
     
     self.setFlags (QGraphicsItem.ItemIsSelectable)
     self.setAcceptHoverEvents (True)
     self.setActive(True)
     
     self.wire_pen = QPen (Qt.white, 3, Qt.DotLine) # Qt.SolidLine
     
     self.const = 3
开发者ID:iras,项目名称:JADE,代码行数:31,代码来源:Wires0.py

示例6: draw_errors

 def draw_errors(self, x, i):
     lower = self.values[i]+self._dw_err[i]
     upper = self.values[i]+self._up_err[i]
     lineItem = QGraphicsLineItem(0, self.coordY(lower), 0,
                                        self.coordY(upper), parent=self.item)
     lineItem.setX(x)
     lineItem.setPen(QPen(QColor('black'),1))
开发者ID:meren,项目名称:ebov,代码行数:7,代码来源:rulerface.py

示例7: _setup

 def _setup(self, x=0, y=0, size=10, pen=QPen(QColor(0,0, 255))):
     a = 0.5*size
     self.p1 = QGraphicsLineItem(QLineF(x-a, y-a, x+a, y+a))
     self.p2 = QGraphicsLineItem(QLineF(x-a, y+a, x+a, y-a))
     self.p1.setPen(pen)
     self.p2.setPen(pen)
     self.addToGroup(self.p1)
     self.addToGroup(self.p2)
开发者ID:BackupTheBerlios,项目名称:simuvis4-svn,代码行数:8,代码来源:Items.py

示例8: __init__

    def __init__(self, lon0, lat0, lon1, lat1, scene, parent=None):
        QGraphicsLineItem.__init__(self, parent=parent, scene=scene)

        self._lon0 = lon0
        self._lat0 = lat0
        self._lon1 = lon1
        self._lat1 = lat1

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

示例9: CrossX

class CrossX(ItemGroupBase):
    """a cross (x) made of two lines"""
    def _setup(self, x=0, y=0, size=10, pen=QPen(QColor(0,0, 255))):
        a = 0.5*size
        self.p1 = QGraphicsLineItem(QLineF(x-a, y-a, x+a, y+a))
        self.p2 = QGraphicsLineItem(QLineF(x-a, y+a, x+a, y-a))
        self.p1.setPen(pen)
        self.p2.setPen(pen)
        self.addToGroup(self.p1)
        self.addToGroup(self.p2)
开发者ID:BackupTheBerlios,项目名称:simuvis4-svn,代码行数:10,代码来源:Items.py

示例10: mouseMoveEvent

    def mouseMoveEvent(self, event):
        if event.buttons() & Qt.LeftButton:

            downPos = event.buttonDownPos(Qt.LeftButton)
            if not self.__tmpLine and self.__dragStartItem and \
                    (downPos - event.pos()).manhattanLength() > \
                        QApplication.instance().startDragDistance():
                # Start a line drag
                line = QGraphicsLineItem(self)
                start = self.__dragStartItem.boundingRect().center()
                start = self.mapFromItem(self.__dragStartItem, start)
                line.setLine(start.x(), start.y(),
                             event.pos().x(), event.pos().y())

                pen = QPen(Qt.black, 4)
                pen.setCapStyle(Qt.RoundCap)
                line.setPen(pen)
                line.show()

                self.__tmpLine = line

            if self.__tmpLine:
                # Update the temp line
                line = self.__tmpLine.line()
                line.setP2(event.pos())
                self.__tmpLine.setLine(line)

        QGraphicsWidget.mouseMoveEvent(self, event)
开发者ID:Micseb,项目名称:orange3,代码行数:28,代码来源:editlinksdialog.py

示例11: Axes

class Axes(ItemGroupBase):
    """two rectangular lines as axes"""
    def _setup(self, x=[0, -100, 100], y=[0, -100, 100], pen=QPen(QColor(255,0,0))):
        if x:
            self.xAxis = QGraphicsLineItem(QLineF(x[1], x[0], x[2], x[0]))
            self.xAxis.setPen(pen)
            self.addToGroup(self.xAxis)
        if y:
            self.yAxis = QGraphicsLineItem(QLineF(y[0], y[1], y[0], y[2]))
            self.yAxis.setPen(pen)
            self.addToGroup(self.yAxis)
开发者ID:BackupTheBerlios,项目名称:simuvis4-svn,代码行数:11,代码来源:Items.py

示例12: __init__

        def __init__(self, scene, *args, **kwords):
            comp.__init__(self, *args, **kwords)
            QGraphicsLineItem.__init__(self,QLineF(), scene = scene)

            pen = QtGui.QPen()
            pen.setWidth(1)
            pen.setBrush(Qt.black)
            pen.setStyle(Qt.NoPen)

            self.setPen(pen)
            self.nextPoint = 1
开发者ID:Rosslaew,项目名称:Archsim,代码行数:11,代码来源:graphical.py

示例13: onEdgeAdd

 def onEdgeAdd(start,end):
   '''
   Whenever a new edge is added to model, this method is to be notified.
   '''
   p1 = nodeToScene[start].rect().center()
   p2 = nodeToScene[end]  .rect().center()
   line = QGraphicsLineItem( QLineF(p1,p2) )
   line.setPen( QPen( QColor(32,32,32), 1 ) )
   groupEdges.addToGroup(line)
   nodeToLineP1[start].add(line)
   nodeToLineP2  [end].add(line)
开发者ID:DirkToewe,项目名称:strandbeest_sim,代码行数:11,代码来源:Strandbeest.py

示例14: draw_curve

 def draw_curve(self, x, y, i):
     # top line
     lineItem = QGraphicsLineItem(0, self.coordY(y), 4,
                                        self.coordY(y), parent=self.item)
     lineItem.setX(x-2)
     lineItem.setPen(QPen(QColor(self.colors[i]),2))
     if i > 0:
         prev = self.values[i-1] if i>0 else self.values[i]
         lineItem = QGraphicsLineItem(0, self.coordY(prev), self.col_w-4,
                                            self.coordY(y), parent=self.item)
         lineItem.setX(x - self.col_w+2)
         lineItem.setPen(QPen(QColor(self.colors[i]),2))
开发者ID:meren,项目名称:ebov,代码行数:12,代码来源:rulerface.py

示例15: update

    def update(self):
        x1 = self.node1.centerX()
        y1 = self.node1.centerY()
        x2 = self.node2.centerX()
        y2 = self.node2.centerY()

        point1 = QPointF(x1,y1)
        point2 = QPointF(x2,y2)

        line = QLineF(point1, point2)

        QGraphicsLineItem.setLine(self,line)
开发者ID:karolszczapa,项目名称:GIS,代码行数:12,代码来源:Edge.py


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