Salome HOME
DCQ : Update msg File.
[modules/kernel.git] / src / SALOMEGUI / QAD_StudyFrame.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_StudyFrame.cxx
25 //  Author : Nicolas REJNERI
26 //  Module : SALOME
27 //  $Header$
28
29 /*!
30   \class QAD_StudyFrame QAD_StudyFrame.h
31   \brief Frame window which contains QAD_LeftFrame and QAD_RightFrame.
32 */
33
34 #include "QAD_StudyFrame.h"
35 #include "QAD_RightFrame.h"
36 #include "QAD_LeftFrame.h"
37 #include "QAD_Splitter.h"
38 #include "QAD_Application.h"
39 #include "QAD_Desktop.h"
40 #include "QAD_Study.h"
41 #include "QAD_ObjectBrowser.h"
42 #include "QAD_PyInterp.h"
43
44 #include <qvaluelist.h>
45
46 using namespace std;
47
48 /*!
49     Constructor
50 */
51 QAD_StudyFrame::QAD_StudyFrame(QAD_Study* theStudy, QWidget* theParent, 
52                                const QString& theTitle, ViewType theTypeView,
53                                QAD_PyInterp*& theInterp, QMutex* theMutex):
54   QMainWindow( theParent , theTitle,  WStyle_NormalBorder | 
55                WStyle_MinMax | WStyle_SysMenu | WDestructiveClose),
56   myTitle(theTitle),
57   myEntry(""),
58   myTypeView(theTypeView),
59   myStudy(theStudy), 
60   myInterp(theInterp)
61 {
62   setCaption( myTitle );
63   setPalette(QAD_Application::getPalette());
64
65   mySplitter = new QAD_Splitter( Qt::Horizontal, this);
66   mySplitter->setCompressEnabled( true );
67
68   setCentralWidget(mySplitter);
69   myLeftFrm = new QAD_LeftFrame(myStudy->getStudyDocument(), mySplitter, theTitle );
70   myRightFrm = new QAD_RightFrame( mySplitter, theTitle, myTypeView, myInterp, theMutex);
71
72   QValueList<int> sizes;
73   sizes.append( (int)(0.30*QAD_Application::getDesktop()->getMainFrame()->width()) );
74   sizes.append( (int)(0.50*QAD_Application::getDesktop()->getMainFrame()->width()) );
75   mySplitter->setSizes( sizes );
76
77   QAD_ASSERT_DEBUG_ONLY ( theParent->inherits("QWorkspaceP") );
78   QAD_ASSERT ( QObject::connect( (QWorkspaceP*)theParent, SIGNAL(windowActivated(QWidget*)), 
79                                  this, SLOT(onStudyFrameActivated(QWidget*))) );
80 }
81
82
83 /*!
84     Destructor
85 */
86 QAD_StudyFrame::~QAD_StudyFrame()
87
88 }
89
90 /*!
91     Returns the rightframe of this frame        
92 */
93 QAD_RightFrame* QAD_StudyFrame::getRightFrame() const
94 {
95   return myRightFrm;
96 }
97
98 /*!
99     Returns the leftframe of this frame 
100 */
101 QAD_LeftFrame* QAD_StudyFrame::getLeftFrame() const
102 {
103   return myLeftFrm;
104 }
105
106 /*!
107     Returns 'true' if studyframe is visible
108 */
109 void QAD_StudyFrame::setVisible( bool visible )
110 {
111   if ( visible == isVisible() )
112     return;
113   
114   if ( visible ) show();
115   else hide();
116 }
117
118 /*!
119    Called when StudyFrame is about to close
120 */
121 void QAD_StudyFrame::closeEvent(QCloseEvent* e)
122 {
123   if ( IsPyLocked() ) {
124     e->ignore();
125     return;
126   }
127
128   emit sfStudyFrameClosing(this); 
129 }
130
131 /*!
132   Call when  
133  */
134 void QAD_StudyFrame::compressLeft()
135 {
136   mySplitter->compress(myLeftFrm);
137 }
138
139 void QAD_StudyFrame::compressRight()
140 {
141   mySplitter->compress(myRightFrm);  
142 }
143
144 void QAD_StudyFrame::unCompressLeft()
145 {
146   mySplitter->unCompress(myLeftFrm);
147 }
148
149 void QAD_StudyFrame::unCompressRight()
150 {
151   mySplitter->unCompress(myRightFrm);  
152 }
153
154 /*!
155     Returns the title of studyframe
156 */
157 const QString& QAD_StudyFrame::title() const
158 {
159     return myTitle;
160 }
161
162 /*!
163     Sets the new title of studyframe
164 */
165 void QAD_StudyFrame::setTitle( const QString& title )
166 {
167   myTitle = title;      
168   setCaption( myTitle );
169 }
170
171 /*!
172     Returns the entry of studyframe
173 */
174 const QString& QAD_StudyFrame::entry() const
175 {
176   return myEntry;
177 }
178
179 /*!
180     Sets the new entru of studyframe
181 */
182 void QAD_StudyFrame::setEntry( const QString& entry )
183 {
184   myEntry = entry;      
185 }
186
187 ViewType QAD_StudyFrame::getTypeView() const
188 {
189   return myTypeView;    
190 }
191
192 /*!
193     The slot is called when a studyframe is activated
194 */
195 void QAD_StudyFrame::onStudyFrameActivated ( QWidget* activeWindow )
196 {
197   emit sfStudyFrameActivated( (QAD_StudyFrame*) activeWindow );
198 }
199
200 /*!
201   Returns the Python interpreter that belongs to this study
202 */
203 QAD_PyInterp* QAD_StudyFrame::get_PyInterp(void)
204 {
205   return myInterp;
206 }