]> SALOME platform Git repositories - modules/shaper.git/blob - src/ConstructionPlugin/ConstructionPlugin_Plugin.cpp
Salome HOME
Task #2924 : Ability to remove a result. Disable ability to remove groups and fields...
[modules/shaper.git] / src / ConstructionPlugin / ConstructionPlugin_Plugin.cpp
1 // Copyright (C) 2014-2019  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 email : webmaster.salome@opencascade.com
18 //
19
20 #include "ConstructionPlugin_Plugin.h"
21 #include "ConstructionPlugin_Point.h"
22 #include "ConstructionPlugin_Axis.h"
23 #include "ConstructionPlugin_Plane.h"
24 #include "ConstructionPlugin_Validators.h"
25
26 #include <Config_PropManager.h>
27
28 #include <ModelAPI_Session.h>
29 #include <ModelAPI_Document.h>
30
31 #define SKETCH_WIDTH        "4"
32 /// face of the square-face displayed for selection of general plane
33 #define PLANE_SIZE          "200"
34
35 // the only created instance of this plugin
36 static ConstructionPlugin_Plugin* MY_CONSTRUCTION_INSTANCE = new ConstructionPlugin_Plugin();
37
38 ConstructionPlugin_Plugin::ConstructionPlugin_Plugin()
39 {
40   SessionPtr aMgr = ModelAPI_Session::get();
41   ModelAPI_ValidatorsFactory* aFactory = aMgr->validators();
42   aFactory->registerValidator("ConstructionPlugin_ValidatorPointLines",
43                               new ConstructionPlugin_ValidatorPointLines());
44   aFactory->registerValidator("ConstructionPlugin_ValidatorPointEdgeAndPlaneNotParallel",
45                               new ConstructionPlugin_ValidatorPointEdgeAndPlaneNotParallel());
46   aFactory->registerValidator("ConstructionPlugin_ValidatorPlaneThreePoints",
47                               new ConstructionPlugin_ValidatorPlaneThreePoints());
48   aFactory->registerValidator("ConstructionPlugin_ValidatorPlaneLinePoint",
49                               new ConstructionPlugin_ValidatorPlaneLinePoint());
50   aFactory->registerValidator("ConstructionPlugin_ValidatorPlaneTwoParallelPlanes",
51                               new ConstructionPlugin_ValidatorPlaneTwoParallelPlanes());
52   aFactory->registerValidator("ConstructionPlugin_ValidatorAxisTwoNotParallelPlanes",
53                               new ConstructionPlugin_ValidatorAxisTwoNotParallelPlanes());
54   aFactory->registerValidator("ConstructionPlugin_ValidatorPointThreeNonParallelPlanes",
55                               new ConstructionPlugin_ValidatorPointThreeNonParallelPlanes());
56
57   Config_PropManager::registerProp(SKETCH_TAB_NAME, "planes_size", "Size", Config_Prop::DblSpin,
58                                    PLANE_SIZE, "0", "1000");
59   Config_PropManager::registerProp(SKETCH_TAB_NAME, "planes_thickness", "Thickness",
60     Config_Prop::IntSpin, SKETCH_WIDTH);
61   Config_PropManager::registerProp(SKETCH_TAB_NAME, "rotate_to_plane",
62     "Rotate to plane when selected", Config_Prop::Boolean, "false");
63
64   // register this plugin
65   ModelAPI_Session::get()->registerPlugin(this);
66
67   // register construction properties
68   Config_PropManager::registerProp("Visualization", "construction_plane_color",
69                                    "Construction plane color",
70                                    Config_Prop::Color, ConstructionPlugin_Plane::DEFAULT_COLOR());
71 }
72
73 FeaturePtr ConstructionPlugin_Plugin::createFeature(std::string theFeatureID)
74 {
75   if (theFeatureID == ConstructionPlugin_Point::ID()) {
76     return FeaturePtr(new ConstructionPlugin_Point);
77   }
78   else if (theFeatureID == ConstructionPlugin_Axis::ID()) {
79     return FeaturePtr(new ConstructionPlugin_Axis);
80   }
81   else if (theFeatureID == ConstructionPlugin_Plane::ID()) {
82     return FeaturePtr(new ConstructionPlugin_Plane);
83   }
84   // feature of such kind is not found
85   return FeaturePtr();
86 }