]> SALOME platform Git repositories - modules/shaper.git/blob - src/PartSetPlugin/PartSetPlugin_Plugin.cxx
Salome HOME
89f7084fa432843c489f66fee7f0eb7608c21687
[modules/shaper.git] / src / PartSetPlugin / PartSetPlugin_Plugin.cxx
1 #include "PartSetPlugin_Plugin.h"
2 #include "PartSetPlugin_Part.h"
3 #include "PartSetPlugin_Point.h"
4 #include <ModelAPI_PluginManager.h>
5 #include <ModelAPI_Document.h>
6
7 using namespace std;
8
9 // the only created instance of this plugin
10 static PartSetPlugin_Plugin* MY_INSTANCE = new PartSetPlugin_Plugin();
11
12 PartSetPlugin_Plugin::PartSetPlugin_Plugin() 
13 {
14   // register this plugin
15   ModelAPI_PluginManager::get()->registerPlugin(this);
16 }
17
18 std::shared_ptr<ModelAPI_Feature> PartSetPlugin_Plugin::createFeature(
19   string theFeatureID, const bool theAddToDoc)
20 {
21   std::shared_ptr<ModelAPI_Feature> aCreated;
22   bool isCurrent = true; // to create a feature in the current document
23   if (theFeatureID == "Part") {
24     aCreated = std::shared_ptr<ModelAPI_Feature>(new PartSetPlugin_Part);
25     isCurrent = false; // allways create in the root document
26   } else if (theFeatureID == "Point") {
27     aCreated = std::shared_ptr<ModelAPI_Feature>(new PartSetPlugin_Point);
28   }
29
30   // add to a root document for the current moment
31   if (aCreated && theAddToDoc) {
32     shared_ptr<ModelAPI_Document> aDoc = isCurrent ? 
33       ModelAPI_PluginManager::get()->currentDocument() :
34       ModelAPI_PluginManager::get()->rootDocument();
35     aDoc->addFeature(aCreated, PARTS_GROUP);
36   }
37   // feature of such kind is not found
38   return aCreated;
39 }