// Author: Adrien Bruneton (CEA)
#include "PVViewer_GUIElements.h"
+#include "PVServer_ServiceWrapper.h"
+#include "PVViewer_Core.h"
+#include "PVViewer_ViewManager.h"
-#include <pqPropertiesPanel.h>
-#include <pqPipelineBrowserWidget.h>
-#include <pqParaViewMenuBuilders.h>
-#include <pqMainControlsToolbar.h>
-#include <pqVCRToolbar.h>
+#include <pqActiveObjects.h>
+#include <pqAnimationManager.h>
#include <pqAnimationTimeToolbar.h>
+#include <pqApplicationCore.h>
+#include <pqApplyBehavior.h>
+#include <pqAxesToolbar.h>
+#include <pqCameraToolbar.h>
#include <pqColorToolbar.h>
+#include <pqMainControlsToolbar.h>
+#include <pqPVApplicationCore.h>
+#include <pqParaViewMenuBuilders.h>
+#include <pqPipelineBrowserWidget.h>
+#include <pqPipelineModel.h>
+#include <pqPropertiesPanel.h>
+#include <pqPythonManager.h>
#include <pqRepresentationToolbar.h>
-#include <pqCameraToolbar.h>
-#include <pqAxesToolbar.h>
+#include <pqServerConnectReaction.h>
+#include <pqServerManagerModel.h>
+#include <pqServerResource.h>
#include <pqSetName.h>
+#include <pqVCRToolbar.h>
-#include <pqPythonManager.h>
-#include <pqApplicationCore.h>
-
+#include <QAction>
+#include <QCoreApplication>
+#include <QLayout>
+#include <QList>
#include <QMainWindow>
#include <QMenu>
-#include <QList>
-#include <QAction>
#include <QToolBar>
-#include <QLayout>
-#include <QCoreApplication>
PVViewer_GUIElements * PVViewer_GUIElements::theInstance = 0;
PVViewer_GUIElements::PVViewer_GUIElements(QMainWindow* desk) :
- propertiesPanel(0), pipelineBrowserWidget(0),
- sourcesMenu(0)
+ myDesktop(desk),
+ propertiesPanel(0),
+ pipelineBrowserWidget(0),
+ sourcesMenu(0),
+ filtersMenu(0),
+ macrosMenu(0),
+ myPVWidgetsFlag(false)
{
- propertiesPanel = new pqPropertiesPanel(desk);
- propertiesPanel->hide();
- pipelineBrowserWidget = new pqPipelineBrowserWidget(desk);
- pipelineBrowserWidget->hide();
-
- sourcesMenu = new QMenu(0);
- pqParaViewMenuBuilders::buildSourcesMenu(*sourcesMenu, desk);
- filtersMenu = new QMenu(0);
- pqParaViewMenuBuilders::buildFiltersMenu(*filtersMenu, desk);
- macrosMenu = new QMenu(0);
- pqParaViewMenuBuilders::buildMacrosMenu(*macrosMenu);
-
- myBuildToolbars(desk);
}
PVViewer_GUIElements * PVViewer_GUIElements::GetInstance(QMainWindow* desk)
* See ParaView source code: pqParaViewMenuBuilders::buildToolbars()
* to keep this function up to date:
*/
-void PVViewer_GUIElements::myBuildToolbars(QMainWindow* mainWindow)
+void PVViewer_GUIElements::buildPVWidgets()
{
- mainToolBar = new pqMainControlsToolbar(mainWindow)
- << pqSetName("MainControlsToolbar");
- mainToolBar->layout()->setSpacing(0);
+ if (!myPVWidgetsFlag) {
- vcrToolbar = new pqVCRToolbar(mainWindow)
- << pqSetName("VCRToolbar");
- vcrToolbar->layout()->setSpacing(0);
+ //Pipeline Browser
+ if ( !pipelineBrowserWidget ) {
+ pipelineBrowserWidget = new pqPipelineBrowserWidget(myDesktop);
+ }
- timeToolbar = new pqAnimationTimeToolbar(mainWindow)
- << pqSetName("currentTimeToolbar");
- timeToolbar->layout()->setSpacing(0);
+ // Properties panel
+ if ( !propertiesPanel ) {
+ propertiesPanel = new pqPropertiesPanel(myDesktop);
+ }
+
+ // Sources Menu
+ if (!sourcesMenu) {
+ sourcesMenu = new QMenu(0);
+ pqParaViewMenuBuilders::buildSourcesMenu(*sourcesMenu, myDesktop);
+ }
- colorToolbar = new pqColorToolbar(mainWindow)
- << pqSetName("variableToolbar");
- colorToolbar->layout()->setSpacing(0);
+ //Filer Menu
+ if (!filtersMenu) {
+ filtersMenu = new QMenu(0);
+ pqParaViewMenuBuilders::buildFiltersMenu(*filtersMenu, myDesktop);
+ }
- reprToolbar = new pqRepresentationToolbar(mainWindow)
- << pqSetName("representationToolbar");
- reprToolbar->layout()->setSpacing(0);
+ // Macros Menu
+ if (!macrosMenu) {
+ macrosMenu = new QMenu(0);
+ pqParaViewMenuBuilders::buildMacrosMenu(*macrosMenu);
+ }
- cameraToolbar = new pqCameraToolbar(mainWindow)
- << pqSetName("cameraToolbar");
- cameraToolbar->layout()->setSpacing(0);
+ mainToolBar = new pqMainControlsToolbar(myDesktop)
+ << pqSetName("MainControlsToolbar");
+ mainToolBar->layout()->setSpacing(0);
- axesToolbar = new pqAxesToolbar(mainWindow)
- << pqSetName("axesToolbar");
- axesToolbar->layout()->setSpacing(0);
+ vcrToolbar = new pqVCRToolbar(myDesktop)
+ << pqSetName("VCRToolbar");
+ vcrToolbar->layout()->setSpacing(0);
- // Give the macros menu to the pqPythonMacroSupervisor
- pqPythonManager* manager = qobject_cast<pqPythonManager*>(
+ timeToolbar = new pqAnimationTimeToolbar(myDesktop)
+ << pqSetName("currentTimeToolbar");
+ timeToolbar->layout()->setSpacing(0);
+
+ colorToolbar = new pqColorToolbar(myDesktop)
+ << pqSetName("variableToolbar");
+ colorToolbar->layout()->setSpacing(0);
+
+ reprToolbar = new pqRepresentationToolbar(myDesktop)
+ << pqSetName("representationToolbar");
+ reprToolbar->layout()->setSpacing(0);
+
+ cameraToolbar = new pqCameraToolbar(myDesktop)
+ << pqSetName("cameraToolbar");
+ cameraToolbar->layout()->setSpacing(0);
+
+ axesToolbar = new pqAxesToolbar(myDesktop)
+ << pqSetName("axesToolbar");
+ axesToolbar->layout()->setSpacing(0);
+
+ // Give the macros menu to the pqPythonMacroSupervisor
+ pqPythonManager* manager = qobject_cast<pqPythonManager*>(
pqApplicationCore::instance()->manager("PYTHON_MANAGER"));
- macrosToolbar = new QToolBar("Macros Toolbars", mainWindow)
+ macrosToolbar = new QToolBar("Macros Toolbars", myDesktop)
<< pqSetName("MacrosToolbar");
- manager->addWidgetForRunMacros(macrosToolbar);
+ manager->addWidgetForRunMacros(macrosToolbar);
+
+ commonToolbar = new QToolBar("Common", myDesktop) << pqSetName("Common");
+ commonToolbar->layout()->setSpacing(0);
+
+ dataToolbar = new QToolBar("DataAnalysis", myDesktop) << pqSetName("DataAnalysis");
+ dataToolbar->layout()->setSpacing(0);
+
+ // add Toolbars
+ myDesktop->addToolBar(Qt::TopToolBarArea, mainToolBar);
+ myDesktop->addToolBar(Qt::TopToolBarArea, vcrToolbar);
+ myDesktop->addToolBar(Qt::TopToolBarArea, timeToolbar);
+ myDesktop->addToolBar(Qt::TopToolBarArea, colorToolbar);
+ myDesktop->insertToolBarBreak(colorToolbar);
+ myDesktop->addToolBar(Qt::TopToolBarArea, reprToolbar);
+ myDesktop->addToolBar(Qt::TopToolBarArea, cameraToolbar);
+ myDesktop->addToolBar(Qt::TopToolBarArea, axesToolbar);
+ myDesktop->addToolBar(Qt::TopToolBarArea, macrosToolbar);
+ myDesktop->addToolBar(Qt::TopToolBarArea, commonToolbar);
+ myDesktop->addToolBar(Qt::TopToolBarArea, dataToolbar);
+
+ mainAction = mainToolBar->toggleViewAction();
+ vcrAction = vcrToolbar->toggleViewAction();
+ timeAction = timeToolbar->toggleViewAction();
+ colorAction = colorToolbar->toggleViewAction();
+ reprAction = reprToolbar->toggleViewAction();
+ cameraAction = cameraToolbar->toggleViewAction();
+ axesAction = axesToolbar->toggleViewAction();
+ macrosAction = macrosToolbar->toggleViewAction();
+ commonAction = commonToolbar->toggleViewAction();
+ dataAction = dataToolbar->toggleViewAction();
+
+ // The piece od the code below is neccessary to correct update "Pipeline Browser",
+ // "Properties Panel", toolbars and menus
+
+ // Initilaize pqApplyBehavior here because witout pqPropertiesPanel instance it doesn't make sence
+ pqApplyBehavior* applyBehavior = new pqApplyBehavior(this);
+ foreach (pqPropertiesPanel* ppanel, myDesktop->findChildren<pqPropertiesPanel*>())
+ {
+ applyBehavior->registerPanel(ppanel);
+ }
+
+ emit pqActiveObjects::instance().portChanged(pqActiveObjects::instance().activePort());
+ emit pqActiveObjects::instance().viewChanged(pqActiveObjects::instance().activeView());
- commonToolbar = new QToolBar("Common", mainWindow) << pqSetName("Common");
- commonToolbar->layout()->setSpacing(0);
+ pqServerManagerModel *smModel = pqApplicationCore::instance()->getServerManagerModel();
+ pqServer* serv = pqActiveObjects::instance().activeServer();
- dataToolbar = new QToolBar("DataAnalysis", mainWindow) << pqSetName("DataAnalysis");
- dataToolbar->layout()->setSpacing(0);
+ if (serv) {
+ emit smModel->serverAdded(serv);
+ emit serv->nameChanged(NULL);
+ }
- addToolbars(mainWindow);
+ myPVWidgetsFlag = true;
+ }
}
void PVViewer_GUIElements::setToolBarVisible(bool show)
-{
+{
QCoreApplication::processEvents();
+ if (!myPVWidgetsFlag)
+ return;
+
mainAction->setChecked(!show);
mainAction->setVisible(show);
mainAction->trigger();
dataAction->trigger();
}
-void PVViewer_GUIElements::addToolbars(QMainWindow* 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);
- desk->addToolBar(Qt::TopToolBarArea, commonToolbar);
- desk->addToolBar(Qt::TopToolBarArea, dataToolbar);
-
- mainAction = mainToolBar->toggleViewAction();
- vcrAction = vcrToolbar->toggleViewAction();
- timeAction = timeToolbar->toggleViewAction();
- colorAction = colorToolbar->toggleViewAction();
- reprAction = reprToolbar->toggleViewAction();
- cameraAction = cameraToolbar->toggleViewAction();
- axesAction = axesToolbar->toggleViewAction();
- macrosAction = macrosToolbar->toggleViewAction();
- commonAction = commonToolbar->toggleViewAction();
- dataAction = dataToolbar->toggleViewAction();
-}
-
QList<QToolBar*> PVViewer_GUIElements::getToolbars()
{
+ buildPVWidgets();
QList<QToolBar*> l;
l << mainToolBar << vcrToolbar << timeToolbar << colorToolbar
<< reprToolbar << cameraToolbar << axesToolbar << macrosToolbar
void PVViewer_GUIElements::setToolBarEnabled(bool enabled)
{
+ if (!myPVWidgetsFlag)
+ return;
+
mainToolBar ->setEnabled(enabled);
vcrToolbar ->setEnabled(enabled);
timeToolbar ->setEnabled(enabled);
commonToolbar->setEnabled(enabled);
dataToolbar ->setEnabled(enabled);
}
+
+
+pqPropertiesPanel* PVViewer_GUIElements::getPropertiesPanel()
+{
+ buildPVWidgets();
+ return propertiesPanel;
+}
+
+pqPipelineBrowserWidget* PVViewer_GUIElements::getPipelineBrowserWidget()
+{
+ buildPVWidgets();
+ return pipelineBrowserWidget;
+}
+
+
+pqVCRToolbar* PVViewer_GUIElements::getVCRToolbar()
+{
+ buildPVWidgets();
+ return vcrToolbar;
+}
+
+pqAnimationTimeToolbar* PVViewer_GUIElements::getTimeToolbar()
+{
+ buildPVWidgets();
+ return timeToolbar;
+}
+
+QMenu* PVViewer_GUIElements::getFiltersMenu() {
+ buildPVWidgets();
+ return filtersMenu;
+}
+QMenu* PVViewer_GUIElements::getSourcesMenu() {
+ buildPVWidgets();
+ return sourcesMenu;
+}
+
+QMenu* PVViewer_GUIElements::getMacrosMenu() {
+ buildPVWidgets();
+ return macrosMenu;
+}