1 from GeomDataAPI import geomDataAPI_Point2D
2 from model.roots import Interface
3 from model.errors import WrongNumberOfArguments
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")
11 # Initialize attributes
12 self._start_point = geomDataAPI_Point2D(
13 self._feature.data().attribute("StartPoint")
15 self._end_point = geomDataAPI_Point2D(
16 self._feature.data().attribute("EndPoint")
19 assert(self._start_point)
20 assert(self._end_point)
25 assert(len(args) in (1, 2, 4))
27 # Set attribute values and execute
29 self.__createByCoordinates(*args)
31 self.__createByPoints(*args)
33 self.__createByName(*args)
38 def __createByCoordinates(self, x1, y1, x2, y2):
39 self._start_point.setValue(x1, y1)
40 self._end_point.setValue(x2, y2)
43 def __createByPoints(self, p1, p2):
44 self._start_point.setValue(p1.x(), p1.y())
45 self._end_point.setValue(p2.x(), p2.y())
48 def __createByName(self, name):
49 self._feature.data().selection("External").selectSubShape("EDGE", name)
52 def startPointData(self):
53 return self._start_point
55 def endPointData(self):
56 return self._end_point
59 return self._feature.firstResult()