]> SALOME platform Git repositories - tools/sat.git/blob - data/templates/PythonComponent/src/View/PolyGraphicsScene.py
Salome HOME
Mise à jour du template PythonComponent
[tools/sat.git] / data / templates / PythonComponent / src / View / PolyGraphicsScene.py
1 from GraphicsScene import GraphicsScene
2 from qtsalome import *
3 from GraphicsRectItem import GraphicsRectItem
4
5 class PolyGraphicsScene(  GraphicsScene ) :
6
7    def __init__( self, controller ) :
8        GraphicsScene.__init__( self, controller )
9        pass
10
11    def draw( self ) :
12        points = self.getModel().getPoints()
13
14        # Drawing the points as small rectangles
15        for i in range( len(points) ) :
16           point = points[i]
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 )
22           pass
23
24        # Linking the points with lines
25        for i in range( len(points) - 1 ) :
26           current = points[i]
27           next = points[i+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 )
36           pass
37        pass
38
39 pass