]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Improve style and structure of many features.
authorspo <sergey.pokhodenko@opencascade.com>
Fri, 30 Oct 2015 14:26:33 +0000 (17:26 +0300)
committerspo <sergey.pokhodenko@opencascade.com>
Fri, 30 Oct 2015 14:26:33 +0000 (17:26 +0300)
21 files changed:
src/PythonAPI/model/construction/axis.py
src/PythonAPI/model/construction/plane.py
src/PythonAPI/model/construction/point.py
src/PythonAPI/model/exchange/exchange.py
src/PythonAPI/model/features/boolean.py
src/PythonAPI/model/features/extrusion.py
src/PythonAPI/model/features/extrusion_boolean.py
src/PythonAPI/model/features/extrusion_sketch.py
src/PythonAPI/model/features/group.py
src/PythonAPI/model/features/partition.py
src/PythonAPI/model/features/placement.py
src/PythonAPI/model/features/revolution.py
src/PythonAPI/model/features/revolution_boolean.py
src/PythonAPI/model/features/revolution_sketch.py
src/PythonAPI/model/features/roots.py
src/PythonAPI/model/features/rotation.py
src/PythonAPI/model/features/translation.py
src/PythonAPI/model/parameter/parameter.py
src/PythonAPI/model/partset/part.py
src/PythonAPI/model/sketcher/arc.py
src/PythonAPI/model/sketcher/sketch.py

index 6bbaea87fcecf5577437fdccd01a172556aca822..9152310b67983954f1d6b9dde91cefb3002c2a14 100644 (file)
@@ -47,11 +47,13 @@ class Axis(Interface):
         if not args:
             return
 
-        assert(len(args) == 2 or len(args) == 1)
+        assert(len(args) in (1, 2))
         if len(args) == 2:
             self.setPoints(*args)
         elif len(args) == 1:
             self.setCylindricalFace(*args)
+
+        self._execute()
         pass
 
     def __clear(self):
index f98c57b3eabfe6882ab7f7bf9e667ce54c309ce1..0da5060062117d000ded87528d8096a2ff2097e9 100644 (file)
@@ -53,11 +53,13 @@ class Plane(Interface):
         if not args:
             return
 
-        assert(len(args) == 2 or len(args) == 4)
+        assert(len(args) in (2, 4))
         if len(args) == 2:
             self.setFaceAndDistance(*args)
         elif len(args) == 4:
             self.setGeneralEquation(*args)
+
+        self._execute()
         pass
 
     def __clear(self):
index c3c649784ec516c3fe4c31b599cb2737f3f58edc..fa81fcf1f3042200462d4d43859b3e95d606a1c8 100644 (file)
@@ -41,7 +41,10 @@ class Point(Interface):
         if not args:
             return
 
+        assert(len(args) == 3)
         self.setPoint(*args)
+
+        self._execute()
         pass
 
     def setPoint(self, x, y, z):
index fdeaa4ccab7e60a35dc8ef312527d36a61c4e816..375c6fd01a212b3ab81c271f9bd7eb3184ebd0fd 100644 (file)
@@ -38,7 +38,9 @@ class Import(Interface):
             return
 
         assert(len(args) == 1)
-        self.setFilePath(*args)
+        self.setFilePath(args[0])
+
+        self._execute()
         pass
 
     def setFilePath(self, file_path):
@@ -91,6 +93,8 @@ class Export(Interface):
         self.setFilePath(args[0])
         self.setFileFormat(args[1])
         self.setObjects(args[2])
+
+        self._execute()
         pass
 
     def setFilePath(self, file_path):
index ce04f2f31435ef650dae9e991592b2203d64b5fa..78cfbefb81fdb9afed0b0045e47d0f1ba93c1617 100644 (file)
@@ -36,7 +36,7 @@ def addIntersection(part, object, tool):
 
 class Boolean(Interface):
     """Abstract root class of Boolean Features."""
-    def __init__(self, feature, main_objects, tool_objects, bool_type):
+    def __init__(self, feature, *args):
         Interface.__init__(self, feature)
         assert(self._feature.getKind() == "Boolean")
 
@@ -48,9 +48,17 @@ class Boolean(Interface):
         assert(self._tool_objects)
         assert(self._bool_type)
 
