Salome HOME
Issue #2476: Replace double inputs by double spin boxes input
[modules/shaper.git] / src / ModelAPI / ModelAPI_Session.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 <ModelAPI_Session.h>
22 // to avoid unresolved ModelAPI_Document()
23 #include <ModelAPI_Document.h>
24 // to avoid unresolved ModelAPI_Feature()
25 #include <ModelAPI_Feature.h>
26 #include <ModelAPI_Object.h>
27 // to avoid unresolved ModelAPI_Data()
28 #include <ModelAPI_Data.h>
29 // to avoid unresolved ModelAPI_Plugin()
30 #include <ModelAPI_Plugin.h>
31 #include <ModelAPI_Attribute.h>
32 #include <ModelAPI_AttributeDocRef.h>
33 #include <ModelAPI_AttributeDouble.h>
34 #include <ModelAPI_AttributeBoolean.h>
35 #include <ModelAPI_AttributeInteger.h>
36 #include <ModelAPI_AttributeString.h>
37 #include <ModelAPI_AttributeReference.h>
38 #include <ModelAPI_AttributeRefAttr.h>
39 #include <ModelAPI_AttributeRefList.h>
40 #include <ModelAPI_AttributeBoolean.h>
41 #include <ModelAPI_AttributeSelection.h>
42 #include <ModelAPI_AttributeSelectionList.h>
43 #include <ModelAPI_Events.h>
44 #include <ModelAPI_Validator.h>
45 #include <ModelAPI_ResultBody.h>
46 #include <ModelAPI_ResultConstruction.h>
47
48 #include <Config_ModuleReader.h>
49 #include <Config_PropManager.h>
50
51 #ifdef WIN32
52 #include <windows.h>
53 #else
54 #include <dlfcn.h>
55 #endif
56
57 #ifdef _DEBUG
58 #include <iostream>
59 #endif
60
61 /// Manager that will be initialized from Model package, one per application
62 std::shared_ptr<ModelAPI_Session> MY_MANAGER;
63
64 void ModelAPI_Session::setSession(std::shared_ptr<ModelAPI_Session> theManager)
65 {
66   MY_MANAGER = theManager;
67 }
68
69 std::shared_ptr<ModelAPI_Session> ModelAPI_Session::get()
70 {
71   if (!MY_MANAGER) {  // import Model library that implements this interface of ModelAPI
72     Config_ModuleReader::loadLibrary("Model");
73
74     Config_PropManager::registerProp("Visualization", "body_deflection",
75                                      "Body deflection coefficient",
76                                      Config_Prop::DblSpin,
77                                      ModelAPI_ResultBody::DEFAULT_DEFLECTION());
78
79     Config_PropManager::registerProp("Visualization", "construction_deflection",
80                                      "Construction deflection coefficient",
81                                      Config_Prop::DblSpin,
82                                      ModelAPI_ResultConstruction::DEFAULT_DEFLECTION());
83
84   }
85   return MY_MANAGER;
86 }
87
88 /// instance of the events creator, one pre application
89 const ModelAPI_EventCreator* MY_API_CREATOR = 0;
90
91 const ModelAPI_EventCreator* ModelAPI_EventCreator::get()
92 {
93   if (!MY_API_CREATOR) {  // import Model library that implements this interface of ModelAPI
94     Config_ModuleReader::loadLibrary("Model");
95   }
96   return MY_API_CREATOR;
97 }
98
99 void ModelAPI_EventCreator::set(const ModelAPI_EventCreator* theCreator)
100 {
101   MY_API_CREATOR = theCreator;
102 }