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