Salome HOME
Merge branch 'Dev_2.8.0'
[modules/shaper.git] / src / FeaturesPlugin / FeaturesPlugin_Plugin.cpp
1 // Copyright (C) 2014-2017  CEA/DEN, EDF R&D
2 //
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License, or (at your option) any later version.
7 //
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11 // Lesser General Public License for more details.
12 //
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16 //
17 // See http://www.salome-platform.org/ or
18 // email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com>
19 //
20
21 #include <FeaturesPlugin_Plugin.h>
22
23 #include <FeaturesPlugin_Boolean.h>
24 #include <FeaturesPlugin_Extrusion.h>
25 #include <FeaturesPlugin_ExtrusionCut.h>
26 #include <FeaturesPlugin_ExtrusionFuse.h>
27 #include <FeaturesPlugin_Intersection.h>
28 #include <FeaturesPlugin_MultiRotation.h>
29 #include <FeaturesPlugin_MultiTranslation.h>
30 #include <FeaturesPlugin_Partition.h>
31 #include <FeaturesPlugin_Pipe.h>
32 #include <FeaturesPlugin_Placement.h>
33 #include <FeaturesPlugin_Recover.h>
34 #include <FeaturesPlugin_RemoveSubShapes.h>
35 #include <FeaturesPlugin_Revolution.h>
36 #include <FeaturesPlugin_RevolutionCut.h>
37 #include <FeaturesPlugin_RevolutionFuse.h>
38 #include <FeaturesPlugin_Rotation.h>
39 #include <FeaturesPlugin_Scale.h>
40 #include <FeaturesPlugin_Symmetry.h>
41 #include <FeaturesPlugin_Translation.h>
42 #include <FeaturesPlugin_Union.h>
43 #include <FeaturesPlugin_ValidatorTransform.h>
44 #include <FeaturesPlugin_Validators.h>
45
46 #include <ModelAPI_Session.h>
47
48 #include <string>
49
50 #include <memory>
51
52 // the only created instance of this plugin
53 static FeaturesPlugin_Plugin* MY_FEATURES_INSTANCE = new FeaturesPlugin_Plugin();
54
55 FeaturesPlugin_Plugin::FeaturesPlugin_Plugin()
56 {
57   SessionPtr aMgr = ModelAPI_Session::get();
58   ModelAPI_ValidatorsFactory* aFactory = aMgr->validators();
59   aFactory->registerValidator("FeaturesPlugin_ValidatorTransform",
60                               new FeaturesPlugin_ValidatorTransform);
61   aFactory->registerValidator("FeaturesPlugin_ValidatorCompositeLauncher",
62                               new FeaturesPlugin_ValidatorCompositeLauncher);
63   aFactory->registerValidator("FeaturesPlugin_ValidatorBaseForGeneration",
64                               new FeaturesPlugin_ValidatorBaseForGeneration);
65   aFactory->registerValidator("FeaturesPlugin_ValidatorBaseForGenerationSketchOrSketchObjects",
66                               new FeaturesPlugin_ValidatorBaseForGenerationSketchOrSketchObjects);
67   aFactory->registerValidator("FeaturesPlugin_ValidatorPipeLocations",
68                               new FeaturesPlugin_ValidatorPipeLocations);
69   aFactory->registerValidator("FeaturesPlugin_ValidatorExtrusionDir",
70                               new FeaturesPlugin_ValidatorExtrusionDir);
71   aFactory->registerValidator("FeaturesPlugin_ValidatorBooleanSelection",
72                               new FeaturesPlugin_ValidatorBooleanSelection);
73   aFactory->registerValidator("FeaturesPlugin_ValidatorPartitionSelection",
74                               new FeaturesPlugin_ValidatorPartitionSelection);
75   aFactory->registerValidator("FeaturesPlugin_ValidatorRemoveSubShapesSelection",
76                               new FeaturesPlugin_ValidatorRemoveSubShapesSelection);
77   aFactory->registerValidator("FeaturesPlugin_ValidatorRemoveSubShapesResult",
78                               new FeaturesPlugin_ValidatorRemoveSubShapesResult);
79   aFactory->registerValidator("FeaturesPlugin_ValidatorPipePath",
80                               new FeaturesPlugin_ValidatorPipePath);
81   aFactory->registerValidator("FeaturesPlugin_ValidatorUnionSelection",
82                               new FeaturesPlugin_ValidatorUnionSelection);
83   aFactory->registerValidator("FeaturesPlugin_ValidatorUnionArguments",
84                               new FeaturesPlugin_ValidatorUnionArguments);
85   aFactory->registerValidator("FeaturesPlugin_ValidatorConcealedResult",
86                               new FeaturesPlugin_ValidatorConcealedResult);
87
88   // register this plugin
89   ModelAPI_Session::get()->registerPlugin(this);
90 }
91
92 FeaturePtr FeaturesPlugin_Plugin::createFeature(std::string theFeatureID)
93 {
94   if (theFeatureID == FeaturesPlugin_Extrusion::ID()) {
95     return FeaturePtr(new FeaturesPlugin_Extrusion);
96   } else if (theFeatureID == FeaturesPlugin_Revolution::ID()) {
97    return FeaturePtr(new FeaturesPlugin_Revolution);
98   } else if (theFeatureID == FeaturesPlugin_Rotation::ID()) {
99     return FeaturePtr(new FeaturesPlugin_Rotation);
100   } else if (theFeatureID == FeaturesPlugin_Translation::ID()) {
101     return FeaturePtr(new FeaturesPlugin_Translation);
102   } else if (theFeatureID == FeaturesPlugin_Boolean::ID()) {
103     return FeaturePtr(new FeaturesPlugin_Boolean);
104   } else if (theFeatureID == FeaturesPlugin_Intersection::ID()) {
105     return FeaturePtr(new FeaturesPlugin_Intersection);
106   } else if (theFeatureID == FeaturesPlugin_Partition::ID()) {
107     return FeaturePtr(new FeaturesPlugin_Partition);
108   } else if (theFeatureID == FeaturesPlugin_Pipe::ID()) {
109     return FeaturePtr(new FeaturesPlugin_Pipe);
110   } else if (theFeatureID == FeaturesPlugin_Placement::ID()) {
111     return FeaturePtr(new FeaturesPlugin_Placement);
112   } else if (theFeatureID == FeaturesPlugin_Recover::ID()) {
113     return FeaturePtr(new FeaturesPlugin_Recover);
114   } else if (theFeatureID == FeaturesPlugin_ExtrusionCut::ID()) {
115     return FeaturePtr(new FeaturesPlugin_ExtrusionCut);
116   } else if (theFeatureID == FeaturesPlugin_ExtrusionFuse::ID()) {
117     return FeaturePtr(new FeaturesPlugin_ExtrusionFuse);
118   } else if (theFeatureID == FeaturesPlugin_RevolutionCut::ID()) {
119     return FeaturePtr(new FeaturesPlugin_RevolutionCut);
120   } else if (theFeatureID == FeaturesPlugin_RevolutionFuse::ID()) {
121     return FeaturePtr(new FeaturesPlugin_RevolutionFuse);
122   } else if (theFeatureID == FeaturesPlugin_RemoveSubShapes::ID()) {
123     return FeaturePtr(new FeaturesPlugin_RemoveSubShapes);
124   } else if (theFeatureID == FeaturesPlugin_Union::ID()) {
125     return FeaturePtr(new FeaturesPlugin_Union);
126   } else if (theFeatureID == FeaturesPlugin_Symmetry::ID()) {
127     return FeaturePtr(new FeaturesPlugin_Symmetry);
128   } else if (theFeatureID == FeaturesPlugin_Scale::ID()) {
129     return FeaturePtr(new FeaturesPlugin_Scale);
130   } else if (theFeatureID == FeaturesPlugin_MultiTranslation::ID()) {
131     return FeaturePtr(new FeaturesPlugin_MultiTranslation);
132   } else if (theFeatureID == FeaturesPlugin_MultiRotation::ID()) {
133     return FeaturePtr(new FeaturesPlugin_MultiRotation);
134   }
135
136   // feature of such kind is not found
137   return FeaturePtr();
138 }