From 3a58e6c4d5232c6f059162bf179695c720e00fb6 Mon Sep 17 00:00:00 2001 From: san Date: Thu, 13 Nov 2008 14:56:16 +0000 Subject: [PATCH] Wrapping pqViewManager in SALOME view manager --- src/PVGUI/Makefile.am | 13 ++++- src/PVGUI/PVGUI_Module.cxx | 33 ++++++++++-- src/PVGUI/PVGUI_Module.h | 5 +- src/PVGUI/PVGUI_ViewManager.cxx | 38 ++++++++++++++ src/PVGUI/PVGUI_ViewManager.h | 36 +++++++++++++ src/PVGUI/PVGUI_ViewModel.cxx | 47 +++++++++++++++++ src/PVGUI/PVGUI_ViewModel.h | 43 ++++++++++++++++ src/PVGUI/PVGUI_ViewWindow.cxx | 89 +++++++++++++++++++++++++++++++++ src/PVGUI/PVGUI_ViewWindow.h | 53 ++++++++++++++++++++ 9 files changed, 350 insertions(+), 7 deletions(-) create mode 100644 src/PVGUI/PVGUI_ViewManager.cxx create mode 100644 src/PVGUI/PVGUI_ViewManager.h create mode 100644 src/PVGUI/PVGUI_ViewModel.cxx create mode 100644 src/PVGUI/PVGUI_ViewModel.h create mode 100644 src/PVGUI/PVGUI_ViewWindow.cxx create mode 100644 src/PVGUI/PVGUI_ViewWindow.h diff --git a/src/PVGUI/Makefile.am b/src/PVGUI/Makefile.am index edcdfe70..5cf4e90d 100644 --- a/src/PVGUI/Makefile.am +++ b/src/PVGUI/Makefile.am @@ -33,11 +33,20 @@ dist_libPARAVIS_la_SOURCES = \ PVGUI_Module.h \ PVGUI_Module.cxx \ PVGUI_ProcessModuleHelper.h \ - PVGUI_ProcessModuleHelper.cxx + PVGUI_ProcessModuleHelper.cxx \ + PVGUI_ViewManager.h \ + PVGUI_ViewManager.cxx \ + PVGUI_ViewModel.h \ + PVGUI_ViewModel.cxx \ + PVGUI_ViewWindow.h \ + PVGUI_ViewWindow.cxx # MOC pre-processing MOC_FILES = \ - PVGUI_Module_moc.cxx + PVGUI_Module_moc.cxx \ + PVGUI_ViewManager_moc.cxx \ + PVGUI_ViewModel_moc.cxx \ + PVGUI_ViewWindow_moc.cxx nodist_libPARAVIS_la_SOURCES = $(MOC_FILES) diff --git a/src/PVGUI/PVGUI_Module.cxx b/src/PVGUI/PVGUI_Module.cxx index 4b1b8e91..fe416645 100644 --- a/src/PVGUI/PVGUI_Module.cxx +++ b/src/PVGUI/PVGUI_Module.cxx @@ -25,15 +25,14 @@ #include "PVGUI_Module.h" #include "PVGUI_ProcessModuleHelper.h" +#include "PVGUI_ViewModel.h" +#include "PVGUI_ViewManager.h" #include #include +#include #include #include -#include -#include -#include -#include #include #include @@ -147,6 +146,13 @@ void PVGUI_Module::initialize( CAM_Application* app ) SUIT_Desktop* desk = application()->desktop(); + /* + int i = 1; + while( i ){ + i = i; + } + */ + if ( pvInit() ) { pvCreateActions(); } @@ -291,6 +297,23 @@ void PVGUI_Module::pvShutdown() { // TODO... } + +/*! + \brief Shows (toShow = true) or hides ParaView view window +*/ +void PVGUI_Module::showView( bool toShow ) +{ + // TODO: check if ParaView view already exists + LightApp_Application* anApp = getApp(); + SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr(); + PVGUI_ViewManager* viewMgr = new PVGUI_ViewManager( anApp->activeStudy(), anApp->desktop() ); + anApp->addViewManager( viewMgr ); + connect( viewMgr, SIGNAL( lastViewClosed( SUIT_ViewManager* ) ), + anApp, SLOT( onCloseView( SUIT_ViewManager* ) ) ); + //connect( viewMgr, SIGNAL( viewCreated( SUIT_ViewWindow* ) ), vm, SLOT( onViewCreated( SUIT_ViewWindow* ) ) ); + //connect( viewMgr, SIGNAL( deleteView( SUIT_ViewWindow* ) ), this, SLOT( onViewDeleted( SUIT_ViewWindow* ) ) ); + SUIT_ViewWindow* wnd = viewMgr->createViewWindow(); +} /*! \brief Create actions for ParaView GUI operations @@ -314,6 +337,8 @@ bool PVGUI_Module::activateModule( SUIT_Study* study ) setMenuShown( true ); + showView( true ); + return isDone; } diff --git a/src/PVGUI/PVGUI_Module.h b/src/PVGUI/PVGUI_Module.h index d64adcb6..6e562fe0 100644 --- a/src/PVGUI/PVGUI_Module.h +++ b/src/PVGUI/PVGUI_Module.h @@ -71,7 +71,10 @@ private: //! Create actions for ParaView GUI operations //! duplicating menus and toolbars in pqMainWindow ParaView class - void pvCreateActions(); + void pvCreateActions(); + + //! Shows or hides ParaView view window + void showView( bool ); public slots: virtual bool activateModule( SUIT_Study* ); diff --git a/src/PVGUI/PVGUI_ViewManager.cxx b/src/PVGUI/PVGUI_ViewManager.cxx new file mode 100644 index 00000000..3cfb15da --- /dev/null +++ b/src/PVGUI/PVGUI_ViewManager.cxx @@ -0,0 +1,38 @@ +// Copyright (C) 2005 OPEN CASCADE, CEA/DEN, EDF R&D, PRINCIPIA 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 +// 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.salome-platform.org/ or email : webmaster.salome@opencascade.com +// +#include +#include + + +/*! + Constructor +*/ +PVGUI_ViewManager::PVGUI_ViewManager( SUIT_Study* study, SUIT_Desktop* desk ) +: SUIT_ViewManager( study, desk, new PVGUI_Viewer() ) +{ + setTitle( tr( "PARAVIEW_VIEW_TITLE" ) ); +} + +/*! + Destructor +*/ +PVGUI_ViewManager::~PVGUI_ViewManager() +{ +} + diff --git a/src/PVGUI/PVGUI_ViewManager.h b/src/PVGUI/PVGUI_ViewManager.h new file mode 100644 index 00000000..a802c5bc --- /dev/null +++ b/src/PVGUI/PVGUI_ViewManager.h @@ -0,0 +1,36 @@ +// Copyright (C) 2005 OPEN CASCADE, CEA/DEN, EDF R&D, PRINCIPIA 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 +// 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.salome-platform.org/ or email : webmaster.salome@opencascade.com +// +#ifndef PVGUI_VIEWMANAGER_H +#define PVGUI_VIEWMANAGER_H + +#include + +class SUIT_Desktop; +class SUIT_Study; + +class PVGUI_ViewManager : public SUIT_ViewManager +{ + Q_OBJECT + +public: + PVGUI_ViewManager( SUIT_Study*, SUIT_Desktop* ); + ~PVGUI_ViewManager(); +}; + +#endif diff --git a/src/PVGUI/PVGUI_ViewModel.cxx b/src/PVGUI/PVGUI_ViewModel.cxx new file mode 100644 index 00000000..3ff348c2 --- /dev/null +++ b/src/PVGUI/PVGUI_ViewModel.cxx @@ -0,0 +1,47 @@ +// Copyright (C) 2005 OPEN CASCADE, CEA/DEN, EDF R&D, PRINCIPIA 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 +// 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.salome-platform.org/ or email : webmaster.salome@opencascade.com +// +// Plot2d_ViewModel.cxx: implementation of the Plot2d_ViewModel class. + +#include "PVGUI_ViewModel.h" +#include "PVGUI_ViewWindow.h" + +/*! + Constructor +*/ +PVGUI_Viewer::PVGUI_Viewer() +:SUIT_ViewModel() +{ +} + +/*! + Destructor +*/ +PVGUI_Viewer::~PVGUI_Viewer() +{ +} + +/*! + Create new instance of view window on desktop \a theDesktop. + \retval SUIT_ViewWindow* - created view window pointer. +*/ +SUIT_ViewWindow* PVGUI_Viewer::createView(SUIT_Desktop* theDesktop) +{ + PVGUI_ViewWindow* aPVView = new PVGUI_ViewWindow(theDesktop, this); + return aPVView; +} diff --git a/src/PVGUI/PVGUI_ViewModel.h b/src/PVGUI/PVGUI_ViewModel.h new file mode 100644 index 00000000..bd25f1c3 --- /dev/null +++ b/src/PVGUI/PVGUI_ViewModel.h @@ -0,0 +1,43 @@ +// Copyright (C) 2005 OPEN CASCADE, CEA/DEN, EDF R&D, PRINCIPIA 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 +// 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.salome-platform.org/ or email : webmaster.salome@opencascade.com +// +#if !defined(_PVGUI_VIEWMODEL_H) +#define _PVGUI_VIEWMODEL_H + +#include + +class SUIT_ViewWindow; +class SUIT_Desktop; + +class PVGUI_Viewer: public SUIT_ViewModel +{ + Q_OBJECT + +public: + static QString Type() { return "ParaView"; } + + PVGUI_Viewer(); + ~PVGUI_Viewer(); + + virtual SUIT_ViewWindow* createView(SUIT_Desktop* theDesktop); + virtual QString getType() const { return Type(); } + +}; + +#endif // !defined(_PVGUI_VIEWMODEL_H) + diff --git a/src/PVGUI/PVGUI_ViewWindow.cxx b/src/PVGUI/PVGUI_ViewWindow.cxx new file mode 100644 index 00000000..6d8cd608 --- /dev/null +++ b/src/PVGUI/PVGUI_ViewWindow.cxx @@ -0,0 +1,89 @@ +// Copyright (C) 2005 OPEN CASCADE, CEA/DEN, EDF R&D, PRINCIPIA 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 +// 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.salome-platform.org/ or email : webmaster.salome@opencascade.com +// +// File : PVGUI_ViewWindow.cxx +// Author : Vadim SANDLER, Open CASCADE S.A.S. (vadim.sandler@opencascade.com) +// + +#include "PVGUI_ViewWindow.h" + +#include +#include +#include +#include + +#include + + +/*! + \class PVGUI_ViewWindow + \brief PVGUI view window. +*/ + +/*! + \brief Constructor. + \param theDesktop parent desktop window + \param theModel plt2d view model +*/ +PVGUI_ViewWindow::PVGUI_ViewWindow( SUIT_Desktop* theDesktop, PVGUI_Viewer* theModel ) + : SUIT_ViewWindow( theDesktop ), myPVMgr( 0 ) +{ + myModel = theModel; + myPVMgr = new pqViewManager( this ); + + setCentralWidget( myPVMgr ); + + myPVMgr->installEventFilter( this ); +} + +/*! + \brief Destructor. +*/ +PVGUI_ViewWindow::~PVGUI_ViewWindow() +{ +} + +/*! + \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 +*/ +QString PVGUI_ViewWindow::getVisualParameters() +{ + return SUIT_ViewWindow::getVisualParameters(); +} + +/*! + \brief Restore visual parameters of the view window from the formated string + \param parameters view window visual parameters +*/ +void PVGUI_ViewWindow::setVisualParameters( const QString& parameters ) +{ + SUIT_ViewWindow::setVisualParameters( parameters ); +} diff --git a/src/PVGUI/PVGUI_ViewWindow.h b/src/PVGUI/PVGUI_ViewWindow.h new file mode 100644 index 00000000..9ea3f967 --- /dev/null +++ b/src/PVGUI/PVGUI_ViewWindow.h @@ -0,0 +1,53 @@ +// Copyright (C) 2005 OPEN CASCADE, CEA/DEN, EDF R&D, PRINCIPIA 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 +// 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.salome-platform.org/ or email : webmaster.salome@opencascade.com +// +// File : Plot2d_ViewWindow.h +// Author : Vadim SANDLER, Open CASCADE S.A.S. (vadim.sandler@opencascade.com) +// + +#ifndef PVGUI_VIEWWINDOW_H +#define PVGUI_VIEWWINDOW_H + +#include +#include + +class SUIT_Desktop; +class PVGUI_Viewer; +class pqViewManager; + +class PVGUI_ViewWindow : public SUIT_ViewWindow +{ + Q_OBJECT + +public: + PVGUI_ViewWindow( SUIT_Desktop*, PVGUI_Viewer* ); + virtual ~PVGUI_ViewWindow(); + + + virtual bool eventFilter( QObject*, QEvent* ); + + virtual QString getVisualParameters(); + virtual void setVisualParameters( const QString& ); + + +private: + PVGUI_Viewer* myModel; + pqViewManager* myPVMgr; +}; + +#endif // PLOT2D_VIEWWINDOW_H -- 2.39.2