Salome HOME
Stabilization of the process of activization of part: when document is loaded, it...
authormpv <mpv@opencascade.com>
Thu, 20 Aug 2015 14:46:31 +0000 (17:46 +0300)
committermpv <mpv@opencascade.com>
Thu, 20 Aug 2015 14:46:31 +0000 (17:46 +0300)
src/Model/Model_Data.cpp
src/Model/Model_ResultPart.cpp
src/Model/Model_ResultPart.h

index aeb1489c47ac39f298439a7dc4090be4d5a174ed..45779f4c8f1a968b87627b9a2ae54e7fd892471a 100644 (file)
@@ -25,6 +25,7 @@
 #include <ModelAPI_Session.h>
 #include <ModelAPI_ResultPart.h>
 #include <ModelAPI_Tools.h>
+#include <Model_Validator.h>
 
 #include <GeomDataAPI_Point.h>
 #include <GeomDataAPI_Point2D.h>
@@ -400,8 +401,6 @@ void Model_Data::updateConcealmentFlag()
   }
 }
 
-#include <Model_Validator.h>
-
 std::set<std::string> set_union(const std::set<std::string>& theLeft, 
                                 const std::set<std::string>& theRight)
 {
index 12361eb33a1054295d3f4c16be76d4c59695ffd5..c01d714f4e4ac5e4048e64b87c47fc31ad71151a 100644 (file)
@@ -41,12 +41,17 @@ std::shared_ptr<ModelAPI_Document> Model_ResultPart::partDoc()
   if (myTrsf.get()) {
     return baseRef()->partDoc();
   }
-  return data()->document("PartDocument")->value();
+  DocumentPtr aRes = data()->document(DOC_REF())->value();
+  if (!aRes.get() && myIsInLoad) { // trying to get this document from the session
+    aRes = document()->subDocument(data()->name());
+  }
+  return aRes;
 }
 
 Model_ResultPart::Model_ResultPart()
 {
   myIsDisabled = true; // by default it is not initialized and false to be after created
+  myIsInLoad = false;
   setIsConcealed(false);
 }
 
@@ -60,7 +65,9 @@ void Model_ResultPart::activate()
   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
+    myIsInLoad = true;
     std::shared_ptr<ModelAPI_Document> aDoc = document()->subDocument(data()->name());
+    myIsInLoad = false;
     if (aDoc) {
       aDocRef->setValue(aDoc);
     }
index b4a147bc97c11a05fd9ca960eaa75a3b7af4a8ee..f53ac5e852c6e48444789f0b1812030357206203 100644 (file)
@@ -23,6 +23,7 @@ class Model_ResultPart : public ModelAPI_ResultPart
 {
   TopoDS_Shape myShape; ///< shape of this part created from bodies (updated only of Part deactivation)
   std::shared_ptr<gp_Trsf> myTrsf; ///< if it is just copy of original shape, keep just transformation
+  bool myIsInLoad; ///< true if document of this part is in the loading process, so, it may be already received
  public:
 
   /// the reference to the base result document, may be null if this is the root, others make sequence of references