]> SALOME platform Git repositories - modules/shaper.git/blobdiff - src/Model/Model_ResultPart.cpp
Salome HOME
Improve loading of parts
[modules/shaper.git] / src / Model / Model_ResultPart.cpp
index 7bbadba0dc02d707400574092a5cd23bdafb39df..f89eff7d738ec5632febcd3f19e9f44ff4b2046a 100644 (file)
@@ -89,7 +89,8 @@ void Model_ResultPart::activate()
   SessionPtr aMgr = ModelAPI_Session::get();
   if (!aMgr->isOperation()) {
     // open transaction even document is not created to set current docs in setActiveDocument
-    aMgr->startOperation("Activation");
+    std::string aMsg = "Activation " + data()->name();
+    aMgr->startOperation(aMsg);
     isNewTransaction = true;
   }
   if (!aDocRef->value().get()) {  // create (or open) a document if it is not yet created
@@ -113,6 +114,22 @@ void Model_ResultPart::activate()
   }
 }
 
+
+void Model_ResultPart::loadPart()
+{
+  std::shared_ptr<ModelAPI_AttributeDocRef> aDocRef = data()->document(DOC_REF());
+  if (!aDocRef->value().get()) {  // create (or open) a document if it is not yet created
+    Handle(Model_Application) anApp = Model_Application::getApplication();
+    if (anApp->isLoadByDemand(data()->name(), aDocRef->docId())) {
+      anApp->loadDocument(data()->name(), aDocRef->docId()); // if it is just new part, load fails
+    }
+    else {
+      anApp->createDocument(aDocRef->docId());
+    }
+  }
+}
+
+
 std::shared_ptr<ModelAPI_ResultPart> Model_ResultPart::original()
 {
   if (myTrsf.get() && baseRef().get()) {  // the second condition is due to #2035