+        if not args:
+            return
+
+        assert(len(args) == 3)
+        main_objects, tool_objects, bool_type = args
+
         self.setMainObjects(main_objects)
         self.setToolObjects(tool_objects)
         self.setBoolType(bool_type)
+
+        self._execute()
         pass
 
     def setMainObjects(self, main_objects):
index 2e0390813ba02ccd29cdbc4371e970fe6a0da5fd..0f1cbea8341df448cd2e503c94598d843d66e81e 100644 (file)
@@ -64,10 +64,11 @@ class Extrusion(Interface):
         if not args:
             return
 
-        self.setBase(args[0])
-
+        assert(len(args) in (2, 3, 5))
+        base = args[0]
         args = args[1:]
-        assert(len(args) in (1, 2, 4))
+
+        self.setBase(base)
 
         if len(args) == 4:
             self.setPlanesAndOffsets(*args)
index a5b3f8804ff58b08f2804820d0cb6e3de82d57fd..f7e168fdef15b5fc716fd55a79d1b7377bed0a57 100644 (file)
@@ -28,7 +28,8 @@ def addExtrusionFuse(part, *args):
 class ExtrusionBoolean(CompositeBoolean):
 
     def __init__(self, feature, *args):
-        CompositeBoolean.__init__(self, feature, *args)
+        CompositeBoolean.__init__(self, feature, *args[:3])
+        args = args[3:]
 
         self._CreationMethod = self._feature.string("CreationMethod")
         self._to_size = self._feature.data().real("to_size")
@@ -49,11 +50,13 @@ class ExtrusionBoolean(CompositeBoolean):
         if not args:
             return
 
-        assert(len(args) == 4 or len(args) == 2)
+        assert(len(args) in (2, 4))
         if len(args) == 4:
             self.setPlanesAndOffsets(*args)
         elif len(args) == 2:
             self.setSizes(*args)
+
+        self._execute()
         pass
 
     def __clear(self):
index dd161f367abc0cbbd019d26e29fd9253b24f0cfa..bf8ae8fe1fbd6451a2ce6b46443e4a4738ce6de2 100644 (file)
@@ -19,7 +19,8 @@ def addExtrusionSketch(part, *args):
 class ExtrusionSketch(CompositeSketch):
 
     def __init__(self, feature, *args):
-        CompositeSketch.__init__(self, feature, *args)
+        CompositeSketch.__init__(self, feature, *args[:2])
+        args = args[2:]
 
         self._CreationMethod = self._feature.string("CreationMethod")
         self._to_size = self._feature.data().real("to_size")
@@ -40,11 +41,13 @@ class ExtrusionSketch(CompositeSketch):
         if not args:
             return
 
-        assert(len(args) == 4 or len(args) == 2)
+        assert(len(args) in (2, 4))
         if len(args) == 4:
             self.setPlanesAndOffsets(*args)
         elif len(args) == 2:
             self.setSizes(*args)
+
+        self._execute()
         pass
 
     def __clear(self):
index a9fbfbe76ea08883aedfe40e3a5deee715c5ab16..e6a7602ac8f639c839598cd30732617fb8894f97 100644 (file)
@@ -26,8 +26,13 @@ class Group(Interface):
 
         assert(self._group_list)
 
+        if not args:
+            return
+
         assert(len(args) == 1)
         self.setGroupList(args[0])
+
+        self._execute()
         pass
 
     def setGroupList(self, main_objects):
index 6fa638d7a84c49ca56793d8b37cfad9d04c2abea..f1064152cd2fbc85a37d2a97cdcb7c6656e4876a 100644 (file)
@@ -19,8 +19,7 @@ def addPartition(part, *args):
 class Partition(Interface):
     """Interface on an Partition feature."""
 
