Salome HOME
[PythonAPI] Sketch circle interface modification (example of new API style discussed...
[modules/shaper.git] / src / PythonAPI / model / sketcher / circle.py
index b6ce45e8a33197fd84a3f922726f9428ad7958e6..a3ba89a1eb8a85051e76c01fff2b68ad98a3ac32 100644 (file)
@@ -5,7 +5,7 @@ from model.roots import Interface
 
 class Circle(Interface):
     """Interface for circle feature data manipulation."""
-    def __init__(self, feature, x, y, radius):
+    def __init__(self, feature, *args):
         Interface.__init__(self, feature)
         assert(self._feature.getKind() == "SketchCircle")
         
@@ -13,8 +13,18 @@ class Circle(Interface):
             self._feature.data().attribute("CircleCenter")
             )
         self._radius = self._feature.data().real("CircleRadius")
-        self.setCenter(x, y)
-        self.setRadius(radius)
+        
+        if not args:
+            return
+        
+        if len(args) != 3:
+            raise TypeError(
+                "Invalid number of arguments, 3 arguments needed  (%s given)" 
+                % len(args)
+                )
+        
+        self.setCenter(args[0], args[1])
+        self.setRadius(args[2])
         self.execute()
 
     def setCenter(self, x, y):
@@ -25,13 +35,17 @@ class Circle(Interface):
         """Set the radius of the circle."""
         self._radius.setValue(radius)
         
-    def centerData(self):
-        """Return center data."""
+    def center(self):
+        """Return the center attribute of the circle."""
         return self._center
 
-    def radiusData(self):
-        """Return radius data."""
-        return self._radius
+    def radius(self):
+        """Return the radius value.
+        
+        :return: radius
+        :rtype: double
+        """
+        return self._radius.value()
 
     def result(self):
         """Return the cicular line attribute."""