]> SALOME platform Git repositories - tools/sat.git/blob - data/templates/PythonComponent/src/View/GraphicsScene.py
Salome HOME
add the template command
[tools/sat.git] / data / templates / PythonComponent / src / View / GraphicsScene.py
1 from View import *
2 from PyQt4.QtGui import *
3 from PyQt4.QtCore import *
4
5 class GraphicsScene( View, QGraphicsScene ) :
6
7    def __init__( self, controller ) :
8        """Constructor"""
9
10        View.__init__( self, controller )
11        QGraphicsScene.__init__( self )
12        pass
13
14    def getRect( self ) :
15        rect = QRectF( 0, 0, self.width(), self.height() )
16        return rect
17
18    def editPoint( self, oldPoint, newPoint ) :
19        polyline = self.getModel()
20        self.getController().editPoint( polyline, oldPoint, newPoint )
21        pass
22
23    def editCenter( self, center ) :
24        circle = self.getModel()
25        self.getController().editCenter( circle, center )
26        pass
27
28    def editRadius( self, radius ) :
29        circle = self.getModel()
30        self.getController().editRadius( circle, radius )
31        pass
32
33    def update( self, mode ) :
34        if mode == 'creation' :
35           self.showInGlobalGraphicsView()
36           pass
37        elif mode == "showing" :
38           self.showInGlobalGraphicsView()
39        elif mode == 'modification' :
40           self.undraw()
41           self.showInGlobalGraphicsView()
42           pass
43        elif mode == 'supression' :
44           self.removeFromGlobalGraphicsView()
45           pass
46        else :
47           return
48
49    def showInGlobalGraphicsView( self ) :
50        self.draw()
51        self.getController().getMainFrame().updateGlobalGraphicsView( self  )
52        pass
53
54    def removeFromGlobalGraphicsView( self ) :
55        self.getController().getMainFrame().updateGlobalGraphicsView( None  )
56        pass
57
58    def draw( self ) :
59        print 'Virtual method'
60        pass
61
62    def undraw( self ) :
63        for item in self.items() :
64           self.removeItem( item )
65           pass
66        pass
67
68 pass