Salome HOME
Make construction elements correctly selected: points, axes, planes
[modules/shaper.git] / src / Model / Model_Session.cpp
index d8e5166986f5a7cfb9329ccf7747ba2e0993dfde..d264be4d34519940d9dd5cda5dbc55886f388248 100644 (file)
@@ -1,3 +1,5 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
 // File:        Model_Session.cxx
 // Created:     20 Mar 2014
 // Author:      Mikhail PONIKAROV
@@ -61,9 +63,15 @@ void Model_Session::finishOperation()
 void Model_Session::abortOperation()
 {
   ROOT_DOC->abortOperation();
+  // here the update mechanism may work after abort, so, supress the warnings about
+  // modifications outside of the transactions
+  bool aWasCheck = myCheckTransactions;
+  myCheckTransactions = false;
   static std::shared_ptr<Events_Message> anAbortMsg
     (new Events_Message(Events_Loop::eventByName("AbortOperation")));
   Events_Loop::loop()->send(anAbortMsg);
+  myCheckTransactions = true;
+  myCheckTransactions = aWasCheck;
 }
 
 bool Model_Session::isOperation()
@@ -141,6 +149,12 @@ std::shared_ptr<ModelAPI_Document> Model_Session::moduleDocument()
       Model_Application::getApplication()->getDocument("root"));
 }
 
+std::shared_ptr<ModelAPI_Document> Model_Session::document(std::string theDocID)
+{
+  return std::shared_ptr<ModelAPI_Document>(
+      Model_Application::getApplication()->getDocument(theDocID));
+}
+
 bool Model_Session::hasModuleDocument()
 {
   return Model_Application::getApplication()->hasDocument("root");
@@ -283,6 +297,14 @@ void Model_Session::registerPlugin(ModelAPI_Plugin* thePlugin)
   static Events_ID EVENT_LOAD = Events_Loop::loop()->eventByName(EVENT_PLUGIN_LOADED);
   ModelAPI_EventCreator::get()->sendUpdated(ObjectPtr(), EVENT_LOAD);
   Events_Loop::loop()->flush(EVENT_LOAD);
+  // If the plugin has an ability to process GUI events, register it
+  Events_Listener* aListener = dynamic_cast<Events_Listener*>(thePlugin);
+  if (aListener) {
+    Events_Loop* aLoop = Events_Loop::loop();
+    static Events_ID aStateRequestEventId =
+        Events_Loop::loop()->eventByName(EVENT_FEATURE_STATE_REQUEST);
+    aLoop->registerListener(aListener, aStateRequestEventId);
+  }
 }
 
 ModelAPI_ValidatorsFactory* Model_Session::validators()