]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Issue #355 Delete: elements of sketch and constraints
authornds <natalia.donis@opencascade.com>
Mon, 19 Jan 2015 09:56:51 +0000 (12:56 +0300)
committersbh <sergey.belash@opencascade.com>
Fri, 30 Jan 2015 08:26:52 +0000 (11:26 +0300)
Remove the first empty feature if the removed feature is not found in the list of sketch sub-elements.

src/SketchPlugin/SketchPlugin_Sketch.cpp

index a3cbc24b5f0c49377501a2cd1939c6096558a4ca..bda3bd879fbf7b681a6ae81cf9ef89b1ea0e4cab 100644 (file)
@@ -138,16 +138,19 @@ void SketchPlugin_Sketch::removeFeature(ModelAPI_Feature* theFeature)
   list<ObjectPtr> aSubs = data()->reflist(SketchPlugin_Sketch::FEATURES_ID())->list();
   list<ObjectPtr>::iterator aSubIt = aSubs.begin(), aLastIt = aSubs.end();
   bool isRemoved = false;
+  bool aHasEmtpyFeature = false;
   for(; aSubIt != aLastIt && !isRemoved; aSubIt++) {
     std::shared_ptr<ModelAPI_Feature> aFeature = std::dynamic_pointer_cast<ModelAPI_Feature>(*aSubIt);
-    if (aFeature.get() != NULL || aFeature.get() == theFeature) {
+    if (aFeature.get() != NULL && aFeature.get() == theFeature) {
       data()->reflist(SketchPlugin_Sketch::FEATURES_ID())->remove(aFeature);
       isRemoved = true;
     }
+    else if (aFeature.get() == NULL)
+      aHasEmtpyFeature = true;
   }
   // if the object is not found in the sketch sub-elements, that means that the object is removed already.
   // Find the first empty element and remove it
-  if (!isRemoved)
+  if (!isRemoved && aHasEmtpyFeature)
     data()->reflist(SketchPlugin_Sketch::FEATURES_ID())->remove(NULL);
 }