Salome HOME
Moved some functionality to VTKViewer_Utilities.h
[modules/kernel.git] / src / SALOMEGUI / QAD_StudyFrame.cxx
index 2148c9b71c7345e45f8614916afbd80620528370..cfba6977e036c9299c380fb63ece7e9ef3146159 100644 (file)
@@ -1,10 +1,29 @@
-using namespace std;
-//  File      : QAD_StudyFrame.cxx
-//  Created   : Sun Jul 22 15:31:59 2001
-//  Author    : Nicolas REJNERI
-//  Project   : SALOME
-//  Module    : SALOMEGUI
-//  Copyright : Open CASCADE
+//  SALOME SALOMEGUI : implementation of desktop and GUI kernel
+//
+//  Copyright (C) 2003  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+//  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS 
+// 
+//  This library is free software; you can redistribute it and/or 
+//  modify it under the terms of the GNU Lesser General Public 
+//  License as published by the Free Software Foundation; either 
+//  version 2.1 of the License. 
+// 
+//  This library is distributed in the hope that it will be useful, 
+//  but WITHOUT ANY WARRANTY; without even the implied warranty of 
+//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU 
+//  Lesser General Public License for more details. 
+// 
+//  You should have received a copy of the GNU Lesser General Public 
+//  License along with this library; if not, write to the Free Software 
+//  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA 
+// 
+//  See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org 
+//
+//
+//
+//  File   : QAD_StudyFrame.cxx
+//  Author : Nicolas REJNERI
+//  Module : SALOME
 //  $Header$
 
 /*!
@@ -12,57 +31,55 @@ using namespace std;
   \brief Frame window which contains QAD_LeftFrame and QAD_RightFrame.
 */
 
+#include "QAD_StudyFrame.h"
 #include "QAD_StudyFrame.h"
 #include "QAD_RightFrame.h"
 #include "QAD_LeftFrame.h"
+#include "QAD_Splitter.h"
 #include "QAD_Application.h"
 #include "QAD_Desktop.h"
 #include "QAD_Study.h"
 #include "QAD_ObjectBrowser.h"
+#include "QAD_PyInterp.h"
+
 #include <qvaluelist.h>
 
+using namespace std;
+
 /*!
     Constructor
 */
