]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
[PythonAPI] Sketch circle interface modification (example of new API style discussed...
authorRenaud NEDELEC <renaud.nedelec@opencascade.com>
Thu, 5 Nov 2015 14:46:30 +0000 (15:46 +0100)
committerRenaud NEDELEC <renaud.nedelec@opencascade.com>
Thu, 5 Nov 2015 14:46:30 +0000 (15:46 +0100)
src/PythonAPI/Test/TestSketcherAddCircle.py
src/PythonAPI/Test/TestSketcherSetRadius.py
src/PythonAPI/model/sketcher/circle.py
src/PythonAPI/model/sketcher/sketch.py

index 932bb6881ca5ca3e92df8108a4e704ed0e16e9a0..9bc6e4c9d4080a0e444419756e69c5ff98c9d09f 100644 (file)
@@ -6,9 +6,9 @@ class SketcherAddCircle(SketcherTestCase):
     def test_add_cricle(self):
         circle = self.sketch.addCircle(0, 10, 20)
         model.do()
-        self.assertEqual(circle.centerData().x(), 0.0)        
-        self.assertEqual(circle.centerData().y(), 10.0)
-        self.assertEqual(circle.radiusData().value(), 20.0)
+        self.assertEqual(circle.center().x(), 0.0)        
+        self.assertEqual(circle.center().y(), 10.0)
+        self.assertEqual(circle.radius(), 20.0)
         
     def test_modify_circle(self):
         circle = self.sketch.addCircle(0, 10, 20)
@@ -16,9 +16,9 @@ class SketcherAddCircle(SketcherTestCase):
         circle.setCenter(10, 10)
         circle.setRadius(30)
         model.do()
-        self.assertEqual(circle.centerData().x(), 10.0)        
-        self.assertEqual(circle.centerData().y(), 10.0)
-        self.assertEqual(circle.radiusData().value(), 30.0)
+        self.assertEqual(circle.center().x(), 10.0)        
+        self.assertEqual(circle.center().y(), 10.0)
+        self.assertEqual(circle.radius(), 30.0)
         
     
 if __name__ == "__main__":
index def3979270cd580b21da969fd12616c507c4f213..0cb6ad9a072c009f912dfc2ac960326ab8c76612 100644 (file)
@@ -7,15 +7,15 @@ class SketcherSetRadius(SketcherTestCase):
         circle = self.sketch.addCircle(0, 10, 20)
         self.sketch.setRadius(circle.result(), 30)
         model.do()
-        self.assertEqual(circle.radiusData().value(), 30.0)
+        self.assertEqual(circle.radius(), 30.0)
         
     def test_modify_radius(self):
         circle = self.sketch.addCircle(0, 10, 20)
-        radius = self.sketch.setRadius(circle.result(), 30)
+        radius_constraint = self.sketch.setRadius(circle.result(), 30)
         model.do()
-        self.sketch.setValue(radius, 20)
+        self.sketch.setValue(radius_constraint, 20)
         model.do()
-        self.assertEqual(circle.radiusData().value(), 20.0)
+        self.assertEqual(circle.radius(), 20.0)
         
 if __name__ == "__main__":
     unittest.main(verbosity=2)
\ No newline at end of file
index c815ab110c230c5f1cabbc8aec775f0228616b40..a3ba89a1eb8a85051e76c01fff2b68ad98a3ac32 100644 (file)
@@ -35,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."""
index 1efd09d1d5a678e59fbd430f0952d308c125a0a8..447e1722433a221114329b97edc307380081c6a3 100644 (file)
@@ -116,7 +116,16 @@ class Sketch(Interface):
         return Circle(circle_feature, *args)
 
     def addArc(self, *args):
-        """Add an arc to the sketch."""
+        """Add an arc to the sketch.
+        
+        :param sequence args: A sequence of arguments that can be:
+        
+           * The center, start and end points
+           * The center, start and end points coordinates
+        :return: arc object
+        :rtype: :class:`model.sketcher.Arc`
+        :raises TypeError: if no argument is provided
+        """
         if not args:
             raise TypeError("No arguments given")
         arc_feature = self._feature.addFeature("SketchArc")
@@ -279,6 +288,7 @@ class Sketch(Interface):
         """Add a mirror transformation of the given objects to the sketch.
         
         This transformation is a constraint.
+        
         :return: interface to the constraint
         :rtype: Mirror object
         """