Salome HOME
Improve PythonAPI documentation
[modules/shaper.git] / src / PythonAPI / model / features / rotation.py
1 """Rotation 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 addRotation(part, *args):
10     """Add a Rotation feature to the Part.
11
12     .. function:: addRotation(part, main_objects, axis_object, angle)
13
14     Args:
15         part (ModelAPI_Document): part document
16         main_objects (list of Selection): main objects
17         axis_object (list of Selection): axis object
18         angle (double): angle
19
20     Returns:
21         Rotation: rotation object
22     """
23     assert(args)
24     feature = part.addFeature("Rotation")
25     return Rotation(feature, *args)
26
27
28 class Rotation(Interface):
29     """Interface class for Rotation features.
30
31     .. function:: Rotation(feature)
32
33         Create interface for the feature without initialization.
34
35     .. function:: Rotation(feature, main_objects, axis_object, angle)
36
37         Create interface for the feature and initialize the feature with arguments.
38     """
39
40     def __init__(self, feature, *args):
41         """x.__init__(...) initializes x; see x.__class__.__doc__ for signature"""
42         Interface.__init__(self, feature)
43         assert(self._feature.getKind() == "Rotation")
44
45         self._main_objects = self._feature.data().selectionList("main_objects")
46         self._axis_object = self._feature.data().selection("axis_object")
47         self._angle = self._feature.data().real("angle")
48
49         assert(self._main_objects)
50         assert(self._axis_object)
51         assert(self._angle)
52
53         if not args:
54             return
55
56         assert(len(args) == 3)
57         self.setMainObjects(args[0])
58         self.setAxisObject(args[1])
59         self.setAngle(args[2])
60
61         self.execute()
62         pass
63
64     def setMainObjects(self, main_objects):
65         """Modify main_objects attribute of the feature.
66
67         See __init__.
68         """
69         self._fillAttribute(self._main_objects, main_objects)
70         pass
71
72     def setAxisObject(self, axis_object):
73         """Modify axis_object attribute of the feature.
74
75         See __init__.
76         """
77         self._fillAttribute(self._axis_object, axis_object)
78         pass
79
80     def setAngle(self, angle):
81         """Modify angle attribute of the feature.
82
83         See __init__.
84         """
85         self._fillAttribute(self._angle, angle)
86         pass