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>
9 // the only created instance of this plugin
10 static PartSetPlugin_Plugin* MY_INSTANCE = new PartSetPlugin_Plugin();
12 PartSetPlugin_Plugin::PartSetPlugin_Plugin()
14 // register this plugin
15 ModelAPI_PluginManager::get()->registerPlugin(this);
18 std::shared_ptr<ModelAPI_Feature> PartSetPlugin_Plugin::createFeature(
19 string theFeatureID, const bool theAddToDoc)
21 std::shared_ptr<ModelAPI_Feature> aCreated;
22 bool isCurrent = true; // to create a feature in the current document
24 if (theFeatureID == "Part") {
25 aCreated = std::shared_ptr<ModelAPI_Feature>(new PartSetPlugin_Part);
26 isCurrent = false; // allways create in the root document
28 } else if (theFeatureID == "Point") {
29 aCreated = std::shared_ptr<ModelAPI_Feature>(new PartSetPlugin_Point);
30 aGroup = CONSTRUCTIONS_GROUP;
33 // add to a root document for the current moment
34 if (aCreated && theAddToDoc) {
35 shared_ptr<ModelAPI_Document> aDoc = isCurrent ?
36 ModelAPI_PluginManager::get()->currentDocument() :
37 ModelAPI_PluginManager::get()->rootDocument();
38 aDoc->addFeature(aCreated, aGroup);
40 // feature of such kind is not found