]> SALOME platform Git repositories - modules/geom.git/blob - src/GEOMContext/GEOMContext.cxx
Salome HOME
DCQ : New Architecture
[modules/geom.git] / src / GEOMContext / GEOMContext.cxx
1 //
2 //  Copyright (C) 2003  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
3 //  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS 
4 // 
5 //  This library is free software; you can redistribute it and/or 
6 //  modify it under the terms of the GNU Lesser General Public 
7 //  License as published by the Free Software Foundation; either 
8 //  version 2.1 of the License. 
9 // 
10 //  This library is distributed in the hope that it will be useful, 
11 //  but WITHOUT ANY WARRANTY; without even the implied warranty of 
12 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU 
13 //  Lesser General Public License for more details. 
14 // 
15 //  You should have received a copy of the GNU Lesser General Public 
16 //  License along with this library; if not, write to the Free Software 
17 //  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA 
18 // 
19 //  See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org 
20 //
21 //
22 //
23 //  File   : GEOMContext.cxx
24 //  Author : Damien COQUERET
25 //  Module : GEOM
26 //  $Header: 
27
28 using namespace std;
29 #include "GEOMContext.h"
30 #include "QAD_Tools.h"
31
32 /* The object itself created in the static method 'GetOrCreateGEOMBase()' */
33 static GEOMContext* GeomGUI = 0;
34
35 //=======================================================================
36 // function : GEOMContext()
37 // purpose  : Constructor
38 //=======================================================================
39 GEOMContext::GEOMContext() :
40   QObject()
41 {
42 }
43
44
45 //=======================================================================
46 // function : ~GEOMContext()
47 // purpose  : Destructor
48 //=======================================================================
49 GEOMContext::~GEOMContext()
50 {
51 }
52
53
54 //=======================================================================
55 // function : GetGEOMContext() static
56 // purpose  : Returns current 'GeomGUI' a static pointer
57 //=======================================================================
58 GEOMContext* GEOMContext::GetGeomGUI()
59 {
60   return GeomGUI;
61 }
62
63
64 //=======================================================================
65 // function : GetOrCreateGEOMBase()
66 // purpose  : Gets or create an object 'GEOMBase' with initialisations
67 //          : Returns 'GeomGUI' as a pointer
68 //=======================================================================
69 GEOMContext* GEOMContext::GetOrCreateGeomGUI(QAD_Desktop* desktop)
70 {
71   if(GeomGUI == 0) {
72     GeomGUI = new GEOMContext();
73     Engines::Component_var comp = desktop->getEngine("FactoryServer", "GEOM");
74     GeomGUI->myComponentGeom = GEOM::GEOM_Gen::_narrow(comp);
75     
76     GeomGUI->myState = -1;
77     GeomGUI->myActiveDialogBox = 0;
78     GeomGUI->myFatherior = "";
79     GeomGUI->myGUILibrary = OSD_SharedLibrary();
80
81     /* GetCurrentStudy */
82     int studyId = desktop->getActiveStudy()->getStudyId();
83     GeomGUI->myComponentGeom->GetCurrentStudy(studyId);
84     GeomGUI->myNbGeom = GeomGUI->myComponentGeom->NbLabels();
85   }
86
87   return GeomGUI;
88 }
89
90
91 //=======================================================================
92 // function : LoadLibrary()
93 // purpose  :
94 //=======================================================================
95 bool GEOMContext::LoadLibrary(QString GUILibrary)
96 {
97   QCString libs;
98   QFileInfo fileInfo;
99   QString GUILib, fileString, dir;
100
101   if(libs = getenv("LD_LIBRARY_PATH")) {
102     QStringList dirList = QStringList::split(":", libs, false); // skip empty entries
103     for(int i = dirList.count()-1; i >= 0; i--) {
104       dir = dirList[i];
105       fileString = QAD_Tools::addSlash(dir) + GUILibrary;
106       fileInfo.setFile(fileString);
107       if(fileInfo.exists()) {
108         GUILib = fileInfo.fileName();
109         break;
110       }
111     }
112   }
113
114   myGUILibrary.SetName(TCollection_AsciiString((char*)GUILib.latin1()).ToCString());
115   bool res = myGUILibrary.DlOpen(OSD_RTLD_LAZY);
116   if(!res)
117     cout<<"Can't open library : "<<myGUILibrary.DlError()<<endl;
118   return res;
119 }
120
121
122 //=======================================================================
123 // function : SetActiveDialogBox()
124 // purpose  : 
125 //=======================================================================
126 void GEOMContext::SetActiveDialogBox(QDialog* aDlg)
127 {
128   myActiveDialogBox = (QDialog*)aDlg;
129   return;
130 }
131
132
133 //=======================================================================
134 // function : EmitSignalDeactivateDialog()
135 // purpose  : Emit a signal to deactivate the active dialog Box
136 //=======================================================================
137 void GEOMContext::EmitSignalDeactivateDialog()
138 {
139   emit SignalDeactivateActiveDialog();
140   return;
141 }
142
143
144 //=======================================================================
145 // function : EmitSignalCloseAllDialogs()
146 // purpose  : Emit a signal to deactivate all non modal dialogs box
147 //=======================================================================
148 void GEOMContext::EmitSignalCloseAllDialogs()
149 {
150   emit SignalCloseAllDialogs();
151   return;
152 }
153
154
155 //=======================================================================
156 // function : EmitSignalDefaultStepValueChanged()
157 // purpose  : 
158 //=======================================================================
159 void GEOMContext::EmitSignalDefaultStepValueChanged(double newVal)
160 {
161   emit SignalDefaultStepValueChanged(newVal);
162   return;
163 }