]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
[PythonAPI] small modifications in sketcher API to follow Daniel's remarks
authorRenaud NEDELEC <renaud.nedelec@opencascade.com>
Mon, 19 Oct 2015 12:16:54 +0000 (14:16 +0200)
committerRenaud NEDELEC <renaud.nedelec@opencascade.com>
Mon, 19 Oct 2015 12:16:54 +0000 (14:16 +0200)
src/PythonAPI/modeler/sketcher/circle.py
src/PythonAPI/modeler/sketcher/line.py
src/PythonAPI/modeler/sketcher/point.py
src/PythonAPI/modeler/sketcher/sketch.py

index 08c890bec05875d4f674fd66f821b0aea238b0d3..56a0e941890eec1a4bc6d1af686e9dbc8e23f219 100644 (file)
@@ -2,11 +2,7 @@
 
 from GeomDataAPI import geomDataAPI_Point2D
 
-def addCircle(sketch, x, y, r):
-    feature = sketch.addFeature("SketchCircle")
-    return CircleInterface(feature, x, y, r)
-
-class CircleInterface():
+class Circle():
     def __init__(self, circle_feature, x, y, r):
         self._feature = circle_feature
         self._center = geomDataAPI_Point2D(
index 543051b29f907979e0e5e2a1755404237625ce74..99d794c9b41c89be968f5874165bb9808f4a6a0c 100644 (file)
@@ -1,11 +1,6 @@
 from GeomDataAPI import geomDataAPI_Point2D
 
-def addLine(sketch, *args):
-    sketch_feature = sketch.addFeature("SketchLine")
-    return LineInterface(sketch_feature, *args)
-    
-    
-class LineInterface():
+class Line():
     """Interface for editing of a sketch line feature."""
     def __init__(self, line_feature, *args):
         self._feature = line_feature
index 2a99aa7a15db826cd4a506d97530c944f48cf8f7..5ba47e784330a1a633eb84bf647a4ebdf09dcc1c 100644 (file)
@@ -2,17 +2,7 @@
 
 from GeomDataAPI import geomDataAPI_Point2D
 
-def addPoint(sketch, x, y):
-    """Add a sketch point feature to the sketch.
-    
-    :return: Interface object on this feature
-    :rtype: sketcher.Point
-    """
-    sketch_point_feature = sketch.addFeature("SketchPoint")
-    return PointInterface(sketch_feature, x, y)
-
-
-class PointInterface():
+class Point():
     """Interface on point feature for data manipulation."""
     def __init__(self, point_feature, x, y):
         self._point_feature = point_feature
index 479bb8c4413ff028b6f55c2d6a078ee76c8d996c..1ec03ca03c7bad6fdbc178d7c303dc3e7b0e812e 100644 (file)
@@ -6,9 +6,9 @@ Copyright (C) 2014-20xx CEA/DEN, EDF R&D
 from ModelAPI    import *
 from GeomDataAPI import *
 from GeomAlgoAPI import *
-import modeler.sketcher.point as sk_point
-import modeler.sketcher.line as sk_line
-import modeler.sketcher.circle as sk_circle
+from modeler.sketcher.point import Point
+from modeler.sketcher.line import Line
+from modeler.sketcher.circle import Circle
 
 def addSketch(doc, plane):
     """Add a Sketch feature to the Part or PartSet and return an interface
@@ -18,7 +18,7 @@ def addSketch(doc, plane):
     it provides an interface for manipulation of the feature data.
     :return: interface on the feature
     :rtype: Sketch object"""
-    feature = featureToCompositeFeature( doc.addFeature("Sketch") )
+    feature = featureToCompositeFeature(doc.addFeature("Sketch"))
     return Sketch(feature, plane)
 
 class Sketch():
@@ -58,14 +58,19 @@ class Sketch():
 # Creation of Geometries
 
     def addPoint (self, *args):
-        """Adds a point to this Sketch."""
-        point_interface = sk_point.addPoint(self._feature, *args)
-        return point_interface
+        """Add a point to this Sketch."""
+        point_feature = self._feature.addFeature("SketchPoint")
+        return Point(point_feature, *args)
 
     def addLine (self, *args):
-        """Adds a line to this Sketch."""
-        line_interface = sk_line.addLine(self._feature, *args)
-        return line_interface
+        """Add a line to this Sketch."""
+        line_feature = self._feature.addFeature("SketchLine")
+        return Line(line_feature, *args)
+    
+    def addCircle (self, *args):
+        """Add a circle to this Sketch."""
+        circle_feature = self._feature.addFeature("SketchCircle")
+        return Circle(circle_feature, *args)
 
     def addPolyline (self, *coords):
         """Adds a poly-line to this Sketch.
@@ -88,23 +93,23 @@ class Sketch():
 
     def addPolygon (self, *coords):
         """Add a polygon to this Sketch.
+        
         The end of consecutive segments are defined as coincident.
         """
         pg = self.addPolyline(*coords)
         # Closing the poly-line supposed being defined by at least 3 points
         c0 = coords[0]
-        cn = coords[len(coords)-1]
+        cn = coords[len(coords) - 1]
         ln = self.addLine(cn, c0)
-        self.setCoincident( pg[len(coords)-2].endPointData(), ln.startPointData() )
-        self.setCoincident( ln.endPointData(), pg[0].startPointData() )
+        self.setCoincident(
+            pg[len(coords) - 2].endPointData(), ln.startPointData()
+            )
+        self.setCoincident(
+            ln.endPointData(), pg[0].startPointData()
+            )
         pg.append(ln)
         return pg
 
-    def addCircle (self, *args):
-        """Adds a circle to this Sketch."""
-        circle_interface = sk_circle.addCircle(self._feature, *args)
-        return circle_interface
-
 
     # Creation of Geometrical and Dimensional Constraints