From: mpv Date: Thu, 11 Sep 2014 08:20:39 +0000 (+0400) Subject: Issue #83: renamed PluginManager to Session X-Git-Tag: V_0.4.4~72^2~2^2~1 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=428673f6b49a1997bf97ebbe5e00501c76439c20;p=modules%2Fshaper.git Issue #83: renamed PluginManager to Session --- diff --git a/src/ConstructionPlugin/ConstructionPlugin_Plugin.cpp b/src/ConstructionPlugin/ConstructionPlugin_Plugin.cpp index 60d5694f5..fd5db868f 100644 --- a/src/ConstructionPlugin/ConstructionPlugin_Plugin.cpp +++ b/src/ConstructionPlugin/ConstructionPlugin_Plugin.cpp @@ -1,7 +1,7 @@ #include "ConstructionPlugin_Plugin.h" #include "ConstructionPlugin_Point.h" -#include +#include #include using namespace std; @@ -12,7 +12,7 @@ static ConstructionPlugin_Plugin* MY_INSTANCE = new ConstructionPlugin_Plugin(); ConstructionPlugin_Plugin::ConstructionPlugin_Plugin() { // register this plugin - ModelAPI_PluginManager::get()->registerPlugin(this); + ModelAPI_Session::get()->registerPlugin(this); } FeaturePtr ConstructionPlugin_Plugin::createFeature(string theFeatureID) diff --git a/src/ConstructionPlugin/ConstructionPlugin_Point.cpp b/src/ConstructionPlugin/ConstructionPlugin_Point.cpp index e39bcc06e..61c20a9ee 100644 --- a/src/ConstructionPlugin/ConstructionPlugin_Point.cpp +++ b/src/ConstructionPlugin/ConstructionPlugin_Point.cpp @@ -3,7 +3,7 @@ // Author: Mikhail PONIKAROV #include "ConstructionPlugin_Point.h" -#include "ModelAPI_PluginManager.h" +#include "ModelAPI_Session.h" #include "ModelAPI_Document.h" #include "ModelAPI_Data.h" #include "ModelAPI_AttributeDouble.h" diff --git a/src/ExchangePlugin/ExchangePlugin_Plugin.cpp b/src/ExchangePlugin/ExchangePlugin_Plugin.cpp index 97d2b6e58..b3256862a 100644 --- a/src/ExchangePlugin/ExchangePlugin_Plugin.cpp +++ b/src/ExchangePlugin/ExchangePlugin_Plugin.cpp @@ -5,7 +5,7 @@ #include #include -#include +#include #include @@ -17,7 +17,7 @@ static ExchangePlugin_Plugin* MY_INSTANCE = new ExchangePlugin_Plugin(); ExchangePlugin_Plugin::ExchangePlugin_Plugin() { // register this plugin - ModelAPI_PluginManager::get()->registerPlugin(this); + ModelAPI_Session::get()->registerPlugin(this); } FeaturePtr ExchangePlugin_Plugin::createFeature(string theFeatureID) diff --git a/src/ExchangePlugin/ExchangePlugin_Validators.cpp b/src/ExchangePlugin/ExchangePlugin_Validators.cpp index 2560fb621..f179e889b 100644 --- a/src/ExchangePlugin/ExchangePlugin_Validators.cpp +++ b/src/ExchangePlugin/ExchangePlugin_Validators.cpp @@ -5,7 +5,7 @@ #include #include #include -#include +#include #include #include @@ -14,7 +14,7 @@ bool ExchangePlugin_ImportFormatValidator::isValid( const AttributePtr& theAttribute, const std::list& theArguments) const { - PluginManagerPtr aMgr = ModelAPI_PluginManager::get(); + SessionPtr aMgr = ModelAPI_Session::get(); ModelAPI_ValidatorsFactory* aFactory = aMgr->validators(); return false; } diff --git a/src/FeaturesPlugin/FeaturesPlugin_Extrusion.cpp b/src/FeaturesPlugin/FeaturesPlugin_Extrusion.cpp index 1fb6e46d5..295fb1c9d 100644 --- a/src/FeaturesPlugin/FeaturesPlugin_Extrusion.cpp +++ b/src/FeaturesPlugin/FeaturesPlugin_Extrusion.cpp @@ -3,7 +3,7 @@ // Author: Vitaly SMETANNIKOV #include "FeaturesPlugin_Extrusion.h" -#include +#include #include #include #include diff --git a/src/FeaturesPlugin/FeaturesPlugin_Plugin.cpp b/src/FeaturesPlugin/FeaturesPlugin_Plugin.cpp index 5c3fd3a43..7d4e26185 100644 --- a/src/FeaturesPlugin/FeaturesPlugin_Plugin.cpp +++ b/src/FeaturesPlugin/FeaturesPlugin_Plugin.cpp @@ -2,7 +2,7 @@ #include "FeaturesPlugin_Extrusion.h" #include "FeaturesPlugin_Boolean.h" -#include +#include #include using namespace std; @@ -13,7 +13,7 @@ static FeaturesPlugin_Plugin* MY_INSTANCE = new FeaturesPlugin_Plugin(); FeaturesPlugin_Plugin::FeaturesPlugin_Plugin() { // register this plugin - ModelAPI_PluginManager::get()->registerPlugin(this); + ModelAPI_Session::get()->registerPlugin(this); } FeaturePtr FeaturesPlugin_Plugin::createFeature(string theFeatureID) diff --git a/src/Model/CMakeLists.txt b/src/Model/CMakeLists.txt index 1642fbaca..8e54742a9 100644 --- a/src/Model/CMakeLists.txt +++ b/src/Model/CMakeLists.txt @@ -4,7 +4,7 @@ SET(PROJECT_HEADERS Model.h Model_Application.h Model_Document.h - Model_PluginManager.h + Model_Session.h Model_Data.h Model_AttributeDouble.h Model_AttributeDocRef.h @@ -26,7 +26,7 @@ SET(PROJECT_HEADERS SET(PROJECT_SOURCES Model_Application.cpp Model_Document.cpp - Model_PluginManager.cpp + Model_Session.cpp Model_Data.cpp Model_AttributeDouble.cpp Model_AttributeDocRef.cpp diff --git a/src/Model/Model_Document.cpp b/src/Model/Model_Document.cpp index cb1b6d307..b66318687 100644 --- a/src/Model/Model_Document.cpp +++ b/src/Model/Model_Document.cpp @@ -5,7 +5,7 @@ #include #include #include -#include +#include #include #include #include @@ -74,7 +74,7 @@ static TCollection_ExtendedString DocFileName(const char* theFileName, const std bool Model_Document::load(const char* theFileName) { Handle(Model_Application) anApp = Model_Application::getApplication(); - if (this == Model_PluginManager::get()->rootDocument().get()) { + if (this == Model_Session::get()->rootDocument().get()) { anApp->setLoadPath(theFileName); } TCollection_ExtendedString aPath(DocFileName(theFileName, myID)); @@ -151,7 +151,7 @@ bool Model_Document::load(const char* theFileName) bool Model_Document::save(const char* theFileName, std::list& theResults) { // create a directory in the root document if it is not yet exist - if (this == Model_PluginManager::get()->rootDocument().get()) { + if (this == Model_Session::get()->rootDocument().get()) { #ifdef WIN32 CreateDirectory(theFileName, NULL); #else @@ -196,7 +196,7 @@ bool Model_Document::save(const char* theFileName, std::list& theRe void Model_Document::close() { - boost::shared_ptr aPM = Model_PluginManager::get(); + boost::shared_ptr aPM = Model_Session::get(); if (this != aPM->rootDocument().get() && this == aPM->currentDocument().get()) { aPM->setCurrentDocument(aPM->rootDocument()); } @@ -253,7 +253,7 @@ void Model_Document::finishOperation() // just to be sure that everybody knows that changes were performed if (!myDoc->HasOpenCommand() && myNestedNum != -1) - boost::static_pointer_cast(Model_PluginManager::get()) + boost::static_pointer_cast(Model_Session::get()) ->setCheckTransactions(false); // for nested transaction commit Events_Loop* aLoop = Events_Loop::loop(); aLoop->flush(Events_Loop::eventByName(EVENT_OBJECT_CREATED)); @@ -261,7 +261,7 @@ void Model_Document::finishOperation() aLoop->flush(Events_Loop::eventByName(EVENT_OBJECT_TO_REDISPLAY)); aLoop->flush(Events_Loop::eventByName(EVENT_OBJECT_DELETED)); if (!myDoc->HasOpenCommand() && myNestedNum != -1) - boost::static_pointer_cast(Model_PluginManager::get()) + boost::static_pointer_cast(Model_Session::get()) ->setCheckTransactions(true); // for nested transaction commit if (myNestedNum != -1) // this nested transaction is owervritten @@ -392,7 +392,7 @@ FeaturePtr Model_Document::addFeature(std::string theID) { TDF_Label anEmptyLab; FeaturePtr anEmptyFeature; - FeaturePtr aFeature = ModelAPI_PluginManager::get()->createFeature(theID); + FeaturePtr aFeature = ModelAPI_Session::get()->createFeature(theID); boost::shared_ptr aDocToAdd = boost::dynamic_pointer_cast( aFeature->documentToAdd()); if (aFeature) { @@ -655,7 +655,7 @@ void Model_Document::synchronizeFeatures(const bool theMarkUpdated) boost::shared_ptr aThis = Model_Application::getApplication()->getDocument(myID); // after all updates, sends a message that groups of features were created or updated - boost::static_pointer_cast(Model_PluginManager::get()) + boost::static_pointer_cast(Model_Session::get()) ->setCheckTransactions(false); Events_Loop* aLoop = Events_Loop::loop(); aLoop->activateFlushes(false); @@ -667,7 +667,7 @@ void Model_Document::synchronizeFeatures(const bool theMarkUpdated) TDF_Label aFeatureLabel = aLabIter.Value()->Label(); if (!myObjs.IsBound(aFeatureLabel)) { // a new feature is inserted // create a feature - FeaturePtr aNewObj = ModelAPI_PluginManager::get()->createFeature( + FeaturePtr aNewObj = ModelAPI_Session::get()->createFeature( TCollection_AsciiString(Handle(TDataStd_Comment)::DownCast(aLabIter.Value())->Get()) .ToCString()); if (!aNewObj) { // somethig is wrong, most probably, the opened document has invalid structure @@ -739,7 +739,7 @@ void Model_Document::synchronizeFeatures(const bool theMarkUpdated) } aLoop->flush(Events_Loop::eventByName(EVENT_OBJECT_DELETED)); aLoop->flush(Events_Loop::eventByName(EVENT_OBJECT_TO_REDISPLAY)); - boost::static_pointer_cast(Model_PluginManager::get()) + boost::static_pointer_cast(Model_Session::get()) ->setCheckTransactions(true); myExecuteFeatures = true; } diff --git a/src/Model/Model_Document.h b/src/Model/Model_Document.h index 7b4072520..7024925ed 100644 --- a/src/Model/Model_Document.h +++ b/src/Model/Model_Document.h @@ -160,7 +160,7 @@ class Model_Document : public ModelAPI_Document void updateResults(FeaturePtr theFeature); friend class Model_Application; - friend class Model_PluginManager; + friend class Model_Session; friend class DFBrowser; private: diff --git a/src/Model/Model_PluginManager.cpp b/src/Model/Model_PluginManager.cpp deleted file mode 100644 index ad5767a5a..000000000 --- a/src/Model/Model_PluginManager.cpp +++ /dev/null @@ -1,171 +0,0 @@ -// File: Model_PluginManager.cxx -// Created: 20 Mar 2014 -// Author: Mikhail PONIKAROV - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include - -using namespace std; - -static Model_PluginManager* myImpl = new Model_PluginManager(); - -FeaturePtr Model_PluginManager::createFeature(string theFeatureID) -{ - if (this != myImpl) - return myImpl->createFeature(theFeatureID); - - LoadPluginsInfo(); - if (myPlugins.find(theFeatureID) != myPlugins.end()) { - myCurrentPluginName = myPlugins[theFeatureID]; - if (myPluginObjs.find(myCurrentPluginName) == myPluginObjs.end()) { - // load plugin library if not yet done - Config_ModuleReader::loadLibrary(myCurrentPluginName); - } - if (myPluginObjs.find(myCurrentPluginName) != myPluginObjs.end()) { - FeaturePtr aCreated = myPluginObjs[myCurrentPluginName]->createFeature(theFeatureID); - if (!aCreated) { - Events_Error::send( - string("Can not initialize feature '") + theFeatureID + "' in plugin '" - + myCurrentPluginName + "'"); - } - return aCreated; - } else { - Events_Error::send(string("Can not load plugin '") + myCurrentPluginName + "'"); - } - } else { - Events_Error::send(string("Feature '") + theFeatureID + "' not found in any plugin"); - } - - return FeaturePtr(); // return nothing -} - -boost::shared_ptr Model_PluginManager::rootDocument() -{ - return boost::shared_ptr( - Model_Application::getApplication()->getDocument("root")); -} - -bool Model_PluginManager::hasRootDocument() -{ - return Model_Application::getApplication()->hasDocument("root"); -} - -boost::shared_ptr Model_PluginManager::currentDocument() -{ - if (!myCurrentDoc || !Model_Application::getApplication()->hasDocument(myCurrentDoc->id())) - myCurrentDoc = rootDocument(); - return myCurrentDoc; -} - -void Model_PluginManager::setCurrentDocument(boost::shared_ptr theDoc) -{ - myCurrentDoc = theDoc; - static Events_Message aMsg(Events_Loop::eventByName("CurrentDocumentChanged")); - Events_Loop::loop()->send(aMsg); -} - -boost::shared_ptr Model_PluginManager::copy( - boost::shared_ptr theSource, std::string theID) -{ - // create a new document - boost::shared_ptr aNew = boost::dynamic_pointer_cast( - Model_Application::getApplication()->getDocument(theID)); - // make a copy of all labels - TDF_Label aSourceRoot = boost::dynamic_pointer_cast(theSource)->document()->Main() - .Father(); - TDF_Label aTargetRoot = aNew->document()->Main().Father(); - Handle(TDF_DataSet) aDS = new TDF_DataSet; - aDS->AddLabel(aSourceRoot); - TDF_ClosureTool::Closure(aDS); - Handle(TDF_RelocationTable) aRT = new TDF_RelocationTable; - aRT->SetRelocation(aSourceRoot, aTargetRoot); - TDF_CopyTool::Copy(aDS, aRT); - - aNew->synchronizeFeatures(); - return aNew; -} - -Model_PluginManager::Model_PluginManager() -{ - myPluginsInfoLoaded = false; - myCheckTransactions = true; - ModelAPI_PluginManager::setPluginManager(boost::shared_ptr(this)); - // register the configuration reading listener - Events_Loop* aLoop = Events_Loop::loop(); - static const Events_ID kFeatureEvent = Events_Loop::eventByName("FeatureRegisterEvent"); - aLoop->registerListener(this, kFeatureEvent); - aLoop->registerListener(this, Events_Loop::eventByName(EVENT_OBJECT_CREATED)); - aLoop->registerListener(this, Events_Loop::eventByName(EVENT_OBJECT_UPDATED)); - aLoop->registerListener(this, Events_Loop::eventByName(EVENT_OBJECT_DELETED)); - aLoop->registerListener(this, Events_Loop::eventByName(EVENT_VALIDATOR_LOADED)); -} - -void Model_PluginManager::processEvent(const Events_Message* theMessage) -{ - static const Events_ID kFeatureEvent = Events_Loop::eventByName("FeatureRegisterEvent"); - static const Events_ID kValidatorEvent = Events_Loop::eventByName(EVENT_VALIDATOR_LOADED); - if (theMessage->eventID() == kFeatureEvent) { - const Config_FeatureMessage* aMsg = dynamic_cast(theMessage); - if (aMsg) { - // proccess the plugin info, load plugin - if (myPlugins.find(aMsg->id()) == myPlugins.end()) { - myPlugins[aMsg->id()] = aMsg->pluginLibrary(); - } - } - // plugins information was started to load, so, it will be loaded - myPluginsInfoLoaded = true; - } else if (theMessage->eventID() == kValidatorEvent) { - const Config_ValidatorMessage* aMsg = dynamic_cast(theMessage); - if (aMsg) { - if (aMsg->attributeId().empty()) { // feature validator - validators()->assignValidator(aMsg->validatorId(), aMsg->featureId(), aMsg->parameters()); - } else { // attribute validator - validators()->assignValidator(aMsg->validatorId(), aMsg->featureId(), aMsg->attributeId(), - aMsg->parameters()); - } - } - } else { // create/update/delete - if (myCheckTransactions && !rootDocument()->isOperation()) - Events_Error::send("Modification of data structure outside of the transaction"); - } -} - -void Model_PluginManager::LoadPluginsInfo() -{ - if (myPluginsInfoLoaded) // nothing to do - return; - - // Read plugins information from XML files - Config_ModuleReader aXMLReader("FeatureRegisterEvent"); - aXMLReader.readAll(); -} - -void Model_PluginManager::registerPlugin(ModelAPI_Plugin* thePlugin) -{ - myPluginObjs[myCurrentPluginName] = 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); -} - -ModelAPI_ValidatorsFactory* Model_PluginManager::validators() -{ - static Model_ValidatorsFactory* aFactory = new Model_ValidatorsFactory; - return aFactory; -} diff --git a/src/Model/Model_PluginManager.h b/src/Model/Model_PluginManager.h deleted file mode 100644 index a1187a10b..000000000 --- a/src/Model/Model_PluginManager.h +++ /dev/null @@ -1,76 +0,0 @@ -// File: Model_PluginManager.hxx -// Created: 20 Mar 2014 -// Author: Mikhail PONIKAROV - -#ifndef Model_PluginManager_H_ -#define Model_PluginManager_H_ - -#include "Model.h" -#include -#include - -#include -#include - -class Model_Document; - -/**\class Model_PluginManager - * \ingroup DataModel - * \brief Object that knows (from the initial XML file) which - * plugin contains which feature, loads and stores reference to loaded plugins by - * the feature functionality request. - */ -class Model_PluginManager : public ModelAPI_PluginManager, public Events_Listener -{ - bool myPluginsInfoLoaded; ///< it true if plugins information is loaded - /// map of feature IDs to plugin name - std::map myPlugins; - std::map myPluginObjs; ///< instances of the already plugins - std::string myCurrentPluginName; ///< name of the plugin that must be loaded currently - boost::shared_ptr myCurrentDoc; ///< current working document - bool myCheckTransactions; ///< if true, generates error if document is updated outside of transaction - public: - /// Returns the root document of the application (that may contains sub-documents) - MODEL_EXPORT virtual boost::shared_ptr rootDocument(); - - /// Return true if root document has been already created - MODEL_EXPORT virtual bool hasRootDocument(); - - /// Returns the current document that used for current work in the application - MODEL_EXPORT virtual boost::shared_ptr currentDocument(); - - /// Defines the current document that used for current work in the application - MODEL_EXPORT virtual void setCurrentDocument(boost::shared_ptr theDoc); - - /// Registers the plugin that creates features. - /// It is obligatory for each plugin to call this function on loading to be found by - /// the plugin manager on call of the feature) - MODEL_EXPORT virtual void registerPlugin(ModelAPI_Plugin* thePlugin); - - /// Processes the configuration file reading - MODEL_EXPORT virtual void processEvent(const Events_Message* theMessage); - - /// Copies the document to the new one wit hthe given id - MODEL_EXPORT virtual boost::shared_ptr copy( - boost::shared_ptr theSource, std::string theID); - - /// Returns the validators factory: the only one instance per application - MODEL_EXPORT virtual ModelAPI_ValidatorsFactory* validators(); - - void setCheckTransactions(const bool theCheck) - { - myCheckTransactions = theCheck; - } - - /// Is called only once, on startup of the application - Model_PluginManager(); - - protected: - /// Loads (if not done yet) the information about the features and plugins - void LoadPluginsInfo(); - - /// Creates the feature object using plugins functionality - virtual FeaturePtr createFeature(std::string theFeatureID); -}; - -#endif diff --git a/src/Model/Model_ResultPart.cpp b/src/Model/Model_ResultPart.cpp index cdafeb6d0..6d1afbf48 100644 --- a/src/Model/Model_ResultPart.cpp +++ b/src/Model/Model_ResultPart.cpp @@ -5,7 +5,7 @@ #include #include #include -#include +#include boost::shared_ptr Model_ResultPart::partDoc() { @@ -40,5 +40,5 @@ void Model_ResultPart::activate() } } if (aDocRef->value()) - ModelAPI_PluginManager::get()->setCurrentDocument(aDocRef->value()); + ModelAPI_Session::get()->setCurrentDocument(aDocRef->value()); } diff --git a/src/Model/Model_Session.cpp b/src/Model/Model_Session.cpp new file mode 100644 index 000000000..730b6eca2 --- /dev/null +++ b/src/Model/Model_Session.cpp @@ -0,0 +1,171 @@ +// File: Model_Session.cxx +// Created: 20 Mar 2014 +// Author: Mikhail PONIKAROV + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include + +using namespace std; + +static Model_Session* myImpl = new Model_Session(); + +FeaturePtr Model_Session::createFeature(string theFeatureID) +{ + if (this != myImpl) + return myImpl->createFeature(theFeatureID); + + LoadPluginsInfo(); + if (myPlugins.find(theFeatureID) != myPlugins.end()) { + myCurrentPluginName = myPlugins[theFeatureID]; + if (myPluginObjs.find(myCurrentPluginName) == myPluginObjs.end()) { + // load plugin library if not yet done + Config_ModuleReader::loadLibrary(myCurrentPluginName); + } + if (myPluginObjs.find(myCurrentPluginName) != myPluginObjs.end()) { + FeaturePtr aCreated = myPluginObjs[myCurrentPluginName]->createFeature(theFeatureID); + if (!aCreated) { + Events_Error::send( + string("Can not initialize feature '") + theFeatureID + "' in plugin '" + + myCurrentPluginName + "'"); + } + return aCreated; + } else { + Events_Error::send(string("Can not load plugin '") + myCurrentPluginName + "'"); + } + } else { + Events_Error::send(string("Feature '") + theFeatureID + "' not found in any plugin"); + } + + return FeaturePtr(); // return nothing +} + +boost::shared_ptr Model_Session::rootDocument() +{ + return boost::shared_ptr( + Model_Application::getApplication()->getDocument("root")); +} + +bool Model_Session::hasRootDocument() +{ + return Model_Application::getApplication()->hasDocument("root"); +} + +boost::shared_ptr Model_Session::currentDocument() +{ + if (!myCurrentDoc || !Model_Application::getApplication()->hasDocument(myCurrentDoc->id())) + myCurrentDoc = rootDocument(); + return myCurrentDoc; +} + +void Model_Session::setCurrentDocument(boost::shared_ptr theDoc) +{ + myCurrentDoc = theDoc; + static Events_Message aMsg(Events_Loop::eventByName("CurrentDocumentChanged")); + Events_Loop::loop()->send(aMsg); +} + +boost::shared_ptr Model_Session::copy( + boost::shared_ptr theSource, std::string theID) +{ + // create a new document + boost::shared_ptr aNew = boost::dynamic_pointer_cast( + Model_Application::getApplication()->getDocument(theID)); + // make a copy of all labels + TDF_Label aSourceRoot = boost::dynamic_pointer_cast(theSource)->document()->Main() + .Father(); + TDF_Label aTargetRoot = aNew->document()->Main().Father(); + Handle(TDF_DataSet) aDS = new TDF_DataSet; + aDS->AddLabel(aSourceRoot); + TDF_ClosureTool::Closure(aDS); + Handle(TDF_RelocationTable) aRT = new TDF_RelocationTable; + aRT->SetRelocation(aSourceRoot, aTargetRoot); + TDF_CopyTool::Copy(aDS, aRT); + + aNew->synchronizeFeatures(); + return aNew; +} + +Model_Session::Model_Session() +{ + myPluginsInfoLoaded = false; + myCheckTransactions = true; + ModelAPI_Session::setSession(boost::shared_ptr(this)); + // register the configuration reading listener + Events_Loop* aLoop = Events_Loop::loop(); + static const Events_ID kFeatureEvent = Events_Loop::eventByName("FeatureRegisterEvent"); + aLoop->registerListener(this, kFeatureEvent); + aLoop->registerListener(this, Events_Loop::eventByName(EVENT_OBJECT_CREATED)); + aLoop->registerListener(this, Events_Loop::eventByName(EVENT_OBJECT_UPDATED)); + aLoop->registerListener(this, Events_Loop::eventByName(EVENT_OBJECT_DELETED)); + aLoop->registerListener(this, Events_Loop::eventByName(EVENT_VALIDATOR_LOADED)); +} + +void Model_Session::processEvent(const Events_Message* theMessage) +{ + static const Events_ID kFeatureEvent = Events_Loop::eventByName("FeatureRegisterEvent"); + static const Events_ID kValidatorEvent = Events_Loop::eventByName(EVENT_VALIDATOR_LOADED); + if (theMessage->eventID() == kFeatureEvent) { + const Config_FeatureMessage* aMsg = dynamic_cast(theMessage); + if (aMsg) { + // proccess the plugin info, load plugin + if (myPlugins.find(aMsg->id()) == myPlugins.end()) { + myPlugins[aMsg->id()] = aMsg->pluginLibrary(); + } + } + // plugins information was started to load, so, it will be loaded + myPluginsInfoLoaded = true; + } else if (theMessage->eventID() == kValidatorEvent) { + const Config_ValidatorMessage* aMsg = dynamic_cast(theMessage); + if (aMsg) { + if (aMsg->attributeId().empty()) { // feature validator + validators()->assignValidator(aMsg->validatorId(), aMsg->featureId(), aMsg->parameters()); + } else { // attribute validator + validators()->assignValidator(aMsg->validatorId(), aMsg->featureId(), aMsg->attributeId(), + aMsg->parameters()); + } + } + } else { // create/update/delete + if (myCheckTransactions && !rootDocument()->isOperation()) + Events_Error::send("Modification of data structure outside of the transaction"); + } +} + +void Model_Session::LoadPluginsInfo() +{ + if (myPluginsInfoLoaded) // nothing to do + return; + + // Read plugins information from XML files + Config_ModuleReader aXMLReader("FeatureRegisterEvent"); + aXMLReader.readAll(); +} + +void Model_Session::registerPlugin(ModelAPI_Plugin* thePlugin) +{ + myPluginObjs[myCurrentPluginName] = 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); +} + +ModelAPI_ValidatorsFactory* Model_Session::validators() +{ + static Model_ValidatorsFactory* aFactory = new Model_ValidatorsFactory; + return aFactory; +} diff --git a/src/Model/Model_Session.h b/src/Model/Model_Session.h new file mode 100644 index 000000000..cc1494a13 --- /dev/null +++ b/src/Model/Model_Session.h @@ -0,0 +1,76 @@ +// File: Model_Session.hxx +// Created: 20 Mar 2014 +// Author: Mikhail PONIKAROV + +#ifndef Model_Session_H_ +#define Model_Session_H_ + +#include "Model.h" +#include +#include + +#include +#include + +class Model_Document; + +/**\class Model_Session + * \ingroup DataModel + * \brief Object that knows (from the initial XML file) which + * plugin contains which feature, loads and stores reference to loaded plugins by + * the feature functionality request. + */ +class Model_Session : public ModelAPI_Session, public Events_Listener +{ + bool myPluginsInfoLoaded; ///< it true if plugins information is loaded + /// map of feature IDs to plugin name + std::map myPlugins; + std::map myPluginObjs; ///< instances of the already plugins + std::string myCurrentPluginName; ///< name of the plugin that must be loaded currently + boost::shared_ptr myCurrentDoc; ///< current working document + bool myCheckTransactions; ///< if true, generates error if document is updated outside of transaction + public: + /// Returns the root document of the application (that may contains sub-documents) + MODEL_EXPORT virtual boost::shared_ptr rootDocument(); + + /// Return true if root document has been already created + MODEL_EXPORT virtual bool hasRootDocument(); + + /// Returns the current document that used for current work in the application + MODEL_EXPORT virtual boost::shared_ptr currentDocument(); + + /// Defines the current document that used for current work in the application + MODEL_EXPORT virtual void setCurrentDocument(boost::shared_ptr theDoc); + + /// Registers the plugin that creates features. + /// It is obligatory for each plugin to call this function on loading to be found by + /// the plugin manager on call of the feature) + MODEL_EXPORT virtual void registerPlugin(ModelAPI_Plugin* thePlugin); + + /// Processes the configuration file reading + MODEL_EXPORT virtual void processEvent(const Events_Message* theMessage); + + /// Copies the document to the new one wit hthe given id + MODEL_EXPORT virtual boost::shared_ptr copy( + boost::shared_ptr theSource, std::string theID); + + /// Returns the validators factory: the only one instance per application + MODEL_EXPORT virtual ModelAPI_ValidatorsFactory* validators(); + + void setCheckTransactions(const bool theCheck) + { + myCheckTransactions = theCheck; + } + + /// Is called only once, on startup of the application + Model_Session(); + + protected: + /// Loads (if not done yet) the information about the features and plugins + void LoadPluginsInfo(); + + /// Creates the feature object using plugins functionality + virtual FeaturePtr createFeature(std::string theFeatureID); +}; + +#endif diff --git a/src/Model/Model_Update.cpp b/src/Model/Model_Update.cpp index 875d22dd1..380d12b3f 100644 --- a/src/Model/Model_Update.cpp +++ b/src/Model/Model_Update.cpp @@ -117,7 +117,7 @@ bool Model_Update::updateFeature(FeaturePtr theFeature) if (boost::dynamic_pointer_cast(theFeature->document())->executeFeatures() || !theFeature->isPersistentResult()) { - ModelAPI_ValidatorsFactory* aFactory = ModelAPI_PluginManager::get()->validators(); + ModelAPI_ValidatorsFactory* aFactory = ModelAPI_Session::get()->validators(); if (aFactory->validate(theFeature)) { try { theFeature->execute(); diff --git a/src/Model/Model_Validator.h b/src/Model/Model_Validator.h index f6f42b3cf..031295485 100644 --- a/src/Model/Model_Validator.h +++ b/src/Model/Model_Validator.h @@ -17,7 +17,7 @@ * Allows to get a validator by the feature identifier and * the attribute identifier (if attribute is validated). * All accessible validators mustbe registered by the ID string first. - * The instance of this factory can be get in the PluginManager. + * The instance of this factory can be get in the Session. * Keeps the validator objects alive and just returns one of it by request. * All the needed information is provided to the validator as an argument, * this allows to work with them independently from the feature specific object. @@ -70,10 +70,10 @@ class Model_ValidatorsFactory : public ModelAPI_ValidatorsFactory protected: void addDefaultValidators(std::list& theValidators) const; - /// Get instance from PluginManager + /// Get instance from Session Model_ValidatorsFactory(); - friend class Model_PluginManager; + friend class Model_Session; }; #endif diff --git a/src/ModelAPI/CMakeLists.txt b/src/ModelAPI/CMakeLists.txt index ccac1a79e..9af7ad47a 100644 --- a/src/ModelAPI/CMakeLists.txt +++ b/src/ModelAPI/CMakeLists.txt @@ -5,7 +5,7 @@ INCLUDE(UnitTest) SET(PROJECT_HEADERS ModelAPI.h - ModelAPI_PluginManager.h + ModelAPI_Session.h ModelAPI_Plugin.h ModelAPI_Feature.h ModelAPI_Data.h @@ -36,7 +36,7 @@ SET(PROJECT_HEADERS SET(PROJECT_SOURCES ModelAPI_Feature.cpp - ModelAPI_PluginManager.cpp + ModelAPI_Session.cpp ModelAPI_Tools.cpp ) diff --git a/src/ModelAPI/ModelAPI.i b/src/ModelAPI/ModelAPI.i index dbcb59eaf..c8fddd2f8 100644 --- a/src/ModelAPI/ModelAPI.i +++ b/src/ModelAPI/ModelAPI.i @@ -5,7 +5,7 @@ #include "GeomAPI_Shape.h" #include "ModelAPI.h" #include "ModelAPI_Document.h" - #include "ModelAPI_PluginManager.h" + #include "ModelAPI_Session.h" #include "ModelAPI_Object.h" #include "ModelAPI_Feature.h" #include "ModelAPI_Data.h" @@ -44,7 +44,7 @@ %shared_ptr(GeomAPI_Interface) %shared_ptr(GeomAPI_Shape) %shared_ptr(ModelAPI_Document) -%shared_ptr(ModelAPI_PluginManager) +%shared_ptr(ModelAPI_Session) %shared_ptr(ModelAPI_Object) %shared_ptr(ModelAPI_Feature) %shared_ptr(ModelAPI_Data) @@ -63,7 +63,7 @@ %include "GeomAPI_Interface.h" %include "GeomAPI_Shape.h" %include "ModelAPI_Document.h" -%include "ModelAPI_PluginManager.h" +%include "ModelAPI_Session.h" %include "ModelAPI_Object.h" %include "ModelAPI_Feature.h" %include "ModelAPI_Data.h" diff --git a/src/ModelAPI/ModelAPI_Feature.cpp b/src/ModelAPI/ModelAPI_Feature.cpp index 488c8e55f..72fdcd9b3 100644 --- a/src/ModelAPI/ModelAPI_Feature.cpp +++ b/src/ModelAPI/ModelAPI_Feature.cpp @@ -88,7 +88,7 @@ void ModelAPI_Feature::eraseResults() boost::shared_ptr ModelAPI_Feature::documentToAdd() { - return ModelAPI_PluginManager::get()->currentDocument(); + return ModelAPI_Session::get()->currentDocument(); } ModelAPI_Feature::~ModelAPI_Feature() diff --git a/src/ModelAPI/ModelAPI_Feature.h b/src/ModelAPI/ModelAPI_Feature.h index ef1212afc..2c252429d 100644 --- a/src/ModelAPI/ModelAPI_Feature.h +++ b/src/ModelAPI/ModelAPI_Feature.h @@ -6,7 +6,7 @@ #define ModelAPI_Feature_H_ #include "ModelAPI_Object.h" -#include "ModelAPI_PluginManager.h" +#include "ModelAPI_Session.h" #include #include diff --git a/src/ModelAPI/ModelAPI_PluginManager.cpp b/src/ModelAPI/ModelAPI_PluginManager.cpp deleted file mode 100644 index 52f14deba..000000000 --- a/src/ModelAPI/ModelAPI_PluginManager.cpp +++ /dev/null @@ -1,74 +0,0 @@ -// File: ModelAPI_PluginManager.hxx -// Created: 20 Mar 2014 -// Author: Mikhail PONIKAROV - -#include -// to avoid unresolved ModelAPI_Document() -#include -// to avoid unresolved ModelAPI_Feature() -#include -#include -// to avoid unresolved ModelAPI_Data() -#include -// to avoid unresolved ModelAPI_Plugin() -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include - -#ifdef WIN32 -#include -#else -#include -#endif - -using namespace std; - -#ifdef _DEBUG -#include -#endif - -/// Manager that will be initialized from Model package, one per application -boost::shared_ptr MY_MANAGER; - -ModelAPI_PluginManager::ModelAPI_PluginManager() -{ -} - -void ModelAPI_PluginManager::setPluginManager(boost::shared_ptr theManager) -{ - MY_MANAGER = theManager; -} - -boost::shared_ptr ModelAPI_PluginManager::get() -{ - if (!MY_MANAGER) { // import Model library that implements this interface of ModelAPI - Config_ModuleReader::loadLibrary("Model"); - } - return MY_MANAGER; -} - -const ModelAPI_EventCreator* MY_API_CREATOR = 0; ///< instance of the events creator, one pre application - -const ModelAPI_EventCreator* ModelAPI_EventCreator::get() -{ - if (!MY_API_CREATOR) { // import Model library that implements this interface of ModelAPI - Config_ModuleReader::loadLibrary("Model"); - } - return MY_API_CREATOR; -} - -void ModelAPI_EventCreator::set(const ModelAPI_EventCreator* theCreator) -{ - MY_API_CREATOR = theCreator; -} diff --git a/src/ModelAPI/ModelAPI_PluginManager.h b/src/ModelAPI/ModelAPI_PluginManager.h deleted file mode 100644 index 90a59a9ef..000000000 --- a/src/ModelAPI/ModelAPI_PluginManager.h +++ /dev/null @@ -1,73 +0,0 @@ -// File: ModelAPI_PluginManager.hxx -// Created: 20 Mar 2014 -// Author: Mikhail PONIKAROV - -#ifndef ModelAPI_PluginManager_H_ -#define ModelAPI_PluginManager_H_ - -#include "ModelAPI.h" -#include -#include - -class ModelAPI_Feature; -class ModelAPI_Plugin; -class ModelAPI_Document; -class ModelAPI_ValidatorsFactory; - -/**\class ModelAPI_PluginManager - * \ingroup DataModel - * \brief Object that knows (from the initial XML file) which - * plugin contains which feature, loads and stores reference to loaded plugins by - * the feature functionality request. - */ - -class MODELAPI_EXPORT ModelAPI_PluginManager -{ - public: - /// Returns the real implementation (the alone instance per application) of the plugin manager - static boost::shared_ptr get(); - - /// Registers the plugin that creates features. - /// It is obligatory for each plugin to call this function on loading to be found by - /// the plugin manager on call of the feature) - virtual void registerPlugin(ModelAPI_Plugin* thePlugin) = 0; - - /// Returns the root document of the application (that may contains sub-documents) - virtual boost::shared_ptr rootDocument() = 0; - - /// Return true if root document has been already created - virtual bool hasRootDocument() = 0; - - /// Returns the current document that used for current work in the application - virtual boost::shared_ptr currentDocument() = 0; - - /// Defines the current document that used for current work in the application - virtual void setCurrentDocument(boost::shared_ptr theDoc) = 0; - - /// Copies the document to the new one wit hthe given id - virtual boost::shared_ptr copy(boost::shared_ptr theSource, - std::string theID) = 0; - - /// Returns the validators factory: the only one instance per application - virtual ModelAPI_ValidatorsFactory* validators() = 0; - - /// Is needed for python wrapping by swig, call Get to get an instance - ModelAPI_PluginManager(); - - /// To virtually destroy the fields of successors - virtual ~ModelAPI_PluginManager() - { - } - - protected: - /// Creates the feature object using plugins functionality - virtual boost::shared_ptr createFeature(std::string theFeatureID) = 0; - - static void setPluginManager(boost::shared_ptr theManager); - - friend class Model_Document; -}; - -typedef boost::shared_ptr PluginManagerPtr; - -#endif diff --git a/src/ModelAPI/ModelAPI_Session.cpp b/src/ModelAPI/ModelAPI_Session.cpp new file mode 100644 index 000000000..1a6ebf6f3 --- /dev/null +++ b/src/ModelAPI/ModelAPI_Session.cpp @@ -0,0 +1,74 @@ +// File: ModelAPI_Session.hxx +// Created: 20 Mar 2014 +// Author: Mikhail PONIKAROV + +#include +// to avoid unresolved ModelAPI_Document() +#include +// to avoid unresolved ModelAPI_Feature() +#include +#include +// to avoid unresolved ModelAPI_Data() +#include +// to avoid unresolved ModelAPI_Plugin() +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#ifdef WIN32 +#include +#else +#include +#endif + +using namespace std; + +#ifdef _DEBUG +#include +#endif + +/// Manager that will be initialized from Model package, one per application +boost::shared_ptr MY_MANAGER; + +ModelAPI_Session::ModelAPI_Session() +{ +} + +void ModelAPI_Session::setSession(boost::shared_ptr theManager) +{ + MY_MANAGER = theManager; +} + +boost::shared_ptr ModelAPI_Session::get() +{ + if (!MY_MANAGER) { // import Model library that implements this interface of ModelAPI + Config_ModuleReader::loadLibrary("Model"); + } + return MY_MANAGER; +} + +const ModelAPI_EventCreator* MY_API_CREATOR = 0; ///< instance of the events creator, one pre application + +const ModelAPI_EventCreator* ModelAPI_EventCreator::get() +{ + if (!MY_API_CREATOR) { // import Model library that implements this interface of ModelAPI + Config_ModuleReader::loadLibrary("Model"); + } + return MY_API_CREATOR; +} + +void ModelAPI_EventCreator::set(const ModelAPI_EventCreator* theCreator) +{ + MY_API_CREATOR = theCreator; +} diff --git a/src/ModelAPI/ModelAPI_Session.h b/src/ModelAPI/ModelAPI_Session.h new file mode 100644 index 000000000..0c6df4987 --- /dev/null +++ b/src/ModelAPI/ModelAPI_Session.h @@ -0,0 +1,73 @@ +// File: ModelAPI_Session.hxx +// Created: 20 Mar 2014 +// Author: Mikhail PONIKAROV + +#ifndef ModelAPI_Session_H_ +#define ModelAPI_Session_H_ + +#include "ModelAPI.h" +#include +#include + +class ModelAPI_Feature; +class ModelAPI_Plugin; +class ModelAPI_Document; +class ModelAPI_ValidatorsFactory; + +/**\class ModelAPI_Session + * \ingroup DataModel + * \brief Object that knows (from the initial XML file) which + * plugin contains which feature, loads and stores reference to loaded plugins by + * the feature functionality request. + */ + +class MODELAPI_EXPORT ModelAPI_Session +{ + public: + /// Returns the real implementation (the alone instance per application) of the plugin manager + static boost::shared_ptr get(); + + /// Registers the plugin that creates features. + /// It is obligatory for each plugin to call this function on loading to be found by + /// the plugin manager on call of the feature) + virtual void registerPlugin(ModelAPI_Plugin* thePlugin) = 0; + + /// Returns the root document of the application (that may contains sub-documents) + virtual boost::shared_ptr rootDocument() = 0; + + /// Return true if root document has been already created + virtual bool hasRootDocument() = 0; + + /// Returns the current document that used for current work in the application + virtual boost::shared_ptr currentDocument() = 0; + + /// Defines the current document that used for current work in the application + virtual void setCurrentDocument(boost::shared_ptr theDoc) = 0; + + /// Copies the document to the new one with the given id + virtual boost::shared_ptr copy(boost::shared_ptr theSource, + std::string theID) = 0; + + /// Returns the validators factory: the only one instance per application + virtual ModelAPI_ValidatorsFactory* validators() = 0; + + /// Is needed for python wrapping by swig, call Get to get an instance + ModelAPI_Session(); + + /// To virtually destroy the fields of successors + virtual ~ModelAPI_Session() + { + } + + protected: + /// Creates the feature object using plugins functionality + virtual boost::shared_ptr createFeature(std::string theFeatureID) = 0; + + static void setSession(boost::shared_ptr theManager); + + friend class Model_Document; +}; + +typedef boost::shared_ptr SessionPtr; + +#endif diff --git a/src/ModelAPI/ModelAPI_Validator.h b/src/ModelAPI/ModelAPI_Validator.h index a3e378856..f4ecd1923 100644 --- a/src/ModelAPI/ModelAPI_Validator.h +++ b/src/ModelAPI/ModelAPI_Validator.h @@ -47,7 +47,7 @@ typedef boost::shared_ptr ValidatorPtr; * Allows to get a validator by the feature identifier and * the attribute identifier (if attribute is validated). * All accessible validators mustbe registered by the ID string first. - * The instance of this factory can be get in the PluginManager. + * The instance of this factory can be get in the Session. * Keeps the validator objects alive and just returns one of it by request. * All the needed information is provided to the validator as an argument, * this allows to work with them independently from the feature specific object. @@ -87,7 +87,7 @@ class MODELAPI_EXPORT ModelAPI_ValidatorsFactory virtual bool validate(const boost::shared_ptr& theFeature) const = 0; protected: - /// Get instance from PluginManager + /// Get instance from Session ModelAPI_ValidatorsFactory() { } diff --git a/src/ModuleBase/ModuleBase_IOperation.cpp b/src/ModuleBase/ModuleBase_IOperation.cpp index e873562e5..fec4856da 100644 --- a/src/ModuleBase/ModuleBase_IOperation.cpp +++ b/src/ModuleBase/ModuleBase_IOperation.cpp @@ -10,7 +10,7 @@ #include "ModuleBase_ModelWidget.h" #include -#include +#include #ifdef _DEBUG #include @@ -51,7 +51,7 @@ bool ModuleBase_IOperation::canBeCommitted() const boost::shared_ptr ModuleBase_IOperation::document() const { - return ModelAPI_PluginManager::get()->rootDocument(); + return ModelAPI_Session::get()->rootDocument(); } void ModuleBase_IOperation::start() diff --git a/src/ModuleBase/ModuleBase_Operation.cpp b/src/ModuleBase/ModuleBase_Operation.cpp index 50d2478ad..30062efc4 100644 --- a/src/ModuleBase/ModuleBase_Operation.cpp +++ b/src/ModuleBase/ModuleBase_Operation.cpp @@ -98,7 +98,7 @@ bool ModuleBase_Operation::canBeCommitted() const /* FeaturePtr aFeature = feature(); std::string aId = aFeature->getKind(); - PluginManagerPtr aMgr = ModelAPI_PluginManager::get(); + SessionPtr aMgr = ModelAPI_Session::get(); ModelAPI_ValidatorsFactory* aFactory = aMgr->validators(); std::list aValidators; aFactory->validators(aId, aValidators); diff --git a/src/ModuleBase/ModuleBase_WidgetFeature.cpp b/src/ModuleBase/ModuleBase_WidgetFeature.cpp index e7c510a83..6586a491a 100644 --- a/src/ModuleBase/ModuleBase_WidgetFeature.cpp +++ b/src/ModuleBase/ModuleBase_WidgetFeature.cpp @@ -71,7 +71,7 @@ bool ModuleBase_WidgetFeature::setValue(ModuleBase_WidgetValue* theValue) bool ModuleBase_WidgetFeature::setObject(const ObjectPtr& theObject, bool theSendEvent) { - PluginManagerPtr aMgr = ModelAPI_PluginManager::get(); + SessionPtr aMgr = ModelAPI_Session::get(); ModelAPI_ValidatorsFactory* aFactory = aMgr->validators(); std::list aValidators; std::list > anArguments; diff --git a/src/PartSet/PartSet_Module.cpp b/src/PartSet/PartSet_Module.cpp index cf2bcbc7c..bb42c3373 100644 --- a/src/PartSet/PartSet_Module.cpp +++ b/src/PartSet/PartSet_Module.cpp @@ -109,7 +109,7 @@ XGUI_Workshop* PartSet_Module::workshop() const void PartSet_Module::createFeatures() { //Registering of validators - PluginManagerPtr aMgr = ModelAPI_PluginManager::get(); + SessionPtr aMgr = ModelAPI_Session::get(); ModelAPI_ValidatorsFactory* aFactory = aMgr->validators(); aFactory->registerValidator("PartSet_DistanceValidator", new PartSet_DistanceValidator); aFactory->registerValidator("PartSet_LengthValidator", new PartSet_LengthValidator); diff --git a/src/PartSet/PartSet_TestOCC.cpp b/src/PartSet/PartSet_TestOCC.cpp index 727a97915..f67a1e06a 100644 --- a/src/PartSet/PartSet_TestOCC.cpp +++ b/src/PartSet/PartSet_TestOCC.cpp @@ -132,7 +132,7 @@ void PartSet_TestOCC::createTestLine(XGUI_Workshop* theWorkshop) if (aPreviewOp) { // create a line - boost::shared_ptr aDoc = ModelAPI_PluginManager::get()->rootDocument(); + boost::shared_ptr aDoc = ModelAPI_Session::get()->rootDocument(); FeaturePtr aFeature = aDoc->addFeature(SketchPlugin_Line::ID()); if (aFeature) // TODO: generate an error if feature was not created aFeature->execute(); diff --git a/src/PartSet/PartSet_Tools.cpp b/src/PartSet/PartSet_Tools.cpp index 92c66ffbe..f301c8e0a 100644 --- a/src/PartSet/PartSet_Tools.cpp +++ b/src/PartSet/PartSet_Tools.cpp @@ -171,7 +171,7 @@ FeaturePtr PartSet_Tools::nearestFeature(QPoint thePoint, Handle_V3d_View theVie boost::shared_ptr PartSet_Tools::document() { - return ModelAPI_PluginManager::get()->rootDocument(); + return ModelAPI_Session::get()->rootDocument(); } void PartSet_Tools::setFeaturePoint(FeaturePtr theFeature, double theX, double theY, diff --git a/src/PartSetPlugin/PartSetPlugin_Duplicate.cpp b/src/PartSetPlugin/PartSetPlugin_Duplicate.cpp index 7f94e6943..f8ebfd900 100644 --- a/src/PartSetPlugin/PartSetPlugin_Duplicate.cpp +++ b/src/PartSetPlugin/PartSetPlugin_Duplicate.cpp @@ -20,7 +20,7 @@ void PartSetPlugin_Duplicate::initAttributes() PartSetPlugin_Part::initAttributes(); data()->addAttribute(ORIGIN_REF(), ModelAPI_AttributeRefAttr::type()); - boost::shared_ptr aPManager = ModelAPI_PluginManager::get(); + boost::shared_ptr aPManager = ModelAPI_Session::get(); boost::shared_ptr aRoot = aPManager->rootDocument(); boost::shared_ptr aSource; // searching for source document attribute for (int a = aRoot->size(getGroup()) - 1; a >= 0; a--) { diff --git a/src/PartSetPlugin/PartSetPlugin_Part.cpp b/src/PartSetPlugin/PartSetPlugin_Part.cpp index e01c02bb0..739f63629 100644 --- a/src/PartSetPlugin/PartSetPlugin_Part.cpp +++ b/src/PartSetPlugin/PartSetPlugin_Part.cpp @@ -3,7 +3,7 @@ // Author: Mikhail PONIKAROV #include "PartSetPlugin_Part.h" -#include "ModelAPI_PluginManager.h" +#include "ModelAPI_Session.h" #include "ModelAPI_Document.h" #include "ModelAPI_Data.h" #include "ModelAPI_AttributeDocRef.h" @@ -32,7 +32,7 @@ void PartSetPlugin_Part::execute() if (!aDocRef->value()) { // create a document if not yet created boost::shared_ptr aPartSetDoc = - ModelAPI_PluginManager::get()->rootDocument(); + ModelAPI_Session::get()->rootDocument(); aDocRef->setValue(aPartSetDoc->subDocument(data()->name())); } */ @@ -40,5 +40,5 @@ void PartSetPlugin_Part::execute() boost::shared_ptr PartSetPlugin_Part::documentToAdd() { - return ModelAPI_PluginManager::get()->rootDocument(); + return ModelAPI_Session::get()->rootDocument(); } diff --git a/src/PartSetPlugin/PartSetPlugin_Plugin.cpp b/src/PartSetPlugin/PartSetPlugin_Plugin.cpp index 6dfc43704..7f331fd76 100644 --- a/src/PartSetPlugin/PartSetPlugin_Plugin.cpp +++ b/src/PartSetPlugin/PartSetPlugin_Plugin.cpp @@ -2,7 +2,7 @@ #include "PartSetPlugin_Part.h" #include "PartSetPlugin_Duplicate.h" #include "PartSetPlugin_Remove.h" -#include +#include #include using namespace std; @@ -13,7 +13,7 @@ static PartSetPlugin_Plugin* MY_INSTANCE = new PartSetPlugin_Plugin(); PartSetPlugin_Plugin::PartSetPlugin_Plugin() { // register this plugin - ModelAPI_PluginManager::get()->registerPlugin(this); + ModelAPI_Session::get()->registerPlugin(this); } FeaturePtr PartSetPlugin_Plugin::createFeature(string theFeatureID) diff --git a/src/PartSetPlugin/PartSetPlugin_Remove.cpp b/src/PartSetPlugin/PartSetPlugin_Remove.cpp index 28ee6b797..d6053e5dc 100644 --- a/src/PartSetPlugin/PartSetPlugin_Remove.cpp +++ b/src/PartSetPlugin/PartSetPlugin_Remove.cpp @@ -11,7 +11,7 @@ void PartSetPlugin_Remove::execute() { - boost::shared_ptr aPManager = ModelAPI_PluginManager::get(); + boost::shared_ptr aPManager = ModelAPI_Session::get(); boost::shared_ptr aRoot = aPManager->rootDocument(); boost::shared_ptr aCurrent; boost::shared_ptr a; diff --git a/src/SketchPlugin/SketchPlugin_Plugin.cpp b/src/SketchPlugin/SketchPlugin_Plugin.cpp index 6fcb0c400..90f54d560 100644 --- a/src/SketchPlugin/SketchPlugin_Plugin.cpp +++ b/src/SketchPlugin/SketchPlugin_Plugin.cpp @@ -12,7 +12,7 @@ #include "SketchPlugin_ConstraintRadius.h" #include "SketchPlugin_Validators.h" #include "SketchPlugin_ResultValidators.h" -#include +#include #include #include @@ -25,7 +25,7 @@ static SketchPlugin_Plugin* MY_INSTANCE = new SketchPlugin_Plugin(); SketchPlugin_Plugin::SketchPlugin_Plugin() { - PluginManagerPtr aMgr = ModelAPI_PluginManager::get(); + SessionPtr aMgr = ModelAPI_Session::get(); ModelAPI_ValidatorsFactory* aFactory = aMgr->validators(); aFactory->registerValidator("SketchPlugin_DistanceAttrValidator", new SketchPlugin_DistanceAttrValidator); @@ -36,7 +36,7 @@ SketchPlugin_Plugin::SketchPlugin_Plugin() aFactory->registerValidator("SketchPlugin_ResultArcValidator", new SketchPlugin_ResultArcValidator); // register this plugin - ModelAPI_PluginManager::get()->registerPlugin(this); + ModelAPI_Session::get()->registerPlugin(this); // register sketcher properties Config_PropManager::registerProp("Sketch planes", "planes_color", "Color", Config_Prop::Color, diff --git a/src/SketchPlugin/SketchPlugin_Validators.cpp b/src/SketchPlugin/SketchPlugin_Validators.cpp index 2d135af00..14f5aaa9b 100644 --- a/src/SketchPlugin/SketchPlugin_Validators.cpp +++ b/src/SketchPlugin/SketchPlugin_Validators.cpp @@ -15,7 +15,7 @@ bool SketchPlugin_DistanceAttrValidator::isValid(const FeaturePtr& theFeature, const ObjectPtr& theObject) const { std::string aParamA = theArguments.front(); - PluginManagerPtr aMgr = ModelAPI_PluginManager::get(); + SessionPtr aMgr = ModelAPI_Session::get(); ModelAPI_ValidatorsFactory* aFactory = aMgr->validators(); // If the object is not a line then it is accepted diff --git a/src/SketchSolver/SketchSolver_ConstraintManager.cpp b/src/SketchSolver/SketchSolver_ConstraintManager.cpp index 4a2cf08ee..480fae603 100644 --- a/src/SketchSolver/SketchSolver_ConstraintManager.cpp +++ b/src/SketchSolver/SketchSolver_ConstraintManager.cpp @@ -56,7 +56,7 @@ SketchSolver_ConstraintManager::~SketchSolver_ConstraintManager() // ============================================================================ // Function: processEvent -// Class: SketchSolver_PluginManager +// Class: SketchSolver_Session // Purpose: listen the event loop and process the message // ============================================================================ void SketchSolver_ConstraintManager::processEvent(const Events_Message* theMessage) @@ -136,7 +136,7 @@ void SketchSolver_ConstraintManager::processEvent(const Events_Message* theMessa // ============================================================================ // Function: changeWorkplane -// Class: SketchSolver_PluginManager +// Class: SketchSolver_Session // Purpose: update workplane by given parameters of the sketch // ============================================================================ bool SketchSolver_ConstraintManager::changeWorkplane( @@ -167,7 +167,7 @@ bool SketchSolver_ConstraintManager::changeWorkplane( // ============================================================================ // Function: changeConstraint -// Class: SketchSolver_PluginManager +// Class: SketchSolver_Session // Purpose: create/update the constraint and place it into appropriate group // ============================================================================ bool SketchSolver_ConstraintManager::changeConstraint( @@ -235,7 +235,7 @@ bool SketchSolver_ConstraintManager::changeConstraint( // ============================================================================ // Function: updateEntity -// Class: SketchSolver_PluginManager +// Class: SketchSolver_Session // Purpose: update any element on the sketch, which is used by constraints // ============================================================================ void SketchSolver_ConstraintManager::updateEntity( @@ -286,7 +286,7 @@ void SketchSolver_ConstraintManager::updateEntity( // ============================================================================ // Function: findGroups -// Class: SketchSolver_PluginManager +// Class: SketchSolver_Session // Purpose: search groups of entities interacting with given constraint // ============================================================================ void SketchSolver_ConstraintManager::findGroups( @@ -312,7 +312,7 @@ void SketchSolver_ConstraintManager::findGroups( // ============================================================================ // Function: findWorkplaneForConstraint -// Class: SketchSolver_PluginManager +// Class: SketchSolver_Session // Purpose: search workplane containing given constraint // ============================================================================ boost::shared_ptr SketchSolver_ConstraintManager::findWorkplaneForConstraint( @@ -342,7 +342,7 @@ boost::shared_ptr SketchSolver_ConstraintManager::findWork // ============================================================================ // Function: resolveConstraints -// Class: SketchSolver_PluginManager +// Class: SketchSolver_Session // Purpose: change entities according to available constraints // ============================================================================ void SketchSolver_ConstraintManager::resolveConstraints() diff --git a/src/XGUI/XGUI_ContextMenuMgr.cpp b/src/XGUI/XGUI_ContextMenuMgr.cpp index c24669c70..34c334147 100644 --- a/src/XGUI/XGUI_ContextMenuMgr.cpp +++ b/src/XGUI/XGUI_ContextMenuMgr.cpp @@ -106,7 +106,7 @@ QMenu* XGUI_ContextMenuMgr::objectBrowserMenu() const QList aObjects = aSelMgr->selection()->selectedObjects(); int aSelected = aObjects.size(); if (aSelected > 0) { - PluginManagerPtr aMgr = ModelAPI_PluginManager::get(); + SessionPtr aMgr = ModelAPI_Session::get(); XGUI_Displayer* aDisplayer = myWorkshop->displayer(); //Process Feature if (aSelected == 1) { diff --git a/src/XGUI/XGUI_DocumentDataModel.cpp b/src/XGUI/XGUI_DocumentDataModel.cpp index 17dfe99b9..0fcbd794b 100644 --- a/src/XGUI/XGUI_DocumentDataModel.cpp +++ b/src/XGUI/XGUI_DocumentDataModel.cpp @@ -3,7 +3,7 @@ #include "XGUI_Workshop.h" #include "XGUI_Tools.h" -#include +#include #include #include #include @@ -45,7 +45,7 @@ XGUI_DocumentDataModel::~XGUI_DocumentDataModel() void XGUI_DocumentDataModel::processEvent(const Events_Message* theMessage) { - DocumentPtr aRootDoc = ModelAPI_PluginManager::get()->rootDocument(); + DocumentPtr aRootDoc = ModelAPI_Session::get()->rootDocument(); // Created object event ******************* if (theMessage->eventID() == Events_Loop::loop()->eventByName(EVENT_OBJECT_CREATED)) { @@ -155,7 +155,7 @@ void XGUI_DocumentDataModel::processEvent(const Events_Message* theMessage) void XGUI_DocumentDataModel::rebuildDataTree() { - DocumentPtr aRootDoc = ModelAPI_PluginManager::get()->rootDocument(); + DocumentPtr aRootDoc = ModelAPI_Session::get()->rootDocument(); beginResetModel(); clearModelIndexes(); @@ -200,7 +200,7 @@ QVariant XGUI_DocumentDataModel::data(const QModelIndex& theIndex, int theRole) case HistoryNode: { int aOffset = historyOffset(); - DocumentPtr aRootDoc = ModelAPI_PluginManager::get()->rootDocument(); + DocumentPtr aRootDoc = ModelAPI_Session::get()->rootDocument(); ObjectPtr aObj = aRootDoc->object(ModelAPI_Feature::group(), theIndex.row() - aOffset); FeaturePtr aFeature = boost::dynamic_pointer_cast(aObj); if (!aFeature) @@ -242,7 +242,7 @@ QVariant XGUI_DocumentDataModel::headerData(int theSection, Qt::Orientation theO int XGUI_DocumentDataModel::rowCount(const QModelIndex& theParent) const { if (!theParent.isValid()) { - DocumentPtr aRootDoc = ModelAPI_PluginManager::get()->rootDocument(); + DocumentPtr aRootDoc = ModelAPI_Session::get()->rootDocument(); // Size of external models int aVal = historyOffset(); // Plus history size @@ -371,7 +371,7 @@ ObjectPtr XGUI_DocumentDataModel::object(const QModelIndex& theIndex) const if (theIndex.internalId() == PartsFolder) return ObjectPtr(); if (theIndex.internalId() == HistoryNode) { - DocumentPtr aRootDoc = ModelAPI_PluginManager::get()->rootDocument(); + DocumentPtr aRootDoc = ModelAPI_Session::get()->rootDocument(); int aOffset = historyOffset(); return aRootDoc->object(ModelAPI_Feature::group(), theIndex.row() - aOffset); } @@ -529,7 +529,7 @@ QModelIndex XGUI_DocumentDataModel::partIndex(const ResultPartPtr& theObject) co QModelIndex XGUI_DocumentDataModel::objectIndex(const ObjectPtr theObject) const { // Check that this feature belongs to root document - DocumentPtr aRootDoc = ModelAPI_PluginManager::get()->rootDocument(); + DocumentPtr aRootDoc = ModelAPI_Session::get()->rootDocument(); DocumentPtr aDoc = theObject->document(); if (aDoc == aRootDoc) { // This feature belongs to histrory or top model diff --git a/src/XGUI/XGUI_ObjectsBrowser.cpp b/src/XGUI/XGUI_ObjectsBrowser.cpp index af509801a..c128f3235 100644 --- a/src/XGUI/XGUI_ObjectsBrowser.cpp +++ b/src/XGUI/XGUI_ObjectsBrowser.cpp @@ -3,7 +3,7 @@ #include "XGUI_Tools.h" #include -#include +#include #include #include @@ -83,7 +83,7 @@ void XGUI_DataTree::commitData(QWidget* theEditor) if (aEditor) { QString aRes = aEditor->text(); ObjectPtr aFeature = mySelectedData.first(); - PluginManagerPtr aMgr = ModelAPI_PluginManager::get(); + SessionPtr aMgr = ModelAPI_Session::get(); aMgr->rootDocument()->startOperation(); aFeature->data()->setName(qPrintable(aRes)); aMgr->rootDocument()->finishOperation(); @@ -119,7 +119,7 @@ XGUI_ObjectsBrowser::XGUI_ObjectsBrowser(QWidget* theParent) aLabelLay->addWidget(aLbl); - PluginManagerPtr aMgr = ModelAPI_PluginManager::get(); + SessionPtr aMgr = ModelAPI_Session::get(); DocumentPtr aDoc = aMgr->rootDocument(); // TODO: Find a name of the root document @@ -226,7 +226,7 @@ void XGUI_ObjectsBrowser::closeDocNameEditing(bool toSave) myActiveDocLbl->setReadOnly(true); if (toSave) { // TODO: Save the name of root document - PluginManagerPtr aMgr = ModelAPI_PluginManager::get(); + SessionPtr aMgr = ModelAPI_Session::get(); DocumentPtr aDoc = aMgr->rootDocument(); } else { myActiveDocLbl->setText(myActiveDocLbl->property("OldText").toString()); diff --git a/src/XGUI/XGUI_OperationMgr.cpp b/src/XGUI/XGUI_OperationMgr.cpp index d10689f04..aa836f4cf 100644 --- a/src/XGUI/XGUI_OperationMgr.cpp +++ b/src/XGUI/XGUI_OperationMgr.cpp @@ -82,7 +82,7 @@ void XGUI_OperationMgr::validateOperation(ModuleBase_Operation* theOperation) QString anOperationId = theOperation->id(); FeaturePtr aFeature = theOperation->feature(); //Get validators for the Id - PluginManagerPtr aMgr = ModelAPI_PluginManager::get(); + SessionPtr aMgr = ModelAPI_Session::get(); ModelAPI_ValidatorsFactory* aFactory = aMgr->validators(); bool isValid = aFactory->validate(aFeature); diff --git a/src/XGUI/XGUI_PartDataModel.cpp b/src/XGUI/XGUI_PartDataModel.cpp index 6a5ffdc96..6f6fc8f04 100644 --- a/src/XGUI/XGUI_PartDataModel.cpp +++ b/src/XGUI/XGUI_PartDataModel.cpp @@ -1,7 +1,7 @@ #include "XGUI_PartDataModel.h" #include "XGUI_Workshop.h" -#include +#include #include #include #include @@ -42,7 +42,7 @@ QVariant XGUI_TopDataModel::data(const QModelIndex& theIndex, int theRole) const case ParamsFolder: return tr("Parameters") + QString(" (%1)").arg(rowCount(theIndex)); case ParamObject: { - DocumentPtr aRootDoc = ModelAPI_PluginManager::get()->rootDocument(); + DocumentPtr aRootDoc = ModelAPI_Session::get()->rootDocument(); ObjectPtr aObject = aRootDoc->object(ModelAPI_ResultParameters::group(), theIndex.row()); if (aObject) return aObject->data()->name().c_str(); @@ -51,7 +51,7 @@ QVariant XGUI_TopDataModel::data(const QModelIndex& theIndex, int theRole) const case ConstructFolder: return tr("Constructions") + QString(" (%1)").arg(rowCount(theIndex)); case ConstructObject: { - DocumentPtr aRootDoc = ModelAPI_PluginManager::get()->rootDocument(); + DocumentPtr aRootDoc = ModelAPI_Session::get()->rootDocument(); ObjectPtr aObject = aRootDoc->object(ModelAPI_ResultConstruction::group(), theIndex.row()); if (aObject) @@ -61,7 +61,7 @@ QVariant XGUI_TopDataModel::data(const QModelIndex& theIndex, int theRole) const case BodiesFolder: return tr("Bodies") + QString(" (%1)").arg(rowCount(theIndex)); case BodiesObject: { - DocumentPtr aRootDoc = ModelAPI_PluginManager::get()->rootDocument(); + DocumentPtr aRootDoc = ModelAPI_Session::get()->rootDocument(); ObjectPtr aObject = aRootDoc->object(ModelAPI_ResultBody::group(), theIndex.row()); if (aObject) return aObject->data()->name().c_str(); @@ -103,7 +103,7 @@ int XGUI_TopDataModel::rowCount(const QModelIndex& theParent) const if (!theParent.isValid()) return 3; - DocumentPtr aRootDoc = ModelAPI_PluginManager::get()->rootDocument(); + DocumentPtr aRootDoc = ModelAPI_Session::get()->rootDocument(); if (theParent.internalId() == ParamsFolder) return aRootDoc->size(ModelAPI_ResultParameters::group()); @@ -175,15 +175,15 @@ ObjectPtr XGUI_TopDataModel::object(const QModelIndex& theIndex) const case BodiesFolder: return ObjectPtr(); case ParamObject: { - DocumentPtr aRootDoc = ModelAPI_PluginManager::get()->rootDocument(); + DocumentPtr aRootDoc = ModelAPI_Session::get()->rootDocument(); return aRootDoc->object(ModelAPI_ResultParameters::group(), theIndex.row()); } case ConstructObject: { - DocumentPtr aRootDoc = ModelAPI_PluginManager::get()->rootDocument(); + DocumentPtr aRootDoc = ModelAPI_Session::get()->rootDocument(); return aRootDoc->object(ModelAPI_ResultConstruction::group(), theIndex.row()); } case BodiesObject: { - DocumentPtr aRootDoc = ModelAPI_PluginManager::get()->rootDocument(); + DocumentPtr aRootDoc = ModelAPI_Session::get()->rootDocument(); return aRootDoc->object(ModelAPI_ResultBody::group(), theIndex.row()); } } @@ -210,7 +210,7 @@ QModelIndex XGUI_TopDataModel::objectIndex(const ObjectPtr& theObject) const { QModelIndex aIndex; if (theObject) { - DocumentPtr aRootDoc = ModelAPI_PluginManager::get()->rootDocument(); + DocumentPtr aRootDoc = ModelAPI_Session::get()->rootDocument(); std::string aGroup = theObject->groupName(); int aNb = aRootDoc->size(aGroup); int aRow = -1; @@ -251,7 +251,7 @@ QVariant XGUI_PartDataModel::data(const QModelIndex& theIndex, int theRole) cons // return a name switch (theIndex.internalId()) { case MyRoot: { - DocumentPtr aRootDoc = ModelAPI_PluginManager::get()->rootDocument(); + DocumentPtr aRootDoc = ModelAPI_Session::get()->rootDocument(); ObjectPtr aObject = aRootDoc->object(ModelAPI_ResultPart::group(), myId); if (aObject) return boost::dynamic_pointer_cast(aObject)->data()->name().c_str(); @@ -325,7 +325,7 @@ QVariant XGUI_PartDataModel::headerData(int section, Qt::Orientation orientation int XGUI_PartDataModel::rowCount(const QModelIndex& parent) const { if (!parent.isValid()) { - DocumentPtr aRootDoc = ModelAPI_PluginManager::get()->rootDocument(); + DocumentPtr aRootDoc = ModelAPI_Session::get()->rootDocument(); if (aRootDoc->object(ModelAPI_ResultPart::group(), myId)) return 1; else @@ -410,7 +410,7 @@ bool XGUI_PartDataModel::hasChildren(const QModelIndex& theParent) const DocumentPtr XGUI_PartDataModel::partDocument() const { - DocumentPtr aRootDoc = ModelAPI_PluginManager::get()->rootDocument(); + DocumentPtr aRootDoc = ModelAPI_Session::get()->rootDocument(); ObjectPtr aObject = aRootDoc->object(ModelAPI_ResultPart::group(), myId); ResultPartPtr aPart = boost::dynamic_pointer_cast(aObject); return aPart->partDoc(); @@ -420,7 +420,7 @@ ObjectPtr XGUI_PartDataModel::object(const QModelIndex& theIndex) const { switch (theIndex.internalId()) { case MyRoot: { - DocumentPtr aRootDoc = ModelAPI_PluginManager::get()->rootDocument(); + DocumentPtr aRootDoc = ModelAPI_Session::get()->rootDocument(); return aRootDoc->object(ModelAPI_ResultPart::group(), myId); } case ParamsFolder: @@ -462,7 +462,7 @@ QModelIndex XGUI_PartDataModel::findGroup(const std::string& theGroup) const ResultPartPtr XGUI_PartDataModel::part() const { - DocumentPtr aRootDoc = ModelAPI_PluginManager::get()->rootDocument(); + DocumentPtr aRootDoc = ModelAPI_Session::get()->rootDocument(); ObjectPtr aObj = aRootDoc->object(ModelAPI_ResultPart::group(), myId); return boost::dynamic_pointer_cast(aObj); } diff --git a/src/XGUI/XGUI_SelectionMgr.cpp b/src/XGUI/XGUI_SelectionMgr.cpp index 2d37228ba..3d3937fc6 100644 --- a/src/XGUI/XGUI_SelectionMgr.cpp +++ b/src/XGUI/XGUI_SelectionMgr.cpp @@ -9,7 +9,7 @@ #include "XGUI_Selection.h" #include -#include +#include #include #include #include diff --git a/src/XGUI/XGUI_Workshop.cpp b/src/XGUI/XGUI_Workshop.cpp index 967f560f2..fa036dbbc 100644 --- a/src/XGUI/XGUI_Workshop.cpp +++ b/src/XGUI/XGUI_Workshop.cpp @@ -24,7 +24,7 @@ #include "XGUI_Preferences.h" #include -#include +#include #include #include #include @@ -530,7 +530,7 @@ void XGUI_Workshop::connectWithOperation(ModuleBase_Operation* theOperation) void XGUI_Workshop::saveDocument(const QString& theName, std::list& theFileNames) { QApplication::restoreOverrideCursor(); - PluginManagerPtr aMgr = ModelAPI_PluginManager::get(); + SessionPtr aMgr = ModelAPI_Session::get(); DocumentPtr aDoc = aMgr->rootDocument(); aDoc->save(theName.toLatin1().constData(), theFileNames); QApplication::restoreOverrideCursor(); @@ -539,7 +539,7 @@ void XGUI_Workshop::saveDocument(const QString& theName, std::list& //****************************************************** void XGUI_Workshop::onExit() { - PluginManagerPtr aMgr = ModelAPI_PluginManager::get(); + SessionPtr aMgr = ModelAPI_Session::get(); DocumentPtr aDoc = aMgr->rootDocument(); if (aDoc->isModified()) { int anAnswer = QMessageBox::question( @@ -581,7 +581,7 @@ void XGUI_Workshop::onNew() void XGUI_Workshop::onOpen() { //save current file before close if modified - PluginManagerPtr aMgr = ModelAPI_PluginManager::get(); + SessionPtr aMgr = ModelAPI_Session::get(); DocumentPtr aDoc = aMgr->rootDocument(); if (aDoc->isModified()) { //TODO(sbh): re-launch the app? @@ -667,7 +667,7 @@ bool XGUI_Workshop::onSaveAs() void XGUI_Workshop::onUndo() { objectBrowser()->treeView()->setCurrentIndex(QModelIndex()); - PluginManagerPtr aMgr = ModelAPI_PluginManager::get(); + SessionPtr aMgr = ModelAPI_Session::get(); DocumentPtr aDoc = aMgr->rootDocument(); if (aDoc->isOperation()) operationMgr()->abortOperation(); @@ -679,7 +679,7 @@ void XGUI_Workshop::onUndo() void XGUI_Workshop::onRedo() { objectBrowser()->treeView()->setCurrentIndex(QModelIndex()); - PluginManagerPtr aMgr = ModelAPI_PluginManager::get(); + SessionPtr aMgr = ModelAPI_Session::get(); DocumentPtr aDoc = aMgr->rootDocument(); if (aDoc->isOperation()) operationMgr()->abortOperation(); @@ -791,7 +791,7 @@ void XGUI_Workshop::updateCommandStatus() foreach (XGUI_Command* aCmd, aMenuBar->features()) aCommands.append(aCmd); } - PluginManagerPtr aMgr = ModelAPI_PluginManager::get(); + SessionPtr aMgr = ModelAPI_Session::get(); if (aMgr->hasRootDocument()) { QAction* aUndoCmd; QAction* aRedoCmd; @@ -936,7 +936,7 @@ void XGUI_Workshop::onFeatureTriggered() //****************************************************** void XGUI_Workshop::changeCurrentDocument(ObjectPtr theObj) { - PluginManagerPtr aMgr = ModelAPI_PluginManager::get(); + SessionPtr aMgr = ModelAPI_Session::get(); if (theObj) { ResultPartPtr aPart = boost::dynamic_pointer_cast(theObj); if (aPart) { @@ -1014,7 +1014,7 @@ void XGUI_Workshop::activatePart(ResultPartPtr theFeature) //************************************************************** void XGUI_Workshop::activateLastPart() { - PluginManagerPtr aMgr = ModelAPI_PluginManager::get(); + SessionPtr aMgr = ModelAPI_Session::get(); DocumentPtr aDoc = aMgr->rootDocument(); std::string aGrpName = ModelAPI_ResultPart::group(); ObjectPtr aLastPart = aDoc->object(aGrpName, aDoc->size(aGrpName) - 1); @@ -1032,7 +1032,7 @@ void XGUI_Workshop::deleteObjects(const QList& theList) QMessageBox::No | QMessageBox::Yes, QMessageBox::No); // ToDo: definbe deleting method if (aRes == QMessageBox::Yes) { - PluginManagerPtr aMgr = ModelAPI_PluginManager::get(); + SessionPtr aMgr = ModelAPI_Session::get(); aMgr->rootDocument()->startOperation(); foreach (ObjectPtr aObj, theList) { @@ -1082,7 +1082,7 @@ void XGUI_Workshop::showOnlyObjects(const QList& theList) //************************************************************** void XGUI_Workshop::updateCommandsOnViewSelection() { - PluginManagerPtr aMgr = ModelAPI_PluginManager::get(); + SessionPtr aMgr = ModelAPI_Session::get(); ModelAPI_ValidatorsFactory* aFactory = aMgr->validators(); XGUI_Selection* aSelection = mySelector->selection(); if (aSelection->getSelected().size() == 0) @@ -1111,14 +1111,14 @@ void XGUI_Workshop::updateCommandsOnViewSelection() //************************************************************** void XGUI_Workshop::registerValidators() const { - PluginManagerPtr aMgr = ModelAPI_PluginManager::get(); + SessionPtr aMgr = ModelAPI_Session::get(); ModelAPI_ValidatorsFactory* aFactory = aMgr->validators(); } //************************************************************** void XGUI_Workshop::displayAllResults() { - PluginManagerPtr aMgr = ModelAPI_PluginManager::get(); + SessionPtr aMgr = ModelAPI_Session::get(); DocumentPtr aRootDoc = aMgr->rootDocument(); displayDocumentResults(aRootDoc); for (int i = 0; i < aRootDoc->size(ModelAPI_ResultPart::group()); i++) {