1 from GeomDataAPI import geomDataAPI_Point2D
2 from model.roots import Interface
3 from model.errors import WrongNumberOfArguments
5 from .entity import Entity
8 """Interface for editing of a sketch line feature."""
9 def __init__(self, feature, *args):
10 Entity.__init__(self, feature)
11 assert(self._feature.getKind() == "SketchLine")
13 # Initialize attributes
14 self._start_point = geomDataAPI_Point2D(
15 self._feature.data().attribute("StartPoint")
17 self._end_point = geomDataAPI_Point2D(
18 self._feature.data().attribute("EndPoint")
21 # If no arguments are given the attributes of the feature
26 # Set attribute values and execute
28 self.__createByCoordinates(*args)
30 self.__createByPoints(*args)
32 self.__createByName(*args)
34 raise WrongNumberOfArguments(
35 "Arc takes 1, 2 or 4 arguments (%s given)" % len(args)
39 def __createByCoordinates(self, x1, y1, x2, y2):
40 self.setStartPoint(x1, y1)
41 self.setEndPoint(x2, y2)
43 def __createByPoints(self, p1, p2):
44 self.setStartPoint(p1.x(), p1.y())
45 self.setEndPoint(p2.x(), p2.y())
47 def __createByName(self, name):
48 self._feature.data().selection("External").selectSubShape("EDGE", name)
56 def setStartPoint(self, x, y):
57 """Set the start point of the line."""
58 self._start_point.setValue(x, y)
60 def setEndPoint(self, x, y):
61 """Set the end point of the line."""
62 self._end_point.setValue(x, y)
64 # TODO : methods below will be removed.
65 # Kept until all tests have been updated
66 def startPointData(self):
67 return self._start_point
69 def endPointData(self):
70 return self._end_point
73 return self._feature.firstResult()