X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FModel%2FModel_Session.cpp;h=159b7a2f678b19e60ac6fac4862c1881100dbeca;hb=a352874d231ad2b117f55cf384c18361a0dfe67a;hp=9e87c0560c993e7d08b5084c07523f346786c9b8;hpb=38afbd899a8645c83e17f2c24a17a2b7414911b4;p=modules%2Fshaper.git diff --git a/src/Model/Model_Session.cpp b/src/Model/Model_Session.cpp index 9e87c0560..159b7a2f6 100644 --- a/src/Model/Model_Session.cpp +++ b/src/Model/Model_Session.cpp @@ -53,6 +53,9 @@ void Model_Session::startOperation() static std::shared_ptr aStartedMsg (new Events_Message(Events_Loop::eventByName("StartOperation"))); Events_Loop::loop()->send(aStartedMsg); + // remove all useless documents that has been closed: on start of operation undo/redo is cleared + std::list > aUsedDocs = allOpenedDocuments(); + Model_Application::getApplication()->removeUselessDocuments(aUsedDocs); } void Model_Session::finishOperation() @@ -63,9 +66,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 anAbortMsg (new Events_Message(Events_Loop::eventByName("AbortOperation"))); Events_Loop::loop()->send(anAbortMsg); + myCheckTransactions = true; + myCheckTransactions = aWasCheck; } bool Model_Session::isOperation() @@ -100,8 +109,9 @@ void Model_Session::redo() FeaturePtr Model_Session::createFeature(string theFeatureID) { - if (this != myImpl) + if (this != myImpl) { return myImpl->createFeature(theFeatureID); + } // load all information about plugins, features and attributes LoadPluginsInfo(); @@ -117,7 +127,7 @@ FeaturePtr Model_Session::createFeature(string theFeatureID) myCurrentPluginName = aPlugin.first; if (myPluginObjs.find(myCurrentPluginName) == myPluginObjs.end()) { // load plugin library if not yet done - Config_ModuleReader::loadLibrary(myCurrentPluginName); + Config_ModuleReader::loadPlugin(myCurrentPluginName); } if (myPluginObjs.find(myCurrentPluginName) != myPluginObjs.end()) { FeaturePtr aCreated = myPluginObjs[myCurrentPluginName]->createFeature(theFeatureID); @@ -183,8 +193,9 @@ std::list > Model_Session::allOpenedDocuments DocumentPtr anAPIDoc = *aDoc; std::shared_ptr aDoc = std::dynamic_pointer_cast(anAPIDoc); if (aDoc) { - std::set::const_iterator aSubIter = aDoc->subDocuments().cbegin(); - for(; aSubIter != aDoc->subDocuments().cend(); aSubIter++) { + const std::set aSubs = aDoc->subDocuments(true); + std::set::const_iterator aSubIter = aSubs.cbegin(); + for(; aSubIter != aSubs.cend(); aSubIter++) { if (!Model_Application::getApplication()->isLoadByDemand(*aSubIter)) { aResult.push_back(Model_Application::getApplication()->getDocument(*aSubIter)); } @@ -291,6 +302,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(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()