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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
23 // File : GEOMContext.cxx
24 // Author : Damien COQUERET
29 #include "GEOMContext.h"
30 #include "QAD_Tools.h"
32 /* The object itself created in the static method 'GetOrCreateGEOMBase()' */
33 static GEOMContext* GeomGUI = 0;
35 //=======================================================================
36 // function : GEOMContext()
37 // purpose : Constructor
38 //=======================================================================
39 GEOMContext::GEOMContext() :
45 //=======================================================================
46 // function : ~GEOMContext()
47 // purpose : Destructor
48 //=======================================================================
49 GEOMContext::~GEOMContext()
54 //=======================================================================
55 // function : GetGEOMContext() static
56 // purpose : Returns current 'GeomGUI' a static pointer
57 //=======================================================================
58 GEOMContext* GEOMContext::GetGeomGUI()
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)
72 GeomGUI = new GEOMContext();
73 Engines::Component_var comp = desktop->getEngine("FactoryServer", "GEOM");
74 GeomGUI->myComponentGeom = GEOM::GEOM_Gen::_narrow(comp);
76 GeomGUI->myState = -1;
77 GeomGUI->myActiveDialogBox = 0;
78 GeomGUI->myFatherior = "";
79 GeomGUI->myGUILibrary = OSD_SharedLibrary();
82 int studyId = desktop->getActiveStudy()->getStudyId();
83 GeomGUI->myComponentGeom->GetCurrentStudy(studyId);
85 GeomGUI->myNbGeom = GeomGUI->myComponentGeom->NbLabels();
89 int studyId = desktop->getActiveStudy()->getStudyId();
90 GeomGUI->myComponentGeom->GetCurrentStudy(studyId);
92 GeomGUI->myNbGeom = GeomGUI->myComponentGeom->NbLabels();
98 //=======================================================================
99 // function : LoadLibrary()
101 //=======================================================================
102 bool GEOMContext::LoadLibrary(QString GUILibrary)
106 QString GUILib, fileString, dir;
108 if(libs = getenv("LD_LIBRARY_PATH")) {
109 QStringList dirList = QStringList::split(":", libs, false); // skip empty entries
110 for(int i = dirList.count()-1; i >= 0; i--) {
112 fileString = QAD_Tools::addSlash(dir) + GUILibrary;
113 fileInfo.setFile(fileString);
114 if(fileInfo.exists()) {
115 GUILib = fileInfo.fileName();
121 myGUILibrary.SetName(TCollection_AsciiString((char*)GUILib.latin1()).ToCString());
122 bool res = myGUILibrary.DlOpen(OSD_RTLD_LAZY);
124 cout<<"Can't open library : "<<myGUILibrary.DlError()<<endl;
129 //=======================================================================
130 // function : SetActiveDialogBox()
132 //=======================================================================
133 void GEOMContext::SetActiveDialogBox(QDialog* aDlg)
135 myActiveDialogBox = (QDialog*)aDlg;
140 //=======================================================================
141 // function : EmitSignalDeactivateDialog()
142 // purpose : Emit a signal to deactivate the active dialog Box
143 //=======================================================================
144 void GEOMContext::EmitSignalDeactivateDialog()
146 emit SignalDeactivateActiveDialog();
151 //=======================================================================
152 // function : EmitSignalCloseAllDialogs()
153 // purpose : Emit a signal to deactivate all non modal dialogs box
154 //=======================================================================
155 void GEOMContext::EmitSignalCloseAllDialogs()
157 emit SignalCloseAllDialogs();
162 //=======================================================================
163 // function : EmitSignalDefaultStepValueChanged()
165 //=======================================================================
166 void GEOMContext::EmitSignalDefaultStepValueChanged(double newVal)
168 emit SignalDefaultStepValueChanged(newVal);