From 40f2662cd936a8ddf3b107fe70c8d916ed4bdef8 Mon Sep 17 00:00:00 2001 From: abn Date: Tue, 2 Aug 2016 11:20:32 +0200 Subject: [PATCH] Enhanced version of paraLight: with toolbar, filter menu and spreadsheet view. --- test/standalone/gui/CMakeLists.txt | 4 +- test/standalone/gui/PLMainWindow.cxx | 56 ++++- test/standalone/gui/PLMainWindow.hxx | 8 + test/standalone/gui/PLViewTab.cxx | 5 + test/standalone/gui/PLViewTab.hxx | 2 + test/standalone/gui/PVViewer_GUIElements.cxx | 2 +- test/standalone/gui/main.cpp | 4 +- test/standalone/gui/ui/light_para.ui | 23 ++ test/standalone/gui/ui/view_tab.ui | 24 ++ test/standalone/gui/xml/ParaViewFilters.xml | 247 +++++++++++++++++++ 10 files changed, 358 insertions(+), 17 deletions(-) create mode 100644 test/standalone/gui/xml/ParaViewFilters.xml diff --git a/test/standalone/gui/CMakeLists.txt b/test/standalone/gui/CMakeLists.txt index a4b18ca2..20f62f86 100644 --- a/test/standalone/gui/CMakeLists.txt +++ b/test/standalone/gui/CMakeLists.txt @@ -57,8 +57,8 @@ SET(ui_resources GENERATE_QT_RESOURCE_FROM_FILES( "${ui_resources}" - "/LightPara/Configuration" - "${PROJECT_SOURCE_DIR}/gui/xml/ParaViewReaders.xml") + "LightPara/Configuration" + "${PROJECT_SOURCE_DIR}/gui/xml/ParaViewReaders.xml;${PROJECT_SOURCE_DIR}/gui/xml/ParaViewFilters.xml") QT_ADD_RESOURCES(rcs_sources ${ui_resources} diff --git a/test/standalone/gui/PLMainWindow.cxx b/test/standalone/gui/PLMainWindow.cxx index e2754985..40b4e9ba 100644 --- a/test/standalone/gui/PLMainWindow.cxx +++ b/test/standalone/gui/PLMainWindow.cxx @@ -50,7 +50,8 @@ PLMainWindow::PLMainWindow(QWidget *parent) : QMainWindow(parent), _pAppC(0), _simplePipeline(), - _autoApply(true) + _autoApply(true), + _filterMenu(0) { _mainWindow.setupUi(this); _autoApply = _mainWindow.actionAuto_apply->isChecked(); @@ -63,25 +64,23 @@ PLMainWindow::PLMainWindow(QWidget *parent) : void PLMainWindow::finishUISetup() { _pAppC = PVViewer_Core::GetPVApplication(); - PVViewer_GUIElements * pvgui = PVViewer_GUIElements::GetInstance(this); - QWidget * wprop = pvgui->getPropertiesPanel(); - QWidget * wpipe = pvgui->getPipelineBrowserWidget(); + _pvgui = PVViewer_GUIElements::GetInstance(this); + + QWidget * wprop = _pvgui->getPropertiesPanel(); + QWidget * wpipe = _pvgui->getPipelineBrowserWidget(); wprop->setParent(_mainWindow.propFrame); _mainWindow.verticalLayoutProp->addWidget(wprop); wpipe->setParent(_mainWindow.pipelineFrame); _mainWindow.verticalLayoutPipe->addWidget(wpipe); - PVViewer_GUIElements * pvge = PVViewer_GUIElements::GetInstance(this); -// pvge->setToolBarVisible(false); - // In this mockup, we play on the parent widget visibility (a QFrame), so show these: - pvge->getPipelineBrowserWidget()->show(); - pvge->getPropertiesPanel()->show(); + _pvgui->getPipelineBrowserWidget()->show(); + _pvgui->getPropertiesPanel()->show(); // and hide these: _mainWindow.propFrame->hide(); _mainWindow.pipelineFrame->hide(); -// pvge->setToolBarEnabled(false); -// pvge->setToolBarVisible(false); +// _pvgui->setToolBarEnabled(false); +// _pvgui->setToolBarVisible(false); } @@ -110,6 +109,19 @@ void PLMainWindow::showPipeline(bool isChecked) isChecked ? _mainWindow.pipelineFrame->show() : _mainWindow.pipelineFrame->hide(); } +void PLMainWindow::onBuildFilterMenu() +{ + if(_filterMenu == 0) + { + _filterMenu = _pvgui->getFiltersMenu(); +// _filterMenu = new QMenu(); + _filterMenu->setTitle("Filters"); + this->menuBar()->addMenu(_filterMenu); + } + else + QMessageBox::warning(this, "Warning", "Filter menu already added!"); +} + void PLMainWindow::addTab() { int c = _mainWindow.tabWidget->count(); @@ -120,6 +132,7 @@ void PLMainWindow::addTab() // Connect buttons QObject::connect(newTab, SIGNAL(onInsertSingleView(PLViewTab *)), this, SLOT(insertSingleView(PLViewTab *))); QObject::connect(newTab, SIGNAL(onInsertMultiView(PLViewTab *)), this, SLOT(insertMultiView(PLViewTab *))); + QObject::connect(newTab, SIGNAL(onInsertSpreadsheetView(PLViewTab *)), this, SLOT(insertSpreadsheetView(PLViewTab *))); } void PLMainWindow::deleteTab() @@ -202,6 +215,26 @@ void PLMainWindow::insertSingleView(PLViewTab * tab) pqActiveObjects::instance().setActiveView(pqview); } +void PLMainWindow::insertSpreadsheetView(PLViewTab * tab) +{ + // Create a new view proxy on the server + pqObjectBuilder* builder = _pAppC->getObjectBuilder(); + pqServer* active_serv = pqActiveObjects::instance().activeServer(); + + std::cout << "About to create spreadsheet view ..." << std::endl; + pqView * pqview = builder->createView(QString("SpreadSheetView"), active_serv); + std::cout << "Created: " << pqview << "!" << std::endl; + + // Retrieve its widget and pass it to the Qt tab: + QWidget* viewWidget = pqview->widget(); + +// QWidget* viewWidget = new QPushButton("toto"); + tab->hideAndReplace(viewWidget, pqview); + + pqActiveObjects::instance().setActiveView(pqview); +} + + void PLMainWindow::insertMultiView(PLViewTab * tab) { // Retrieve TabbedMultiView and see if it is already attached to someone: @@ -221,7 +254,6 @@ void PLMainWindow::insertMultiView(PLViewTab * tab) } } - void PLMainWindow::doShrink() { if(!_simplePipeline.isEmpty()) diff --git a/test/standalone/gui/PLMainWindow.hxx b/test/standalone/gui/PLMainWindow.hxx index 91bd85a4..727361ce 100644 --- a/test/standalone/gui/PLMainWindow.hxx +++ b/test/standalone/gui/PLMainWindow.hxx @@ -31,6 +31,7 @@ class pqServer; class pqProxy; class PLViewTab; +class PVViewer_GUIElements; /** Main window of the application. */ @@ -73,18 +74,25 @@ private slots: void insertSingleView(PLViewTab *); void insertMultiView(PLViewTab *); + void insertSpreadsheetView(PLViewTab *); void currentTabChanged(int); + void onBuildFilterMenu(); + private: Ui::MainWindow _mainWindow; + PVViewer_GUIElements * _pvgui; + pqPVApplicationCore * _pAppC; //pqServer * _activeServer; //pqPipelineSource * _activeSource; // last pipeline element QStack _simplePipeline; bool _autoApply; + + QMenu * _filterMenu; }; #endif /* PLVIEWWIDGET_H_ */ diff --git a/test/standalone/gui/PLViewTab.cxx b/test/standalone/gui/PLViewTab.cxx index 9411d513..1840d446 100644 --- a/test/standalone/gui/PLViewTab.cxx +++ b/test/standalone/gui/PLViewTab.cxx @@ -28,6 +28,11 @@ _renderView(0) _viewTab.setupUi(this); } +void PLViewTab::insertSpreadsheetView() +{ + emit onInsertSpreadsheetView(this); +} + void PLViewTab::insertSingleView() { emit onInsertSingleView(this); diff --git a/test/standalone/gui/PLViewTab.hxx b/test/standalone/gui/PLViewTab.hxx index 6ff4dac9..75248dfe 100644 --- a/test/standalone/gui/PLViewTab.hxx +++ b/test/standalone/gui/PLViewTab.hxx @@ -42,11 +42,13 @@ public: private slots: void insertSingleView(); void insertMultiView(); + void insertSpreadsheetView(); void viewDestroyed(); signals: void onInsertSingleView(PLViewTab *); void onInsertMultiView(PLViewTab *); + void onInsertSpreadsheetView(PLViewTab *); private: Ui::ViewTab _viewTab; diff --git a/test/standalone/gui/PVViewer_GUIElements.cxx b/test/standalone/gui/PVViewer_GUIElements.cxx index 7daff83c..23ea9348 100644 --- a/test/standalone/gui/PVViewer_GUIElements.cxx +++ b/test/standalone/gui/PVViewer_GUIElements.cxx @@ -70,7 +70,7 @@ PVViewer_GUIElements::PVViewer_GUIElements(QMainWindow* desk) : macrosMenu = new QMenu(0); pqParaViewMenuBuilders::buildMacrosMenu(*macrosMenu); - //myBuildToolbars(desk); +// myBuildToolbars(desk); } PVViewer_GUIElements * PVViewer_GUIElements::GetInstance(QMainWindow* desk) diff --git a/test/standalone/gui/main.cpp b/test/standalone/gui/main.cpp index bcb3f303..c7e3d08e 100644 --- a/test/standalone/gui/main.cpp +++ b/test/standalone/gui/main.cpp @@ -58,8 +58,8 @@ int main(int argc, char ** argv) //para_widget->updateActiveServer(); - //std::cout << "Load config ..." << std::endl; - //PVViewer_Core::ParaviewLoadConfigurations(QString(":/LightPara/Configuration/")); + std::cout << "Load config ..." << std::endl; + PVViewer_Core::ParaviewLoadConfigurations(QString(":/LightPara/Configuration")); /* Inspired from ParaView source code: * leave time for the GUI to update itself before displaying the main window: */ diff --git a/test/standalone/gui/ui/light_para.ui b/test/standalone/gui/ui/light_para.ui index 47c38e3a..2c0e833b 100644 --- a/test/standalone/gui/ui/light_para.ui +++ b/test/standalone/gui/ui/light_para.ui @@ -276,6 +276,7 @@ + @@ -346,6 +347,11 @@ Show pipeline + + + Build filter menu + + @@ -637,6 +643,22 @@ + + actionBuild_filter_menu + triggered() + MainWindow + onBuildFilterMenu() + + + -1 + -1 + + + 504 + 338 + + + changedCurrentFile(QString) @@ -650,5 +672,6 @@ showPipeline(bool) showProp(bool) currentTabChanged(int) + onBuildFilterMenu() diff --git a/test/standalone/gui/ui/view_tab.ui b/test/standalone/gui/ui/view_tab.ui index 67cae6a8..2d001bdd 100644 --- a/test/standalone/gui/ui/view_tab.ui +++ b/test/standalone/gui/ui/view_tab.ui @@ -69,6 +69,13 @@ + + + + Spreadsheet view + + + @@ -136,9 +143,26 @@ + + spreadsheetViewButton + clicked() + ViewTab + insertSpreadsheetView() + + + 89 + 286 + + + 274 + 309 + + + insertMultiView() insertSingleView() + insertSpreadsheetView() diff --git a/test/standalone/gui/xml/ParaViewFilters.xml b/test/standalone/gui/xml/ParaViewFilters.xml new file mode 100644 index 00000000..d1da9c30 --- /dev/null +++ b/test/standalone/gui/xml/ParaViewFilters.xml @@ -0,0 +1,247 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + -- 2.39.2