]> SALOME platform Git repositories - modules/shaper.git/blob - src/PythonAPI/model/sketcher/line.py
Salome HOME
[PythonAPI / sketcher] Update of setRadius test with radius modification
[modules/shaper.git] / src / PythonAPI / model / sketcher / line.py
1 from GeomDataAPI import geomDataAPI_Point2D
2 from model.roots import Interface
3 from model.errors import WrongNumberOfArguments
4
5 class Line(Interface):
6     """Interface for editing of a sketch line feature."""
7     def __init__(self, feature, *args):
8         Interface.__init__(self, feature)
9         assert(self._feature.getKind() == "SketchLine")
10
11         # Initialize attributes
12         self._start_point = geomDataAPI_Point2D(
13             self._feature.data().attribute("StartPoint")
14             )
15         self._end_point = geomDataAPI_Point2D(
16             self._feature.data().attribute("EndPoint")
17             )
18
19         assert(self._start_point)
20         assert(self._end_point)
21
22         if not args:
23             return
24
25         assert(len(args) in (1, 2, 4))
26
27         # Set attribute values and execute
28         if len(args) == 4:
29             self.__createByCoordinates(*args)
30         elif len(args) == 2:
31             self.__createByPoints(*args)
32         elif len(args) == 1:
33             self.__createByName(*args)
34
35         self._execute()
36         pass
37
38     def __createByCoordinates(self, x1, y1, x2, y2):
39         self._start_point.setValue(x1, y1)
40         self._end_point.setValue(x2, y2)
41         pass
42
43     def __createByPoints(self, p1, p2):
44         self._start_point.setValue(p1.x(), p1.y())
45         self._end_point.setValue(p2.x(), p2.y())
46         pass
47
48     def __createByName(self, name):
49         self._feature.data().selection("External").selectSubShape("EDGE", name)
50         pass
51
52     def startPointData(self):
53         return self._start_point
54
55     def endPointData(self):
56         return self._end_point
57
58     def result(self):
59         return self._feature.firstResult()