]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Issue #216: fixed the problem with loading part and activating by double click
authormpv <mikhail.ponikarov@opencascade.com>
Thu, 6 Nov 2014 12:04:52 +0000 (15:04 +0300)
committermpv <mikhail.ponikarov@opencascade.com>
Thu, 6 Nov 2014 12:04:52 +0000 (15:04 +0300)
src/Model/Model_Document.cpp
src/Model/Model_Session.cpp
src/Model/Model_Session.h
src/ModelAPI/ModelAPI_Session.h
src/PartSetPlugin/PartSetPlugin_Part.cpp

index 4ad70e8470680dc3df6074cfc0455f3a43a55ef8..8bb7c7809bce575ab456c856da75880378202186 100644 (file)
@@ -147,8 +147,10 @@ bool Model_Document::load(const char* theFileName)
   if (!isError) {
     myDoc->SetUndoLimit(UNDO_LIMIT);
     // to avoid the problem that feature is created in the current, not this, document
-    Model_Session::get()->setActiveDocument(anApp->getDocument(myID));
+    Model_Session::get()->setActiveDocument(anApp->getDocument(myID), false);
     synchronizeFeatures(false, true);
+    Model_Session::get()->setActiveDocument(Model_Session::get()->moduleDocument(), false);
+    Model_Session::get()->setActiveDocument(anApp->getDocument(myID), true);
   }
   return !isError;
 }
index 13b8a9a50665b05f3e5319b14142e0dcba851590..f78bfb76b4d1efef79f23936a6215f432a1d0719 100644 (file)
@@ -144,12 +144,15 @@ boost::shared_ptr<ModelAPI_Document> Model_Session::activeDocument()
   return myCurrentDoc;
 }
 
-void Model_Session::setActiveDocument(boost::shared_ptr<ModelAPI_Document> theDoc)
+void Model_Session::setActiveDocument(
+  boost::shared_ptr<ModelAPI_Document> theDoc, bool theSendSignal)
 {
   if (myCurrentDoc != theDoc) {
     myCurrentDoc = theDoc;
-    static boost::shared_ptr<Events_Message> aMsg(new Events_Message(Events_Loop::eventByName("CurrentDocumentChanged")));
-    Events_Loop::loop()->send(aMsg);
+    if (theSendSignal) {
+      static boost::shared_ptr<Events_Message> aMsg(new Events_Message(Events_Loop::eventByName("CurrentDocumentChanged")));
+      Events_Loop::loop()->send(aMsg);
+    }
   }
 }
 
index e691cea306f281d799c829a38cb0f3e35f9de2c4..fd4f9c0b5ac3e35a1800082dbba8b67bf2036521 100644 (file)
@@ -73,7 +73,8 @@ class Model_Session : public ModelAPI_Session, public Events_Listener
   MODEL_EXPORT virtual boost::shared_ptr<ModelAPI_Document> activeDocument();
 
   /// Defines the current document that used for current work in the application
-  MODEL_EXPORT virtual void setActiveDocument(boost::shared_ptr<ModelAPI_Document> theDoc);
+  MODEL_EXPORT virtual void setActiveDocument(
+    boost::shared_ptr<ModelAPI_Document> theDoc, bool theSendSignal = true);
 
   /// Returns all the opened documents of the session (without postponed)
   MODEL_EXPORT virtual std::list<boost::shared_ptr<ModelAPI_Document> > allOpenedDocuments();
index b5e4d5d3bc7a192c73553e8940bb1c7b13e78f4e..c97105421512fd83b16efbab28bdd012501b3666 100644 (file)
@@ -75,7 +75,8 @@ class MODELAPI_EXPORT ModelAPI_Session
   virtual boost::shared_ptr<ModelAPI_Document> activeDocument() = 0;
 
   /// Defines the current document that used for current work in the application
-  virtual void setActiveDocument(boost::shared_ptr<ModelAPI_Document> theDoc) = 0;
+  virtual void setActiveDocument(
+    boost::shared_ptr<ModelAPI_Document> theDoc, bool theSendSignal = true) = 0;
 
   /// Returns all the opened documents of the session (without postponed)
   virtual std::list<boost::shared_ptr<ModelAPI_Document> > allOpenedDocuments() = 0;
index 9c5e6e62a93e4ef8cb0956dd2fe4ffbb2716d6a0..48d338267b04554fb857d5cf5d263ed87fc8a4b1 100644 (file)
@@ -27,16 +27,6 @@ void PartSetPlugin_Part::execute()
     setResult(aResult);
     aResult->activate();
   }
-  /*
-  boost::shared_ptr<ModelAPI_AttributeDocRef> aDocRef = aResult->data()->docRef(
-      ModelAPI_ResultPart::DOC_REF());
-  
-  if (!aDocRef->value()) {  // create a document if not yet created
-    boost::shared_ptr<ModelAPI_Document> aPartSetDoc =
-        ModelAPI_Session::get()->moduleDocument();
-    aDocRef->setValue(aPartSetDoc->subDocument(data()->name()));
-  }
-  */
 }
 
 boost::shared_ptr<ModelAPI_Document> PartSetPlugin_Part::documentToAdd()