Salome HOME
Modify box macros and interface to match style and structure requirements.
[modules/shaper.git] / src / PythonAPI / extension / box.py
1 """Box macro-feature Interface
2 Author: Daniel Brunier-Coulin
3 Copyright (C) 2014-20xx CEA/DEN, EDF R&D
4 """
5
6 from model import Interface
7 from macros.box.feature import BoxFeature as MY
8
9
10 def addBox(container, *args):
11     feature = container.addFeature(MY.ID())
12     return Box(feature, *args)
13
14
15 class Box(Interface):
16     """Executes the macro-feature Box."""
17
18     def __init__(self, feature, *args):
19         Interface.__init__(self, feature)
20         assert(self._feature.getKind() == MY.ID())
21
22         self._width = self._feature.real(MY.WIDTH_ID())
23         self._length = self._feature.real(MY.LENGTH_ID())
24         self._height = self._feature.real(MY.HEIGHT_ID())
25
26         assert(self._width)
27         assert(self._length)
28         assert(self._height)
29
30         if not args:
31             return
32
33         assert(len(args) == 3)
34         dx, dy, dz = args
35         self.setWidth(dx)
36         self.setLength(dy)
37         self.setHeight(dz)
38
39         self._execute()
40         pass
41
42     def setWidth(self, width):
43         self._fill_attribute(self._width, width)
44         pass
45
46     def setLength(self, length):
47         self._fill_attribute(self._length, length)
48         pass
49
50     def setHeight(self, height):
51         self._fill_attribute(self._height, height)
52         pass