Salome HOME
Add construction plugin without tests.
[modules/shaper.git] / src / PythonAPI / model / sketcher / point.py
1 """Sketch point feature interface."""
2
3 from GeomDataAPI import geomDataAPI_Point2D
4 from model.roots import Interface
5 from model.errors import FeatureInputInvalid
6
7 class Point(Interface):
8     """Interface on point feature for data manipulation."""
9     def __init__(self, feature, x, y):
10         Interface.__init__(self, feature)
11         assert(self._feature.getKind() == "SketchPoint")
12         
13         # Initialize attributes of the feature
14         self._point_data = geomDataAPI_Point2D(
15             self._feature.data().attribute("PointCoordinates")
16             )
17         self._point_data.setValue(x, y)
18         
19         # Control input and execute
20         if self.areInputValid():
21             self.execute()
22         else:
23             raise FeatureInputInvalid(
24                 "cannot create the Sketch Point, the input is invalid"
25                 )
26
27     def pointData (self):
28         """Return the point data."""
29         return self._point_data
30
31     def result (self):
32         """Return the feature result."""
33         return self._point_feature.firstResult()