Salome HOME
Merge from V6_main 11/02/2013
[modules/paravis.git] / src / PVGUI / PVGUI_ViewWindow.cxx
index 51ec369edfd36ac6879ec1477b2050bf6d298f97..30486c8f9e886f36f12493338f8aedd410e2406b 100644 (file)
@@ -1,17 +1,17 @@
-// Copyright (C) 2005  OPEN CASCADE, CEA/DEN, EDF R&D, PRINCIPIA R&D
-// 
+// Copyright (C) 2010-2012  CEA/DEN, EDF R&D
+//
 // 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 
+// 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 
+//
+// 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 
+// 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.salome-platform.org/ or email : webmaster.salome@opencascade.com
@@ -27,8 +27,8 @@
 #include <SUIT_Session.h>
 #include <SUIT_Desktop.h>
 
-#include <pqViewManager.h>
-
+#include <pqTabbedMultiViewWidget.h>
+#include <pqApplicationCore.h>
 
 /*!
   \class PVGUI_ViewWindow
@@ -44,27 +44,32 @@ PVGUI_ViewWindow::PVGUI_ViewWindow( SUIT_Desktop* theDesktop, PVGUI_Viewer* theM
   : SUIT_ViewWindow( theDesktop ), myPVMgr( 0 )
 {
   myModel = theModel;
+  myPVMgr = qobject_cast<pqTabbedMultiViewWidget*>(pqApplicationCore::instance()->manager("MULTIVIEW_WIDGET"));
+  if (myPVMgr) {
+    myPVMgr->setParent( this );
+    // This is mandatory, see setParent() method in Qt 4 documentation
+    myPVMgr->show();
+    setCentralWidget( myPVMgr );
+  } else
+    qDebug("No multiViewManager defined");
 }
 
 /*!
   \brief Destructor.
+  As pqViewManager persists through the whole session,
+  the destructor first removes it from the children of this PVGUI_ViewWindow
+  to prevent its unexpected deletion.
 */
 PVGUI_ViewWindow::~PVGUI_ViewWindow()
 {
+  if ( myPVMgr ) {
+    myPVMgr->setParent( 0 );
+    myPVMgr->hide();
+    myPVMgr = 0;
+    setCentralWidget( 0 );
+  }
 }
 
-/*!
-  \brief Custom event filter.
-  \param watched event receiver object
-  \param e event
-  \return \c true if further event processing should be stopped
-*/
-bool PVGUI_ViewWindow::eventFilter( QObject* watched, QEvent* e )
-{
-  return SUIT_ViewWindow::eventFilter( watched, e );
-}
-
-
 /*!
   \brief Get the visual parameters of the view window.
   \return visual parameters of this view window formatted to the string
@@ -83,23 +88,11 @@ void PVGUI_ViewWindow::setVisualParameters( const QString& parameters )
   SUIT_ViewWindow::setVisualParameters( parameters );
 }
 
-/*!
-  \brief Sets the ParaView multi-view manager for this view window
-*/
-void PVGUI_ViewWindow::setMultiViewManager( pqViewManager* viewMgr )
-{
-  myPVMgr = viewMgr;
-  myPVMgr->setParent( this );
-  // This is mandatory, see setParent() documentation 
-  myPVMgr->show();
-  setCentralWidget( myPVMgr );
-  myPVMgr->installEventFilter( this );
-}
 
 /*!
   \brief Returns the ParaView multi-view manager previously set with setMultiViewManager()
 */
-pqViewManager* PVGUI_ViewWindow::getMultiViewManager() const
+pqTabbedMultiViewWidget* PVGUI_ViewWindow::getMultiViewManager() const
 {
   return myPVMgr;
 }