Skip to content
Snippets Groups Projects
Commit 5eaf5a0b authored by MelanieCarriere's avatar MelanieCarriere
Browse files

[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.
parent ee96534c
No related branches found
No related tags found
1 merge request!140Fix spreadsheet view
Pipeline #199283 canceled
Pipeline: LidarView

#199284

    ......@@ -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()
    {
    ......
    ......@@ -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();
    };
    ......
    0% Loading or .
    You are about to add 0 people to the discussion. Proceed with caution.
    Finish editing this message first!
    Please register or to comment