Salome HOME
Merge branch 'Dev_0.6' of newgeom:newgeom into Dev_0.6
[modules/shaper.git] / src / Model / Model_ResultPart.cpp
1 // File:        ModelAPI_ResultPart.cpp
2 // Created:     07 Jul 2014
3 // Author:      Mikhail PONIKAROV
4
5 #include <Model_ResultPart.h>
6 #include <ModelAPI_Data.h>
7 #include <ModelAPI_AttributeDocRef.h>
8 #include <ModelAPI_Session.h>
9
10 std::shared_ptr<ModelAPI_Document> Model_ResultPart::partDoc()
11 {
12   return data()->document("PartDocument")->value();
13 }
14
15 std::shared_ptr<ModelAPI_Feature> Model_ResultPart::owner()
16 {
17   return std::shared_ptr<ModelAPI_Feature>();  // return empty pointer
18 }
19
20 Model_ResultPart::Model_ResultPart()
21 {
22   setIsConcealed(false);
23 }
24
25 void Model_ResultPart::setData(std::shared_ptr<ModelAPI_Data> theData)
26 {
27   ModelAPI_Result::setData(theData);
28   if (theData) {
29     data()->addAttribute(DOC_REF(), ModelAPI_AttributeDocRef::type());
30   }
31 }
32
33 void Model_ResultPart::activate()
34 {
35   std::shared_ptr<ModelAPI_AttributeDocRef> aDocRef = data()->document(DOC_REF());
36   
37   if (!aDocRef->value()) {  // create (or open) a document if it is not yet created
38     std::shared_ptr<ModelAPI_Document> aDoc = document()->subDocument(data()->name());
39     if (aDoc) {
40       aDocRef->setValue(aDoc);
41     }
42   }
43   if (aDocRef->value())
44     ModelAPI_Session::get()->setActiveDocument(aDocRef->value());
45 }