X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FModel%2FModel_Session.cpp;h=04229f2c2257af2b46404547d8a463d4c23fe384;hb=refs%2Ftags%2FV_1.2.1;hp=816b87f750d1e391f44a92ef939a0981d5214289;hpb=a2686c838648dcf05659df3c31d9b90aca42b792;p=modules%2Fshaper.git diff --git a/src/Model/Model_Session.cpp b/src/Model/Model_Session.cpp index 816b87f75..04229f2c2 100644 --- a/src/Model/Model_Session.cpp +++ b/src/Model/Model_Session.cpp @@ -9,6 +9,7 @@ #include #include #include +#include #include #include #include @@ -19,6 +20,7 @@ #include #include #include +#include #include #include @@ -35,7 +37,7 @@ static Model_Session* myImpl = new Model_Session(); bool Model_Session::load(const char* theFileName) { - bool aRes = ROOT_DOC->load(theFileName); + bool aRes = ROOT_DOC->load(theFileName, ROOT_DOC); return aRes; } @@ -46,13 +48,13 @@ bool Model_Session::save(const char* theFileName, std::list& theRes void Model_Session::closeAll() { - ROOT_DOC->close(true); Model_Application::getApplication()->deleteAllDocuments(); } -void Model_Session::startOperation() +void Model_Session::startOperation(const std::string& theId) { ROOT_DOC->startOperation(); + ROOT_DOC->operationId(theId); static std::shared_ptr aStartedMsg (new Events_Message(Events_Loop::eventByName("StartOperation"))); Events_Loop::loop()->send(aStartedMsg); @@ -118,10 +120,21 @@ void Model_Session::redo() setCheckTransactions(true); } -FeaturePtr Model_Session::createFeature(string theFeatureID) +//! Returns stack of performed operations +std::list Model_Session::undoList() +{ + return ROOT_DOC->undoList(); +} +//! Returns stack of rolled back operations +std::list Model_Session::redoList() +{ + return ROOT_DOC->redoList(); +} + +FeaturePtr Model_Session::createFeature(string theFeatureID, Model_Document* theDocOwner) { if (this != myImpl) { - return myImpl->createFeature(theFeatureID); + return myImpl->createFeature(theFeatureID, theDocOwner); } // load all information about plugins, features and attributes @@ -129,7 +142,7 @@ FeaturePtr Model_Session::createFeature(string theFeatureID) if (myPlugins.find(theFeatureID) != myPlugins.end()) { std::pair& aPlugin = myPlugins[theFeatureID]; // plugin and doc kind - if (!aPlugin.second.empty() && aPlugin.second != activeDocument()->kind()) { + if (!aPlugin.second.empty() && aPlugin.second != theDocOwner->kind()) { Events_Error::send( string("Feature '") + theFeatureID + "' can be created only in document '" + aPlugin.second + "' by the XML definition"); @@ -160,8 +173,18 @@ FeaturePtr Model_Session::createFeature(string theFeatureID) std::shared_ptr Model_Session::moduleDocument() { - return std::shared_ptr( + bool aFirstCall = !Model_Application::getApplication()->hasDocument("root"); + if (aFirstCall) { + // creation of the root document is always outside of the transaction, so, avoid checking it + setCheckTransactions(false); + } + std::shared_ptr aDoc = std::shared_ptr( Model_Application::getApplication()->getDocument("root")); + if (aFirstCall) { + // creation of the root document is always outside of the transaction, so, avoid checking it + setCheckTransactions(true); + } + return aDoc; } std::shared_ptr Model_Session::document(std::string theDocID) @@ -193,7 +216,7 @@ void Model_Session::setActiveDocument( if (aDoc.get()) { bool aWasChecked = myCheckTransactions; setCheckTransactions(false); - aDoc->synchronizeFeatures(false, true); + aDoc->objects()->synchronizeFeatures(false, true, true); if (aWasChecked) setCheckTransactions(true); } @@ -226,6 +249,11 @@ std::list > Model_Session::allOpenedDocuments return aResult; } +bool Model_Session::isLoadByDemand(const std::string theDocID) +{ + return Model_Application::getApplication()->isLoadByDemand(theDocID); +} + std::shared_ptr Model_Session::copy( std::shared_ptr theSource, std::string theID) { @@ -243,7 +271,7 @@ std::shared_ptr Model_Session::copy( aRT->SetRelocation(aSourceRoot, aTargetRoot); TDF_CopyTool::Copy(aDS, aRT); - aNew->synchronizeFeatures(false, true); + aNew->objects()->synchronizeFeatures(false, true, true); return aNew; } @@ -287,7 +315,10 @@ void Model_Session::processEvent(const std::shared_ptr& theMessa if(aMsgAttr->isConcealment()) { validators()->registerConcealment(aMsgAttr->featureId(), aMsgAttr->attributeId()); } - + if (!aMsgAttr->caseId().empty()) { + validators()->registerCase(aMsgAttr->featureId(), aMsgAttr->attributeId(), + aMsgAttr->switchId(), aMsgAttr->caseId()); + } } } // plugins information was started to load, so, it will be loaded @@ -326,8 +357,15 @@ void Model_Session::LoadPluginsInfo() return; // Read plugins information from XML files - Config_ModuleReader aXMLReader(Config_FeatureMessage::MODEL_EVENT()); - aXMLReader.readAll(); + Config_ModuleReader aModuleReader(Config_FeatureMessage::MODEL_EVENT()); + aModuleReader.readAll(); + std::set aFiles = aModuleReader.modulePluginFiles(); + std::set::iterator it = aFiles.begin(); + for ( ; it != aFiles.end(); it++ ) { + Config_ValidatorReader aValidatorReader (*it); + aValidatorReader.readAll(); + }; + } void Model_Session::registerPlugin(ModelAPI_Plugin* thePlugin)