1 // File: ModelAPI_ResultPart.cpp
2 // Created: 07 Jul 2014
3 // Author: Mikhail PONIKAROV
5 #include <Model_ResultPart.h>
6 #include <ModelAPI_Data.h>
7 #include <ModelAPI_AttributeDocRef.h>
8 #include <ModelAPI_PluginManager.h>
10 boost::shared_ptr<ModelAPI_Document> Model_ResultPart::partDoc()
12 return data()->docRef("PartDocument")->value();
15 boost::shared_ptr<ModelAPI_Feature> Model_ResultPart::owner()
17 return boost::shared_ptr<ModelAPI_Feature>(); // return empty pointer
20 Model_ResultPart::Model_ResultPart()
24 void Model_ResultPart::setData(boost::shared_ptr<ModelAPI_Data> theData)
26 ModelAPI_Result::setData(theData);
28 data()->addAttribute(DOC_REF(), ModelAPI_AttributeDocRef::type());
32 void Model_ResultPart::activate()
34 boost::shared_ptr<ModelAPI_AttributeDocRef> aDocRef = data()->docRef(DOC_REF());
36 if (!aDocRef->value()) { // create (or open) a document if it is not yet created
37 boost::shared_ptr<ModelAPI_Document> aDoc = document()->subDocument(data()->name());
39 aDocRef->setValue(aDoc);
43 ModelAPI_PluginManager::get()->setCurrentDocument(aDocRef->value());