From 5eaf5a0b09c9ad5c4a75a00ea2a770585e06cc71 Mon Sep 17 00:00:00 2001 From: Melanie <melanie.carriere@kitware.com> Date: Mon, 9 Nov 2020 12:29:59 +0100 Subject: [PATCH] [feature] Save the "Show only selected point" options of the spreadheet The option is saved in the settings and reapply everytime the spreadsheet is opened When we open Veloview for the first time this option is set to false This avoid having an empty spreadsheet an misleading the user. --- .../lqSpreadSheetManager.cxx | 33 +++++++++++++++++++ ApplicationComponents/lqSpreadSheetManager.h | 2 ++ 2 files changed, 35 insertions(+) diff --git a/ApplicationComponents/lqSpreadSheetManager.cxx b/ApplicationComponents/lqSpreadSheetManager.cxx index 552003928..3e5e99399 100644 --- a/ApplicationComponents/lqSpreadSheetManager.cxx +++ b/ApplicationComponents/lqSpreadSheetManager.cxx @@ -18,12 +18,22 @@ #include <pqApplicationCore.h> #include <pqActiveObjects.h> +#include <vtkEventQtSlotConnect.h> +#include "vtkSMProperty.h" +#include <vtkSMPropertyHelper.h> +#include <vtkSMViewProxy.h> + #include <assert.h> //----------------------------------------------------------------------------- lqSpreadSheetManager::lqSpreadSheetManager(QObject* parent) : QObject(parent) { this->Settings = pqApplicationCore::instance()->settings(); + + // we disable the "show only selection" because otherwise if you quit LidarView with this option ON + // when you will open Lidarview again the Spreadsheet will be empty because no points are selected. + // This can be misleading for the user so we set this property to false on opening of lidarview + this->Settings->setValue("ShowOnlySelectedElement", false); } //----------------------------------------------------------------------------- @@ -66,6 +76,12 @@ void lqSpreadSheetManager::constructSpreadSheet() QObject::connect(this->SpreadSheetView, SIGNAL(endRender()), this, SLOT(onSpreadSheetEndRender())); QObject::connect(this, SIGNAL(saveColumnSelection()), this, SLOT(onSaveColumnSelection())); + // Connect the "Selection only" property to a slot to save this property information + vtkEventQtSlotConnect* connector = vtkEventQtSlotConnect::New(); + vtkSMViewProxy* viewModule = this->SpreadSheetView->getViewProxy(); + connector->Connect(viewModule->GetProperty("SelectionOnly"), vtkCommand::ModifiedEvent, + this, SLOT(onSpreadSheetSelectionOnly())); + this->SpreadSheetViewDec = new pqSpreadSheetViewDecorator(this->SpreadSheetView); this->SpreadSheetViewDec->setPrecision(3); this->SpreadSheetViewDec->setFixedRepresentation(true); @@ -174,6 +190,7 @@ void lqSpreadSheetManager::onSpreadSheetEndRender() conditionnallyHideColumn("Data", "Points_m_XYZ"); // hide dupe of pt coords conditionnallyHideColumn("TrailingFrame", "Points_m_XYZ"); + this->restoreShowOnlySelectedElement(); this->restoreColumnSelection(); } @@ -240,6 +257,22 @@ void lqSpreadSheetManager::restoreColumnSelection() } } +//----------------------------------------------------------------------------- +void lqSpreadSheetManager::onSpreadSheetSelectionOnly() +{ + // Save if "Show only selected elements" is enabled + int showOnlySelectedElement = vtkSMPropertyHelper(this->SpreadSheetView->getProxy(), "SelectionOnly").GetAsInt(); + this->Settings->setValue("ShowOnlySelectedElement", showOnlySelectedElement); +} + +//----------------------------------------------------------------------------- +void lqSpreadSheetManager::restoreShowOnlySelectedElement() +{ + int showOnlySelectedElement = this->Settings->value("ShowOnlySelectedElement").toInt(); + vtkSMPropertyHelper(this->SpreadSheetView->getProxy(), "SelectionOnly").Set(showOnlySelectedElement); + this->SpreadSheetView->getProxy()->UpdateProperty("SelectionOnly", true); +} + //----------------------------------------------------------------------------- std::string lqSpreadSheetManager::getCurrentShownObjectName() { diff --git a/ApplicationComponents/lqSpreadSheetManager.h b/ApplicationComponents/lqSpreadSheetManager.h index 6b85ec55f..051fc2c28 100644 --- a/ApplicationComponents/lqSpreadSheetManager.h +++ b/ApplicationComponents/lqSpreadSheetManager.h @@ -49,6 +49,7 @@ protected slots: // only the list of hidden columns is saved void onSaveColumnSelection(); + void onSpreadSheetSelectionOnly(); private: QDockWidget* spreadSheetDock = nullptr; pqRenderView* mainView = nullptr; @@ -64,6 +65,7 @@ private: void conditionnallyHideColumn(const std::string& conditionSrcName, const std::string& columnName); void restoreColumnSelection(); + void restoreShowOnlySelectedElement(); std::string getCurrentShownObjectName(); }; -- GitLab