Skip to content

Commit 741494d

Browse files
Add check to stop being able to drop whatever cluster data on scatterplot data (#215)
* Add a check when dropping cluster data on a scatterplot to check whether its compatible * Don't copy clusters when tallying
1 parent 0ca8f81 commit 741494d

File tree

1 file changed

+24
-6
lines changed

1 file changed

+24
-6
lines changed

src/ScatterplotPlugin.cpp

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -238,12 +238,30 @@ ScatterplotPlugin::ScatterplotPlugin(const PluginFactory* factory) :
238238
});
239239
}
240240
else {
241-
242-
// Use the clusters set for points color
243-
dropRegions << new DropWidget::DropRegion(this, "Color", description, "palette", true, [this, candidateDataset]() {
244-
_settingsAction.getColoringAction().addColorDataset(candidateDataset);
245-
_settingsAction.getColoringAction().setCurrentColorDataset(candidateDataset);
246-
});
241+
if (candidateDataset.isValid())
242+
{
243+
// Check to set whether the number of data points comprised throughout all clusters is the same number
244+
// as the number of data points in the dataset we are trying to color
245+
int totalNumIndices = 0;
246+
for (const Cluster& cluster : candidateDataset->getClusters())
247+
{
248+
totalNumIndices += cluster.getIndices().size();
249+
}
250+
251+
if (totalNumIndices == _positionDataset->getNumPoints())
252+
{
253+
// Use the clusters set for points color
254+
dropRegions << new DropWidget::DropRegion(this, "Color", description, "palette", true, [this, candidateDataset]() {
255+
_settingsAction.getColoringAction().addColorDataset(candidateDataset);
256+
_settingsAction.getColoringAction().setCurrentColorDataset(candidateDataset);
257+
});
258+
}
259+
else
260+
{
261+
// Number of indices in clusters doesn't match point dataset
262+
dropRegions << new DropWidget::DropRegion(this, "Incompatible data", "Cluster data does not match number of data points", "exclamation-circle", false);
263+
}
264+
}
247265
}
248266
}
249267
else {

0 commit comments

Comments
 (0)