#include "ConstructionPlugin_Plugin.h"
#include "ConstructionPlugin_Point.h"
-#include <ModelAPI_PluginManager.h>
+#include <ModelAPI_Session.h>
#include <ModelAPI_Document.h>
using namespace std;
ConstructionPlugin_Plugin::ConstructionPlugin_Plugin()
{
// register this plugin
- ModelAPI_PluginManager::get()->registerPlugin(this);
+ ModelAPI_Session::get()->registerPlugin(this);
}
FeaturePtr ConstructionPlugin_Plugin::createFeature(string theFeatureID)
// 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"
#include <ExchangePlugin_Plugin.h>
#include <ExchangePlugin_ImportFeature.h>
-#include <ModelAPI_PluginManager.h>
+#include <ModelAPI_Session.h>
#include <boost/smart_ptr/shared_ptr.hpp>
ExchangePlugin_Plugin::ExchangePlugin_Plugin()
{
// register this plugin
- ModelAPI_PluginManager::get()->registerPlugin(this);
+ ModelAPI_Session::get()->registerPlugin(this);
}
FeaturePtr ExchangePlugin_Plugin::createFeature(string theFeatureID)
#include <ExchangePlugin_Validators.h>
#include <ModelAPI_Feature.h>
#include <ModelAPI_Object.h>
-#include <ModelAPI_PluginManager.h>
+#include <ModelAPI_Session.h>
#include <list>
#include <string>
bool ExchangePlugin_ImportFormatValidator::isValid(
const AttributePtr& theAttribute, const std::list<std::string>& theArguments) const
{
- PluginManagerPtr aMgr = ModelAPI_PluginManager::get();
+ SessionPtr aMgr = ModelAPI_Session::get();
ModelAPI_ValidatorsFactory* aFactory = aMgr->validators();
return false;
}
// Author: Vitaly SMETANNIKOV
#include "FeaturesPlugin_Extrusion.h"
-#include <ModelAPI_PluginManager.h>
+#include <ModelAPI_Session.h>
#include <ModelAPI_Document.h>
#include <ModelAPI_Data.h>
#include <ModelAPI_ResultConstruction.h>
#include "FeaturesPlugin_Extrusion.h"
#include "FeaturesPlugin_Boolean.h"
-#include <ModelAPI_PluginManager.h>
+#include <ModelAPI_Session.h>
#include <ModelAPI_Document.h>
using namespace std;
FeaturesPlugin_Plugin::FeaturesPlugin_Plugin()
{
// register this plugin
- ModelAPI_PluginManager::get()->registerPlugin(this);
+ ModelAPI_Session::get()->registerPlugin(this);
}
FeaturePtr FeaturesPlugin_Plugin::createFeature(string theFeatureID)
Model.h
Model_Application.h
Model_Document.h
- Model_PluginManager.h
+ Model_Session.h
Model_Data.h
Model_AttributeDouble.h
Model_AttributeDocRef.h
SET(PROJECT_SOURCES
Model_Application.cpp
Model_Document.cpp
- Model_PluginManager.cpp
+ Model_Session.cpp
Model_Data.cpp
Model_AttributeDouble.cpp
Model_AttributeDocRef.cpp
#include <Model_Document.h>
#include <Model_Data.h>
#include <Model_Application.h>
-#include <Model_PluginManager.h>
+#include <Model_Session.h>
#include <Model_Events.h>
#include <Model_ResultPart.h>
#include <Model_ResultConstruction.h>
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));
bool Model_Document::save(const char* theFileName, std::list<std::string>& 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
void Model_Document::close()
{
- boost::shared_ptr<ModelAPI_PluginManager> aPM = Model_PluginManager::get();
+ boost::shared_ptr<ModelAPI_Session> aPM = Model_Session::get();
if (this != aPM->rootDocument().get() && this == aPM->currentDocument().get()) {
aPM->setCurrentDocument(aPM->rootDocument());
}
// just to be sure that everybody knows that changes were performed
if (!myDoc->HasOpenCommand() && myNestedNum != -1)
- boost::static_pointer_cast<Model_PluginManager>(Model_PluginManager::get())
+ boost::static_pointer_cast<Model_Session>(Model_Session::get())
->setCheckTransactions(false); // for nested transaction commit
Events_Loop* aLoop = Events_Loop::loop();
aLoop->flush(Events_Loop::eventByName(EVENT_OBJECT_CREATED));
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>(Model_PluginManager::get())
+ boost::static_pointer_cast<Model_Session>(Model_Session::get())
->setCheckTransactions(true); // for nested transaction commit
if (myNestedNum != -1) // this nested transaction is owervritten
{
TDF_Label anEmptyLab;
FeaturePtr anEmptyFeature;
- FeaturePtr aFeature = ModelAPI_PluginManager::get()->createFeature(theID);
+ FeaturePtr aFeature = ModelAPI_Session::get()->createFeature(theID);
boost::shared_ptr<Model_Document> aDocToAdd = boost::dynamic_pointer_cast<Model_Document>(
aFeature->documentToAdd());
if (aFeature) {
boost::shared_ptr<ModelAPI_Document> 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>(Model_PluginManager::get())
+ boost::static_pointer_cast<Model_Session>(Model_Session::get())
->setCheckTransactions(false);
Events_Loop* aLoop = Events_Loop::loop();
aLoop->activateFlushes(false);
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
}
aLoop->flush(Events_Loop::eventByName(EVENT_OBJECT_DELETED));
aLoop->flush(Events_Loop::eventByName(EVENT_OBJECT_TO_REDISPLAY));
- boost::static_pointer_cast<Model_PluginManager>(Model_PluginManager::get())
+ boost::static_pointer_cast<Model_Session>(Model_Session::get())
->setCheckTransactions(true);
myExecuteFeatures = true;
}
void updateResults(FeaturePtr theFeature);
friend class Model_Application;
- friend class Model_PluginManager;
+ friend class Model_Session;
friend class DFBrowser;
private:
+++ /dev/null
-// File: Model_PluginManager.cxx
-// Created: 20 Mar 2014
-// Author: Mikhail PONIKAROV
-
-#include <Model_PluginManager.h>
-#include <ModelAPI_Feature.h>
-#include <ModelAPI_Plugin.h>
-#include <Model_Data.h>
-#include <Model_Document.h>
-#include <Model_Application.h>
-#include <Model_Events.h>
-#include <Model_Validator.h>
-#include <Events_Loop.h>
-#include <Events_Error.h>
-#include <Config_FeatureMessage.h>
-#include <Config_ValidatorMessage.h>
-#include <Config_ModuleReader.h>
-
-#include <TDF_CopyTool.hxx>
-#include <TDF_DataSet.hxx>
-#include <TDF_RelocationTable.hxx>
-#include <TDF_ClosureTool.hxx>
-
-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<ModelAPI_Document> Model_PluginManager::rootDocument()
-{
- return boost::shared_ptr<ModelAPI_Document>(
- Model_Application::getApplication()->getDocument("root"));
-}
-
-bool Model_PluginManager::hasRootDocument()
-{
- return Model_Application::getApplication()->hasDocument("root");
-}
-
-boost::shared_ptr<ModelAPI_Document> Model_PluginManager::currentDocument()
-{
- if (!myCurrentDoc || !Model_Application::getApplication()->hasDocument(myCurrentDoc->id()))
- myCurrentDoc = rootDocument();
- return myCurrentDoc;
-}
-
-void Model_PluginManager::setCurrentDocument(boost::shared_ptr<ModelAPI_Document> theDoc)
-{
- myCurrentDoc = theDoc;
- static Events_Message aMsg(Events_Loop::eventByName("CurrentDocumentChanged"));
- Events_Loop::loop()->send(aMsg);
-}
-
-boost::shared_ptr<ModelAPI_Document> Model_PluginManager::copy(
- boost::shared_ptr<ModelAPI_Document> theSource, std::string theID)
-{
- // create a new document
- boost::shared_ptr<Model_Document> aNew = boost::dynamic_pointer_cast<Model_Document>(
- Model_Application::getApplication()->getDocument(theID));
- // make a copy of all labels
- TDF_Label aSourceRoot = boost::dynamic_pointer_cast<Model_Document>(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<ModelAPI_PluginManager>(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<const Config_FeatureMessage*>(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<const Config_ValidatorMessage*>(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;
-}
+++ /dev/null
-// File: Model_PluginManager.hxx
-// Created: 20 Mar 2014
-// Author: Mikhail PONIKAROV
-
-#ifndef Model_PluginManager_H_
-#define Model_PluginManager_H_
-
-#include "Model.h"
-#include <ModelAPI_PluginManager.h>
-#include <ModelAPI_Feature.h>
-
-#include <Events_Listener.h>
-#include <map>
-
-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<std::string, std::string> myPlugins;
- std::map<std::string, ModelAPI_Plugin*> myPluginObjs; ///< instances of the already plugins
- std::string myCurrentPluginName; ///< name of the plugin that must be loaded currently
- boost::shared_ptr<ModelAPI_Document> 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<ModelAPI_Document> 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<ModelAPI_Document> currentDocument();
-
- /// Defines the current document that used for current work in the application
- MODEL_EXPORT virtual void setCurrentDocument(boost::shared_ptr<ModelAPI_Document> 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<ModelAPI_Document> copy(
- boost::shared_ptr<ModelAPI_Document> 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
#include <Model_ResultPart.h>
#include <ModelAPI_Data.h>
#include <ModelAPI_AttributeDocRef.h>
-#include <ModelAPI_PluginManager.h>
+#include <ModelAPI_Session.h>
boost::shared_ptr<ModelAPI_Document> Model_ResultPart::partDoc()
{
}
}
if (aDocRef->value())
- ModelAPI_PluginManager::get()->setCurrentDocument(aDocRef->value());
+ ModelAPI_Session::get()->setCurrentDocument(aDocRef->value());
}
--- /dev/null
+// File: Model_Session.cxx
+// Created: 20 Mar 2014
+// Author: Mikhail PONIKAROV
+
+#include <Model_Session.h>
+#include <ModelAPI_Feature.h>
+#include <ModelAPI_Plugin.h>
+#include <Model_Data.h>
+#include <Model_Document.h>
+#include <Model_Application.h>
+#include <Model_Events.h>
+#include <Model_Validator.h>
+#include <Events_Loop.h>
+#include <Events_Error.h>
+#include <Config_FeatureMessage.h>
+#include <Config_ValidatorMessage.h>
+#include <Config_ModuleReader.h>
+
+#include <TDF_CopyTool.hxx>
+#include <TDF_DataSet.hxx>
+#include <TDF_RelocationTable.hxx>
+#include <TDF_ClosureTool.hxx>
+
+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<ModelAPI_Document> Model_Session::rootDocument()
+{
+ return boost::shared_ptr<ModelAPI_Document>(
+ Model_Application::getApplication()->getDocument("root"));
+}
+
+bool Model_Session::hasRootDocument()
+{
+ return Model_Application::getApplication()->hasDocument("root");
+}
+
+boost::shared_ptr<ModelAPI_Document> Model_Session::currentDocument()
+{
+ if (!myCurrentDoc || !Model_Application::getApplication()->hasDocument(myCurrentDoc->id()))
+ myCurrentDoc = rootDocument();
+ return myCurrentDoc;
+}
+
+void Model_Session::setCurrentDocument(boost::shared_ptr<ModelAPI_Document> theDoc)
+{
+ myCurrentDoc = theDoc;
+ static Events_Message aMsg(Events_Loop::eventByName("CurrentDocumentChanged"));
+ Events_Loop::loop()->send(aMsg);
+}
+
+boost::shared_ptr<ModelAPI_Document> Model_Session::copy(
+ boost::shared_ptr<ModelAPI_Document> theSource, std::string theID)
+{
+ // create a new document
+ boost::shared_ptr<Model_Document> aNew = boost::dynamic_pointer_cast<Model_Document>(
+ Model_Application::getApplication()->getDocument(theID));
+ // make a copy of all labels
+ TDF_Label aSourceRoot = boost::dynamic_pointer_cast<Model_Document>(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<ModelAPI_Session>(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<const Config_FeatureMessage*>(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<const Config_ValidatorMessage*>(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;
+}
--- /dev/null
+// File: Model_Session.hxx
+// Created: 20 Mar 2014
+// Author: Mikhail PONIKAROV
+
+#ifndef Model_Session_H_
+#define Model_Session_H_
+
+#include "Model.h"
+#include <ModelAPI_Session.h>
+#include <ModelAPI_Feature.h>
+
+#include <Events_Listener.h>
+#include <map>
+
+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<std::string, std::string> myPlugins;
+ std::map<std::string, ModelAPI_Plugin*> myPluginObjs; ///< instances of the already plugins
+ std::string myCurrentPluginName; ///< name of the plugin that must be loaded currently
+ boost::shared_ptr<ModelAPI_Document> 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<ModelAPI_Document> 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<ModelAPI_Document> currentDocument();
+
+ /// Defines the current document that used for current work in the application
+ MODEL_EXPORT virtual void setCurrentDocument(boost::shared_ptr<ModelAPI_Document> 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<ModelAPI_Document> copy(
+ boost::shared_ptr<ModelAPI_Document> 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
if (boost::dynamic_pointer_cast<Model_Document>(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();
* 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.
protected:
void addDefaultValidators(std::list<ModelAPI_Validator*>& theValidators) const;
- /// Get instance from PluginManager
+ /// Get instance from Session
Model_ValidatorsFactory();
- friend class Model_PluginManager;
+ friend class Model_Session;
};
#endif
SET(PROJECT_HEADERS
ModelAPI.h
- ModelAPI_PluginManager.h
+ ModelAPI_Session.h
ModelAPI_Plugin.h
ModelAPI_Feature.h
ModelAPI_Data.h
SET(PROJECT_SOURCES
ModelAPI_Feature.cpp
- ModelAPI_PluginManager.cpp
+ ModelAPI_Session.cpp
ModelAPI_Tools.cpp
)
#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"
%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)
%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"
boost::shared_ptr<ModelAPI_Document> ModelAPI_Feature::documentToAdd()
{
- return ModelAPI_PluginManager::get()->currentDocument();
+ return ModelAPI_Session::get()->currentDocument();
}
ModelAPI_Feature::~ModelAPI_Feature()
#define ModelAPI_Feature_H_
#include "ModelAPI_Object.h"
-#include "ModelAPI_PluginManager.h"
+#include "ModelAPI_Session.h"
#include <string>
#include <list>
+++ /dev/null
-// File: ModelAPI_PluginManager.hxx
-// Created: 20 Mar 2014
-// Author: Mikhail PONIKAROV
-
-#include <ModelAPI_PluginManager.h>
-// to avoid unresolved ModelAPI_Document()
-#include <ModelAPI_Document.h>
-// to avoid unresolved ModelAPI_Feature()
-#include <ModelAPI_Feature.h>
-#include <ModelAPI_Object.h>
-// to avoid unresolved ModelAPI_Data()
-#include <ModelAPI_Data.h>
-// to avoid unresolved ModelAPI_Plugin()
-#include <ModelAPI_Plugin.h>
-#include <ModelAPI_Attribute.h>
-#include <ModelAPI_AttributeDocRef.h>
-#include <ModelAPI_AttributeDouble.h>
-#include <ModelAPI_AttributeBoolean.h>
-#include <ModelAPI_AttributeInteger.h>
-#include <ModelAPI_AttributeString.h>
-#include <ModelAPI_AttributeReference.h>
-#include <ModelAPI_AttributeRefAttr.h>
-#include <ModelAPI_AttributeRefList.h>
-#include <ModelAPI_Events.h>
-#include <ModelAPI_Validator.h>
-
-#include <Config_ModuleReader.h>
-
-#ifdef WIN32
-#include <windows.h>
-#else
-#include <dlfcn.h>
-#endif
-
-using namespace std;
-
-#ifdef _DEBUG
-#include <iostream>
-#endif
-
-/// Manager that will be initialized from Model package, one per application
-boost::shared_ptr<ModelAPI_PluginManager> MY_MANAGER;
-
-ModelAPI_PluginManager::ModelAPI_PluginManager()
-{
-}
-
-void ModelAPI_PluginManager::setPluginManager(boost::shared_ptr<ModelAPI_PluginManager> theManager)
-{
- MY_MANAGER = theManager;
-}
-
-boost::shared_ptr<ModelAPI_PluginManager> 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;
-}
+++ /dev/null
-// File: ModelAPI_PluginManager.hxx
-// Created: 20 Mar 2014
-// Author: Mikhail PONIKAROV
-
-#ifndef ModelAPI_PluginManager_H_
-#define ModelAPI_PluginManager_H_
-
-#include "ModelAPI.h"
-#include <string>
-#include <boost/shared_ptr.hpp>
-
-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<ModelAPI_PluginManager> 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<ModelAPI_Document> 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<ModelAPI_Document> currentDocument() = 0;
-
- /// Defines the current document that used for current work in the application
- virtual void setCurrentDocument(boost::shared_ptr<ModelAPI_Document> theDoc) = 0;
-
- /// Copies the document to the new one wit hthe given id
- virtual boost::shared_ptr<ModelAPI_Document> copy(boost::shared_ptr<ModelAPI_Document> 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<ModelAPI_Feature> createFeature(std::string theFeatureID) = 0;
-
- static void setPluginManager(boost::shared_ptr<ModelAPI_PluginManager> theManager);
-
- friend class Model_Document;
-};
-
-typedef boost::shared_ptr<ModelAPI_PluginManager> PluginManagerPtr;
-
-#endif
--- /dev/null
+// File: ModelAPI_Session.hxx
+// Created: 20 Mar 2014
+// Author: Mikhail PONIKAROV
+
+#include <ModelAPI_Session.h>
+// to avoid unresolved ModelAPI_Document()
+#include <ModelAPI_Document.h>
+// to avoid unresolved ModelAPI_Feature()
+#include <ModelAPI_Feature.h>
+#include <ModelAPI_Object.h>
+// to avoid unresolved ModelAPI_Data()
+#include <ModelAPI_Data.h>
+// to avoid unresolved ModelAPI_Plugin()
+#include <ModelAPI_Plugin.h>
+#include <ModelAPI_Attribute.h>
+#include <ModelAPI_AttributeDocRef.h>
+#include <ModelAPI_AttributeDouble.h>
+#include <ModelAPI_AttributeBoolean.h>
+#include <ModelAPI_AttributeInteger.h>
+#include <ModelAPI_AttributeString.h>
+#include <ModelAPI_AttributeReference.h>
+#include <ModelAPI_AttributeRefAttr.h>
+#include <ModelAPI_AttributeRefList.h>
+#include <ModelAPI_Events.h>
+#include <ModelAPI_Validator.h>
+
+#include <Config_ModuleReader.h>
+
+#ifdef WIN32
+#include <windows.h>
+#else
+#include <dlfcn.h>
+#endif
+
+using namespace std;
+
+#ifdef _DEBUG
+#include <iostream>
+#endif
+
+/// Manager that will be initialized from Model package, one per application
+boost::shared_ptr<ModelAPI_Session> MY_MANAGER;
+
+ModelAPI_Session::ModelAPI_Session()
+{
+}
+
+void ModelAPI_Session::setSession(boost::shared_ptr<ModelAPI_Session> theManager)
+{
+ MY_MANAGER = theManager;
+}
+
+boost::shared_ptr<ModelAPI_Session> 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;
+}
--- /dev/null
+// File: ModelAPI_Session.hxx
+// Created: 20 Mar 2014
+// Author: Mikhail PONIKAROV
+
+#ifndef ModelAPI_Session_H_
+#define ModelAPI_Session_H_
+
+#include "ModelAPI.h"
+#include <string>
+#include <boost/shared_ptr.hpp>
+
+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<ModelAPI_Session> 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<ModelAPI_Document> 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<ModelAPI_Document> currentDocument() = 0;
+
+ /// Defines the current document that used for current work in the application
+ virtual void setCurrentDocument(boost::shared_ptr<ModelAPI_Document> theDoc) = 0;
+
+ /// Copies the document to the new one with the given id
+ virtual boost::shared_ptr<ModelAPI_Document> copy(boost::shared_ptr<ModelAPI_Document> 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<ModelAPI_Feature> createFeature(std::string theFeatureID) = 0;
+
+ static void setSession(boost::shared_ptr<ModelAPI_Session> theManager);
+
+ friend class Model_Document;
+};
+
+typedef boost::shared_ptr<ModelAPI_Session> SessionPtr;
+
+#endif
* 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.
virtual bool validate(const boost::shared_ptr<ModelAPI_Feature>& theFeature) const = 0;
protected:
- /// Get instance from PluginManager
+ /// Get instance from Session
ModelAPI_ValidatorsFactory()
{
}
#include "ModuleBase_ModelWidget.h"
#include <ModelAPI_Document.h>
-#include <ModelAPI_PluginManager.h>
+#include <ModelAPI_Session.h>
#ifdef _DEBUG
#include <QDebug>
boost::shared_ptr<ModelAPI_Document> ModuleBase_IOperation::document() const
{
- return ModelAPI_PluginManager::get()->rootDocument();
+ return ModelAPI_Session::get()->rootDocument();
}
void ModuleBase_IOperation::start()
/* 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<ModelAPI_Validator*> aValidators;
aFactory->validators(aId, aValidators);
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<ModelAPI_Validator*> aValidators;
std::list<std::list<std::string> > anArguments;
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);
if (aPreviewOp) {
// create a line
- boost::shared_ptr<ModelAPI_Document> aDoc = ModelAPI_PluginManager::get()->rootDocument();
+ boost::shared_ptr<ModelAPI_Document> 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();
boost::shared_ptr<ModelAPI_Document> PartSet_Tools::document()
{
- return ModelAPI_PluginManager::get()->rootDocument();
+ return ModelAPI_Session::get()->rootDocument();
}
void PartSet_Tools::setFeaturePoint(FeaturePtr theFeature, double theX, double theY,
PartSetPlugin_Part::initAttributes();
data()->addAttribute(ORIGIN_REF(), ModelAPI_AttributeRefAttr::type());
- boost::shared_ptr<ModelAPI_PluginManager> aPManager = ModelAPI_PluginManager::get();
+ boost::shared_ptr<ModelAPI_Session> aPManager = ModelAPI_Session::get();
boost::shared_ptr<ModelAPI_Document> aRoot = aPManager->rootDocument();
boost::shared_ptr<ModelAPI_ResultPart> aSource; // searching for source document attribute
for (int a = aRoot->size(getGroup()) - 1; a >= 0; a--) {
// 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"
if (!aDocRef->value()) { // create a document if not yet created
boost::shared_ptr<ModelAPI_Document> aPartSetDoc =
- ModelAPI_PluginManager::get()->rootDocument();
+ ModelAPI_Session::get()->rootDocument();
aDocRef->setValue(aPartSetDoc->subDocument(data()->name()));
}
*/
boost::shared_ptr<ModelAPI_Document> PartSetPlugin_Part::documentToAdd()
{
- return ModelAPI_PluginManager::get()->rootDocument();
+ return ModelAPI_Session::get()->rootDocument();
}
#include "PartSetPlugin_Part.h"
#include "PartSetPlugin_Duplicate.h"
#include "PartSetPlugin_Remove.h"
-#include <ModelAPI_PluginManager.h>
+#include <ModelAPI_Session.h>
#include <ModelAPI_Document.h>
using namespace std;
PartSetPlugin_Plugin::PartSetPlugin_Plugin()
{
// register this plugin
- ModelAPI_PluginManager::get()->registerPlugin(this);
+ ModelAPI_Session::get()->registerPlugin(this);
}
FeaturePtr PartSetPlugin_Plugin::createFeature(string theFeatureID)
void PartSetPlugin_Remove::execute()
{
- boost::shared_ptr<ModelAPI_PluginManager> aPManager = ModelAPI_PluginManager::get();
+ boost::shared_ptr<ModelAPI_Session> aPManager = ModelAPI_Session::get();
boost::shared_ptr<ModelAPI_Document> aRoot = aPManager->rootDocument();
boost::shared_ptr<ModelAPI_Document> aCurrent;
boost::shared_ptr<PartSetPlugin_Part> a;
#include "SketchPlugin_ConstraintRadius.h"
#include "SketchPlugin_Validators.h"
#include "SketchPlugin_ResultValidators.h"
-#include <ModelAPI_PluginManager.h>
+#include <ModelAPI_Session.h>
#include <ModelAPI_Document.h>
#include <ModelAPI_Validator.h>
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);
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,
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
// ============================================================================
// 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)
// ============================================================================
// Function: changeWorkplane
-// Class: SketchSolver_PluginManager
+// Class: SketchSolver_Session
// Purpose: update workplane by given parameters of the sketch
// ============================================================================
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(
// ============================================================================
// Function: updateEntity
-// Class: SketchSolver_PluginManager
+// Class: SketchSolver_Session
// Purpose: update any element on the sketch, which is used by constraints
// ============================================================================
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(
// ============================================================================
// Function: findWorkplaneForConstraint
-// Class: SketchSolver_PluginManager
+// Class: SketchSolver_Session
// Purpose: search workplane containing given constraint
// ============================================================================
boost::shared_ptr<SketchPlugin_Feature> SketchSolver_ConstraintManager::findWorkplaneForConstraint(
// ============================================================================
// Function: resolveConstraints
-// Class: SketchSolver_PluginManager
+// Class: SketchSolver_Session
// Purpose: change entities according to available constraints
// ============================================================================
void SketchSolver_ConstraintManager::resolveConstraints()
QList<ObjectPtr> 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) {
#include "XGUI_Workshop.h"
#include "XGUI_Tools.h"
-#include <ModelAPI_PluginManager.h>
+#include <ModelAPI_Session.h>
#include <ModelAPI_Document.h>
#include <ModelAPI_Feature.h>
#include <ModelAPI_Data.h>
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)) {
void XGUI_DocumentDataModel::rebuildDataTree()
{
- DocumentPtr aRootDoc = ModelAPI_PluginManager::get()->rootDocument();
+ DocumentPtr aRootDoc = ModelAPI_Session::get()->rootDocument();
beginResetModel();
clearModelIndexes();
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<ModelAPI_Feature>(aObj);
if (!aFeature)
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
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);
}
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
#include "XGUI_Tools.h"
#include <ModelAPI_Data.h>
-#include <ModelAPI_PluginManager.h>
+#include <ModelAPI_Session.h>
#include <ModelAPI_Document.h>
#include <ModelAPI_Object.h>
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();
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
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());
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);
#include "XGUI_PartDataModel.h"
#include "XGUI_Workshop.h"
-#include <ModelAPI_PluginManager.h>
+#include <ModelAPI_Session.h>
#include <ModelAPI_Document.h>
#include <ModelAPI_Feature.h>
#include <ModelAPI_Result.h>
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();
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)
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();
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());
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());
}
}
{
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;
// 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<ModelAPI_Object>(aObject)->data()->name().c_str();
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
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<ModelAPI_ResultPart>(aObject);
return aPart->partDoc();
{
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:
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<ModelAPI_ResultPart>(aObj);
}
#include "XGUI_Selection.h"
#include <ModelAPI_Feature.h>
-#include <ModelAPI_PluginManager.h>
+#include <ModelAPI_Session.h>
#include <ModelAPI_AttributeDocRef.h>
#include <ModelAPI_Data.h>
#include <ModelAPI_Result.h>
#include "XGUI_Preferences.h"
#include <ModelAPI_Events.h>
-#include <ModelAPI_PluginManager.h>
+#include <ModelAPI_Session.h>
#include <ModelAPI_Feature.h>
#include <ModelAPI_Data.h>
#include <ModelAPI_AttributeDocRef.h>
void XGUI_Workshop::saveDocument(const QString& theName, std::list<std::string>& 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();
//******************************************************
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(
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?
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();
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();
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;
//******************************************************
void XGUI_Workshop::changeCurrentDocument(ObjectPtr theObj)
{
- PluginManagerPtr aMgr = ModelAPI_PluginManager::get();
+ SessionPtr aMgr = ModelAPI_Session::get();
if (theObj) {
ResultPartPtr aPart = boost::dynamic_pointer_cast<ModelAPI_ResultPart>(theObj);
if (aPart) {
//**************************************************************
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);
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)
{
//**************************************************************
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)
//**************************************************************
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++) {