diff --git a/ApplicationComponents/lqSpreadSheetManager.cxx b/ApplicationComponents/lqSpreadSheetManager.cxx index 5520039287bb9ba10d48957e692d9e0e2c919769..3e5e99399d1e0b62e9373f60375b08ba74577dc3 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 6b85ec55fe1022b30aa26c544f55295360dec037..051fc2c28c94b9460dd8c6e73ebe2f10df048eb3 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(); };