Salome HOME
Fix for registering of parameters in command line.
[modules/shaper.git] / src / ConstructionPlugin / ConstructionPlugin_Plugin.cpp
1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D
2
3 #include "ConstructionPlugin_Plugin.h"
4 #include "ConstructionPlugin_Point.h"
5 #include "ConstructionPlugin_Axis.h"
6 #include "ConstructionPlugin_Plane.h"
7 #include "ConstructionPlugin_Validators.h"
8
9 #include <Config_PropManager.h>
10
11 #include <ModelAPI_Session.h>
12 #include <ModelAPI_Document.h>
13
14 #define SKETCH_WIDTH        "4"
15 /// face of the square-face displayed for selection of general plane
16 #define PLANE_SIZE          "200"
17
18 // the only created instance of this plugin
19 static ConstructionPlugin_Plugin* MY_CONSTRUCTION_INSTANCE = new ConstructionPlugin_Plugin();
20
21 ConstructionPlugin_Plugin::ConstructionPlugin_Plugin()
22 {
23   SessionPtr aMgr = ModelAPI_Session::get();
24   ModelAPI_ValidatorsFactory* aFactory = aMgr->validators();
25   aFactory->registerValidator("ConstructionPlugin_ValidatorPointLines",
26                               new ConstructionPlugin_ValidatorPointLines());
27   aFactory->registerValidator("ConstructionPlugin_ValidatorPointLineAndPlaneNotParallel",
28                               new ConstructionPlugin_ValidatorPointLineAndPlaneNotParallel());
29   aFactory->registerValidator("ConstructionPlugin_ValidatorPlaneThreePoints",
30                               new ConstructionPlugin_ValidatorPlaneThreePoints());
31   aFactory->registerValidator("ConstructionPlugin_ValidatorPlaneLinePoint",
32                               new ConstructionPlugin_ValidatorPlaneLinePoint());
33   aFactory->registerValidator("ConstructionPlugin_ValidatorPlaneTwoParallelPlanes",
34                               new ConstructionPlugin_ValidatorPlaneTwoParallelPlanes());
35   aFactory->registerValidator("ConstructionPlugin_ValidatorAxisTwoNotParallelPlanes",
36                               new ConstructionPlugin_ValidatorAxisTwoNotParallelPlanes());
37
38   Config_PropManager::registerProp(SKETCH_TAB_NAME, "planes_size", "Size", Config_Prop::Double,
39                                    PLANE_SIZE);
40   Config_PropManager::registerProp(SKETCH_TAB_NAME, "planes_thickness", "Thickness",
41                                    Config_Prop::Integer, SKETCH_WIDTH);
42   Config_PropManager::registerProp(SKETCH_TAB_NAME, "rotate_to_plane",
43     "Rotate to plane when selected", Config_Prop::Boolean, "false");
44
45   // register this plugin
46   ModelAPI_Session::get()->registerPlugin(this);
47
48   // register construction properties
49   Config_PropManager::registerProp("Visualization", "construction_plane_color",
50                                    "Construction plane color",
51                                    Config_Prop::Color, ConstructionPlugin_Plane::DEFAULT_COLOR());
52 }
53
54 FeaturePtr ConstructionPlugin_Plugin::createFeature(std::string theFeatureID)
55 {
56   if (theFeatureID == ConstructionPlugin_Point::ID()) {
57     return FeaturePtr(new ConstructionPlugin_Point);
58   }
59   else if (theFeatureID == ConstructionPlugin_Axis::ID()) {
60     return FeaturePtr(new ConstructionPlugin_Axis);
61   }
62   else if (theFeatureID == ConstructionPlugin_Plane::ID()) {
63     return FeaturePtr(new ConstructionPlugin_Plane);
64   }
65   // feature of such kind is not found
66   return FeaturePtr();
67 }