Salome HOME
Simplification of "Update" algorithm and "Macro" flag implementation for the box...
[modules/shaper.git] / src / ModelAPI / ModelAPI_Feature.cpp
index 1a2e641a2981aa18d740c5963c742d56ce8f9418..8a5d93cbdc04eee1933bc77bb1c1be2ba9dfc6f6 100644 (file)
@@ -89,6 +89,28 @@ void ModelAPI_Feature::removeResult(const std::shared_ptr<ModelAPI_Result>& theR
   }
 }
 
+void ModelAPI_Feature::removeResults(const int theSinceIndex)
+{
+  if (theSinceIndex == 0) {
+    eraseResults();
+    return;
+  }
+
+  std::list<std::shared_ptr<ModelAPI_Result> >::iterator aResIter = myResults.begin();
+  for(int anIndex = 0; anIndex < theSinceIndex && aResIter != myResults.end(); anIndex++)
+    aResIter++;
+  std::list<std::shared_ptr<ModelAPI_Result> >::iterator aNextIter = aResIter;
+  for(; aNextIter != myResults.end(); aNextIter++) {
+    static Events_ID anEvent = Events_Loop::eventByName(EVENT_OBJECT_DELETED);
+    static Events_Loop* aLoop = Events_Loop::loop();
+    static Events_ID EVENT_DISP = aLoop->eventByName(EVENT_OBJECT_TO_REDISPLAY);
+    static const ModelAPI_EventCreator* aECreator = ModelAPI_EventCreator::get();
+    ModelAPI_EventCreator::get()->sendDeleted(document(), (*aNextIter)->groupName());
+    aECreator->sendUpdated(*aNextIter, EVENT_DISP);
+  }
+  myResults.erase(aResIter, myResults.end());
+}
+
 void ModelAPI_Feature::eraseResults()
 {
   if (!myResults.empty()) {
@@ -106,13 +128,15 @@ void ModelAPI_Feature::eraseResults()
     // flush it to avoid left presentations after input of invalid arguments (radius=0)
     static Events_ID anEvent = Events_Loop::eventByName(EVENT_OBJECT_DELETED);
     Events_Loop::loop()->flush(anEvent);
+    Events_Loop::loop()->flush(EVENT_DISP);
   }
 }
 
-std::shared_ptr<ModelAPI_Document> ModelAPI_Feature::documentToAdd()
+const std::string& ModelAPI_Feature::documentToAdd()
 {
-  // null pointer t ouse the current document
-  return std::shared_ptr<ModelAPI_Document>();
+  // empty to use the current document
+  static const std::string anEmpty;
+  return anEmpty;
 }
 
 void ModelAPI_Feature::erase()
@@ -147,3 +171,9 @@ FeaturePtr ModelAPI_Feature::feature(ObjectPtr theObject)
   }
   return aFeature;
 }
+
+
+bool ModelAPI_Feature::isMacro() const
+{
+  return false;
+}