Salome HOME
Fix Platine test
[modules/shaper.git] / src / PythonAPI / model / sketcher / line.py
index eb8d735e022f00ad7c554f5d49323c966ae23d2c..128e7b3c80f367b8a9b279081915ca5eeb186e71 100644 (file)
@@ -2,10 +2,12 @@ from GeomDataAPI import geomDataAPI_Point2D
 from model.roots import Interface
 from model.errors import WrongNumberOfArguments
 
-class Line(Interface):
+from .entity import Entity
+
+class Line(Entity):
     """Interface for editing of a sketch line feature."""
     def __init__(self, feature, *args):
-        Interface.__init__(self, feature)
+        Entity.__init__(self, feature)
         assert(self._feature.getKind() == "SketchLine")
 
         # Initialize attributes
@@ -15,13 +17,13 @@ class Line(Interface):
         self._end_point = geomDataAPI_Point2D(
             self._feature.data().attribute("EndPoint")
             )
+        self._external = self._feature.selection("External")
 
-        # Check that input arguments are not None
+        # If no arguments are given the attributes of the feature
+        # are'nt initialized
         if args is None:
-            raise WrongNumberOfArguments(
-                "No argument given, at least one argument needed"
-                )
-        
+            return
+
         # Set attribute values and execute
         if len(args) == 4:
             self.__createByCoordinates(*args)
@@ -33,7 +35,7 @@ class Line(Interface):
             raise WrongNumberOfArguments(
                 "Arc takes 1, 2 or 4 arguments (%s given)" % len(args)
                 )
-        self._execute()
+        self.execute()
 
     def __createByCoordinates(self, x1, y1, x2, y2):
         self.setStartPoint(x1, y1)
@@ -44,29 +46,33 @@ class Line(Interface):
         self.setEndPoint(p2.x(), p2.y())
 
     def __createByName(self, name):
-        self._feature.data().selection("External").selectSubShape("EDGE", name)
-    
+        self.setExternal(name)
+
     #######
     #
     # Set methods
     #
     #######
-    
+
     def setStartPoint(self, x, y):
         """Set the start point of the line."""
         self._start_point.setValue(x, y)
-        
+
     def setEndPoint(self, x, y):
         """Set the end point of the line."""
         self._end_point.setValue(x, y)
 
-    # TODO : methods below will be removed. 
-    # Kept until all tests have been updated
-    def startPointData(self):
+    # TODO : methods below will be removed.
+    # Kept until all tests have been updated
+    def startPoint(self):
         return self._start_point
 
-    def endPointData(self):
+    def endPoint(self):
         return self._end_point
 
+    def setExternal(self, name):
+        """Set external edge"""
+        self._external.selectSubShape("EDGE", name)
+
     def result(self):
         return self._feature.firstResult()