]> SALOME platform Git repositories - modules/kernel.git/blob - src/SALOMEGUI/QAD_RightFrame.cxx
Salome HOME
DCQ : Update msg File.
[modules/kernel.git] / src / SALOMEGUI / QAD_RightFrame.cxx
1 //  SALOME SALOMEGUI : implementation of desktop and GUI kernel
2 //
3 //  Copyright (C) 2003  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 //  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS 
5 // 
6 //  This library is free software; you can redistribute it and/or 
7 //  modify it under the terms of the GNU Lesser General Public 
8 //  License as published by the Free Software Foundation; either 
9 //  version 2.1 of the License. 
10 // 
11 //  This library is distributed in the hope that it will be useful, 
12 //  but WITHOUT ANY WARRANTY; without even the implied warranty of 
13 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU 
14 //  Lesser General Public License for more details. 
15 // 
16 //  You should have received a copy of the GNU Lesser General Public 
17 //  License along with this library; if not, write to the Free Software 
18 //  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA 
19 // 
20 //  See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org 
21 //
22 //
23 //
24 //  File   : QAD_RightFrame.cxx
25 //  Author : Nicolas REJNERI
26 //  Module : SALOME
27 //  $Header$
28
29 #include "QAD_RightFrame.h"
30 #include "QAD_Application.h"
31 #include "QAD_Desktop.h"
32 #include "QAD_StudyFrame.h"
33 #include "QAD_Tools.h"
34 #include "QAD_PyEditor.h"
35 #include "QAD_PyInterp.h"
36
37 #include <qvaluelist.h>
38
39 // QT Include
40 #include <qmessagebox.h>
41
42 // Open CASCADE Include
43 #include <OSD_SharedLibrary.hxx>
44
45 using namespace std;
46
47 /*!
48   \class QAD_RightFrame QAD_RightFrame.h
49   \brief Frame window which contains QAD_ViewFrame, QAD_PyInterp and QAD_Message.
50 */
51
52 typedef QAD_ViewFrame* View(QAD_RightFrame*);
53
54
55 /*!
56     Constructor
57 */
58 QAD_RightFrame::QAD_RightFrame(QWidget *theParent, 
59                                const char *theTitle, ViewType theTypeView,
60                                QAD_PyInterp*& theInterp, QMutex* theMutex): 
61   QAD_Splitter( Qt::Vertical, theParent, theTitle ),
62   myViewType(theTypeView),
63   myInterp(theInterp)
64 {
65   this->setCompressEnabled( true );
66
67   QAD_Desktop* Desktop = QAD_Application::getDesktop();
68   int DesktopHeight = Desktop->getMainFrame()->width();
69   int DesktopWidth  = Desktop->getMainFrame()->height();
70
71   OSD_SharedLibrary SharedLib = OSD_SharedLibrary();
72   QString ComponentLib;
73   QCString dir;
74   QFileInfo fileInfo ;
75   bool found = false;
76   if (myViewType == VIEW_OCC) {    
77     if ( (dir = getenv("KERNEL_ROOT_DIR")) && !found ) {
78       dir = QAD_Tools::addSlash(dir) ;
79       dir = dir + "lib" ;
80       dir = QAD_Tools::addSlash(dir) ;
81       dir = dir + "salome" ;
82       dir = QAD_Tools::addSlash(dir) ;
83 #ifdef WNT
84       dir = dir + "libOCCViewer.dll" ;
85 #else
86       dir = dir + "libOCCViewer.so" ;
87 #endif
88       MESSAGE ( " GUI library = " << dir )
89       fileInfo.setFile(dir) ;
90       if (fileInfo.exists()) {
91         ComponentLib = fileInfo.fileName();
92         found = true;
93         MESSAGE (" Found ")
94       } else
95         MESSAGE (" Not found ")
96     }
97   } else if (myViewType == VIEW_VTK) {
98     if ( (dir = getenv("KERNEL_ROOT_DIR")) && !found ) {
99       dir = QAD_Tools::addSlash(dir) ;
100       dir = dir + "lib" ;
101       dir = QAD_Tools::addSlash(dir) ;
102       dir = dir + "salome" ;
103       dir = QAD_Tools::addSlash(dir) ;
104 #ifdef WNT
105       dir = dir + "libVTKViewer.dll" ;
106 #else
107       dir = dir + "libVTKViewer.so" ;
108 #endif
109       MESSAGE ( " GUI library = " << dir );
110       fileInfo.setFile(dir) ;
111       if (fileInfo.exists()) {
112         ComponentLib = fileInfo.fileName();
113         found = true;
114         MESSAGE (" Found ");
115       } else
116         MESSAGE (" Not found ");
117     }
118   } else if (myViewType == VIEW_GRAPHSUPERV) {
119     if ( (dir = getenv("KERNEL_ROOT_DIR")) && !found ) {
120       dir = QAD_Tools::addSlash(dir) ;
121       dir = dir + "lib" ;
122       dir = QAD_Tools::addSlash(dir) ;
123       dir = dir + "salome" ;
124       dir = QAD_Tools::addSlash(dir) ;
125 #ifdef WNT
126       dir = dir + "libSUPERVGraph.dll" ;
127 #else
128       dir = dir + "libSUPERVGraph.so" ;
129 #endif
130       MESSAGE ( " GUI library = " << dir )
131       fileInfo.setFile(dir) ;
132       if (fileInfo.exists()) {
133         ComponentLib = fileInfo.fileName() ;
134         found = true;
135         MESSAGE (" Found ")
136       } else
137         MESSAGE (" Not found ")
138     }
139   } else if (myViewType == VIEW_PLOT2D) {
140     if ( (dir = getenv("KERNEL_ROOT_DIR")) && !found ) {
141       dir = QAD_Tools::addSlash(dir) ;
142       dir = dir + "lib" ;
143       dir = QAD_Tools::addSlash(dir) ;
144       dir = dir + "salome" ;
145       dir = QAD_Tools::addSlash(dir) ;
146 #ifdef WNT
147       dir = dir + "libPlot2d.dll" ;
148 #else
149       dir = dir + "libPlot2d.so" ;
150 #endif
151       MESSAGE ( " GUI library = " << dir )
152       fileInfo.setFile(dir) ;
153       if (fileInfo.exists()) {
154         ComponentLib = fileInfo.fileName() ;
155         found = true;
156         MESSAGE (" Found ")
157       } else
158         MESSAGE (" Not found ")
159     }
160   } else {
161     QMessageBox::critical( this,
162                            tr("ERR_ERROR"),
163                            tr("undefined view type") );
164     return;
165   }
166
167   SharedLib.SetName( strdup(ComponentLib) );
168   
169   bool ok = SharedLib.DlOpen(OSD_RTLD_LAZY);
170   if (!ok) {
171     QMessageBox::critical( this,
172                            tr("ERR_ERROR"),
173                            tr( SharedLib.DlError() ) );
174     return;
175   } else {
176     OSD_Function osdF = SharedLib.DlSymb("createView");
177     if ( osdF != NULL ) {
178       View (*f1) = (QAD_ViewFrame* (*) (QAD_RightFrame*)) osdF;
179       myViewFrame = (*f1)(this);
180     } else {
181       QMessageBox::critical( this,
182                              tr("ERR_ERROR"),
183                              tr("createView undefined") );
184       return;
185     }
186   }
187
188   QValueList<int> sizes;
189
190   myViewFrame->setMinimumSize( 1, 1 );
191   mySplitter = new QAD_Splitter( Qt::Horizontal, this );
192   mySplitter->setMinimumSize( 1, 1 );
193   mySplitter->setCompressEnabled( true );
194
195   myPyEditor = new QAD_PyEditor(myInterp, theMutex, mySplitter ,"Python Interpreter");
196   myPyEditor->setMinimumSize( 1, 1 );
197   myPyEditor->Init();
198
199   myMessage  = new QAD_Message( mySplitter ,"Message");  
200   myMessage->setMinimumSize( 1, 1 );
201
202   sizes.append( (int)(0.48 * DesktopHeight) );
203   sizes.append( (int)(0.16 * DesktopHeight) );
204   setSizes( sizes );
205   sizes.clear();
206   sizes.append( (int)(0.25 * DesktopWidth) );
207   sizes.append( (int)(0.25 * DesktopWidth) );
208   mySplitter->setSizes( sizes );
209 }
210
211 /*!
212     Destructor
213 */
214 QAD_RightFrame::~QAD_RightFrame()
215 {  
216 }
217
218 QAD_ViewFrame* QAD_RightFrame::getViewFrame() const
219 {
220   return myViewFrame;
221 }
222
223 /*!
224     Returns reference to the message window [ static ]
225 */
226 QAD_Message* QAD_RightFrame::getMessage() const
227 {
228   return myMessage;
229 }
230
231 /*!
232   Returns the Python interpreter that belongs to this study
233 */
234 QAD_PyInterp* QAD_RightFrame::get_PyInterp(void)
235 {
236   return myInterp;
237 }
238
239 /*!
240     Returns reference to the Python window [ static ]
241 */
242 QAD_PyEditor* QAD_RightFrame::getPyEditor() const
243 {
244   return myPyEditor;
245 }
246
247 /*!
248     Compress views
249 */
250 void QAD_RightFrame::compressUp()
251 {
252   QSplitterPHandle* h = getHandleAfter(myViewFrame);
253   if (h)
254     h->compressBefore();
255 }
256
257 /*!
258     Uncompress views
259 */
260 void QAD_RightFrame::unCompressUp()
261 {
262   QSplitterPHandle* h = getHandleAfter(myViewFrame);
263   if (h)
264     h->unCompressBefore();
265 }
266
267 /*!
268     Compress Python Interpreter and Messages windows
269 */
270 void QAD_RightFrame::compressBottom()
271 {
272   QSplitterPHandle* h = getHandleAfter(myViewFrame);
273   if (h)
274     h->compressAfter();
275 }
276
277 /*!
278     Uncompress Python Interpreter and Messages windows
279 */
280 void QAD_RightFrame::unCompressBottom()
281 {
282   QSplitterPHandle* h = getHandleAfter(myViewFrame);
283   if (h)
284     h->unCompressAfter();
285 }
286