Salome HOME
Fix Platine test
[modules/shaper.git] / src / PythonAPI / model / sketcher / circle.py
1 """Sketch circle feature interface."""
2
3 from GeomDataAPI import geomDataAPI_Point2D
4 from model.roots import Interface
5
6 class Circle(Interface):
7     """Interface for circle feature data manipulation."""
8     def __init__(self, feature, *args):
9         Interface.__init__(self, feature)
10         assert(self._feature.getKind() == "SketchCircle")
11         
12         self._center = geomDataAPI_Point2D(
13             self._feature.data().attribute("CircleCenter")
14             )
15         self._radius = self._feature.data().real("CircleRadius")
16         
17         if not args:
18             return
19         
20         if len(args) != 3:
21             raise TypeError(
22                 "Invalid number of arguments, 3 arguments needed  (%s given)" 
23                 % len(args)
24                 )
25         
26         self.setCenter(args[0], args[1])
27         self.setRadius(args[2])
28         self.execute()
29
30     def setCenter(self, x, y):
31         """Set the center of the circle."""
32         self._center.setValue(x, y)
33         
34     def setRadius(self, radius):
35         """Set the radius of the circle."""
36         self._radius.setValue(radius)
37         
38     def center(self):
39         """Return the center attribute of the circle."""
40         return self._center
41
42     def radius(self):
43         """Return the radius value.
44         
45         :return: radius
46         :rtype: double
47         """
48         return self._radius.value()
49
50     def result(self):
51         """Return the cicular line attribute."""
52         return self._feature.lastResult()