1 // Copyright (C) 2014-2017 CEA/DEN, EDF R&D
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.
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.
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
17 // See http://www.salome-platform.org/ or
18 // email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com>
21 #include "ConstructionPlugin_Plugin.h"
22 #include "ConstructionPlugin_Point.h"
23 #include "ConstructionPlugin_Axis.h"
24 #include "ConstructionPlugin_Plane.h"
25 #include "ConstructionPlugin_Validators.h"
27 #include <Config_PropManager.h>
29 #include <ModelAPI_Session.h>
30 #include <ModelAPI_Document.h>
32 #define SKETCH_WIDTH "4"
33 /// face of the square-face displayed for selection of general plane
34 #define PLANE_SIZE "200"
36 // the only created instance of this plugin
37 static ConstructionPlugin_Plugin* MY_CONSTRUCTION_INSTANCE = new ConstructionPlugin_Plugin();
39 ConstructionPlugin_Plugin::ConstructionPlugin_Plugin()
41 SessionPtr aMgr = ModelAPI_Session::get();
42 ModelAPI_ValidatorsFactory* aFactory = aMgr->validators();
43 aFactory->registerValidator("ConstructionPlugin_ValidatorPointLines",
44 new ConstructionPlugin_ValidatorPointLines());
45 aFactory->registerValidator("ConstructionPlugin_ValidatorPointEdgeAndPlaneNotParallel",
46 new ConstructionPlugin_ValidatorPointEdgeAndPlaneNotParallel());
47 aFactory->registerValidator("ConstructionPlugin_ValidatorPlaneThreePoints",
48 new ConstructionPlugin_ValidatorPlaneThreePoints());
49 aFactory->registerValidator("ConstructionPlugin_ValidatorPlaneLinePoint",
50 new ConstructionPlugin_ValidatorPlaneLinePoint());
51 aFactory->registerValidator("ConstructionPlugin_ValidatorPlaneTwoParallelPlanes",
52 new ConstructionPlugin_ValidatorPlaneTwoParallelPlanes());
53 aFactory->registerValidator("ConstructionPlugin_ValidatorAxisTwoNotParallelPlanes",
54 new ConstructionPlugin_ValidatorAxisTwoNotParallelPlanes());
56 Config_PropManager::registerProp(SKETCH_TAB_NAME, "planes_size", "Size", Config_Prop::Double,
58 Config_PropManager::registerProp(SKETCH_TAB_NAME, "planes_thickness", "Thickness",
59 Config_Prop::Integer, SKETCH_WIDTH);
60 Config_PropManager::registerProp(SKETCH_TAB_NAME, "rotate_to_plane",
61 "Rotate to plane when selected", Config_Prop::Boolean, "false");
63 // register this plugin
64 ModelAPI_Session::get()->registerPlugin(this);
66 // register construction properties
67 Config_PropManager::registerProp("Visualization", "construction_plane_color",
68 "Construction plane color",
69 Config_Prop::Color, ConstructionPlugin_Plane::DEFAULT_COLOR());
72 FeaturePtr ConstructionPlugin_Plugin::createFeature(std::string theFeatureID)
74 if (theFeatureID == ConstructionPlugin_Point::ID()) {
75 return FeaturePtr(new ConstructionPlugin_Point);
77 else if (theFeatureID == ConstructionPlugin_Axis::ID()) {
78 return FeaturePtr(new ConstructionPlugin_Axis);
80 else if (theFeatureID == ConstructionPlugin_Plane::ID()) {
81 return FeaturePtr(new ConstructionPlugin_Plane);
83 // feature of such kind is not found