Salome HOME
Merge remote-tracking branch 'remotes/origin/Filters_Development_2'
[modules/shaper.git] / src / Model / Model_Document.cpp
index 8b26c6a037303c1185bc42d894fb48f0460d297c..082a6c60fd51f13be8e96a2cacab2d9b536eac75 100644 (file)
@@ -1244,6 +1244,18 @@ void Model_Document::setCurrentFeature(
       }
     }
   }
+  if (theVisible) { // make RemoveResults feature be active even it is performed after the current
+    int anIndex = kUNDEFINED_FEATURE_INDEX;
+    FeaturePtr aNext =
+      theCurrent.get() ? myObjs->nextFeature(theCurrent, anIndex, false) : myObjs->firstFeature();
+    for (; aNext.get(); aNext = myObjs->nextFeature(theCurrent, anIndex, false)) {
+      if (aNext->isInHistory()) {
+        break; // next in history is not needed
+      } else if (aNext->getKind() == "RemoveResults"){
+        theCurrent = aNext;
+      }
+    }
+  }
   if (theCurrent.get()) {
     std::shared_ptr<Model_Data> aData = std::static_pointer_cast<Model_Data>(theCurrent->data());
     if (!aData.get() || !aData->isValid()) {
@@ -2037,6 +2049,16 @@ void Model_Document::eraseAllFeatures()
     myObjs->eraseAllFeatures();
 }
 
+std::shared_ptr<ModelAPI_Feature> Model_Document::nextFeature(
+  std::shared_ptr<ModelAPI_Feature> theCurrent, const bool theReverse) const
+{
+  if (theCurrent.get() && myObjs) {
+    int anIndex = kUNDEFINED_FEATURE_INDEX;
+    return myObjs->nextFeature(theCurrent, anIndex, theReverse);
+  }
+  return FeaturePtr(); // nothing by default
+}
+
 void Model_Document::setExecuteFeatures(const bool theFlag)
 {
   myExecuteFeatures = theFlag;