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 # If no arguments are given the attributes of the feature
24 # Set attribute values and execute
26 self.__createByCoordinates(*args)
28 self.__createByPoints(*args)
30 self.__createByName(*args)
32 raise WrongNumberOfArguments(
33 "Arc takes 1, 2 or 4 arguments (%s given)" % len(args)
37 def __createByCoordinates(self, x1, y1, x2, y2):
38 self.setStartPoint(x1, y1)
39 self.setEndPoint(x2, y2)
41 def __createByPoints(self, p1, p2):
42 self.setStartPoint(p1.x(), p1.y())
43 self.setEndPoint(p2.x(), p2.y())
45 def __createByName(self, name):
46 self._feature.data().selection("External").selectSubShape("EDGE", name)
54 def setStartPoint(self, x, y):
55 """Set the start point of the line."""
56 self._start_point.setValue(x, y)
58 def setEndPoint(self, x, y):
59 """Set the end point of the line."""
60 self._end_point.setValue(x, y)
62 # TODO : methods below will be removed.
63 # Kept until all tests have been updated
64 def startPointData(self):
65 return self._start_point
67 def endPointData(self):
68 return self._end_point
71 return self._feature.firstResult()