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