-QAD_StudyFrame::QAD_StudyFrame(QAD_Study* study, QWidget* parent, const QString& title, 
-                              QAD_PyInterp* interp, ViewType typeView) :
-  QMainWindow( parent , title,  WStyle_NormalBorder | 
+QAD_StudyFrame::QAD_StudyFrame(QAD_Study* theStudy, QWidget* theParent, 
+                              const QString& theTitle, ViewType theTypeView,
+                              QAD_PyInterp*& theInterp, QMutex* theMutex):
+  QMainWindow( theParent , theTitle,  WStyle_NormalBorder | 
               WStyle_MinMax | WStyle_SysMenu | WDestructiveClose),
-  myStudy(study)
+  myTitle(theTitle),
+  myEntry(""),
+  myTypeView(theTypeView),
+  myStudy(theStudy), 
+  myInterp(theInterp)
 {
-  myTypeView = typeView;
-  myTitle = title;
   setCaption( myTitle );
   setPalette(QAD_Application::getPalette());
 
-  myEntry = "";
-  _interp = interp;
+  mySplitter = new QAD_Splitter( Qt::Horizontal, this);
+  mySplitter->setCompressEnabled( true );
 
-  s1 = new QAD_Splitter( Qt::Horizontal, this);
-  s1->setCompressEnabled( true );
-
-  setCentralWidget( s1 );
-  myLeftFrm = new QAD_LeftFrame(study->getStudyDocument(), s1 , title );
-  myRightFrm = new QAD_RightFrame( s1, title, _interp, myTypeView);
+  setCentralWidget(mySplitter);
+  myLeftFrm = new QAD_LeftFrame(myStudy->getStudyDocument(), mySplitter, theTitle );
+  myRightFrm = new QAD_RightFrame( mySplitter, theTitle, myTypeView, myInterp, theMutex);
 
   QValueList<int> sizes;
-  sizes.append( 0.30*QAD_Application::getDesktop()->getMainFrame()->width() );
-  sizes.append( 0.50*QAD_Application::getDesktop()->getMainFrame()->width() );
-  s1->setSizes( sizes );
+  sizes.append( (int)(0.30*QAD_Application::getDesktop()->getMainFrame()->width()) );
+  sizes.append( (int)(0.50*QAD_Application::getDesktop()->getMainFrame()->width()) );
+  mySplitter->setSizes( sizes );
 
-  QAD_ASSERT_DEBUG_ONLY ( parent->inherits("QWorkspaceP") );
-  QAD_ASSERT ( QObject::connect( (QWorkspaceP*)parent, SIGNAL(windowActivated(QWidget*)), 
+  QAD_ASSERT_DEBUG_ONLY ( theParent->inherits("QWorkspaceP") );
+  QAD_ASSERT ( QObject::connect( (QWorkspaceP*)theParent, SIGNAL(windowActivated(QWidget*)), 
                                 this, SLOT(onStudyFrameActivated(QWidget*))) );
 }
 
-/*!
-    Constructor
-*/
-QAD_StudyFrame::QAD_StudyFrame(QAD_Study* study, QWidget* parent  ) :
-  QMainWindow ( parent ),
-  myStudy(study)
-{
-}
 
 /*!
     Destructor
@@ -104,7 +121,11 @@ void QAD_StudyFrame::setVisible( bool visible )
 */
 void QAD_StudyFrame::closeEvent(QCloseEvent* e)
 {
-  emit sfBeforeStudyFrameClosing(this); 
+  if ( IsPyLocked() ) {
+    e->ignore();
+    return;
+  }
+
   emit sfStudyFrameClosing(this); 
 }
 
@@ -113,22 +134,40 @@ void QAD_StudyFrame::closeEvent(QCloseEvent* e)
  */
 void QAD_StudyFrame::compressLeft()
 {
-  s1->compress(myLeftFrm);
+  QSplitterPHandle* h = mySplitter->getHandleAfter(myLeftFrm);
+  if( h ) 
+    h->compressBefore();
 }
 
 void QAD_StudyFrame::compressRight()
 {
-  s1->compress(myRightFrm);  
+  QSplitterPHandle* h = mySplitter->getHandleAfter(myLeftFrm);
+  if( h )
+    h->compressAfter();
 }
 
 void QAD_StudyFrame::unCompressLeft()
 {
-  s1->unCompress(myLeftFrm);
+  QSplitterPHandle* h = mySplitter->getHandleAfter(myLeftFrm);
+  if( h )
+    h->unCompressBefore();
 }
 
 void QAD_StudyFrame::unCompressRight()
 {
-  s1->unCompress(myRightFrm);  
+  QSplitterPHandle* h = mySplitter->getHandleAfter(myLeftFrm);
+  if( h )
+    h->unCompressAfter();
+}
+
+bool QAD_StudyFrame::isCompressedLeft() const
+{
+  return mySplitter->isCompressed(myLeftFrm);
+}
+
+bool QAD_StudyFrame::isCompressedRight() const
+{
+  return mySplitter->isCompressed(myRightFrm);
 }
 
 /*!
@@ -175,6 +214,7 @@ ViewType QAD_StudyFrame::getTypeView() const
 void QAD_StudyFrame::onStudyFrameActivated ( QWidget* activeWindow )
 {
   emit sfStudyFrameActivated( (QAD_StudyFrame*) activeWindow );
+  getRightFrame()->getViewFrame()->Activate( getStudy() );
 }
 
 /*!
@@ -182,5 +222,5 @@ void QAD_StudyFrame::onStudyFrameActivated ( QWidget* activeWindow )
 */
 QAD_PyInterp* QAD_StudyFrame::get_PyInterp(void)
 {
-  return _interp;
+  return myInterp;
 }