Salome HOME
Issue #1343 Improvement of Extrusion and Revolution operations: sketcher start or...
[modules/shaper.git] / src / FeaturesPlugin / FeaturesPlugin_Plugin.cpp
1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D -->
2
3 #include <FeaturesPlugin_Plugin.h>
4
5 #include <FeaturesPlugin_Boolean.h>
6 #include <FeaturesPlugin_Extrusion.h>
7 #include <FeaturesPlugin_ExtrusionSketch.h>
8 #include <FeaturesPlugin_ExtrusionCut.h>
9 #include <FeaturesPlugin_ExtrusionFuse.h>
10 #include <FeaturesPlugin_Group.h>
11 #include <FeaturesPlugin_Intersection.h>
12 #include <FeaturesPlugin_Translation.h>
13 #include <FeaturesPlugin_Partition.h>
14 #include <FeaturesPlugin_Pipe.h>
15 #include <FeaturesPlugin_Placement.h>
16 #include <FeaturesPlugin_Revolution.h>
17 #include <FeaturesPlugin_RevolutionSketch.h>
18 #include <FeaturesPlugin_RevolutionCut.h>
19 #include <FeaturesPlugin_RevolutionFuse.h>
20 #include <FeaturesPlugin_Rotation.h>
21 #include <FeaturesPlugin_ValidatorTransform.h>
22 #include <FeaturesPlugin_ValidatorExtrusionBase.h>
23 #include <FeaturesPlugin_Validators.h>
24
25 #include <ModelAPI_Session.h>
26
27 #include <string>
28
29 #include <memory>
30
31 using namespace std;
32
33 // the only created instance of this plugin
34 static FeaturesPlugin_Plugin* MY_FEATURES_INSTANCE = new FeaturesPlugin_Plugin();
35
36 FeaturesPlugin_Plugin::FeaturesPlugin_Plugin()
37 {
38   SessionPtr aMgr = ModelAPI_Session::get();
39   ModelAPI_ValidatorsFactory* aFactory = aMgr->validators();
40   aFactory->registerValidator("FeaturesPlugin_ValidatorTransform",
41                               new FeaturesPlugin_ValidatorTransform);
42   aFactory->registerValidator("FeaturesPlugin_ValidatorExtrusionBase",
43                               new FeaturesPlugin_ValidatorExtrusionBase);
44   aFactory->registerValidator("FeaturesPlugin_PipeLocationsValidator",
45                               new FeaturesPlugin_PipeLocationsValidator);
46
47   // register this plugin
48   ModelAPI_Session::get()->registerPlugin(this);
49 }
50
51 FeaturePtr FeaturesPlugin_Plugin::createFeature(string theFeatureID)
52 {
53   if (theFeatureID == FeaturesPlugin_Extrusion::ID()) {
54     return FeaturePtr(new FeaturesPlugin_Extrusion);
55   } else if (theFeatureID == FeaturesPlugin_Revolution::ID()) {
56    return FeaturePtr(new FeaturesPlugin_Revolution);
57   } else if (theFeatureID == FeaturesPlugin_Rotation::ID()) {
58     return FeaturePtr(new FeaturesPlugin_Rotation);
59   } else if (theFeatureID == FeaturesPlugin_Translation::ID()) {
60     return FeaturePtr(new FeaturesPlugin_Translation);
61   } else if (theFeatureID == FeaturesPlugin_Boolean::ID()) {
62     return FeaturePtr(new FeaturesPlugin_Boolean);
63   } else if (theFeatureID == FeaturesPlugin_Group::ID()) {
64     return FeaturePtr(new FeaturesPlugin_Group);
65   } else if (theFeatureID == FeaturesPlugin_Intersection::ID()) {
66     return FeaturePtr(new FeaturesPlugin_Intersection);
67   } else if (theFeatureID == FeaturesPlugin_Partition::ID()) {
68     return FeaturePtr(new FeaturesPlugin_Partition);
69   } else if (theFeatureID == FeaturesPlugin_Pipe::ID()) {
70     return FeaturePtr(new FeaturesPlugin_Pipe);
71   } else if (theFeatureID == FeaturesPlugin_Placement::ID()) {
72     return FeaturePtr(new FeaturesPlugin_Placement);
73   } else if (theFeatureID == FeaturesPlugin_ExtrusionCut::ID()) {
74     return FeaturePtr(new FeaturesPlugin_ExtrusionCut);
75   } else if (theFeatureID == FeaturesPlugin_ExtrusionFuse::ID()) {
76     return FeaturePtr(new FeaturesPlugin_ExtrusionFuse);
77   } else if (theFeatureID == FeaturesPlugin_RevolutionCut::ID()) {
78     return FeaturePtr(new FeaturesPlugin_RevolutionCut);
79   } else if (theFeatureID == FeaturesPlugin_RevolutionFuse::ID()) {
80     return FeaturePtr(new FeaturesPlugin_RevolutionFuse);
81   } else if (theFeatureID == FeaturesPlugin_ExtrusionSketch::ID()) {
82     return FeaturePtr(new FeaturesPlugin_ExtrusionSketch);
83   } else if (theFeatureID == FeaturesPlugin_RevolutionSketch::ID()) {
84     return FeaturePtr(new FeaturesPlugin_RevolutionSketch);
85   }
86   // feature of such kind is not found
87   return FeaturePtr();
88 }