1 // File: ModelAPI_Feature.cpp
2 // Created: 17 Jul 2014
3 // Author: Mikhail PONIKAROV
5 #include "ModelAPI_Feature.h"
6 #include <ModelAPI_Events.h>
7 #include <ModelAPI_Result.h>
8 #include <Events_Loop.h>
10 const std::list<boost::shared_ptr<ModelAPI_Result> >& ModelAPI_Feature::results()
15 boost::shared_ptr<ModelAPI_Result> ModelAPI_Feature::firstResult()
17 return myResults.empty() ? boost::shared_ptr<ModelAPI_Result>() : *(myResults.begin());
20 void ModelAPI_Feature::setResult(const boost::shared_ptr<ModelAPI_Result>& theResult)
22 if (firstResult() == theResult) { // just updated
23 static Events_ID anEvent = Events_Loop::eventByName(EVENT_OBJECT_UPDATED);
24 ModelAPI_EventCreator::get()->sendUpdated(theResult, anEvent);
28 while(!myResults.empty()) { // remove one by one with messages
29 boost::shared_ptr<ModelAPI_Result> aRes = *(myResults.begin());
30 myResults.erase(myResults.begin());
31 ModelAPI_EventCreator::get()->sendDeleted(aRes->document(), aRes->groupName());
33 myResults.push_back(theResult);
34 static Events_ID anEvent = Events_Loop::eventByName(EVENT_OBJECT_CREATED);
35 ModelAPI_EventCreator::get()->sendUpdated(theResult, anEvent);
36 // Create event for first Feature
37 Events_Loop::loop()->flush(anEvent);
40 boost::shared_ptr<ModelAPI_Document> ModelAPI_Feature::documentToAdd()
42 return ModelAPI_PluginManager::get()->currentDocument();
45 ModelAPI_Feature::~ModelAPI_Feature()
47 while(!myResults.empty()) { // remove one by one with messages
48 boost::shared_ptr<ModelAPI_Result> aRes = *(myResults.begin());
49 myResults.erase(myResults.begin());
50 ModelAPI_EventCreator::get()->sendDeleted(aRes->document(), aRes->groupName());