From dd545e1cd7eeafe34dff49e8affd92fa2d76480b Mon Sep 17 00:00:00 2001 From: Alexander Vieth Date: Fri, 31 Oct 2025 09:20:58 +0100 Subject: [PATCH 1/2] Handle derived data in cluster drop (#218) --- src/ScatterplotPlugin.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/ScatterplotPlugin.cpp b/src/ScatterplotPlugin.cpp index a7aed60..3155337 100644 --- a/src/ScatterplotPlugin.cpp +++ b/src/ScatterplotPlugin.cpp @@ -248,7 +248,13 @@ ScatterplotPlugin::ScatterplotPlugin(const PluginFactory* factory) : totalNumIndices += cluster.getIndices().size(); } - if (totalNumIndices == _positionDataset->getNumPoints()) + int totalNumPoints = 0; + if (_positionDataset->isDerivedData()) + totalNumPoints = _positionSourceDataset->getFullDataset()->getNumPoints(); + else + totalNumPoints = _positionDataset->getFullDataset()->getNumPoints(); + + if (totalNumIndices == totalNumPoints) { // Use the clusters set for points color dropRegions << new DropWidget::DropRegion(this, "Color", description, "palette", true, [this, candidateDataset]() { From 1cddb54b7f9337f906fd0ab6f193339a45c88d13 Mon Sep 17 00:00:00 2001 From: Thomas Kroes Date: Tue, 4 Nov 2025 09:43:41 +0100 Subject: [PATCH 2/2] Refactor color dataset handling in ScatterplotPlugin Introduces a dedicated _colorDataset member to manage the dataset used for coloring. Updates signal connections to ensure proper synchronization and heads-up display updates when the color dataset or color-by option changes. The heads-up display now only shows color metadata when the color-by index is >= 2. --- src/ScatterplotPlugin.cpp | 27 ++++++++++++++++++++++++--- src/ScatterplotPlugin.h | 1 + 2 files changed, 25 insertions(+), 3 deletions(-) diff --git a/src/ScatterplotPlugin.cpp b/src/ScatterplotPlugin.cpp index 3155337..1e35b7c 100644 --- a/src/ScatterplotPlugin.cpp +++ b/src/ScatterplotPlugin.cpp @@ -394,8 +394,27 @@ void ScatterplotPlugin::init() connect(&_positionDataset, &Dataset<>::changed, this, &ScatterplotPlugin::updateHeadsUpDisplay); connect(&_positionDataset, &Dataset<>::guiNameChanged, this, &ScatterplotPlugin::updateHeadsUpDisplay); - connect(&_settingsAction.getColoringAction(), &ColoringAction::currentColorDatasetChanged, this, &ScatterplotPlugin::updateHeadsUpDisplay); - connect(&_settingsAction.getColoringAction().getColorByAction(), &OptionAction::currentIndexChanged, this, &ScatterplotPlugin::updateHeadsUpDisplay); + connect(&_positionDataset, &Dataset<>::guiNameChanged, this, &ScatterplotPlugin::updateHeadsUpDisplay); + + const auto currentColorDatasetChanged = [this](Dataset currentColorDataset) -> void { + if (_colorDataset == currentColorDataset) + return; + + if (_colorDataset.isValid()) + disconnect(&_colorDataset, &Dataset<>::guiNameChanged, this, nullptr); + + _colorDataset = currentColorDataset; + + connect(&_colorDataset, &Dataset<>::guiNameChanged, this, &ScatterplotPlugin::updateHeadsUpDisplay); + + updateHeadsUpDisplay(); + }; + + connect(&_settingsAction.getColoringAction(), &ColoringAction::currentColorDatasetChanged, this, currentColorDatasetChanged); + connect(&_settingsAction.getColoringAction().getColorByAction(), &OptionAction::currentIndexChanged, this, [this, currentColorDatasetChanged](const std::int32_t& currentIndex) -> void { + currentColorDatasetChanged(_settingsAction.getColoringAction().getCurrentColorDataset()); + }); + connect(&_settingsAction.getPlotAction().getPointPlotAction().getSizeAction(), &ScalarAction::sourceDataChanged, this, &ScatterplotPlugin::updateHeadsUpDisplay); connect(&_settingsAction.getPlotAction().getPointPlotAction().getOpacityAction(), &ScalarAction::sourceDataChanged, this, &ScatterplotPlugin::updateHeadsUpDisplay); @@ -1010,7 +1029,9 @@ void ScatterplotPlugin::updateHeadsUpDisplay() getHeadsUpDisplayAction().addHeadsUpDisplayItem(QString("%1 by:").arg(metaDataName), data->getGuiName(), "", itemPtr); }; - addMetaDataToHeadsUpDisplay("Color", _settingsAction.getColoringAction().getCurrentColorDataset(), datasetsItem); + if (_settingsAction.getColoringAction().getColorByAction().getCurrentIndex() >= 2) + addMetaDataToHeadsUpDisplay("Color", _colorDataset, datasetsItem); + addMetaDataToHeadsUpDisplay("Size", _settingsAction.getPlotAction().getPointPlotAction().getSizeAction().getCurrentDataset(), datasetsItem); addMetaDataToHeadsUpDisplay("Opacity", _settingsAction.getPlotAction().getPointPlotAction().getOpacityAction().getCurrentDataset(), datasetsItem); diff --git a/src/ScatterplotPlugin.h b/src/ScatterplotPlugin.h index e795c72..4155039 100644 --- a/src/ScatterplotPlugin.h +++ b/src/ScatterplotPlugin.h @@ -116,6 +116,7 @@ class ScatterplotPlugin : public ViewPlugin ScatterplotWidget* _scatterPlotWidget; /** The visualization widget */ Dataset _positionDataset; /** Smart pointer to points dataset for point position */ Dataset _positionSourceDataset; /** Smart pointer to source of the points dataset for point position (if any) */ + Dataset _colorDataset; /** Smart pointer to dataset used for coloring (if any) */ std::vector _positions; /** Point positions */ unsigned int _numPoints; /** Number of point positions */ SettingsAction _settingsAction; /** Group action for all settings */