Salome HOME
Copyright update 2020
[modules/shaper.git] / src / Model / Model_ResultPart.cpp
index b8fb440d742ac10ce1390ccb52057722e993008a..cd3997aca18d7403b857ba48031da2cead5b28de 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2014-2019  CEA/DEN, EDF R&D
+// Copyright (C) 2014-2020  CEA/DEN, EDF R&D
 //
 // This library is free software; you can redistribute it and/or
 // modify it under the terms of the GNU Lesser General Public
@@ -54,6 +54,7 @@ void Model_ResultPart::initAttributes()
   data()->addAttribute(BASE_REF_ID(), ModelAPI_AttributeReference::typeId());
   data()->addAttribute(DEFLECTION_ID(), ModelAPI_AttributeDouble::typeId());
   data()->addAttribute(TRANSPARENCY_ID(), ModelAPI_AttributeDouble::typeId());
+  data()->addAttribute(ISO_LINES_ID(), ModelAPI_AttributeIntArray::typeId());
 
   if (aDocRef->isInitialized() && // initialized immediately means already exist and will be loaded
       !Model_Application::getApplication()->hasDocument(aDocRef->docId()))
@@ -89,7 +90,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 +115,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
@@ -415,3 +433,10 @@ void Model_ResultPart::setTrsf(std::shared_ptr<ModelAPI_Result> theThis,
   static Events_ID EVENT_DISP = aLoop->eventByName(EVENT_OBJECT_TO_REDISPLAY);
   ModelAPI_EventCreator::get()->sendUpdated(theThis, EVENT_DISP); // flush is in preview-update
 }
+
+std::shared_ptr<GeomAPI_Trsf> Model_ResultPart::summaryTrsf()
+{
+  GeomTrsfPtr aResult(new GeomAPI_Trsf);
+  aResult->setImpl<gp_Trsf>(new gp_Trsf(sumTrsf()));
+  return aResult;
+}