Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • LidarView/lidarview-core
  • nick.laurenson/lidarview-core
  • aerezarang/lidarview-core
3 results
Show changes
Commits on Source (4)
...@@ -17,13 +17,23 @@ ...@@ -17,13 +17,23 @@
#include <pqObjectBuilder.h> #include <pqObjectBuilder.h>
#include <pqApplicationCore.h> #include <pqApplicationCore.h>
#include <pqActiveObjects.h> #include <pqActiveObjects.h>
#include <pqSettings.h>
#include <vtkEventQtSlotConnect.h>
#include "vtkSMProperty.h"
#include <vtkSMPropertyHelper.h>
#include <vtkSMViewProxy.h>
#include <assert.h> #include <assert.h>
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
lqSpreadSheetManager::lqSpreadSheetManager(QObject* parent) : QObject(parent) 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() ...@@ -66,6 +76,12 @@ void lqSpreadSheetManager::constructSpreadSheet()
QObject::connect(this->SpreadSheetView, SIGNAL(endRender()), this, SLOT(onSpreadSheetEndRender())); QObject::connect(this->SpreadSheetView, SIGNAL(endRender()), this, SLOT(onSpreadSheetEndRender()));
QObject::connect(this, SIGNAL(saveColumnSelection()), this, SLOT(onSaveColumnSelection())); 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 = new pqSpreadSheetViewDecorator(this->SpreadSheetView);
this->SpreadSheetViewDec->setPrecision(3); this->SpreadSheetViewDec->setPrecision(3);
this->SpreadSheetViewDec->setFixedRepresentation(true); this->SpreadSheetViewDec->setFixedRepresentation(true);
...@@ -164,19 +180,18 @@ void lqSpreadSheetManager::conditionnallyHideColumn(const std::string& condition ...@@ -164,19 +180,18 @@ void lqSpreadSheetManager::conditionnallyHideColumn(const std::string& condition
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
void lqSpreadSheetManager::onSpreadSheetEndRender() void lqSpreadSheetManager::onSpreadSheetEndRender()
{ {
// endRender may not be the best signal to use because it will be called at // Every time the spreadsheet has to be rendered:
// each frame whereas we would prefer to update only when the source is // - we hide the column "Points_m_XYZ" because it's too wide.
// changed. However I tried pqSpreadSheetView::showing and // - we check which columns have to be displayed (some of them could have been hidden by the user
// pqSpreadSheetView::viewportUpdated but none worked because column names // We do this every time (not only for each new frame)
// are not yet updated // Because if the user opens and closes the spreadsheet on the same frame, it should display the same things.
if (this->getCurrentShownObjectName() != this->lastShownObjectName)
{
conditionnallyHideColumn("Data", "Points_m_XYZ"); // hide dupe of pt coords
conditionnallyHideColumn("TrailingFrame", "Points_m_XYZ");
this->restoreColumnSelection();
} conditionnallyHideColumn("Data", "Points_m_XYZ"); // hide dupe of pt coords
this->lastShownObjectName = this->getCurrentShownObjectName(); conditionnallyHideColumn("TrailingFrame", "Points_m_XYZ");
this->restoreShowOnlySelectedElement();
this->restoreColumnSelection();
} }
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
...@@ -215,8 +230,6 @@ void lqSpreadSheetManager::onSaveColumnSelection() ...@@ -215,8 +230,6 @@ void lqSpreadSheetManager::onSaveColumnSelection()
return; return;
} }
pqSettings* settings = pqApplicationCore::instance()->settings();
const int cols = this->SpreadSheetView->getViewModel()->columnCount(); const int cols = this->SpreadSheetView->getViewModel()->columnCount();
QStringList hiddenArrays; QStringList hiddenArrays;
for (int i = 0; i < cols; i++) for (int i = 0; i < cols; i++)
...@@ -229,22 +242,37 @@ void lqSpreadSheetManager::onSaveColumnSelection() ...@@ -229,22 +242,37 @@ void lqSpreadSheetManager::onSaveColumnSelection()
} }
std::string key = getHiddenArraysKey(this->getCurrentShownObjectName()); std::string key = getHiddenArraysKey(this->getCurrentShownObjectName());
settings->setValue(key.c_str(), hiddenArrays); this->Settings->setValue(key.c_str(), hiddenArrays);
} }
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
void lqSpreadSheetManager::restoreColumnSelection() void lqSpreadSheetManager::restoreColumnSelection()
{ {
pqSettings* settings = pqApplicationCore::instance()->settings();
std::string objectName = this->getCurrentShownObjectName(); std::string objectName = this->getCurrentShownObjectName();
std::string key = getHiddenArraysKey(objectName); std::string key = getHiddenArraysKey(objectName);
QStringList hiddenArrays = settings->value(key.c_str()).toStringList(); QStringList hiddenArrays = this->Settings->value(key.c_str()).toStringList();
foreach (QString array, hiddenArrays) foreach (QString array, hiddenArrays)
{ {
this->conditionnallyHideColumn(objectName, array.toStdString()); this->conditionnallyHideColumn(objectName, array.toStdString());
} }
} }
//-----------------------------------------------------------------------------
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() std::string lqSpreadSheetManager::getCurrentShownObjectName()
{ {
......
...@@ -16,6 +16,7 @@ ...@@ -16,6 +16,7 @@
#define __lqSpreadSheetManager_h #define __lqSpreadSheetManager_h
#include <pqRenderView.h> #include <pqRenderView.h>
#include <pqSettings.h>
#include <pqSpreadSheetView.h> #include <pqSpreadSheetView.h>
#include <pqSpreadSheetViewModel.h> #include <pqSpreadSheetViewModel.h>
#include <pqSpreadSheetViewDecorator.h> #include <pqSpreadSheetViewDecorator.h>
...@@ -48,6 +49,7 @@ protected slots: ...@@ -48,6 +49,7 @@ protected slots:
// only the list of hidden columns is saved // only the list of hidden columns is saved
void onSaveColumnSelection(); void onSaveColumnSelection();
void onSpreadSheetSelectionOnly();
private: private:
QDockWidget* spreadSheetDock = nullptr; QDockWidget* spreadSheetDock = nullptr;
pqRenderView* mainView = nullptr; pqRenderView* mainView = nullptr;
...@@ -55,14 +57,16 @@ private: ...@@ -55,14 +57,16 @@ private:
pqSpreadSheetView* SpreadSheetView = nullptr; pqSpreadSheetView* SpreadSheetView = nullptr;
pqSpreadSheetViewDecorator* SpreadSheetViewDec = nullptr; pqSpreadSheetViewDecorator* SpreadSheetViewDec = nullptr;
pqSettings* Settings;
void constructSpreadSheet(); void constructSpreadSheet();
void destructSpreadSheet(); void destructSpreadSheet();
bool isSpreadSheetOpen(); bool isSpreadSheetOpen();
void conditionnallyHideColumn(const std::string& conditionSrcName, void conditionnallyHideColumn(const std::string& conditionSrcName,
const std::string& columnName); const std::string& columnName);
void restoreColumnSelection(); void restoreColumnSelection();
void restoreShowOnlySelectedElement();
std::string getCurrentShownObjectName(); std::string getCurrentShownObjectName();
std::string lastShownObjectName = "";
}; };
#endif // __lqSpreadSheetManager_h #endif // __lqSpreadSheetManager_h