]> SALOME platform Git repositories - modules/yacs.git/blob - src/SALOMEGUI/QAD_RightFrame.cxx
Salome HOME
sources v1.2
[modules/yacs.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 using namespace std;
30 #include "QAD_RightFrame.h"
31 #include "QAD_Application.h"
32 #include "QAD_Desktop.h"
33 #include "QAD_StudyFrame.h"
34 #include "QAD_Tools.h"
35 #include <qvaluelist.h>
36
37 // QT Include
38 #include <qmessagebox.h>
39
40 // Open CASCADE Include
41 #include <OSD_SharedLibrary.hxx>
42
43 /*!
44   \class QAD_RightFrame QAD_RightFrame.h
45   \brief Frame window which contains QAD_ViewFrame, QAD_PyInterp and QAD_Message.
46 */
47
48 typedef QAD_ViewFrame* View(QAD_RightFrame*);
49
50
51 /*!
52     Constructor
53 */
54 QAD_RightFrame::QAD_RightFrame(QWidget *parent, const char *name,
55                                QAD_PyInterp* interp, ViewType vt)
56   : QAD_Splitter( Qt::Vertical, parent, name )
57 {
58   this->setCompressEnabled( true );
59   myViewType  = vt;
60
61   QAD_Desktop* Desktop = QAD_Application::getDesktop();
62   int DesktopHeight = Desktop->getMainFrame()->width();
63   int DesktopWidth  = Desktop->getMainFrame()->height();
64
65   _interp = interp;
66
67   OSD_SharedLibrary SharedLib = OSD_SharedLibrary();
68   QString ComponentLib;
69   QCString dir;
70   QFileInfo fileInfo ;
71   bool found = false;
72   if (myViewType == VIEW_OCC) {
73     if ( dir = getenv("SALOME_SITE_DIR")) {
74       dir = QAD_Tools::addSlash(dir) ;
75       dir = dir + "lib" ;
76       dir = QAD_Tools::addSlash(dir) ;
77 #ifdef WNT
78       dir = dir + "libOCCViewer.dll" ;
79 #else
80       dir = dir + "libOCCViewer.so" ;
81 #endif
82       MESSAGE ( " GUI library = " << dir )
83       fileInfo.setFile(dir) ;
84       if (fileInfo.exists()) {
85         ComponentLib = fileInfo.fileName();
86         found = true;
87         MESSAGE (" Found ")
88       } else
89         MESSAGE (" Not found ")
90     }
91     
92     if ( (dir = getenv("SALOME_ROOT_DIR")) && !found ) {
93       dir = QAD_Tools::addSlash(dir) ;
94       dir = dir + "lib" ;
95       dir = QAD_Tools::addSlash(dir) ;
96 #ifdef WNT
97       dir = dir + "libOCCViewer.dll" ;
98 #else
99       dir = dir + "libOCCViewer.so" ;
100 #endif
101       MESSAGE ( " GUI library = " << dir )
102       fileInfo.setFile(dir) ;
103       if (fileInfo.exists()) {
104         ComponentLib = fileInfo.fileName();
105         found = true;
106         MESSAGE (" Found ")
107       } else
108         MESSAGE (" Not found ")
109     }
110   } else if (myViewType == VIEW_VTK) {
111     
112     if ( dir = getenv("SALOME_SITE_DIR")) {
113       dir = QAD_Tools::addSlash(dir) ;
114       dir = dir + "lib" ;
115       dir = QAD_Tools::addSlash(dir) ;
116 #ifdef WNT
117       dir = dir + "libVTKViewer.dll" ;
118 #else
119       dir = dir + "libVTKViewer.so" ;
120 #endif
121       MESSAGE ( " GUI library = " << dir );
122       fileInfo.setFile(dir) ;
123       if (fileInfo.exists()) {
124         ComponentLib = fileInfo.fileName();
125         found = true;
126         MESSAGE (" Found ");
127       } else
128         MESSAGE (" Not found ");
129     }
130         
131     if ( (dir = getenv("SALOME_ROOT_DIR")) && !found ) {
132       dir = QAD_Tools::addSlash(dir) ;
133       dir = dir + "lib" ;
134       dir = QAD_Tools::addSlash(dir) ;
135 #ifdef WNT
136       dir = dir + "libVTKViewer.dll" ;
137 #else
138       dir = dir + "libVTKViewer.so" ;
139 #endif
140       MESSAGE ( " GUI library = " << dir );
141       fileInfo.setFile(dir) ;
142       if (fileInfo.exists()) {
143         ComponentLib = fileInfo.fileName();
144         found = true;
145         MESSAGE (" Found ");
146       } else
147         MESSAGE (" Not found ");
148     }
149   } else if (myViewType == VIEW_GRAPHSUPERV) {
150     if ( dir = getenv("SALOME_SITE_DIR")){
151       dir = QAD_Tools::addSlash(dir) ;
152       dir = dir + "lib" ;
153       dir = QAD_Tools::addSlash(dir) ;
154 #ifdef WNT
155       dir = dir + "libSUPERVGraph.dll" ;
156 #else
157       dir = dir + "libSUPERVGraph.so" ;
158 #endif
159       MESSAGE ( " GUI library = " << dir )
160       fileInfo.setFile(dir) ;
161       if (fileInfo.exists()) {
162         ComponentLib = fileInfo.fileName() ;
163         found = true;
164         MESSAGE (" Found ")
165       } else
166         MESSAGE (" Not found ")
167     }
168     
169     if ( (dir = getenv("SALOME_ROOT_DIR")) && !found ) {
170       dir = QAD_Tools::addSlash(dir) ;
171       dir = dir + "lib" ;
172       dir = QAD_Tools::addSlash(dir) ;
173 #ifdef WNT
174       dir = dir + "libSUPERVGraph.dll" ;
175 #else
176       dir = dir + "libSUPERVGraph.so" ;
177 #endif
178       MESSAGE ( " GUI library = " << dir )
179       fileInfo.setFile(dir) ;
180       if (fileInfo.exists()) {
181         ComponentLib = fileInfo.fileName() ;
182         found = true;
183         MESSAGE (" Found ")
184       } else
185         MESSAGE (" Not found ")
186     }
187   } else if (myViewType == VIEW_PLOT2D) {
188     if ( dir = getenv("SALOME_SITE_DIR")){
189       dir = QAD_Tools::addSlash(dir) ;
190       dir = dir + "lib" ;
191       dir = QAD_Tools::addSlash(dir) ;
192 #ifdef WNT
193       dir = dir + "libPlot2d.dll" ;
194 #else
195       dir = dir + "libPlot2d.so" ;
196 #endif
197       MESSAGE ( " GUI library = " << dir )
198       fileInfo.setFile(dir) ;
199       if (fileInfo.exists()) {
200         ComponentLib = fileInfo.fileName() ;
201         found = true;
202         MESSAGE (" Found ")
203       } else
204         MESSAGE (" Not found ")
205     }
206     
207     if ( (dir = getenv("SALOME_ROOT_DIR")) && !found ) {
208       dir = QAD_Tools::addSlash(dir) ;
209       dir = dir + "lib" ;
210       dir = QAD_Tools::addSlash(dir) ;
211 #ifdef WNT
212       dir = dir + "libPlot2d.dll" ;
213 #else
214       dir = dir + "libPlot2d.so" ;
215 #endif
216       MESSAGE ( " GUI library = " << dir )
217       fileInfo.setFile(dir) ;
218       if (fileInfo.exists()) {
219         ComponentLib = fileInfo.fileName() ;
220         found = true;
221         MESSAGE (" Found ")
222       } else
223         MESSAGE (" Not found ")
224     }
225   } else {
226     QMessageBox::critical( this,
227                            tr("ERR_ERROR"),
228                            tr("undefined view type") );
229     return;
230   }
231
232   SharedLib.SetName( strdup(ComponentLib) );
233   
234   bool ok = SharedLib.DlOpen(OSD_RTLD_LAZY);
235   if (!ok) {
236     QMessageBox::critical( this,
237                            tr("ERR_ERROR"),
238                            tr( SharedLib.DlError() ) );
239     return;
240   } else {
241     OSD_Function osdF = SharedLib.DlSymb("createView");
242     if ( osdF != NULL ) {
243       View (*f1) = (QAD_ViewFrame* (*) (QAD_RightFrame*)) osdF;
244       myViewFrame = (*f1)(this);
245     } else {
246       QMessageBox::critical( this,
247                              tr("ERR_ERROR"),
248                              tr("createView undefined") );
249       return;
250     }
251   }
252
253   QValueList<int> sizes;
254
255   myViewFrame->setMinimumSize( 1, 1 );
256   vsplitter = new QAD_Splitter( Qt::Horizontal, this );
257   vsplitter->setMinimumSize( 1, 1 );
258   vsplitter->setCompressEnabled( true );
259   myPyEditor = new QAD_PyEditor(_interp, vsplitter ,"Python Interpreter");
260   myPyEditor->setMinimumSize( 1, 1 );
261   myMessage  = new QAD_Message( vsplitter ,"Message");  
262   myMessage->setMinimumSize( 1, 1 );
263
264   sizes.append( (int)(0.48 * DesktopHeight) );
265   sizes.append( (int)(0.16 * DesktopHeight) );
266   setSizes( sizes );
267   sizes.clear();
268   sizes.append( (int)(0.25 * DesktopWidth) );
269   sizes.append( (int)(0.25 * DesktopWidth) );
270   vsplitter->setSizes( sizes );
271 }
272
273 /*!
274     Destructor
275 */
276 QAD_RightFrame::~QAD_RightFrame()
277 {  
278 }
279
280 QAD_ViewFrame* QAD_RightFrame::getViewFrame() const
281 {
282   return myViewFrame;
283 }
284
285 /*!
286     Returns reference to the message window [ static ]
287 */
288 QAD_Message* QAD_RightFrame::getMessage() const
289 {
290   return myMessage;
291 }
292
293 /*!
294   Returns the Python interpreter that belongs to this study
295 */
296 QAD_PyInterp* QAD_RightFrame::get_PyInterp(void)
297 {
298   return _interp;
299 }
300
301 /*!
302     Returns reference to the Python window [ static ]
303 */
304 QAD_PyEditor* QAD_RightFrame::getPyEditor() const
305 {
306   return myPyEditor;
307 }
308
309 /*!
310     Compress views
311 */
312 void QAD_RightFrame::compressUp()
313 {
314   QSplitterPHandle* h = getHandleAfter(myViewFrame);
315   if (h)
316     h->compressBefore();
317 }
318
319 /*!
320     Uncompress views
321 */
322 void QAD_RightFrame::unCompressUp()
323 {
324   QSplitterPHandle* h = getHandleAfter(myViewFrame);
325   if (h)
326     h->unCompressBefore();
327 }
328
329 /*!
330     Compress Python Interpreter and Messages windows
331 */
332 void QAD_RightFrame::compressBottom()
333 {
334   QSplitterPHandle* h = getHandleAfter(myViewFrame);
335   if (h)
336     h->compressAfter();
337 }
338
339 /*!
340     Uncompress Python Interpreter and Messages windows
341 */
342 void QAD_RightFrame::unCompressBottom()
343 {
344   QSplitterPHandle* h = getHandleAfter(myViewFrame);
345   if (h)
346     h->unCompressAfter();
347 }
348