Salome HOME
Resolve batch runtime errors on debian squeeze
[modules/shaper.git] / src / Model / Model_ResultPart.cpp
1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D
2
3 // File:        ModelAPI_ResultPart.cpp
4 // Created:     07 Jul 2014
5 // Author:      Mikhail PONIKAROV
6
7 #include <Model_ResultPart.h>
8 #include <ModelAPI_Data.h>
9 #include <ModelAPI_AttributeDocRef.h>
10 #include <ModelAPI_Session.h>
11
12 std::shared_ptr<ModelAPI_Document> Model_ResultPart::partDoc()
13 {
14   return data()->document("PartDocument")->value();
15 }
16
17 std::shared_ptr<ModelAPI_Feature> Model_ResultPart::owner()
18 {
19   return std::shared_ptr<ModelAPI_Feature>();  // return empty pointer
20 }
21
22 Model_ResultPart::Model_ResultPart()
23 {
24   setIsConcealed(false);
25 }
26
27 void Model_ResultPart::setData(std::shared_ptr<ModelAPI_Data> theData)
28 {
29   ModelAPI_Result::setData(theData);
30   if (theData) {
31     data()->addAttribute(DOC_REF(), ModelAPI_AttributeDocRef::typeId());
32   }
33 }
34
35 void Model_ResultPart::activate()
36 {
37   std::shared_ptr<ModelAPI_AttributeDocRef> aDocRef = data()->document(DOC_REF());
38   
39   if (!aDocRef->value().get()) {  // create (or open) a document if it is not yet created
40     std::shared_ptr<ModelAPI_Document> aDoc = document()->subDocument(data()->name());
41     if (aDoc) {
42       aDocRef->setValue(aDoc);
43     }
44   }
45   if (aDocRef->value().get()) {
46     ModelAPI_Session::get()->setActiveDocument(aDocRef->value());
47   }
48 }
49
50 bool Model_ResultPart::isActivated() 
51 {
52   std::shared_ptr<ModelAPI_AttributeDocRef> aDocRef = data()->document(DOC_REF());
53   return aDocRef->value().get();
54 }