]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Issue #2044: Error detection in the parametric API
authordbv <dbv@opencascade.com>
Wed, 29 Mar 2017 13:35:11 +0000 (16:35 +0300)
committerdbv <dbv@opencascade.com>
Wed, 29 Mar 2017 13:35:38 +0000 (16:35 +0300)
Set attribute invalid flag when selection with bad name passed.

src/Model/Model_AttributeSelection.cpp
src/ModelHighAPI/ModelHighAPI_Selection.cpp
src/PythonAPI/CMakeLists.txt
src/PythonAPI/Test/Test2044.py [new file with mode: 0644]

index 9ebc852596933efb58c8747649f55e09410b5e9e..d6c3cf17c55afe2468a03ac9001b3f2e519e11f0 100644 (file)
@@ -664,6 +664,9 @@ void Model_AttributeSelection::selectSubShape(
     }
     setValue(aCont, aShapeToBeSelected);
   }
+
+  setInvalidIfFalse(selectionLabel(), false);
+  reset();
 }
 
 int Model_AttributeSelection::Id()
index e446cff41b16ea33f764baf76007f2fb14d22a2b..61becae78807cf04e4cfc4d4c325fe667baf79e2 100644 (file)
@@ -12,6 +12,7 @@
 #include <ModelAPI_AttributeIntArray.h>
 #include <ModelAPI_AttributeSelection.h>
 #include <ModelAPI_AttributeSelectionList.h>
+#include <ModelAPI_Feature.h>
 #include <ModelAPI_ResultCompSolid.h>
 //--------------------------------------------------------------------------------------
 
@@ -50,6 +51,11 @@ void ModelHighAPI_Selection::fillAttribute(
       return;
     case VT_TypeSubShapeNamePair:
       theAttribute->selectSubShape(myTypeSubShapeNamePair.first, myTypeSubShapeNamePair.second);
+      if(theAttribute->isInvalid()) {
+        FeaturePtr aFeature = ModelAPI_Feature::feature(theAttribute->owner());
+        aFeature->setError(
+          std::string("Error: attribute \"") + theAttribute->id() + std::string("\" is invalid."));
+      }
       return;
   }
 }
index f68c872585210383296496a7122f21bb1a9d8a86..109e19e3bf57313bd1bd0d1f0a537d79406e3dc8 100644 (file)
@@ -33,10 +33,12 @@ ADD_UNIT_TESTS(
   TestFeatures.py
   TestFeaturesExtrusion.py
   #TestFeaturesRevolution.py
-  
+
   TestPrimitivesBox.py
 
   TestMakeBrick1.py
   TestMakeBrick2.py
   TestPlatine.py
+
+  Test2044.py
   )
diff --git a/src/PythonAPI/Test/Test2044.py b/src/PythonAPI/Test/Test2044.py
new file mode 100644 (file)
index 0000000..1d8442d
--- /dev/null
@@ -0,0 +1,22 @@
+from salome.shaper import model
+
+model.begin()
+partSet = model.moduleDocument()
+Part_1 = model.addPart(partSet)
+Part_1_doc = Part_1.document()
+Sketch_1 = model.addSketch(Part_1_doc, model.defaultPlane("XOY"))
+SketchLine_1 = Sketch_1.addLine(-184.375, -81.25, -71.87500000000006, 206.2500000000001)
+SketchLine_2 = Sketch_1.addLine(-71.87500000000006, 206.2500000000001, 281.2500000000001, 178.125)
+SketchConstraintCoincidence_1 = Sketch_1.setCoincident(SketchLine_1.endPoint(), SketchLine_2.startPoint())
+SketchLine_3 = Sketch_1.addLine(281.2500000000001, 178.125, 184.3750000000001, -109.375)
+SketchConstraintCoincidence_2 = Sketch_1.setCoincident(SketchLine_2.endPoint(), SketchLine_3.startPoint())
+SketchLine_4 = Sketch_1.addLine(184.3750000000001, -109.375, -184.375, -81.25)
+SketchConstraintCoincidence_3 = Sketch_1.setCoincident(SketchLine_3.endPoint(), SketchLine_4.startPoint())
+SketchConstraintCoincidence_4 = Sketch_1.setCoincident(SketchLine_1.startPoint(), SketchLine_4.endPoint())
+model.do()
+Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("WIRE", "Sketch_1/Wire-SketchLine_1r-SketchLine_2r-SketchLine_3r-SketchLine_4r")], model.selection("EDGE", "PartSet/OZ"), 50, 0)
+model.do()
+Extrusion_1.setDirection(model.selection("EDGE", "OX"))
+model.do()
+print Extrusion_1.feature().error()
+model.end()