Salome HOME
Remove redirection to execute(). Replace it with Interface.execute() with validation.
[modules/shaper.git] / src / PythonAPI / model / features / placement.py
1 """Placement Interface
2 Author: Sergey Pokhodenko
3 Copyright (C) 2014-20xx CEA/DEN, EDF R&D
4 """
5
6 from model.roots import Interface
7
8
9 def addPlacement(part, *args):
10     """Add an Placement feature to the Part and return Placement.
11
12     Pass all args to Placement __init__ function.
13     """
14     assert(args)
15     feature = part.addFeature("Placement")
16     return Placement(feature, *args)
17
18
19 class Placement(Interface):
20     """Interface class for Placement feature.
21
22     Placement(feature) -> feature interface without initialization
23     Placement(feature, objects_list, start_shape, end_shape,
24               reverse_direction, centering) ->
25         feature interface initialized from arguments:
26         - objects_list
27         - start_shape
28         - end_shape
29         - reverse_direction
30         - centering
31     """
32
33     def __init__(self, feature, *args):
34         """x.__init__(...) initializes x; see x.__class__.__doc__ for signature"""
35         Interface.__init__(self, feature)
36         assert(self._feature.getKind() == "Placement")
37
38         self._objects_list = self._feature.data().selectionList("placement_objects_list")
39         self._start_shape = self._feature.data().selection("placement_start_shape")
40         self._end_shape = self._feature.data().selection("placement_end_shape")
41         self._reverse_direction = self._feature.data().boolean("placement_reverse_direction")
42         self._centering = self._feature.data().boolean("placement_centering")
43
44         assert(self._objects_list)
45         assert(self._start_shape)
46         assert(self._end_shape)
47         assert(self._reverse_direction)
48         assert(self._centering)
49
50         if not args:
51             return
52
53         assert(len(args) == 5)
54         self.setObjectList(args[0])
55         self.setStartShape(args[1])
56         self.setEndShape(args[2])
57         self.setReverseDirection(args[3])
58         self.setCentering(args[4])
59
60         self.execute()
61         pass
62
63     def setObjectList(self, objects_list):
64         """Modify placement_objects_list attribute of the feature.
65
66         See __init__.
67         """
68         self._fillAttribute(self._objects_list, objects_list)
69         pass
70
71     def setStartShape(self, start_shape):
72         """Modify start_shape attribute of the feature.
73
74         See __init__.
75         """
76         self._fillAttribute(self._start_shape, start_shape)
77         pass
78
79     def setEndShape(self, end_shape):
80         """Modify end_shape attribute of the feature.
81
82         See __init__.
83         """
84         self._fillAttribute(self._end_shape, end_shape)
85         pass
86
87     def setReverseDirection(self, reverse_direction):
88         """Modify reverse_direction attribute of the feature.
89
90         See __init__.
91         """
92         self._fillAttribute(self._reverse_direction, reverse_direction)
93         pass
94
95     def setCentering(self, centering):
96         """Modify centering attribute of the feature.
97
98         See __init__.
99         """
100         self._fillAttribute(self._centering, centering)
101         pass