-    def __init__(self, feature, main_objects=None,
-                 tool_objects=None, partition_combine=None):
+    def __init__(self, feature, *args):
         """Initialize an Partition feature with given parameters.
 
         Expected arguments:
@@ -42,12 +41,17 @@ class Partition(Interface):
         assert(self._tool_objects)
         assert(self._partition_combine)
 
-        if main_objects is None:
+        if not args:
             return
 
-        self._fill_attribute(self._main_objects, main_objects)
-        self._fill_attribute(self._tool_objects, tool_objects)
-        self._fill_attribute(self._partition_combine, partition_combine)
+        assert(len(args) == 3)
+        main_objects, tool_objects, partition_combine = args
+
+        self.setMainObjects(main_objects)
+        self.setToolObjects(tool_objects)
+        self.setPartitionCombine(partition_combine)
+
+        self._execute()
         pass
 
     def setMainObjects(self, main_objects):
index 78f2bf9ec42edad74e554961d724bc2e0f8b55c8..ab8ac046fa93553cae5a64867e27c10b62a4f662 100644 (file)
@@ -34,12 +34,17 @@ class Placement(Interface):
         assert(self._reverse_direction)
         assert(self._centering)
 
+        if not args:
+            return
+
         assert(len(args) == 5)
         self.setObjectList(args[0])
         self.setStartShape(args[1])
         self.setEndShape(args[2])
         self.setReverseDirection(args[3])
         self.setCentering(args[4])
+
+        self._execute()
         pass
 
     def setObjectList(self, objects_list):
index c2eaaae58d29eadb3b44d5dc86774723c630b424..6b0fdd21a0474bc6e27414587c0200b35f0e46b7 100644 (file)
@@ -19,7 +19,7 @@ def addRevolution(part, *args):
 class Revolution(Interface):
     """Interface on an Revolution feature."""
 
-    def __init__(self, feature, base=None, axis_object=None, *args):
+    def __init__(self, feature, *args):
         """Initialize an Revolution feature with given parameters.
 
         Expected arguments for all modes:
@@ -63,29 +63,23 @@ class Revolution(Interface):
         assert(self._from_object)
         assert(self._from_offset)
 
-        if base is None:
+        if not args:
             return
 
-        self.__setBase(base)
-        self.__setAxisObject(axis_object)
+        assert(len(args) in (4, 6))
+
+        base, axis_object = args[:2]
+        args = args[2:]
+
+        self.setBase(base)
+        self.setAxisObject(axis_object)
 
         if len(args) == 4:
-            self.__createByPlanesAndOffsets(*args)
+            self.setPlanesAndOffsets(*args)
         elif len(args) == 2:
-            self.__createByAngles(*args)
-        else:
-            raise AssertionError(
-                "Revolution takes 5 or 7 arguments (%s given)" %
-                (len(args) + 3)
-                )
-        pass
+            self.setAngles(*args)
 
-    def __setBase(self, base):
-        self._fill_attribute(self._base, base)
-        pass
-
-    def __setAxisObject(self, axis_object):
-        self._fill_attribute(self._axis_object, axis_object)
+        self._execute()
         pass
 
     def __clear(self):
@@ -98,29 +92,12 @@ class Revolution(Interface):
         self._fill_attribute(self._from_offset, 0)
         pass
 
-    def __createByAngles(self, to_angle, from_angle):
-        self.__clear()
-        self._CreationMethod.setValue("ByAngles")
-        self._fill_attribute(self._to_angle, to_angle)
-        self._fill_attribute(self._from_angle, from_angle)
-        pass
-
-    def __createByPlanesAndOffsets(self, to_object, to_offset,
-                                   from_object, from_offset):
-        self.__clear()
-        self._CreationMethod.setValue("ByPlanesAndOffsets")
-        self._fill_attribute(self._to_object, to_object)
-        self._fill_attribute(self._to_offset, to_offset)
-        self._fill_attribute(self._from_object, from_object)
-        self._fill_attribute(self._from_offset, from_offset)
-        pass
-
     def setBase(self, base):
         """Modify base attribute of the feature.
 
         See __init__.
         """
-        self.__setBase(base)
+        self._fill_attribute(self._base, base)
         pass
 
     def setAxisObject(self, axis_object):
