Salome HOME
Make model.end() in unit-tests set current feature to the last feature of the active...
authormpv <mpv@opencascade.com>
Wed, 16 Jan 2019 08:22:23 +0000 (11:22 +0300)
committermpv <mpv@opencascade.com>
Wed, 16 Jan 2019 08:22:23 +0000 (11:22 +0300)
src/ModelAPI/Test/Test2401.py
src/ModelAPI/Test/TestFeatureSelection_2.py
src/ModelAPI/Test/TestSelectionScope.py
src/ModelHighAPI/ModelHighAPI_Services.cpp
src/SketchPlugin/Test/Test2654.py

index 80869d143098ce66184482025a677362dda7eeb7..e5b4456c5efb8d4b61f8cbf93418eaa7a34d6325 100644 (file)
@@ -77,8 +77,6 @@ model.do()
 SketchLine_8 = Sketch_1.addLine(0, 3, 8, 3)
 SketchConstraintCoincidence_9 = Sketch_1.setCoincident(SketchLine_1.endPoint(), SketchLine_8.startPoint())
 SketchConstraintCoincidence_10 = Sketch_1.setCoincident(SketchLine_4.endPoint(), SketchLine_8.endPoint())
-model.do()
-Part_1_doc.setCurrentFeature(Fill_1.feature(), True)
 model.end()
 
 # check that the plane is located as previously
index e1d41a397a10728d431e86842dc411c2282e9a73..b9a47dd3a480896d37e883a3dc4d1e37c679fa03 100644 (file)
@@ -56,9 +56,6 @@ model.do()
 
 # update the parameter N => number of sketch contours is changed
 Param_N.setValue(4)
-Part_1_doc.setCurrentFeature(None, True)
-model.do()
-Part_1_doc.setCurrentFeature(Cut_1.feature(), True)
 model.end()
 
 assert(Cut_1.result().numberOfSubs() == 4)
index f8a754dc8038c712f71aba880eab5f63d8e7bf4d..b11a40e30a6d9950171944ec2bb99f9578f50ba5 100644 (file)
@@ -71,7 +71,6 @@ Cylinder_2 = model.addCylinder(Part_1_doc, model.selection("VERTEX", "[Extrusion
 model.do()
 # make sketch_2 cut the whole top face of the initial extrusion, so, one of the cylinder becomes invalid
 lenParam.setValue(100)
-Part_1_doc.setCurrentFeature(Cylinder_2.feature(), True)
 model.do()
 # update selection of cylinder base points
 model.selection("VERTEX", "[ExtrusionCut_1_1/Modified_Face&Sketch_1/SketchLine_1][Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_2][(ExtrusionCut_1_1/Modified_Face&Sketch_1/SketchLine_1)(Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_2)(ExtrusionCut_1_1/Generated_Face&Sketch_2/SketchLine_6)(ExtrusionCut_1_1/Modified_Face&Sketch_1/SketchLine_3)]").fillAttribute(Cylinder_1.basePoint())
index 20e21e1b47af7ba811e9af87fef05d29f14981bc..443b861ad9a99ebc3f25fd8d5174452691570cc6 100644 (file)
@@ -103,6 +103,15 @@ void begin()
 
 void end()
 {
+  // some operations make the current feature not the last one (like "galeries" change parameters)
+  DocumentPtr anActive = ModelAPI_Session::get()->activeDocument();
+  int aSize = anActive->size("Features");
+  if (aSize > 0) {
+    FeaturePtr aLastFeat =
+      std::dynamic_pointer_cast<ModelAPI_Feature>(anActive->object("Features", aSize - 1));
+    anActive->setCurrentFeature(aLastFeat, true);
+  }
+
   ModelAPI_Session::get()->finishOperation();
   // to update data tree in the end of dumped script execution
   ModelAPI_EventCreator::get()->sendReordered(FeaturePtr());
index f78931992358f506b5a7b1a570838788eda7f0cb..540142fd0e0b97617eae4240007a8f0c3284006b 100644 (file)
@@ -178,9 +178,6 @@ assert(Split_1.feature().error() != "")
 Part_1_doc.removeFeature(Split_1.feature())
 model.do()
 model.checkSketch(Sketch_2, 0)
-
-Part_1_doc.setCurrentFeature(Extrusion_2.feature(), True)
-
 model.end()
 
 assert(model.checkPythonDump())