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
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"
37 #include <qvaluelist.h>
40 #include <qmessagebox.h>
42 // Open CASCADE Include
43 #include <OSD_SharedLibrary.hxx>
48 \class QAD_RightFrame QAD_RightFrame.h
49 \brief Frame window which contains QAD_ViewFrame, QAD_PyInterp and QAD_Message.
52 typedef QAD_ViewFrame* View(QAD_RightFrame*);
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),
65 this->setCompressEnabled( true );
67 QAD_Desktop* Desktop = QAD_Application::getDesktop();
68 int DesktopHeight = Desktop->getMainFrame()->width();
69 int DesktopWidth = Desktop->getMainFrame()->height();
71 OSD_SharedLibrary SharedLib = OSD_SharedLibrary();
76 if (myViewType == VIEW_OCC) {
77 if ( (dir = getenv("KERNEL_ROOT_DIR")) && !found ) {
78 dir = QAD_Tools::addSlash(dir) ;
80 dir = QAD_Tools::addSlash(dir) ;
81 dir = dir + "salome" ;
82 dir = QAD_Tools::addSlash(dir) ;
84 dir = dir + "libOCCViewer.dll" ;
86 dir = dir + "libOCCViewer.so" ;
88 MESSAGE ( " GUI library = " << dir )
89 fileInfo.setFile(dir) ;
90 if (fileInfo.exists()) {
91 ComponentLib = fileInfo.fileName();
95 MESSAGE (" Not found ")
97 } else if (myViewType == VIEW_VTK) {
98 if ( (dir = getenv("KERNEL_ROOT_DIR")) && !found ) {
99 dir = QAD_Tools::addSlash(dir) ;
101 dir = QAD_Tools::addSlash(dir) ;
102 dir = dir + "salome" ;
103 dir = QAD_Tools::addSlash(dir) ;
105 dir = dir + "libVTKViewer.dll" ;
107 dir = dir + "libVTKViewer.so" ;
109 MESSAGE ( " GUI library = " << dir );
110 fileInfo.setFile(dir) ;
111 if (fileInfo.exists()) {
112 ComponentLib = fileInfo.fileName();
116 MESSAGE (" Not found ");
118 } else if (myViewType == VIEW_GRAPHSUPERV) {
119 if ( (dir = getenv("KERNEL_ROOT_DIR")) && !found ) {
120 dir = QAD_Tools::addSlash(dir) ;
122 dir = QAD_Tools::addSlash(dir) ;
123 dir = dir + "salome" ;
124 dir = QAD_Tools::addSlash(dir) ;
126 dir = dir + "libSUPERVGraph.dll" ;
128 dir = dir + "libSUPERVGraph.so" ;
130 MESSAGE ( " GUI library = " << dir )
131 fileInfo.setFile(dir) ;
132 if (fileInfo.exists()) {
133 ComponentLib = fileInfo.fileName() ;
137 MESSAGE (" Not found ")
139 } else if (myViewType == VIEW_PLOT2D) {
140 if ( (dir = getenv("KERNEL_ROOT_DIR")) && !found ) {
141 dir = QAD_Tools::addSlash(dir) ;
143 dir = QAD_Tools::addSlash(dir) ;
144 dir = dir + "salome" ;
145 dir = QAD_Tools::addSlash(dir) ;
147 dir = dir + "libPlot2d.dll" ;
149 dir = dir + "libPlot2d.so" ;
151 MESSAGE ( " GUI library = " << dir )
152 fileInfo.setFile(dir) ;
153 if (fileInfo.exists()) {
154 ComponentLib = fileInfo.fileName() ;
158 MESSAGE (" Not found ")
161 QMessageBox::critical( this,
163 tr("undefined view type") );
167 const Standard_CString aCopyCL = CORBA::string_dup(ComponentLib);
168 SharedLib.SetName( aCopyCL);
172 bool ok = SharedLib.DlOpen(OSD_RTLD_LAZY);
174 QMessageBox::critical( this,
176 tr( SharedLib.DlError() ) );
179 OSD_Function osdF = SharedLib.DlSymb("createView");
180 if ( osdF != NULL ) {
181 View (*f1) = (QAD_ViewFrame* (*) (QAD_RightFrame*)) osdF;
182 myViewFrame = (*f1)(this);
184 QMessageBox::critical( this,
186 tr("createView undefined") );
191 QValueList<int> sizes;
193 myViewFrame->setMinimumSize( 1, 1 );
194 mySplitter = new QAD_Splitter( Qt::Horizontal, this );
195 mySplitter->setMinimumSize( 1, 1 );
196 mySplitter->setCompressEnabled( true );
198 myPyEditor = new QAD_PyEditor(myInterp, theMutex, mySplitter ,"Python Interpreter");
199 myPyEditor->setMinimumSize( 1, 1 );
202 myMessage = new QAD_Message( mySplitter ,"Message");
203 myMessage->setMinimumSize( 1, 1 );
205 sizes.append( (int)(0.48 * DesktopHeight) );
206 sizes.append( (int)(0.16 * DesktopHeight) );
209 sizes.append( (int)(0.25 * DesktopWidth) );
210 sizes.append( (int)(0.25 * DesktopWidth) );
211 mySplitter->setSizes( sizes );
217 QAD_RightFrame::~QAD_RightFrame()
221 QAD_ViewFrame* QAD_RightFrame::getViewFrame() const
227 Returns reference to the message window [ static ]
229 QAD_Message* QAD_RightFrame::getMessage() const
235 Returns the Python interpreter that belongs to this study
237 QAD_PyInterp* QAD_RightFrame::get_PyInterp(void)
243 Returns reference to the Python window [ static ]
245 QAD_PyEditor* QAD_RightFrame::getPyEditor() const
253 void QAD_RightFrame::compressUp()
255 QSplitterPHandle* h = getHandleAfter(myViewFrame);
263 void QAD_RightFrame::unCompressUp()
265 QSplitterPHandle* h = getHandleAfter(myViewFrame);
267 h->unCompressBefore();
271 Compress Python Interpreter and Messages windows
273 void QAD_RightFrame::compressBottom()
275 QSplitterPHandle* h = getHandleAfter(myViewFrame);
281 Uncompress Python Interpreter and Messages windows
283 void QAD_RightFrame::unCompressBottom()
285 QSplitterPHandle* h = getHandleAfter(myViewFrame);
287 h->unCompressAfter();
290 void QAD_RightFrame::compressLeft()
292 QSplitterPHandle* h = mySplitter->getHandleAfter( getPyEditor() );
297 void QAD_RightFrame::compressRight()
299 QSplitterPHandle* h = mySplitter->getHandleAfter( getPyEditor() );
304 void QAD_RightFrame::unCompressLeft()
306 QSplitterPHandle* h = mySplitter->getHandleAfter( getPyEditor() );
308 h->unCompressBefore();
311 void QAD_RightFrame::unCompressRight()
313 QSplitterPHandle* h = mySplitter->getHandleAfter( getPyEditor() );
315 h->unCompressAfter();
318 bool QAD_RightFrame::isCompressedViewFrame() const
320 return isCompressed( myViewFrame );
323 bool QAD_RightFrame::isCompressedPython() const
325 return mySplitter->isCompressed( getPyEditor() );
328 bool QAD_RightFrame::isCompressedMessage() const
330 return mySplitter->isCompressed( getMessage() );