Salome HOME
Added the hasRootDocument method for GUI NewDocument checking
[modules/shaper.git] / src / Model / Model_PluginManager.cxx
index f2b7a55947445e063f08d3bc6938144f9afbf627..724f30e2639c812c5af0569a209a28f09259f6cc 100644 (file)
@@ -5,7 +5,7 @@
 #include <Model_PluginManager.h>
 #include <ModelAPI_Feature.h>
 #include <ModelAPI_Plugin.h>
-#include <Model_Object.h>
+#include <Model_Data.h>
 #include <Model_Document.h>
 #include <Model_Application.h>
 #include <Event_Loop.h>
@@ -16,7 +16,7 @@ using namespace std;
 
 static Model_PluginManager* myImpl = new Model_PluginManager();
 
-std::shared_ptr<ModelAPI_Feature> Model_PluginManager::createFeature(string theFeatureID)
+shared_ptr<ModelAPI_Feature> Model_PluginManager::createFeature(string theFeatureID)
 {
   if (this != myImpl) return myImpl->createFeature(theFeatureID);
 
@@ -43,11 +43,28 @@ std::shared_ptr<ModelAPI_Document> Model_PluginManager::rootDocument()
     Model_Application::getApplication()->getDocument("root"));
 }
 
+bool Model_PluginManager::hasRootDocument()
+{
+  return Model_Application::getApplication()->hasDocument("root");
+}
+
+shared_ptr<ModelAPI_Document> Model_PluginManager::currentDocument()
+{
+  if (!myCurrentDoc)
+    myCurrentDoc = rootDocument();
+  return myCurrentDoc;
+}
+
+void Model_PluginManager::setCurrentDocument(shared_ptr<ModelAPI_Document> theDoc)
+{
+  myCurrentDoc = theDoc;
+}
 
 Model_PluginManager::Model_PluginManager()
 {
   myPluginsInfoLoaded = false;
-  static Event_ID aFeatureEvent = Event_Loop::eventByName("RegisterFeature");
+  //TODO(sbh): Implement static method to extract event id [SEID]
+  static Event_ID aFeatureEvent = Event_Loop::eventByName("FeatureEvent");
 
   ModelAPI_PluginManager::SetPluginManager(std::shared_ptr<ModelAPI_PluginManager>(this));
   // register the configuration reading listener