Salome HOME
Make second open notcrashed in this vearion
[modules/shaper.git] / src / Model / Model_ResultPart.cpp
index cdafeb6d0e7ae59a9603ea6b3063d17a5e577a27..a54ca670999c64d005f81c59f45d2a4712baf07e 100644 (file)
@@ -1,3 +1,5 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
 // File:        ModelAPI_ResultPart.cpp
 // Created:     07 Jul 2014
 // Author:      Mikhail PONIKAROV
@@ -5,40 +7,48 @@
 #include <Model_ResultPart.h>
 #include <ModelAPI_Data.h>
 #include <ModelAPI_AttributeDocRef.h>
-#include <ModelAPI_PluginManager.h>
+#include <ModelAPI_Session.h>
 
-boost::shared_ptr<ModelAPI_Document> Model_ResultPart::partDoc()
+std::shared_ptr<ModelAPI_Document> Model_ResultPart::partDoc()
 {
-  return data()->docRef("PartDocument")->value();
+  return data()->document("PartDocument")->value();
 }
 
-boost::shared_ptr<ModelAPI_Feature> Model_ResultPart::owner()
+std::shared_ptr<ModelAPI_Feature> Model_ResultPart::owner()
 {
-  return boost::shared_ptr<ModelAPI_Feature>();  // return empty pointer
+  return std::shared_ptr<ModelAPI_Feature>();  // return empty pointer
 }
 
 Model_ResultPart::Model_ResultPart()
 {
+  setIsConcealed(false);
 }
 
-void Model_ResultPart::setData(boost::shared_ptr<ModelAPI_Data> theData)
+void Model_ResultPart::setData(std::shared_ptr<ModelAPI_Data> theData)
 {
   ModelAPI_Result::setData(theData);
   if (theData) {
-    data()->addAttribute(DOC_REF(), ModelAPI_AttributeDocRef::type());
+    data()->addAttribute(DOC_REF(), ModelAPI_AttributeDocRef::typeId());
   }
 }
 
 void Model_ResultPart::activate()
 {
-  boost::shared_ptr<ModelAPI_AttributeDocRef> aDocRef = data()->docRef(DOC_REF());
+  std::shared_ptr<ModelAPI_AttributeDocRef> aDocRef = data()->document(DOC_REF());
   
-  if (!aDocRef->value()) {  // create (or open) a document if it is not yet created
-    boost::shared_ptr<ModelAPI_Document> aDoc = document()->subDocument(data()->name());
+  if (!aDocRef->value().get()) {  // create (or open) a document if it is not yet created
+    std::shared_ptr<ModelAPI_Document> aDoc = document()->subDocument(data()->name());
     if (aDoc) {
       aDocRef->setValue(aDoc);
     }
   }
-  if (aDocRef->value())
-    ModelAPI_PluginManager::get()->setCurrentDocument(aDocRef->value());
+  if (aDocRef->value().get()) {
+    ModelAPI_Session::get()->setActiveDocument(aDocRef->value());
+  }
+}
+
+bool Model_ResultPart::isActivated() 
+{
+  std::shared_ptr<ModelAPI_AttributeDocRef> aDocRef = data()->document(DOC_REF());
+  return aDocRef->value().get();
 }