@@ -128,21 +105,30 @@ class Revolution(Interface):
 
         See __init__.
         """
-        self.__setAxisObject(axis_object)
+        self._fill_attribute(self._axis_object, axis_object)
         pass
 
-    def setAngles(self, *args):
+    def setAngles(self, to_angle, from_angle):
         """Modify the to_angle, from_angle attributes of the feature.
 
         See __init__.
         """
-        self.__createByAngles(*args)
+        self.__clear()
+        self._CreationMethod.setValue("ByAngles")
+        self._fill_attribute(self._to_angle, to_angle)
+        self._fill_attribute(self._from_angle, from_angle)
         pass
 
-    def setPlanesAndOffsets(self, *args):
+    def setPlanesAndOffsets(self, to_object, to_offset,
+                            from_object, from_offset):
         """Modify planes and offsets attributes of the feature.
 
         See __init__.
         """
-        self.__createByPlanesAndOffsets(*args)
+        self.__clear()
+        self._CreationMethod.setValue("ByPlanesAndOffsets")
+        self._fill_attribute(self._to_object, to_object)
+        self._fill_attribute(self._to_offset, to_offset)
+        self._fill_attribute(self._from_object, from_object)
+        self._fill_attribute(self._from_offset, from_offset)
         pass
index 3dd8ef7df6b4a985469fb49520d8e8edee61ef9a..d93b9f034f66c05b5fe3240eaa99b711b310186f 100644 (file)
@@ -28,7 +28,8 @@ def addRevolutionFuse(part, *args):
 class RevolutionBoolean(CompositeBoolean):
 
     def __init__(self, feature, *args):
-        CompositeBoolean.__init__(self, feature, *args)
+        CompositeBoolean.__init__(self, feature, *args[:3])
+        args = args[3:]
 
         self._axis_object = self._feature.data().selection("axis_object")
         self._CreationMethod = self._feature.string("CreationMethod")
@@ -51,12 +52,18 @@ class RevolutionBoolean(CompositeBoolean):
         if not args:
             return
 
-        self.setAxisObject(args[0])
+        assert(len(args) in (3, 5))
+        axis_object = args[0]
+        args = args[1:]
+
+        self.setAxisObject(axis_object)
 
         if len(args) == 4:
-            self.setPlanesAndOffsets(*args[1:])
+            self.setPlanesAndOffsets(*args)
         elif len(args) == 2:
-            self.setAngles(*args[1:])
+            self.setAngles(*args)
+
+        self._execute()
         pass
 
     def __clear(self):
index 95de94dd36bf19f9a0ef376827d9d06f20873bc5..20d896e74a4c394e87faceb4463f0deac5b18979 100644 (file)
@@ -19,7 +19,8 @@ def addRevolutionSketch(part, *args):
 class RevolutionSketch(CompositeSketch):
 
     def __init__(self, feature, *args):
-        CompositeSketch.__init__(self, feature, *args)
+        CompositeSketch.__init__(self, feature, *args[:2])
+        args = args[2:]
 
         self._axis_object = self._feature.data().selection("axis_object")
         self._CreationMethod = self._feature.string("CreationMethod")
@@ -42,12 +43,18 @@ class RevolutionSketch(CompositeSketch):
         if not args:
             return
 
-        self.setAxisObject(args[0])
+        assert(len(args) in (3, 5))
+        axis_object = args[0]
+        args = args[1:]
+
+        self.setAxisObject(axis_object)
 
         if len(args) == 4:
-            self.setPlanesAndOffsets(*args[1:])
+            self.setPlanesAndOffsets(*args)
         elif len(args) == 2:
-            self.setAngles(*args[1:])
+            self.setAngles(*args)
+
+        self._execute()
         pass
 
     def __clear(self):
index ab7ac3e32afc94b49d0a44d6fccaca6780cf1dbd..a69cdd7349f65f49b8ebc9be76b59c9d71bc5058 100644 (file)
@@ -1,5 +1,4 @@
 
-
 from model.roots import Interface
 
 
@@ -12,9 +11,34 @@ class CompositeBoolean(Interface):
         self._sketch_selection = self._feature.selection("sketch_selection")
         self._boolean_objects = self._feature.selectionList("boolean_objects")
 
+        assert(self._sketch)
+        assert(self._sketch_selection)
+        assert(self._boolean_objects)
+
         if not args:
             return
 
+        assert(len(args) == 3)
+        sketch, sketch_selection, boolean_objects = args
+
+        self.setSketch(sketch)
+        self.setSketchSelection(sketch_selection)
+        self.setBooleanObjects(boolean_objects)
+        pass
+
+    def setSketch(self, sketch):
+        self._fill_attribute(self._sketch, sketch)
+        pass
+
+    def setSketchSelection(self, sketch_selection):
+        self._fill_attribute(self._sketch_selection, sketch_selection)
+        pass
+
+    def setBooleanObjects(self, boolean_objects):
+        self._fill_attribute(self._boolean_objects, boolean_objects)
+        pass
+
+
 class CompositeSketch(Interface):
 
     def __init__(self, feature, *args):
@@ -23,5 +47,23 @@ class CompositeSketch(Interface):
         self._sketch = self._feature.reference("sketch")
         self._sketch_selection = self._feature.selection("sketch_selection")
 
+        assert(self._sketch)
+        assert(self._sketch_selection)
+
         if not args:
             return
+
+        assert(len(args) == 2)
+        sketch, sketch_selection = args
+
+        self.setSketch(sketch)
+        self.setSketchSelection(sketch_selection)
+        pass
+
+    def setSketch(self, sketch):
+        self._fill_attribute(self._sketch, sketch)
+        pass
+
+    def setSketchSelection(self, sketch_selection):
+        self._fill_attribute(self._sketch_selection, sketch_selection)
+        pass
index bbec2c31e16eae18bf41d9d38270e42cbb575bce..3318cd16bdb1b16520243d64dcaf3af55526d36b 100644 (file)
@@ -30,10 +30,15 @@ class Rotation(Interface):
         assert(self._axis_object)
         assert(self._angle)
 
+        if not args:
+            return
+
         assert(len(args) == 3)
         self.setMainObjects(args[0])
         self.setAxisObject(args[1])
         self.setAngle(args[2])
+
+        self._execute()
         pass
 
     def setMainObjects(self, main_objects):
index 0260c643da2e2309903234dca0460e034745b24f..1004b8ea61b1892fa184d26d7cf0cb814a46695a 100644 (file)
@@ -30,10 +30,15 @@ class Translation(Interface):
         assert(self._axis_object)
         assert(self._distance)
 
+        if not args:
+            return
+
         assert(len(args) == 3)
         self.setMainObjects(args[0])
         self.setAxisObject(args[1])
         self.setDistance(args[2])
+
+        self._execute()
         pass
 
     def setMainObjects(self, main_objects):
index 377992d7c9c2c5213156eab076afe8fa90ccc5b9..51c9024fd3707415119c035cdc0350cb6f786710 100644 (file)
@@ -43,6 +43,8 @@ class Parameter(Interface):
         assert(len(args) == 2)
         self.setName(args[0])
         self.setExpression(args[1])
+
+        self._execute()
         pass
 
     def setName(self, name):
index 50eb352b9ecf56580d906f2b757daf472ffb4939..e916975ff765f0dd73608ffd9ae836a594736fe5 100644 (file)
@@ -34,6 +34,8 @@ class Part(Interface):
         """Adds a new Part to the given Partset and activates the Part."""
         Interface.__init__(self, feature)
         assert(self._feature.getKind() == "Part")
+
+        self._execute()
         pass
 
     def document(self):
index e4d12e3bae84fe89ea70c97da5cfd239ce36447c..d685befe4d015455498986a5c5b1a669f95f1b08 100644 (file)
@@ -9,7 +9,7 @@ class Arc(Interface):
     def __init__(self, feature, *args):
         Interface.__init__(self, feature)
         assert(self._feature.getKind() == "SketchArc")
-        
+
         self._center = geomDataAPI_Point2D(
             self._feature.data().attribute("ArcCenter")
             )
@@ -31,11 +31,11 @@ class Arc(Interface):
     def centerData(self):
         """Return the center point data."""
         return self._center
-    
+
     def startPointData(self):
         """Return the start point data."""
         return self._start_point
-    
+
     def endPointData(self):
         """Return the end point data."""
         return self._end_point
@@ -43,30 +43,25 @@ class Arc(Interface):
     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, 
+
+    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 f8e162c9b69dcf06a16c524d015f5abcb4ae8da3..58b582d4d694656ba1d8e8f6abad49aec7ff75e2 100644 (file)
@@ -67,6 +67,7 @@ class Sketch(Interface):
             self.__sketchOnFace(plane)
         else:
             self.__sketchOnPlane(plane)
+        pass
 
     def __sketchOnPlane(self, plane):
         """Create the sketch on a plane."""