1 // SALOME SALOMEGUI : implementation of desktop and GUI kernel
3 // Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
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.
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.
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
20 // See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
24 // File : QAD_RightFrame.cxx
25 // Author : Nicolas REJNERI
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>
38 #include <qmessagebox.h>
40 // Open CASCADE Include
41 #include <OSD_SharedLibrary.hxx>
44 \class QAD_RightFrame QAD_RightFrame.h
45 \brief Frame window which contains QAD_ViewFrame, QAD_PyInterp and QAD_Message.
48 typedef QAD_ViewFrame* View(QAD_RightFrame*);
54 QAD_RightFrame::QAD_RightFrame(QWidget *parent, const char *name,
55 QAD_PyInterp* interp, ViewType vt)
56 : QAD_Splitter( Qt::Vertical, parent, name )
58 this->setCompressEnabled( true );
61 QAD_Desktop* Desktop = QAD_Application::getDesktop();
62 int DesktopHeight = Desktop->getMainFrame()->width();
63 int DesktopWidth = Desktop->getMainFrame()->height();
67 OSD_SharedLibrary SharedLib = OSD_SharedLibrary();
72 if (myViewType == VIEW_OCC) {
73 if ( dir = getenv("SALOME_SITE_DIR")) {
74 dir = QAD_Tools::addSlash(dir) ;
76 dir = QAD_Tools::addSlash(dir) ;
77 dir = dir + "salome" ;
78 dir = QAD_Tools::addSlash(dir) ;
80 dir = dir + "libOCCViewer.dll" ;
82 dir = dir + "libOCCViewer.so" ;
84 MESSAGE ( " GUI library = " << dir )
85 fileInfo.setFile(dir) ;
86 if (fileInfo.exists()) {
87 ComponentLib = fileInfo.fileName();
91 MESSAGE (" Not found ")
94 if ( (dir = getenv("SALOME_ROOT_DIR")) && !found ) {
95 dir = QAD_Tools::addSlash(dir) ;
97 dir = QAD_Tools::addSlash(dir) ;
98 dir = dir + "salome" ;
99 dir = QAD_Tools::addSlash(dir) ;
101 dir = dir + "libOCCViewer.dll" ;
103 dir = dir + "libOCCViewer.so" ;
105 MESSAGE ( " GUI library = " << dir )
106 fileInfo.setFile(dir) ;
107 if (fileInfo.exists()) {
108 ComponentLib = fileInfo.fileName();
112 MESSAGE (" Not found ")
115 if ( (dir = getenv("KERNEL_ROOT_DIR")) && !found ) {
116 dir = QAD_Tools::addSlash(dir) ;
118 dir = QAD_Tools::addSlash(dir) ;
119 dir = dir + "salome" ;
120 dir = QAD_Tools::addSlash(dir) ;
121 dir = dir + "salome" ;
122 dir = QAD_Tools::addSlash(dir) ;
124 dir = dir + "libOCCViewer.dll" ;
126 dir = dir + "libOCCViewer.so" ;
128 MESSAGE ( " GUI library = " << dir )
129 fileInfo.setFile(dir) ;
130 if (fileInfo.exists()) {
131 ComponentLib = fileInfo.fileName();
135 MESSAGE (" Not found ")
137 } else if (myViewType == VIEW_VTK) {
139 if ( dir = getenv("SALOME_SITE_DIR")) {
140 dir = QAD_Tools::addSlash(dir) ;
142 dir = QAD_Tools::addSlash(dir) ;
143 dir = dir + "salome" ;
144 dir = QAD_Tools::addSlash(dir) ;
146 dir = dir + "libVTKViewer.dll" ;
148 dir = dir + "libVTKViewer.so" ;
150 MESSAGE ( " GUI library = " << dir );
151 fileInfo.setFile(dir) ;
152 if (fileInfo.exists()) {
153 ComponentLib = fileInfo.fileName();
157 MESSAGE (" Not found ");
160 if ( (dir = getenv("SALOME_ROOT_DIR")) && !found ) {
161 dir = QAD_Tools::addSlash(dir) ;
163 dir = QAD_Tools::addSlash(dir) ;
164 dir = dir + "salome" ;
165 dir = QAD_Tools::addSlash(dir) ;
167 dir = dir + "libVTKViewer.dll" ;
169 dir = dir + "libVTKViewer.so" ;
171 MESSAGE ( " GUI library = " << dir );
172 fileInfo.setFile(dir) ;
173 if (fileInfo.exists()) {
174 ComponentLib = fileInfo.fileName();
178 MESSAGE (" Not found ");
181 if ( (dir = getenv("KERNEL_ROOT_DIR")) && !found ) {
182 dir = QAD_Tools::addSlash(dir) ;
184 dir = QAD_Tools::addSlash(dir) ;
185 dir = dir + "salome" ;
186 dir = QAD_Tools::addSlash(dir) ;
187 dir = dir + "salome" ;
188 dir = QAD_Tools::addSlash(dir) ;
190 dir = dir + "libVTKViewer.dll" ;
192 dir = dir + "libVTKViewer.so" ;
194 MESSAGE ( " GUI library = " << dir );
195 fileInfo.setFile(dir) ;
196 if (fileInfo.exists()) {
197 ComponentLib = fileInfo.fileName();
201 MESSAGE (" Not found ");
203 } else if (myViewType == VIEW_GRAPHSUPERV) {
204 if ( dir = getenv("SALOME_SITE_DIR")){
205 dir = QAD_Tools::addSlash(dir) ;
207 dir = QAD_Tools::addSlash(dir) ;
208 dir = dir + "salome" ;
209 dir = QAD_Tools::addSlash(dir) ;
211 dir = dir + "libSUPERVGraph.dll" ;
213 dir = dir + "libSUPERVGraph.so" ;
215 MESSAGE ( " GUI library = " << dir )
216 fileInfo.setFile(dir) ;
217 if (fileInfo.exists()) {
218 ComponentLib = fileInfo.fileName() ;
222 MESSAGE (" Not found ")
225 if ( (dir = getenv("SALOME_ROOT_DIR")) && !found ) {
226 dir = QAD_Tools::addSlash(dir) ;
228 dir = QAD_Tools::addSlash(dir) ;
229 dir = dir + "salome" ;
230 dir = QAD_Tools::addSlash(dir) ;
232 dir = dir + "libSUPERVGraph.dll" ;
234 dir = dir + "libSUPERVGraph.so" ;
236 MESSAGE ( " GUI library = " << dir )
237 fileInfo.setFile(dir) ;
238 if (fileInfo.exists()) {
239 ComponentLib = fileInfo.fileName() ;
243 MESSAGE (" Not found ")
246 if ( (dir = getenv("KERNEL_ROOT_DIR")) && !found ) {
247 dir = QAD_Tools::addSlash(dir) ;
249 dir = QAD_Tools::addSlash(dir) ;
250 dir = dir + "salome" ;
251 dir = QAD_Tools::addSlash(dir) ;
253 dir = dir + "libSUPERVGraph.dll" ;
255 dir = dir + "libSUPERVGraph.so" ;
257 MESSAGE ( " GUI library = " << dir )
258 fileInfo.setFile(dir) ;
259 if (fileInfo.exists()) {
260 ComponentLib = fileInfo.fileName() ;
264 MESSAGE (" Not found ")
266 } else if (myViewType == VIEW_PLOT2D) {
267 if ( dir = getenv("SALOME_SITE_DIR")){
268 dir = QAD_Tools::addSlash(dir) ;
270 dir = QAD_Tools::addSlash(dir) ;
271 dir = dir + "salome" ;
272 dir = QAD_Tools::addSlash(dir) ;
274 dir = dir + "libPlot2d.dll" ;
276 dir = dir + "libPlot2d.so" ;
278 MESSAGE ( " GUI library = " << dir )
279 fileInfo.setFile(dir) ;
280 if (fileInfo.exists()) {
281 ComponentLib = fileInfo.fileName() ;
285 MESSAGE (" Not found ")
288 if ( (dir = getenv("SALOME_ROOT_DIR")) && !found ) {
289 dir = QAD_Tools::addSlash(dir) ;
291 dir = QAD_Tools::addSlash(dir) ;
292 dir = dir + "salome" ;
293 dir = QAD_Tools::addSlash(dir) ;
295 dir = dir + "libPlot2d.dll" ;
297 dir = dir + "libPlot2d.so" ;
299 MESSAGE ( " GUI library = " << dir )
300 fileInfo.setFile(dir) ;
301 if (fileInfo.exists()) {
302 ComponentLib = fileInfo.fileName() ;
306 MESSAGE (" Not found ")
309 if ( (dir = getenv("KERNEL_ROOT_DIR")) && !found ) {
310 dir = QAD_Tools::addSlash(dir) ;
312 dir = QAD_Tools::addSlash(dir) ;
313 dir = dir + "salome" ;
314 dir = QAD_Tools::addSlash(dir) ;
316 dir = dir + "libPlot2d.dll" ;
318 dir = dir + "libPlot2d.so" ;
320 MESSAGE ( " GUI library = " << dir )
321 fileInfo.setFile(dir) ;
322 if (fileInfo.exists()) {
323 ComponentLib = fileInfo.fileName() ;
327 MESSAGE (" Not found ")
330 QMessageBox::critical( this,
332 tr("undefined view type") );
336 SharedLib.SetName( strdup(ComponentLib) );
338 bool ok = SharedLib.DlOpen(OSD_RTLD_LAZY);
340 QMessageBox::critical( this,
342 tr( SharedLib.DlError() ) );
345 OSD_Function osdF = SharedLib.DlSymb("createView");
346 if ( osdF != NULL ) {
347 View (*f1) = (QAD_ViewFrame* (*) (QAD_RightFrame*)) osdF;
348 myViewFrame = (*f1)(this);
350 QMessageBox::critical( this,
352 tr("createView undefined") );
357 QValueList<int> sizes;
359 myViewFrame->setMinimumSize( 1, 1 );
360 vsplitter = new QAD_Splitter( Qt::Horizontal, this );
361 vsplitter->setMinimumSize( 1, 1 );
362 vsplitter->setCompressEnabled( true );
363 myPyEditor = new QAD_PyEditor(_interp, vsplitter ,"Python Interpreter");
364 myPyEditor->setMinimumSize( 1, 1 );
365 myMessage = new QAD_Message( vsplitter ,"Message");
366 myMessage->setMinimumSize( 1, 1 );
368 sizes.append( (int)(0.48 * DesktopHeight) );
369 sizes.append( (int)(0.16 * DesktopHeight) );
372 sizes.append( (int)(0.25 * DesktopWidth) );
373 sizes.append( (int)(0.25 * DesktopWidth) );
374 vsplitter->setSizes( sizes );
380 QAD_RightFrame::~QAD_RightFrame()
384 QAD_ViewFrame* QAD_RightFrame::getViewFrame() const
390 Returns reference to the message window [ static ]
392 QAD_Message* QAD_RightFrame::getMessage() const
398 Returns the Python interpreter that belongs to this study
400 QAD_PyInterp* QAD_RightFrame::get_PyInterp(void)
406 Returns reference to the Python window [ static ]
408 QAD_PyEditor* QAD_RightFrame::getPyEditor() const
416 void QAD_RightFrame::compressUp()
418 QSplitterPHandle* h = getHandleAfter(myViewFrame);
426 void QAD_RightFrame::unCompressUp()
428 QSplitterPHandle* h = getHandleAfter(myViewFrame);
430 h->unCompressBefore();
434 Compress Python Interpreter and Messages windows
436 void QAD_RightFrame::compressBottom()
438 QSplitterPHandle* h = getHandleAfter(myViewFrame);
444 Uncompress Python Interpreter and Messages windows
446 void QAD_RightFrame::unCompressBottom()
448 QSplitterPHandle* h = getHandleAfter(myViewFrame);
450 h->unCompressAfter();