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) ;
78 dir = dir + "libOCCViewer.dll" ;
80 dir = dir + "libOCCViewer.so" ;
82 MESSAGE ( " GUI library = " << dir )
83 fileInfo.setFile(dir) ;
84 if (fileInfo.exists()) {
85 ComponentLib = fileInfo.fileName();
89 MESSAGE (" Not found ")
92 if ( (dir = getenv("SALOME_ROOT_DIR")) && !found ) {
93 dir = QAD_Tools::addSlash(dir) ;
95 dir = QAD_Tools::addSlash(dir) ;
97 dir = dir + "libOCCViewer.dll" ;
99 dir = dir + "libOCCViewer.so" ;
101 MESSAGE ( " GUI library = " << dir )
102 fileInfo.setFile(dir) ;
103 if (fileInfo.exists()) {
104 ComponentLib = fileInfo.fileName();
108 MESSAGE (" Not found ")
111 if ( (dir = getenv("KERNEL_ROOT_DIR")) && !found ) {
112 dir = QAD_Tools::addSlash(dir) ;
114 dir = QAD_Tools::addSlash(dir) ;
115 dir = dir + "salome" ;
116 dir = QAD_Tools::addSlash(dir) ;
118 dir = dir + "libOCCViewer.dll" ;
120 dir = dir + "libOCCViewer.so" ;
122 MESSAGE ( " GUI library = " << dir )
123 fileInfo.setFile(dir) ;
124 if (fileInfo.exists()) {
125 ComponentLib = fileInfo.fileName();
129 MESSAGE (" Not found ")
131 } else if (myViewType == VIEW_VTK) {
133 if ( dir = getenv("SALOME_SITE_DIR")) {
134 dir = QAD_Tools::addSlash(dir) ;
136 dir = QAD_Tools::addSlash(dir) ;
138 dir = dir + "libVTKViewer.dll" ;
140 dir = dir + "libVTKViewer.so" ;
142 MESSAGE ( " GUI library = " << dir );
143 fileInfo.setFile(dir) ;
144 if (fileInfo.exists()) {
145 ComponentLib = fileInfo.fileName();
149 MESSAGE (" Not found ");
152 if ( (dir = getenv("SALOME_ROOT_DIR")) && !found ) {
153 dir = QAD_Tools::addSlash(dir) ;
155 dir = QAD_Tools::addSlash(dir) ;
157 dir = dir + "libVTKViewer.dll" ;
159 dir = dir + "libVTKViewer.so" ;
161 MESSAGE ( " GUI library = " << dir );
162 fileInfo.setFile(dir) ;
163 if (fileInfo.exists()) {
164 ComponentLib = fileInfo.fileName();
168 MESSAGE (" Not found ");
171 if ( (dir = getenv("KERNEL_ROOT_DIR")) && !found ) {
172 dir = QAD_Tools::addSlash(dir) ;
174 dir = QAD_Tools::addSlash(dir) ;
175 dir = dir + "salome" ;
176 dir = QAD_Tools::addSlash(dir) ;
178 dir = dir + "libVTKViewer.dll" ;
180 dir = dir + "libVTKViewer.so" ;
182 MESSAGE ( " GUI library = " << dir );
183 fileInfo.setFile(dir) ;
184 if (fileInfo.exists()) {
185 ComponentLib = fileInfo.fileName();
189 MESSAGE (" Not found ");
191 } else if (myViewType == VIEW_GRAPHSUPERV) {
192 if ( dir = getenv("SALOME_SITE_DIR")){
193 dir = QAD_Tools::addSlash(dir) ;
195 dir = QAD_Tools::addSlash(dir) ;
197 dir = dir + "libSUPERVGraph.dll" ;
199 dir = dir + "libSUPERVGraph.so" ;
201 MESSAGE ( " GUI library = " << dir )
202 fileInfo.setFile(dir) ;
203 if (fileInfo.exists()) {
204 ComponentLib = fileInfo.fileName() ;
208 MESSAGE (" Not found ")
211 if ( (dir = getenv("SALOME_ROOT_DIR")) && !found ) {
212 dir = QAD_Tools::addSlash(dir) ;
214 dir = QAD_Tools::addSlash(dir) ;
216 dir = dir + "libSUPERVGraph.dll" ;
218 dir = dir + "libSUPERVGraph.so" ;
220 MESSAGE ( " GUI library = " << dir )
221 fileInfo.setFile(dir) ;
222 if (fileInfo.exists()) {
223 ComponentLib = fileInfo.fileName() ;
227 MESSAGE (" Not found ")
230 if ( (dir = getenv("KERNEL_ROOT_DIR")) && !found ) {
231 dir = QAD_Tools::addSlash(dir) ;
233 dir = QAD_Tools::addSlash(dir) ;
234 dir = dir + "salome" ;
235 dir = QAD_Tools::addSlash(dir) ;
237 dir = dir + "libSUPERVGraph.dll" ;
239 dir = dir + "libSUPERVGraph.so" ;
241 MESSAGE ( " GUI library = " << dir )
242 fileInfo.setFile(dir) ;
243 if (fileInfo.exists()) {
244 ComponentLib = fileInfo.fileName() ;
248 MESSAGE (" Not found ")
250 } else if (myViewType == VIEW_PLOT2D) {
251 if ( dir = getenv("SALOME_SITE_DIR")){
252 dir = QAD_Tools::addSlash(dir) ;
254 dir = QAD_Tools::addSlash(dir) ;
256 dir = dir + "libPlot2d.dll" ;
258 dir = dir + "libPlot2d.so" ;
260 MESSAGE ( " GUI library = " << dir )
261 fileInfo.setFile(dir) ;
262 if (fileInfo.exists()) {
263 ComponentLib = fileInfo.fileName() ;
267 MESSAGE (" Not found ")
270 if ( (dir = getenv("SALOME_ROOT_DIR")) && !found ) {
271 dir = QAD_Tools::addSlash(dir) ;
273 dir = QAD_Tools::addSlash(dir) ;
275 dir = dir + "libPlot2d.dll" ;
277 dir = dir + "libPlot2d.so" ;
279 MESSAGE ( " GUI library = " << dir )
280 fileInfo.setFile(dir) ;
281 if (fileInfo.exists()) {
282 ComponentLib = fileInfo.fileName() ;
286 MESSAGE (" Not found ")
289 if ( (dir = getenv("KERNEL_ROOT_DIR")) && !found ) {
290 dir = QAD_Tools::addSlash(dir) ;
292 dir = QAD_Tools::addSlash(dir) ;
293 dir = dir + "salome" ;
294 dir = QAD_Tools::addSlash(dir) ;
296 dir = dir + "libPlot2d.dll" ;
298 dir = dir + "libPlot2d.so" ;
300 MESSAGE ( " GUI library = " << dir )
301 fileInfo.setFile(dir) ;
302 if (fileInfo.exists()) {
303 ComponentLib = fileInfo.fileName() ;
307 MESSAGE (" Not found ")
310 QMessageBox::critical( this,
312 tr("undefined view type") );
316 SharedLib.SetName( strdup(ComponentLib) );
318 bool ok = SharedLib.DlOpen(OSD_RTLD_LAZY);
320 QMessageBox::critical( this,
322 tr( SharedLib.DlError() ) );
325 OSD_Function osdF = SharedLib.DlSymb("createView");
326 if ( osdF != NULL ) {
327 View (*f1) = (QAD_ViewFrame* (*) (QAD_RightFrame*)) osdF;
328 myViewFrame = (*f1)(this);
330 QMessageBox::critical( this,
332 tr("createView undefined") );
337 QValueList<int> sizes;
339 myViewFrame->setMinimumSize( 1, 1 );
340 vsplitter = new QAD_Splitter( Qt::Horizontal, this );
341 vsplitter->setMinimumSize( 1, 1 );
342 vsplitter->setCompressEnabled( true );
343 myPyEditor = new QAD_PyEditor(_interp, vsplitter ,"Python Interpreter");
344 myPyEditor->setMinimumSize( 1, 1 );
345 myMessage = new QAD_Message( vsplitter ,"Message");
346 myMessage->setMinimumSize( 1, 1 );
348 sizes.append( (int)(0.48 * DesktopHeight) );
349 sizes.append( (int)(0.16 * DesktopHeight) );
352 sizes.append( (int)(0.25 * DesktopWidth) );
353 sizes.append( (int)(0.25 * DesktopWidth) );
354 vsplitter->setSizes( sizes );
360 QAD_RightFrame::~QAD_RightFrame()
364 QAD_ViewFrame* QAD_RightFrame::getViewFrame() const
370 Returns reference to the message window [ static ]
372 QAD_Message* QAD_RightFrame::getMessage() const
378 Returns the Python interpreter that belongs to this study
380 QAD_PyInterp* QAD_RightFrame::get_PyInterp(void)
386 Returns reference to the Python window [ static ]
388 QAD_PyEditor* QAD_RightFrame::getPyEditor() const
396 void QAD_RightFrame::compressUp()
398 QSplitterPHandle* h = getHandleAfter(myViewFrame);
406 void QAD_RightFrame::unCompressUp()
408 QSplitterPHandle* h = getHandleAfter(myViewFrame);
410 h->unCompressBefore();
414 Compress Python Interpreter and Messages windows
416 void QAD_RightFrame::compressBottom()
418 QSplitterPHandle* h = getHandleAfter(myViewFrame);
424 Uncompress Python Interpreter and Messages windows
426 void QAD_RightFrame::unCompressBottom()
428 QSplitterPHandle* h = getHandleAfter(myViewFrame);
430 h->unCompressAfter();