Salome HOME
Rename _fill_attribute to _fillAttribute. Make redirection using functions.
[modules/shaper.git] / src / PythonAPI / model / construction / axis.py
index 498ca567a780f677c72fe254d50e160fdf0953d9..2ec9ab00fee28c15465adb50d6a472470a04b321 100644 (file)
@@ -11,26 +11,26 @@ def addAxis(part, *args):
 
     Pass all args to Axis __init__ function.
     """
+    assert(args)
     feature = part.addFeature("Axis")
     return Axis(feature, *args)
 
 
 class Axis(Interface):
-    """Interface on an Axis feature."""
+    """Interface class for Axis feature.
+
+    Axis(feature) -> feature interface without initialization
+    Axis(feature, p1, p2) ->
+        feature interface initialized from arguments:
+        - p1 -- FirstPoint
+        - p2 -- SecondPoint
+    Axis(feature, face) ->
+        feature interface initialized from arguments:
+        - face -- CylindricalFace
+    """
 
     def __init__(self, feature, *args):
-        """Initialize an Axis feature with given parameters.
-
-        Expected arguments for all modes:
-        feature -- a Axis feature
-
-        For AxisByPointsCase mode (expect 2 arguments):
-        p1 -- FirstPoint
-        p2 -- SecondPoint
-
-        For AxisByCylindricalFaceCase mode (expect 1 argument):
-        face -- CylindricalFace
-        """
+        """x.__init__(...) initializes x; see x.__class__.__doc__ for signature"""
         Interface.__init__(self, feature)
         assert(self._feature.getKind() == "Axis")
 
@@ -39,21 +39,28 @@ class Axis(Interface):
         self._SecondPoint = self._feature.data().selection("SecondPoint")
         self._CylindricalFace = self._feature.data().selection("CylindricalFace")
 
+        assert(self._CreationMethod)
+        assert(self._FirstPoint)
+        assert(self._SecondPoint)
+        assert(self._CylindricalFace)
+
         if not args:
             return
 
-        assert(len(args) == 2 or len(args) == 1)
+        assert(len(args) in (1, 2))
         if len(args) == 2:
             self.setPoints(*args)
         elif len(args) == 1:
             self.setCylindricalFace(*args)
+
+        self._execute()
         pass
 
     def __clear(self):
-        self._fill_attribute(self._CreationMethod, "AxisByPointsCase")
-        self._fill_attribute(self._FirstPoint, None)
-        self._fill_attribute(self._SecondPoint, None)
-        self._fill_attribute(self._CylindricalFace, None)
+        self._fillAttribute(self._CreationMethod, "AxisByPointsCase")
+        self._fillAttribute(self._FirstPoint, None)
+        self._fillAttribute(self._SecondPoint, None)
+        self._fillAttribute(self._CylindricalFace, None)
 
     def setPoints(self, p1, p2):
         """Modify points attribute of the feature.
@@ -61,9 +68,9 @@ class Axis(Interface):
         See __init__.
         """
         self.__clear()
-        self._fill_attribute(self._CreationMethod, "AxisByPointsCase")
-        self._fill_attribute(self._FirstPoint, p1)
-        self._fill_attribute(self._SecondPoint, p2)
+        self._fillAttribute(self._CreationMethod, "AxisByPointsCase")
+        self._fillAttribute(self._FirstPoint, p1)
+        self._fillAttribute(self._SecondPoint, p2)
         pass
 
     def setCylindricalFace(self, face):
@@ -72,6 +79,6 @@ class Axis(Interface):
         See __init__.
         """
         self.__clear()
-        self._fill_attribute(self._CreationMethod, "AxisByCylindricalFaceCase")
-        self._fill_attribute(self._CylindricalFace, face)
+        self._fillAttribute(self._CreationMethod, "AxisByCylindricalFaceCase")
+        self._fillAttribute(self._CylindricalFace, face)
         pass