Salome HOME
Merge branch 'Dev_0.6.1' of newgeom:newgeom into Dev_0.6.1
[modules/shaper.git] / src / Model / Model_ResultPart.cpp
index 38b72fad98b2c268f8724a80b14fb22c4673757f..cc1666e5b3a43976ba1d61d718bebbcc69565d1d 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,18 +7,41 @@
 #include <Model_ResultPart.h>
 #include <ModelAPI_Data.h>
 #include <ModelAPI_AttributeDocRef.h>
+#include <ModelAPI_Session.h>
+
+std::shared_ptr<ModelAPI_Document> Model_ResultPart::partDoc()
+{
+  return data()->document("PartDocument")->value();
+}
+
+std::shared_ptr<ModelAPI_Feature> Model_ResultPart::owner()
+{
+  return std::shared_ptr<ModelAPI_Feature>();  // return empty pointer
+}
 
-boost::shared_ptr<ModelAPI_Document> Model_ResultPart::partDoc()
+Model_ResultPart::Model_ResultPart()
 {
-  return data()->docRef("PartDocument")->value();
+  setIsConcealed(false);
 }
 
-boost::shared_ptr<ModelAPI_Feature> Model_ResultPart::owner()
+void Model_ResultPart::setData(std::shared_ptr<ModelAPI_Data> theData)
 {
-  return boost::shared_ptr<ModelAPI_Feature>(); // return empty pointer
+  ModelAPI_Result::setData(theData);
+  if (theData) {
+    data()->addAttribute(DOC_REF(), ModelAPI_AttributeDocRef::type());
+  }
 }
 
-Model_ResultPart::Model_ResultPart(
-const boost::shared_ptr<ModelAPI_Feature>& theFeature)
+void Model_ResultPart::activate()
 {
+  std::shared_ptr<ModelAPI_AttributeDocRef> aDocRef = data()->document(DOC_REF());
+  
+  if (!aDocRef->value()) {  // 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_Session::get()->setActiveDocument(aDocRef->value());
 }