From 6114835c183b214e8754c8aa4f5498eb560e395a Mon Sep 17 00:00:00 2001 From: Soumyadeep Basu <44787782+basusoumyadeep@users.noreply.github.com> Date: Thu, 21 Aug 2025 20:13:40 +0200 Subject: [PATCH 1/4] Add dimension changed event to coloring point dataset --- src/ColoringAction.cpp | 17 +++++++++++++++-- src/ColoringAction.h | 1 + 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/src/ColoringAction.cpp b/src/ColoringAction.cpp index 0ade6d0..2419a6f 100644 --- a/src/ColoringAction.cpp +++ b/src/ColoringAction.cpp @@ -71,11 +71,24 @@ ColoringAction::ColoringAction(QObject* parent, const QString& title) : _constantColorAction.setEnabled(currentIndex == 0); const auto currentColorDataset = getCurrentColorDataset(); - + disconnect(&_currentColorPointsDataset, &Dataset::dataDimensionsChanged, this, nullptr); + _currentColorPointsDataset = Dataset(); if (currentColorDataset.isValid()) { const auto currentColorDatasetTypeIsPointType = currentColorDataset->getDataType() == PointType; - _dimensionAction.setPointsDataset(currentColorDatasetTypeIsPointType ? Dataset(currentColorDataset) : Dataset()); + if (currentColorDatasetTypeIsPointType) { + _currentColorPointsDataset = currentColorDataset.get(); + connect(&_currentColorPointsDataset, &Dataset::dataDimensionsChanged, this, [this]() { + _dimensionAction.setPointsDataset(_currentColorPointsDataset); + updateScatterPlotWidgetColors(); + }); + _dimensionAction.setPointsDataset(_currentColorPointsDataset); + + + } + else { + _dimensionAction.setPointsDataset(Dataset()); + } //_dimensionAction.setVisible(currentColorDatasetTypeIsPointType); emit currentColorDatasetChanged(currentColorDataset); diff --git a/src/ColoringAction.h b/src/ColoringAction.h index 2cc75b2..cf9dc87 100644 --- a/src/ColoringAction.h +++ b/src/ColoringAction.h @@ -134,6 +134,7 @@ class ColoringAction : public VerticalGroupAction DimensionPickerAction _dimensionAction; /** Dimension picker action */ ColorMap1DAction _colorMap1DAction; /** One-dimensional color map action */ ColorMap2DAction _colorMap2DAction; /** Two-dimensional color map action */ + Dataset _currentColorPointsDataset; /** Current color dataset */ /** Default constant color */ static const QColor DEFAULT_CONSTANT_COLOR; From 124064c0500d09d31bfbf50045601f47198c769a Mon Sep 17 00:00:00 2001 From: Soumyadeep Basu <44787782+basusoumyadeep@users.noreply.github.com> Date: Thu, 21 Aug 2025 20:40:20 +0200 Subject: [PATCH 2/4] add dataset validity checks --- src/ColoringAction.cpp | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/src/ColoringAction.cpp b/src/ColoringAction.cpp index 2419a6f..611be0d 100644 --- a/src/ColoringAction.cpp +++ b/src/ColoringAction.cpp @@ -71,20 +71,23 @@ ColoringAction::ColoringAction(QObject* parent, const QString& title) : _constantColorAction.setEnabled(currentIndex == 0); const auto currentColorDataset = getCurrentColorDataset(); - disconnect(&_currentColorPointsDataset, &Dataset::dataDimensionsChanged, this, nullptr); + if (_currentColorPointsDataset.isValid()) + { + disconnect(&_currentColorPointsDataset, &Dataset::dataDimensionsChanged, this, nullptr); + } _currentColorPointsDataset = Dataset(); if (currentColorDataset.isValid()) { const auto currentColorDatasetTypeIsPointType = currentColorDataset->getDataType() == PointType; - if (currentColorDatasetTypeIsPointType) { + if (currentColorDatasetTypeIsPointType) { _currentColorPointsDataset = currentColorDataset.get(); - connect(&_currentColorPointsDataset, &Dataset::dataDimensionsChanged, this, [this]() { - _dimensionAction.setPointsDataset(_currentColorPointsDataset); - updateScatterPlotWidgetColors(); - }); + if (_currentColorPointsDataset.isValid()) { + connect(&_currentColorPointsDataset, &Dataset::dataDimensionsChanged, this, [this]() { + _dimensionAction.setPointsDataset(_currentColorPointsDataset); + updateScatterPlotWidgetColors(); + }); + } _dimensionAction.setPointsDataset(_currentColorPointsDataset); - - } else { _dimensionAction.setPointsDataset(Dataset()); From 618cb7e8da77e267959909aade1668d74a81f53b Mon Sep 17 00:00:00 2001 From: Soumyadeep Basu <44787782+basusoumyadeep@users.noreply.github.com> Date: Thu, 21 Aug 2025 20:49:58 +0200 Subject: [PATCH 3/4] add dataset validity check inside connect --- src/ColoringAction.cpp | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/ColoringAction.cpp b/src/ColoringAction.cpp index 611be0d..2458392 100644 --- a/src/ColoringAction.cpp +++ b/src/ColoringAction.cpp @@ -83,11 +83,18 @@ ColoringAction::ColoringAction(QObject* parent, const QString& title) : _currentColorPointsDataset = currentColorDataset.get(); if (_currentColorPointsDataset.isValid()) { connect(&_currentColorPointsDataset, &Dataset::dataDimensionsChanged, this, [this]() { - _dimensionAction.setPointsDataset(_currentColorPointsDataset); - updateScatterPlotWidgetColors(); + if (_currentColorPointsDataset.isValid()) + { + _dimensionAction.setPointsDataset(_currentColorPointsDataset); + updateScatterPlotWidgetColors(); + } }); + _dimensionAction.setPointsDataset(_currentColorPointsDataset); } - _dimensionAction.setPointsDataset(_currentColorPointsDataset); + else { + _dimensionAction.setPointsDataset(Dataset()); + } + } else { _dimensionAction.setPointsDataset(Dataset()); From 5512ee440c694b89fc71ebeb48e0be784621989f Mon Sep 17 00:00:00 2001 From: Thomas Kroes Date: Fri, 22 Aug 2025 08:03:56 +0200 Subject: [PATCH 4/4] Coding/style improvements --- src/ColoringAction.cpp | 18 +++++++++--------- src/ColoringAction.h | 16 ++++++++-------- 2 files changed, 17 insertions(+), 17 deletions(-) diff --git a/src/ColoringAction.cpp b/src/ColoringAction.cpp index 2458392..6463937 100644 --- a/src/ColoringAction.cpp +++ b/src/ColoringAction.cpp @@ -71,30 +71,30 @@ ColoringAction::ColoringAction(QObject* parent, const QString& title) : _constantColorAction.setEnabled(currentIndex == 0); const auto currentColorDataset = getCurrentColorDataset(); - if (_currentColorPointsDataset.isValid()) - { + + if (_currentColorPointsDataset.isValid()) { disconnect(&_currentColorPointsDataset, &Dataset::dataDimensionsChanged, this, nullptr); } + _currentColorPointsDataset = Dataset(); - if (currentColorDataset.isValid()) { - const auto currentColorDatasetTypeIsPointType = currentColorDataset->getDataType() == PointType; - if (currentColorDatasetTypeIsPointType) { + if (currentColorDataset.isValid()) { + if (currentColorDataset->getDataType() == PointType) { _currentColorPointsDataset = currentColorDataset.get(); + if (_currentColorPointsDataset.isValid()) { connect(&_currentColorPointsDataset, &Dataset::dataDimensionsChanged, this, [this]() { - if (_currentColorPointsDataset.isValid()) - { + if (_currentColorPointsDataset.isValid()) { _dimensionAction.setPointsDataset(_currentColorPointsDataset); updateScatterPlotWidgetColors(); } - }); + }); + _dimensionAction.setPointsDataset(_currentColorPointsDataset); } else { _dimensionAction.setPointsDataset(Dataset()); } - } else { _dimensionAction.setPointsDataset(Dataset()); diff --git a/src/ColoringAction.h b/src/ColoringAction.h index cf9dc87..4a1d480 100644 --- a/src/ColoringAction.h +++ b/src/ColoringAction.h @@ -127,14 +127,14 @@ class ColoringAction : public VerticalGroupAction void currentColorDatasetChanged(Dataset currentColorDataset); private: - ScatterplotPlugin* _scatterplotPlugin; /** Pointer to scatter plot plugin */ - ColorSourceModel _colorByModel; /** Color by model (model input for the color by action) */ - OptionAction _colorByAction; /** Action for picking the coloring type */ - ColorAction _constantColorAction; /** Action for picking the constant color */ - DimensionPickerAction _dimensionAction; /** Dimension picker action */ - ColorMap1DAction _colorMap1DAction; /** One-dimensional color map action */ - ColorMap2DAction _colorMap2DAction; /** Two-dimensional color map action */ - Dataset _currentColorPointsDataset; /** Current color dataset */ + ScatterplotPlugin* _scatterplotPlugin; /** Pointer to scatter plot plugin */ + ColorSourceModel _colorByModel; /** Color by model (model input for the color by action) */ + OptionAction _colorByAction; /** Action for picking the coloring type */ + ColorAction _constantColorAction; /** Action for picking the constant color */ + DimensionPickerAction _dimensionAction; /** Dimension picker action */ + ColorMap1DAction _colorMap1DAction; /** One-dimensional color map action */ + ColorMap2DAction _colorMap2DAction; /** Two-dimensional color map action */ + Dataset _currentColorPointsDataset; /** Current color dataset */ /** Default constant color */ static const QColor DEFAULT_CONSTANT_COLOR;