]> SALOME platform Git repositories - modules/shaper.git/blob - src/BuildPlugin/BuildPlugin_Plugin.cpp
Salome HOME
Add command "Rename" to a folder context menu
[modules/shaper.git] / src / BuildPlugin / BuildPlugin_Plugin.cpp
1 // Copyright (C) 2017-20xx  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 "BuildPlugin_Plugin.h"
22
23 #include <ModelAPI_Session.h>
24 #include <ModelAPI_Validator.h>
25
26 #include <BuildPlugin_Vertex.h>
27 #include <BuildPlugin_Edge.h>
28 #include <BuildPlugin_Wire.h>
29 #include <BuildPlugin_Face.h>
30 #include <BuildPlugin_Shell.h>
31 #include <BuildPlugin_Solid.h>
32 #include <BuildPlugin_CompSolid.h>
33 #include <BuildPlugin_Compound.h>
34 #include <BuildPlugin_SubShapes.h>
35 #include <BuildPlugin_Filling.h>
36 #include <BuildPlugin_Validators.h>
37
38 // the only created instance of this plugin
39 static BuildPlugin_Plugin* MY_INSTANCE = new BuildPlugin_Plugin();
40
41 //=================================================================================================
42 BuildPlugin_Plugin::BuildPlugin_Plugin()
43 {
44   // Register validators.
45   SessionPtr aMgr = ModelAPI_Session::get();
46   ModelAPI_ValidatorsFactory* aFactory = aMgr->validators();
47   aFactory->registerValidator("BuildPlugin_ValidatorBaseForBuild",
48                               new BuildPlugin_ValidatorBaseForBuild());
49   aFactory->registerValidator("BuildPlugin_ValidatorBaseForWire",
50                               new BuildPlugin_ValidatorBaseForWire());
51   aFactory->registerValidator("BuildPlugin_ValidatorBaseForFace",
52                               new BuildPlugin_ValidatorBaseForFace());
53   aFactory->registerValidator("BuildPlugin_ValidatorSubShapesSelection",
54                               new BuildPlugin_ValidatorSubShapesSelection());
55   aFactory->registerValidator("BuildPlugin_ValidatorFillingSelection",
56                               new BuildPlugin_ValidatorFillingSelection());
57
58   // Register this plugin.
59   ModelAPI_Session::get()->registerPlugin(this);
60 }
61
62 //=================================================================================================
63 FeaturePtr BuildPlugin_Plugin::createFeature(std::string theFeatureID)
64 {
65   if(theFeatureID == BuildPlugin_Vertex::ID()) {
66     return FeaturePtr(new BuildPlugin_Vertex());
67   } else if(theFeatureID == BuildPlugin_Edge::ID()) {
68     return FeaturePtr(new BuildPlugin_Edge());
69   } else if(theFeatureID == BuildPlugin_Wire::ID()) {
70     return FeaturePtr(new BuildPlugin_Wire());
71   } else if(theFeatureID == BuildPlugin_Face::ID()) {
72     return FeaturePtr(new BuildPlugin_Face());
73   } else if(theFeatureID == BuildPlugin_Shell::ID()) {
74     return FeaturePtr(new BuildPlugin_Shell());
75   } else if(theFeatureID == BuildPlugin_Solid::ID()) {
76     return FeaturePtr(new BuildPlugin_Solid());
77   } else if(theFeatureID == BuildPlugin_CompSolid::ID()) {
78     return FeaturePtr(new BuildPlugin_CompSolid());
79   } else if(theFeatureID == BuildPlugin_Compound::ID()) {
80     return FeaturePtr(new BuildPlugin_Compound());
81   } else if(theFeatureID == BuildPlugin_SubShapes::ID()) {
82     return FeaturePtr(new BuildPlugin_SubShapes());
83   } else if(theFeatureID == BuildPlugin_Filling::ID()) {
84     return FeaturePtr(new BuildPlugin_Filling());
85   }
86
87   // Feature of such kind is not found.
88   return FeaturePtr();
89 }