Skip to content

Commit 009b91c

Browse files
committed
Check scalar source dataset point count
When the source picker index points to a dataset, verify that the selected scalar source dataset has the same number of points as the ScatterplotPlugin's position dataset. If the counts differ, suppress emitting sourceSelectionChanged and add a user notification explaining the mismatch to prevent invalid selection. Also fix a parameter name in ScalarSourceAction.h's doc comment (variantMap).
1 parent 33c5b6b commit 009b91c

File tree

2 files changed

+18
-2
lines changed

2 files changed

+18
-2
lines changed

src/ScalarAction.cpp

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,23 @@ ScalarAction::ScalarAction(QObject* parent, const QString& title, const float& m
1818
addAction(&_sourceAction);
1919

2020
connect(&_sourceAction.getPickerAction(), &OptionAction::currentIndexChanged, this, [this](const std::uint32_t& currentIndex) {
21-
emit sourceSelectionChanged(currentIndex);
21+
bool emitSourceSelectionChanged = true;
22+
23+
if (currentIndex >= ScalarSourceModel::DefaultRow::DatasetStart) {
24+
if (auto scatterplotPlugin = dynamic_cast<ScatterplotPlugin*>(findPluginAncestor())) {
25+
auto positionDataset = scatterplotPlugin->getPositionDataset();
26+
auto scalarSourcePointsDataset = Dataset<Points>(getCurrentDataset());
27+
28+
if (scalarSourcePointsDataset->getNumPoints() != positionDataset->getNumPoints()) {
29+
emitSourceSelectionChanged = false;
30+
31+
scatterplotPlugin->addNotification("The number of points in the scalar source dataset does not match the number of points in the position dataset.");
32+
}
33+
}
34+
}
35+
36+
if (emitSourceSelectionChanged)
37+
emit sourceSelectionChanged(currentIndex);
2238
});
2339

2440
connect(&_magnitudeAction, &DecimalAction::valueChanged, this, [this](const float& value) {

src/ScalarSourceAction.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ class ScalarSourceAction : public GroupAction
5454

5555
/**
5656
* Load widget action from variant map
57-
* @param Variant map representation of the widget action
57+
* @param variantMap Variant map representation of the widget action
5858
*/
5959
void fromVariantMap(const QVariantMap& variantMap) override;
6060

0 commit comments

Comments
 (0)