2 // Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
3 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
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.
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.
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
19 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
23 // File : GEOMContext.cxx
24 // Author : Damien COQUERET
28 #include "GEOMContext.h"
29 #include "QAD_Tools.h"
33 /* The object itself created in the static method 'GetOrCreateGEOMBase()' */
34 static GEOMContext* GeomGUI = 0;
36 //=======================================================================
37 // function : GEOMContext()
38 // purpose : Constructor
39 //=======================================================================
40 GEOMContext::GEOMContext() :
46 //=======================================================================
47 // function : ~GEOMContext()
48 // purpose : Destructor
49 //=======================================================================
50 GEOMContext::~GEOMContext()
55 //=======================================================================
56 // function : GetGEOMContext() static
57 // purpose : Returns current 'GeomGUI' a static pointer
58 //=======================================================================
59 GEOMContext* GEOMContext::GetGeomGUI()
65 //=======================================================================
66 // function : GetOrCreateGEOMBase()
67 // purpose : Gets or create an object 'GEOMBase' with initialisations
68 // : Returns 'GeomGUI' as a pointer
69 //=======================================================================
70 GEOMContext* GEOMContext::GetOrCreateGeomGUI(QAD_Desktop* desktop)
73 GeomGUI = new GEOMContext();
74 Engines::Component_var comp = desktop->getEngine("FactoryServer", "GEOM");
75 GeomGUI->myComponentGeom = GEOM::GEOM_Gen::_narrow(comp);
77 GeomGUI->myState = -1;
78 GeomGUI->myActiveDialogBox = 0;
79 GeomGUI->myFatherior = "";
80 GeomGUI->myGUILibrary = OSD_SharedLibrary();
83 int studyId = desktop->getActiveStudy()->getStudyId();
84 GeomGUI->myComponentGeom->GetCurrentStudy(studyId);
86 GeomGUI->myNbGeom = GeomGUI->myComponentGeom->NbLabels();
90 int studyId = desktop->getActiveStudy()->getStudyId();
91 GeomGUI->myComponentGeom->GetCurrentStudy(studyId);
93 GeomGUI->myNbGeom = GeomGUI->myComponentGeom->NbLabels();
99 //=======================================================================
100 // function : LoadLibrary()
102 //=======================================================================
103 bool GEOMContext::LoadLibrary(QString GUILibrary)
107 QString GUILib, fileString, dir;
109 if(libs = getenv("LD_LIBRARY_PATH")) {
110 QStringList dirList = QStringList::split(":", libs, false); // skip empty entries
111 for(int i = dirList.count()-1; i >= 0; i--) {
113 fileString = QAD_Tools::addSlash(dir) + GUILibrary;
114 fileInfo.setFile(fileString);
115 if(fileInfo.exists()) {
116 GUILib = fileInfo.fileName();
122 myGUILibrary.SetName(TCollection_AsciiString((char*)GUILib.latin1()).ToCString());
123 bool res = myGUILibrary.DlOpen(OSD_RTLD_LAZY);
125 cout<<"Can't open library : "<<myGUILibrary.DlError()<<endl;
130 //=======================================================================
131 // function : SetActiveDialogBox()
133 //=======================================================================
134 void GEOMContext::SetActiveDialogBox(QDialog* aDlg)
136 myActiveDialogBox = (QDialog*)aDlg;
141 //=======================================================================
142 // function : EmitSignalDeactivateDialog()
143 // purpose : Emit a signal to deactivate the active dialog Box
144 //=======================================================================
145 void GEOMContext::EmitSignalDeactivateDialog()
147 emit SignalDeactivateActiveDialog();
152 //=======================================================================
153 // function : EmitSignalCloseAllDialogs()
154 // purpose : Emit a signal to deactivate all non modal dialogs box
155 //=======================================================================
156 void GEOMContext::EmitSignalCloseAllDialogs()
158 emit SignalCloseAllDialogs();
163 //=======================================================================
164 // function : EmitSignalDefaultStepValueChanged()
166 //=======================================================================
167 void GEOMContext::EmitSignalDefaultStepValueChanged(double newVal)
169 emit SignalDefaultStepValueChanged(newVal);