1 from GraphicsScene import GraphicsScene
3 from GraphicsRectItem import GraphicsRectItem
5 class PolyGraphicsScene( GraphicsScene ) :
7 def __init__( self, controller ) :
8 GraphicsScene.__init__( self, controller )
12 points = self.getModel().getPoints()
14 # Drawing the points as small rectangles
15 for i in range( len(points) ) :
17 xPoint = float( point[0] )
18 yPoint = float( point[1] )
19 # Constructing a rectangle centered on point
20 pointItem = GraphicsRectItem( xPoint-0.1, yPoint-0.1, 0.2, 0.2, i )
21 self.addItem( pointItem )
24 # Linking the points with lines
25 for i in range( len(points) - 1 ) :
28 xCurrent = float( current[0] )
29 yCurrent = float( current[1] )
30 xNext = float( next[0] )
31 yNext = float( next[1] )
32 line = QLineF( xCurrent, yCurrent, xNext, yNext )
33 lineItem = QGraphicsLineItem()
34 lineItem.setLine( line )
35 self.addItem( lineItem )