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=e9edb8856c2c0d1c9ba490caa0c8400951cbc07e;hpb=030b6397f0ab0519ed4457133f3883768b4faf33;p=modules%2Fshaper.git diff --git a/src/Model/Model_Session.cpp b/src/Model/Model_Session.cpp index e9edb8856..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(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); @@ -121,23 +123,18 @@ void Model_Session::redo() //! Returns stack of performed operations std::list Model_Session::undoList() { - std::list temp; - temp.push_front("Part"); - temp.push_front("Sketch"); - temp.push_front("Extrusion"); - return temp; + return ROOT_DOC->undoList(); } //! Returns stack of rolled back operations std::list Model_Session::redoList() { - std::list temp; - return temp; + return ROOT_DOC->redoList(); } -FeaturePtr Model_Session::createFeature(string theFeatureID) +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 @@ -145,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"); @@ -176,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) @@ -209,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); } @@ -242,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) { @@ -259,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; } @@ -303,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 @@ -342,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)