From 5ed3bed7b50f84d0aad5802add19dad844b7a205 Mon Sep 17 00:00:00 2001 From: Julian Thijssen Date: Sun, 26 Oct 2025 19:37:53 +0100 Subject: [PATCH 1/2] Add a check when dropping cluster data on a scatterplot to check whether its compatible --- src/ScatterplotPlugin.cpp | 30 ++++++++++++++++++++++++------ 1 file changed, 24 insertions(+), 6 deletions(-) diff --git a/src/ScatterplotPlugin.cpp b/src/ScatterplotPlugin.cpp index 0429892..b9ed5d9 100644 --- a/src/ScatterplotPlugin.cpp +++ b/src/ScatterplotPlugin.cpp @@ -238,12 +238,30 @@ ScatterplotPlugin::ScatterplotPlugin(const PluginFactory* factory) : }); } else { - - // Use the clusters set for points color - dropRegions << new DropWidget::DropRegion(this, "Color", description, "palette", true, [this, candidateDataset]() { - _settingsAction.getColoringAction().addColorDataset(candidateDataset); - _settingsAction.getColoringAction().setCurrentColorDataset(candidateDataset); - }); + if (candidateDataset.isValid()) + { + // Check to set whether the number of data points comprised throughout all clusters is the same number + // as the number of data points in the dataset we are trying to color + int totalNumIndices = 0; + for (Cluster cluster : candidateDataset->getClusters()) + { + totalNumIndices += cluster.getIndices().size(); + } + + if (totalNumIndices == _positionDataset->getNumPoints()) + { + // Use the clusters set for points color + dropRegions << new DropWidget::DropRegion(this, "Color", description, "palette", true, [this, candidateDataset]() { + _settingsAction.getColoringAction().addColorDataset(candidateDataset); + _settingsAction.getColoringAction().setCurrentColorDataset(candidateDataset); + }); + } + else + { + // Number of indices in clusters doesn't match point dataset + dropRegions << new DropWidget::DropRegion(this, "Incompatible data", "Cluster data does not match number of data points", "exclamation-circle", false); + } + } } } else { From 7eaefbc3ed3332f03acb83f261255768a7881427 Mon Sep 17 00:00:00 2001 From: Julian Thijssen Date: Mon, 27 Oct 2025 12:41:09 +0100 Subject: [PATCH 2/2] Don't copy clusters when tallying --- src/ScatterplotPlugin.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ScatterplotPlugin.cpp b/src/ScatterplotPlugin.cpp index b9ed5d9..3056c2e 100644 --- a/src/ScatterplotPlugin.cpp +++ b/src/ScatterplotPlugin.cpp @@ -243,7 +243,7 @@ ScatterplotPlugin::ScatterplotPlugin(const PluginFactory* factory) : // Check to set whether the number of data points comprised throughout all clusters is the same number // as the number of data points in the dataset we are trying to color int totalNumIndices = 0; - for (Cluster cluster : candidateDataset->getClusters()) + for (const Cluster& cluster : candidateDataset->getClusters()) { totalNumIndices += cluster.getIndices().size(); }