From 651a7397543ef86bbf6c5d187ce185699ce0c1cb Mon Sep 17 00:00:00 2001 From: akl Date: Tue, 31 Mar 2015 17:05:43 +0400 Subject: [PATCH] Additional fix of INTPAL 52639: Creation of ParaView viewer makes Paraview toolbars unavailable. --- src/PVGUI/PVGUI_Module.cxx | 32 +++++++++++++++++++++++++++++- src/PVGUI/PVGUI_Module.h | 7 ++++++- src/PVGUI/PVGUI_Module_widgets.cxx | 16 +++++++++------ 3 files changed, 47 insertions(+), 8 deletions(-) diff --git a/src/PVGUI/PVGUI_Module.cxx b/src/PVGUI/PVGUI_Module.cxx index 39c8b243..0010354d 100644 --- a/src/PVGUI/PVGUI_Module.cxx +++ b/src/PVGUI/PVGUI_Module.cxx @@ -1305,7 +1305,7 @@ void PVGUI_Module::onPushTraceTimer() QString PVGUI_Module::getHelpFileName() { QString aPVHome(getenv("PVHOME")); if (aPVHome.isNull()) { - qWarning("Wariable PVHOME is not defined"); + qWarning("Variable PVHOME is not defined"); return QString(); } QChar aSep = QDir::separator(); @@ -1373,6 +1373,36 @@ void PVGUI_Module::loadSelectedState(bool toClear) } } +void PVGUI_Module::onViewManagerAdded( SUIT_ViewManager* vm ) +{ + if (PVViewer_ViewManager* pvvm = dynamic_cast(vm)) { + connect(pvvm, SIGNAL(viewCreated(SUIT_ViewWindow*)), this, SLOT(onPVViewCreated(SUIT_ViewWindow*))); + connect(pvvm, SIGNAL(deleteView(SUIT_ViewWindow*)), this, SLOT(onPVViewDelete(SUIT_ViewWindow*))); + } +} + +void PVGUI_Module::onViewManagerRemoved( SUIT_ViewManager* vm ) +{ + if (PVViewer_ViewManager* pvvm = dynamic_cast(vm)) + disconnect(pvvm, SIGNAL(viewCreated(SUIT_ViewWindow*)), this, SLOT(onPVViewCreated(SUIT_ViewWindow*))); +} + +/*!Show toolbars at \a vw PV view window creating when PARAVIS is active. +*/ +void PVGUI_Module::onPVViewCreated( SUIT_ViewWindow* vw ) +{ + myGuiElements->setToolBarVisible(true); + restoreDockWidgetsState(); +} + +/*!Save toolbars state at \a view view closing. +*/ +void PVGUI_Module::onPVViewDelete(SUIT_ViewWindow* view) +{ + if (dynamic_cast(view)) + saveDockWidgetsState( false ); +} + /*! \fn CAM_Module* createModule(); \brief Export module instance (factory function). diff --git a/src/PVGUI/PVGUI_Module.h b/src/PVGUI/PVGUI_Module.h index f955a6e1..64340d5f 100644 --- a/src/PVGUI/PVGUI_Module.h +++ b/src/PVGUI/PVGUI_Module.h @@ -50,6 +50,7 @@ class pqDataRepresentation; class pqRepresentation; class PVViewer_GUIElements; class PVViewer_EngineWrapper; +class SUIT_ViewWindow; class PVGUI_Module : public SalomeApp_Module { @@ -190,7 +191,7 @@ private: void setupDockWidgets(); //! Save states of dockable ParaView widgets - void saveDockWidgetsState(); + void saveDockWidgetsState( bool hideWidgets = true ); //! Restore states of dockable ParaView widgets void restoreDockWidgetsState(); @@ -264,6 +265,10 @@ protected slots: virtual void onModelOpened(); virtual void onPushTraceTimer(); virtual void onInitTimer(); + virtual void onViewManagerAdded( SUIT_ViewManager* ); + virtual void onViewManagerRemoved( SUIT_ViewManager* ); + virtual void onPVViewCreated( SUIT_ViewWindow* ); + virtual void onPVViewDelete( SUIT_ViewWindow* ); private: int mySelectionControlsTb; diff --git a/src/PVGUI/PVGUI_Module_widgets.cxx b/src/PVGUI/PVGUI_Module_widgets.cxx index f441e1d5..a20a3af4 100644 --- a/src/PVGUI/PVGUI_Module_widgets.cxx +++ b/src/PVGUI/PVGUI_Module_widgets.cxx @@ -343,7 +343,7 @@ void PVGUI_Module::setupDockWidgets() /*! \brief Save states of dockable ParaView widgets. */ -void PVGUI_Module::saveDockWidgetsState() +void PVGUI_Module::saveDockWidgetsState(bool hideWidgets) { SUIT_Desktop* desk = application()->desktop(); @@ -362,8 +362,10 @@ void PVGUI_Module::saveDockWidgetsState() it1.next(); QDockWidget* dw = qobject_cast( it1.key() ); myDockWidgets[dw] = dw->isVisible(); - dw->setVisible( false ); - dw->toggleViewAction()->setVisible( false ); + if ( hideWidgets ) { + dw->setVisible( false ); + dw->toggleViewAction()->setVisible( false ); + } } // store toolbar breaks state and remove all tollbar breaks QMapIterator it2( myToolbarBreaks ); @@ -371,7 +373,7 @@ void PVGUI_Module::saveDockWidgetsState() it2.next(); QToolBar* tb = qobject_cast( it2.key() ); myToolbarBreaks[tb] = desk->toolBarBreak( tb ); - if ( myToolbarBreaks[tb] ) + if ( myToolbarBreaks[tb] && hideWidgets ) desk->removeToolBarBreak( tb ); } // store toolbars visibility state and hide'em all @@ -380,8 +382,10 @@ void PVGUI_Module::saveDockWidgetsState() it3.next(); QToolBar* tb = qobject_cast( it3.key() ); myToolbars[tb] = tb->isVisible(); - tb->setVisible( false ); - tb->toggleViewAction()->setVisible( false ); + if ( hideWidgets ) { + tb->setVisible( false ); + tb->toggleViewAction()->setVisible( false ); + } } } -- 2.39.2