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 ")
110 } else if (myViewType == VIEW_VTK) {
112 if ( dir = getenv("SALOME_SITE_DIR")) {
113 dir = QAD_Tools::addSlash(dir) ;
115 dir = QAD_Tools::addSlash(dir) ;
117 dir = dir + "libVTKViewer.dll" ;
119 dir = dir + "libVTKViewer.so" ;
121 MESSAGE ( " GUI library = " << dir );
122 fileInfo.setFile(dir) ;
123 if (fileInfo.exists()) {
124 ComponentLib = fileInfo.fileName();
128 MESSAGE (" Not found ");
131 if ( (dir = getenv("SALOME_ROOT_DIR")) && !found ) {
132 dir = QAD_Tools::addSlash(dir) ;
134 dir = QAD_Tools::addSlash(dir) ;
136 dir = dir + "libVTKViewer.dll" ;
138 dir = dir + "libVTKViewer.so" ;
140 MESSAGE ( " GUI library = " << dir );
141 fileInfo.setFile(dir) ;
142 if (fileInfo.exists()) {
143 ComponentLib = fileInfo.fileName();
147 MESSAGE (" Not found ");
149 } else if (myViewType == VIEW_GRAPHSUPERV) {
150 if ( dir = getenv("SALOME_SITE_DIR")){
151 dir = QAD_Tools::addSlash(dir) ;
153 dir = QAD_Tools::addSlash(dir) ;
155 dir = dir + "libSUPERVGraph.dll" ;
157 dir = dir + "libSUPERVGraph.so" ;
159 MESSAGE ( " GUI library = " << dir )
160 fileInfo.setFile(dir) ;
161 if (fileInfo.exists()) {
162 ComponentLib = fileInfo.fileName() ;
166 MESSAGE (" Not found ")
169 if ( (dir = getenv("SALOME_ROOT_DIR")) && !found ) {
170 dir = QAD_Tools::addSlash(dir) ;
172 dir = QAD_Tools::addSlash(dir) ;
174 dir = dir + "libSUPERVGraph.dll" ;
176 dir = dir + "libSUPERVGraph.so" ;
178 MESSAGE ( " GUI library = " << dir )
179 fileInfo.setFile(dir) ;
180 if (fileInfo.exists()) {
181 ComponentLib = fileInfo.fileName() ;
185 MESSAGE (" Not found ")
187 } else if (myViewType == VIEW_PLOT2D) {
188 if ( dir = getenv("SALOME_SITE_DIR")){
189 dir = QAD_Tools::addSlash(dir) ;
191 dir = QAD_Tools::addSlash(dir) ;
193 dir = dir + "libPlot2d.dll" ;
195 dir = dir + "libPlot2d.so" ;
197 MESSAGE ( " GUI library = " << dir )
198 fileInfo.setFile(dir) ;
199 if (fileInfo.exists()) {
200 ComponentLib = fileInfo.fileName() ;
204 MESSAGE (" Not found ")
207 if ( (dir = getenv("SALOME_ROOT_DIR")) && !found ) {
208 dir = QAD_Tools::addSlash(dir) ;
210 dir = QAD_Tools::addSlash(dir) ;
212 dir = dir + "libPlot2d.dll" ;
214 dir = dir + "libPlot2d.so" ;
216 MESSAGE ( " GUI library = " << dir )
217 fileInfo.setFile(dir) ;
218 if (fileInfo.exists()) {
219 ComponentLib = fileInfo.fileName() ;
223 MESSAGE (" Not found ")
226 QMessageBox::critical( this,
228 tr("undefined view type") );
232 SharedLib.SetName( strdup(ComponentLib) );
234 bool ok = SharedLib.DlOpen(OSD_RTLD_LAZY);
236 QMessageBox::critical( this,
238 tr( SharedLib.DlError() ) );
241 OSD_Function osdF = SharedLib.DlSymb("createView");
242 if ( osdF != NULL ) {
243 View (*f1) = (QAD_ViewFrame* (*) (QAD_RightFrame*)) osdF;
244 myViewFrame = (*f1)(this);
246 QMessageBox::critical( this,
248 tr("createView undefined") );
253 QValueList<int> sizes;
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 );
264 sizes.append( (int)(0.48 * DesktopHeight) );
265 sizes.append( (int)(0.16 * DesktopHeight) );
268 sizes.append( (int)(0.25 * DesktopWidth) );
269 sizes.append( (int)(0.25 * DesktopWidth) );
270 vsplitter->setSizes( sizes );
276 QAD_RightFrame::~QAD_RightFrame()
280 QAD_ViewFrame* QAD_RightFrame::getViewFrame() const
286 Returns reference to the message window [ static ]
288 QAD_Message* QAD_RightFrame::getMessage() const
294 Returns the Python interpreter that belongs to this study
296 QAD_PyInterp* QAD_RightFrame::get_PyInterp(void)
302 Returns reference to the Python window [ static ]
304 QAD_PyEditor* QAD_RightFrame::getPyEditor() const
312 void QAD_RightFrame::compressUp()
314 QSplitterPHandle* h = getHandleAfter(myViewFrame);
322 void QAD_RightFrame::unCompressUp()
324 QSplitterPHandle* h = getHandleAfter(myViewFrame);
326 h->unCompressBefore();
330 Compress Python Interpreter and Messages windows
332 void QAD_RightFrame::compressBottom()
334 QSplitterPHandle* h = getHandleAfter(myViewFrame);
340 Uncompress Python Interpreter and Messages windows
342 void QAD_RightFrame::unCompressBottom()
344 QSplitterPHandle* h = getHandleAfter(myViewFrame);
346 h->unCompressAfter();