Salome HOME
Issue #2657: Impossible to create sketch line with start point in the origin
[modules/shaper.git] / src / ParametersPlugin / ParametersPlugin_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 <pyconfig.h>
22
23 #include <ParametersPlugin_Plugin.h>
24 #include <ParametersPlugin_Parameter.h>
25 #include <ParametersPlugin_ParametersMgr.h>
26 #include <ParametersPlugin_Validators.h>
27 #include <ParametersPlugin_WidgetCreator.h>
28
29 #include <ModuleBase_WidgetCreatorFactory.h>
30
31 #include <ModelAPI_Session.h>
32 #include <ModelAPI_Validator.h>
33
34 #include <memory>
35
36 // the only created instance of this plugin
37 static ParametersPlugin_Plugin* MY_PARAMETERSPLUGIN_INSTANCE = new ParametersPlugin_Plugin();
38
39 ParametersPlugin_Plugin::ParametersPlugin_Plugin()
40 {
41   // register this plugin
42   WidgetCreatorFactoryPtr aWidgetCreatorFactory = ModuleBase_WidgetCreatorFactory::get();
43   aWidgetCreatorFactory->registerCreator(
44    std::shared_ptr<ParametersPlugin_WidgetCreator>(new ParametersPlugin_WidgetCreator()));
45
46   SessionPtr aSession = ModelAPI_Session::get();
47   aSession->registerPlugin(this);
48
49   ModelAPI_ValidatorsFactory* aFactory = aSession->validators();
50   aFactory->registerValidator("Parameters_VariableValidator",
51                               new ParametersPlugin_VariableValidator);
52   aFactory->registerValidator("Parameters_ExpressionValidator",
53                               new ParametersPlugin_ExpressionValidator);
54
55   myEvalListener =
56     std::shared_ptr<ParametersPlugin_EvalListener>(new ParametersPlugin_EvalListener());
57 }
58
59 FeaturePtr ParametersPlugin_Plugin::createFeature(std::string theFeatureID)
60 {
61   // TODO: register some features
62   if (theFeatureID == ParametersPlugin_Parameter::ID()) {
63     return FeaturePtr(new ParametersPlugin_Parameter);
64   }
65   if (theFeatureID == ParametersPlugin_ParametersMgr::ID()) {
66     return FeaturePtr(new ParametersPlugin_ParametersMgr);
67   }
68   return FeaturePtr();
69 }
70