]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Merge branch 'python_parametric_api' of https://git.salome-platform.org/git/modules...
authorRenaud NEDELEC <renaud.nedelec@opencascade.com>
Tue, 20 Oct 2015 09:27:06 +0000 (11:27 +0200)
committerRenaud NEDELEC <renaud.nedelec@opencascade.com>
Tue, 20 Oct 2015 09:27:06 +0000 (11:27 +0200)
1  2 
src/PythonAPI/model/sketcher/arc.py
src/PythonAPI/model/sketcher/circle.py
src/PythonAPI/model/sketcher/line.py

index 0000000000000000000000000000000000000000,8e1bb1a503c4d5c9a018dcffba534e05dadc06a9..b025c4636160e0be7ef2ece7c6e1f3a47bec0eb8
mode 000000,100644..100644
--- /dev/null
@@@ -1,0 -1,65 +1,69 @@@
 -    def centerData (self):
+ """Sketch circle feature interface."""
+ from GeomDataAPI import geomDataAPI_Point2D
+ from model.errors import WrongNumberOfArguments
+ class Arc():
++    """Interface for editing a sketch arc feature."""
+     def __init__(self, arc_feature, *args):
+         self._feature = arc_feature
+         self._center = geomDataAPI_Point2D(
+             self._feature.data().attribute("ArcCenter")
+             )
+         self._start_point = geomDataAPI_Point2D(
+             self._feature.data().attribute("ArcStartPoint")
+             )
+         self._end_point = geomDataAPI_Point2D(
+             self._feature.data().attribute("ArcEndPoint")
+             )
+         if len(args) == 6:
+             self.__createByCoordinates(*args)
+         elif len(args) == 3:
+             self.__createByPoints(*args)
+         else:
+             raise WrongNumberOfArguments(
+                 "Arc takes 3 or 6 arguments (%s given)" % len(args)
+                 )
 -    def startPointData (self):
++    def centerData(self):
++        """Return the center point data."""
+         return self._center
+     
 -    def endPointData (self):
++    def startPointData(self):
++        """Return the start point data."""
+         return self._start_point
+     
 -    def result (self):
++    def endPointData(self):
++        """Return the end point data."""
+         return self._end_point
 -    def __createByCoordinates(self, 
 -                         center_x, center_y, 
 -                         start_x, start_y, 
 -                         end_x, end_y):
++    def result(self):
++        """Return the arc circular line attribute."""
+         return self._feature.lastResult()
+     
+     ########
+     #
+     # Private methods
+     #
+     ########
+     
++    def __createByCoordinates(self, center_x, center_y, 
++                              start_x, start_y, 
++                              end_x, end_y):
+         """Create an arc by point coordinates."""
+         self._center.setValue(center_x, center_y)
+         self._start_point.setValue(start_x, start_y)
+         self._end_point.setValue(end_x, end_y)
+         self._feature.execute()
+         
+     def __createByPoints(self, center, start, end):
+         """Create an arc with point objects."""
+         self._center.setValue(center.x(), center.y())
+         self._start_point.setValue(start.x(), start.y())
+         self._end_point.setValue(end.x(), end.y())
+         self._feature.execute()
+         
+         
+         
+         
+         
index 0000000000000000000000000000000000000000,56a0e941890eec1a4bc6d1af686e9dbc8e23f219..a6a0134cb50f3cd6d6654cc9a2408c38e2b56033
mode 000000,100644..100644
--- /dev/null
@@@ -1,0 -1,23 +1,28 @@@
 -    def centerData (self):
+ """Sketch circle feature interface."""
+ from GeomDataAPI import geomDataAPI_Point2D
+ class Circle():
++    """Interface for circle feature data manipulation."""
++
+     def __init__(self, circle_feature, x, y, r):
+         self._feature = circle_feature
+         self._center = geomDataAPI_Point2D(
+             self._feature.data().attribute("CircleCenter")
+             )
+         self._radius = self._feature.data().real("CircleRadius")
+         self._center.setValue(x, y)
+         self._radius.setValue(r)
+         self._feature.execute()
 -    
 -    def radiusData (self):
++    def centerData(self):
++        """Return center data."""
+         return self._center
 -    def result (self):
 -        return self._feature.lastResult()   # Returns the circular line attribute
++
++    def radiusData(self):
++        """Return radius data."""
+         return self._radius
++    def result(self):
++        """Return the cicular line attribute."""
++        return self._feature.lastResult()
index 0000000000000000000000000000000000000000,99d794c9b41c89be968f5874165bb9808f4a6a0c..dfe8a1c93cecd569627772ab391160d108794f3a
mode 000000,100644..100644
--- /dev/null
@@@ -1,0 -1,45 +1,45 @@@
 -        rigid.refattr("ConstraintEntityA").setObject( self._feature.firstResult() )
+ from GeomDataAPI import geomDataAPI_Point2D
+ class Line():
+     """Interface for editing of a sketch line feature."""
+     def __init__(self, line_feature, *args):
+         self._feature = line_feature
+         self._start_point = geomDataAPI_Point2D(
+             self._feature.data().attribute("StartPoint")
+             )
+         self._end_point = geomDataAPI_Point2D(
+             self._feature.data().attribute("EndPoint")
+             )
+         if len(args) == 4:
+             self.__createByCoordinates(*args)
+         elif len(args) == 2:
+             self.__createByPoints(*args)
+         elif len(args) == 1:
+             self.__createByName(sketch, *args)
+         else:
+             raise Exception("cannot create the Line")
+     def __createByCoordinates(self, x1, y1, x2, y2):
+         self._start_point.setValue(x1, y1)
+         self._end_point.setValue(x2, y2)
+         self._feature.execute()
+     def __createByPoints(self, p1, p2):
+         self._start_point.setValue(p1.x(), p1.y())
+         self._end_point.setValue(p2.x(), p2.y())
+         self._feature.execute()
+     def __createByName(self, sketch, name):
+         self._feature.data().selection("External").selectSubShape("EDGE", name)
+         self._feature.execute()
+         rigid = sketch.addFeature("SketchConstraintRigid")
 -    def startPointData (self):
++        rigid.refattr("ConstraintEntityA").setObject(self._feature.firstResult())
 -    def endPointData (self):
++    def startPointData(self):
+         return self._start_point
 -    def result (self):
++    def endPointData(self):
+         return self._end_point
++    def result(self):
+         return self._feature.firstResult()