Salome HOME
Improve PythonAPI documentstion.
[modules/shaper.git] / src / PythonAPI / model / features / translation.py
1 """Translation 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 addTranslation(part, *args):
10     """Add an Translation feature to the Part and return Translation.
11
12     Pass all args to Translation __init__ function.
13     """
14     assert(args)
15     feature = part.addFeature("Translation")
16     return Translation(feature, *args)
17
18
19 class Translation(Interface):
20     """Interface class for Translation features.
21
22     Translation(feature) -> feature interface without initialization
23     Translation(feature, main_objects, axis_object, distance) ->
24         feature interface initialized from arguments:
25         - main_objects
26         - axis_object
27         - distance
28     """
29
30     def __init__(self, feature, *args):
31         """x.__init__(...) initializes x; see x.__class__.__doc__ for signature"""
32         Interface.__init__(self, feature)
33         assert(self._feature.getKind() == "Translation")
34
35         self._main_objects = self._feature.data().selectionList("main_objects")
36         self._axis_object = self._feature.data().selection("axis_object")
37         self._distance = self._feature.data().real("distance")
38
39         assert(self._main_objects)
40         assert(self._axis_object)
41         assert(self._distance)
42
43         if not args:
44             return
45
46         assert(len(args) == 3)
47         self.setMainObjects(args[0])
48         self.setAxisObject(args[1])
49         self.setDistance(args[2])
50
51         self._execute()
52         pass
53
54     def setMainObjects(self, main_objects):
55         """Modify main_objects attribute of the feature.
56
57         See __init__.
58         """
59         self._fill_attribute(self._main_objects, main_objects)
60         pass
61
62     def setAxisObject(self, axis_object):
63         """Modify axis_object attribute of the feature.
64
65         See __init__.
66         """
67         self._fill_attribute(self._axis_object, axis_object)
68         pass
69
70     def setDistance(self, distance):
71         """Modify distance attribute of the feature.
72
73         See __init__.
74         """
75         self._fill_attribute(self._distance, distance)
76         pass