Salome HOME
Merge branch 'Dev_1.1.0' of newgeom:newgeom into Dev_1.1.0
[modules/shaper.git] / src / ModelAPI / ModelAPI_Feature.cpp
index 5be82475ee0c95045f61916a32f3d25bdf32dc45..d9533e83e33d17c570bcc013ab65332f3be084dd 100644 (file)
@@ -1,3 +1,5 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
 // File:        ModelAPI_Feature.cpp
 // Created:     17 Jul 2014
 // Author:      Mikhail PONIKAROV
@@ -87,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()) {
@@ -104,12 +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()
 {
-  return ModelAPI_Session::get()->activeDocument();
+  // empty to use the current document
+  static const std::string anEmpty;
+  return anEmpty;
 }
 
 void ModelAPI_Feature::erase()