From 0c473ecbde6441b7b00fb1f6b10193726ca32620 Mon Sep 17 00:00:00 2001 From: abn Date: Wed, 17 Dec 2014 16:09:58 +0100 Subject: [PATCH] Fixing timesteps/timerange when activating PARAVIS after having launched a PVViewer --- src/PVViewer/PVViewer_GUIElements.cxx | 142 ++++++++++++++++------ src/PVViewer/PVViewer_GUIElements.h | 30 +++++ src/PVViewer/PVViewer_ViewWindow.cxx | 5 + src/SALOME_PYQT/SalomePyQt/SalomePyQt.cxx | 4 +- 4 files changed, 141 insertions(+), 40 deletions(-) diff --git a/src/PVViewer/PVViewer_GUIElements.cxx b/src/PVViewer/PVViewer_GUIElements.cxx index c534b8a72..1d5c3e6ad 100644 --- a/src/PVViewer/PVViewer_GUIElements.cxx +++ b/src/PVViewer/PVViewer_GUIElements.cxx @@ -24,10 +24,25 @@ #include #include #include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include #include #include #include +#include +#include + +#include PVViewer_GUIElements * PVViewer_GUIElements::theInstance = 0; @@ -46,6 +61,8 @@ PVViewer_GUIElements::PVViewer_GUIElements(SUIT_Desktop* desk) : pqParaViewMenuBuilders::buildFiltersMenu(*filtersMenu, desk); macrosMenu = new QMenu(0); pqParaViewMenuBuilders::buildMacrosMenu(*macrosMenu); + + myBuildToolbars(desk); } PVViewer_GUIElements * PVViewer_GUIElements::GetInstance(SUIT_Desktop* desk) @@ -55,46 +72,93 @@ PVViewer_GUIElements * PVViewer_GUIElements::GetInstance(SUIT_Desktop* desk) return theInstance; } -//void PVViewer_GUIElements::updateSourcesMenu(QMenu *menu) -//{ -// if (menu) -// { -// menu->clear(); -// QList act_list = sourcesMenu->actions(); -// foreach(QAction * a, act_list) -// { -// menu->addAction(a); -// } -// } -//} -// -//void PVViewer_GUIElements::updateFiltersMenu(QMenu *menu) -//{ -// if (menu) -// { -// filtersMenu->linkToMenu(menu); -// menu->clear(); -// QList act_list = filtersMenu->actions(); -// foreach(QAction * a, act_list) -// { -// menu->addAction(a); -// } -// } -//} -// -//void PVViewer_GUIElements::updateMacrosMenu(QMenu *menu) -//{ -// if (menu) -// { -// menu->clear(); -// QList act_list = macrosMenu->actions(); -// foreach(QAction * a, act_list) -// { -// menu->addAction(a); -// } -// } -//} +/** + * See ParaView source code: pqParaViewMenuBuilders::buildToolbars() + * to keep this function up to date: + */ +void PVViewer_GUIElements::myBuildToolbars(SUIT_Desktop* mainWindow) +{ + mainToolBar = new pqMainControlsToolbar(mainWindow) + << pqSetName("MainControlsToolbar"); + mainToolBar->layout()->setSpacing(0); + + vcrToolbar = new pqVCRToolbar(mainWindow) + << pqSetName("VCRToolbar"); + vcrToolbar->layout()->setSpacing(0); + + timeToolbar = new pqAnimationTimeToolbar(mainWindow) + << pqSetName("currentTimeToolbar"); + timeToolbar->layout()->setSpacing(0); + + colorToolbar = new pqColorToolbar(mainWindow) + << pqSetName("variableToolbar"); + colorToolbar->layout()->setSpacing(0); + + reprToolbar = new pqRepresentationToolbar(mainWindow) + << pqSetName("representationToolbar"); + reprToolbar->layout()->setSpacing(0); + + cameraToolbar = new pqCameraToolbar(mainWindow) + << pqSetName("cameraToolbar"); + cameraToolbar->layout()->setSpacing(0); + axesToolbar = new pqAxesToolbar(mainWindow) + << pqSetName("axesToolbar"); + axesToolbar->layout()->setSpacing(0); + + // Give the macros menu to the pqPythonMacroSupervisor + pqPythonManager* manager = qobject_cast( + pqApplicationCore::instance()->manager("PYTHON_MANAGER")); + + macrosToolbar = new QToolBar("Macros Toolbars", mainWindow) + << pqSetName("MacrosToolbar"); + manager->addWidgetForRunMacros(macrosToolbar); + + addToolbars(mainWindow); +} + +void PVViewer_GUIElements::setToolBarVisible(bool show) +{ + QCoreApplication::processEvents(); + mainAction->setChecked(!show); + mainAction->trigger(); + vcrAction->setChecked(!show); + vcrAction->trigger(); + timeAction->setChecked(!show); + timeAction->trigger(); + colorAction->setChecked(!show); + colorAction->trigger(); + reprAction->setChecked(!show); + reprAction->trigger(); + cameraAction->setChecked(!show); + cameraAction->trigger(); + axesAction->setChecked(!show); + axesAction->trigger(); + macrosAction->setChecked(!show); + macrosAction->trigger(); +} + +void PVViewer_GUIElements::addToolbars(SUIT_Desktop* desk) +{ + desk->addToolBar(Qt::TopToolBarArea, mainToolBar); + desk->addToolBar(Qt::TopToolBarArea, vcrToolbar); + desk->addToolBar(Qt::TopToolBarArea, timeToolbar); + desk->addToolBar(Qt::TopToolBarArea, colorToolbar); + desk->insertToolBarBreak(colorToolbar); + desk->addToolBar(Qt::TopToolBarArea, reprToolbar); + desk->addToolBar(Qt::TopToolBarArea, cameraToolbar); + desk->addToolBar(Qt::TopToolBarArea, axesToolbar); + desk->addToolBar(Qt::TopToolBarArea, macrosToolbar); + + mainAction = mainToolBar->toggleViewAction(); + vcrAction = vcrToolbar->toggleViewAction(); + timeAction = timeToolbar->toggleViewAction(); + colorAction = colorToolbar->toggleViewAction(); + reprAction = reprToolbar->toggleViewAction(); + cameraAction = cameraToolbar->toggleViewAction(); + axesAction = axesToolbar->toggleViewAction(); + macrosAction = macrosToolbar->toggleViewAction(); +} void PVViewer_GUIElements::onEmulateApply() { diff --git a/src/PVViewer/PVViewer_GUIElements.h b/src/PVViewer/PVViewer_GUIElements.h index c9d2d3f2d..4360de94a 100644 --- a/src/PVViewer/PVViewer_GUIElements.h +++ b/src/PVViewer/PVViewer_GUIElements.h @@ -29,6 +29,10 @@ class pqPropertiesPanel; class pqPipelineBrowserWidget; class SUIT_Desktop; class QMenu; +class QToolBar; +class QAction; +class pqAnimationTimeToolbar; +class pqVCRToolbar; /*! * Some GUI elements of ParaView need to be instanciated in a proper order. This class @@ -48,6 +52,12 @@ public: QMenu * getSourcesMenu() { return sourcesMenu; } QMenu * getMacrosMenu() { return macrosMenu; } + pqVCRToolbar * getVCRToolbar() { return vcrToolbar; } + pqAnimationTimeToolbar * getTimeToolbar() { return timeToolbar; } + + void myBuildToolbars(SUIT_Desktop* desk); + void addToolbars(SUIT_Desktop* desk); + void setToolBarVisible(bool show); public slots: void onEmulateApply(); // better use the slot from PVViewer_ViewManager if you want to trigger "Apply" @@ -66,6 +76,26 @@ private: QMenu * sourcesMenu; QMenu * filtersMenu; QMenu * macrosMenu; + + // Toolbars also need to be instanciated early: + QToolBar* mainToolBar; + pqVCRToolbar* vcrToolbar; + pqAnimationTimeToolbar * timeToolbar; + QToolBar* colorToolbar; + QToolBar* reprToolbar; + QToolBar* cameraToolbar; + QToolBar* axesToolbar; + QToolBar* macrosToolbar; + +public: + QAction * mainAction; + QAction * vcrAction; + QAction * timeAction; + QAction * colorAction; + QAction * reprAction; + QAction * cameraAction; + QAction * axesAction; + QAction * macrosAction; }; #endif /* PVVIEWERGUIELEMENTS_H_ */ diff --git a/src/PVViewer/PVViewer_ViewWindow.cxx b/src/PVViewer/PVViewer_ViewWindow.cxx index bdb1edfa0..07c192a2e 100644 --- a/src/PVViewer/PVViewer_ViewWindow.cxx +++ b/src/PVViewer/PVViewer_ViewWindow.cxx @@ -33,6 +33,7 @@ #include #include + /*! \class PVViewer_ViewWindow \brief PVGUI view window. @@ -59,6 +60,10 @@ PVViewer_ViewWindow::PVViewer_ViewWindow( SUIT_Desktop* theDesktop, PVViewer_Vie PVViewer_ViewManager::ParaviewInitBehaviors(true, theDesktop); PVViewer_ViewManager::ConnectToExternalPVServer(theDesktop); PVViewer_ViewManager::ParaviewLoadConfigurations(); + + // Hide toolbars + PVViewer_GUIElements * pvge = PVViewer_GUIElements::GetInstance(theDesktop); + pvge->setToolBarVisible(false); } else qDebug("No multiViewManager defined"); } diff --git a/src/SALOME_PYQT/SalomePyQt/SalomePyQt.cxx b/src/SALOME_PYQT/SalomePyQt/SalomePyQt.cxx index e6edb9d98..595e10701 100644 --- a/src/SALOME_PYQT/SalomePyQt/SalomePyQt.cxx +++ b/src/SALOME_PYQT/SalomePyQt/SalomePyQt.cxx @@ -2698,7 +2698,9 @@ public: }; int SalomePyQt::createView( const QString& type, QWidget* w ) { - return ProcessEvent( new TCreateViewWg( type, w ) ); + int ret = ProcessEvent( new TCreateViewWg( type, w ) ); + QCoreApplication::processEvents(); + return ret; } /*! -- 2.39.2