Skip to content

Commit 227f92f

Browse files
authored
Remove point size restriction (#234)
* Remove point size restriction * 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). * Show point counts in dataset mismatch warning Cache the number of points for the scalar source and position datasets and use those values in the mismatch notification. This avoids repeated getNumPoints() calls and provides a clearer notification message (includes numPositions and numScalars) when the two datasets have different sizes.
1 parent 08e712d commit 227f92f

File tree

3 files changed

+25
-21
lines changed

3 files changed

+25
-21
lines changed

src/DatasetsAction.cpp

Lines changed: 5 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -181,17 +181,10 @@ void DatasetsAction::setupPointSizeDatasetPickerAction(ScatterplotPlugin* scatte
181181
auto& pointSizeAction = pointPlotAction.getSizeAction();
182182

183183
_pointSizeDatasetPickerAction.setFilterFunction([this, scatterplotPlugin](mv::Dataset<DatasetImpl> dataset) -> bool {
184-
if (dataset->getDataType() != PointType)
184+
if (!scatterplotPlugin->getPositionDataset().isValid())
185185
return false;
186186

187-
const auto positionDataset = scatterplotPlugin->getPositionDataset();
188-
189-
if (!positionDataset.isValid())
190-
return false;
191-
192-
const mv::Dataset<Points> candidatePoints(dataset);
193-
194-
if (candidatePoints->getNumPoints() != positionDataset->getNumPoints())
187+
if (dataset->getDataType() != PointType)
195188
return false;
196189

197190
return true;
@@ -228,19 +221,12 @@ void DatasetsAction::setupPointOpacityDatasetPickerAction(ScatterplotPlugin* sca
228221
auto& pointOpacityAction = pointPlotAction.getOpacityAction();
229222

230223
_pointOpacityDatasetPickerAction.setFilterFunction([this, scatterplotPlugin](mv::Dataset<DatasetImpl> dataset) -> bool {
231-
if (dataset->getDataType() != PointType)
232-
return false;
233-
234-
const auto positionDataset = scatterplotPlugin->getPositionDataset();
235-
236-
if (!positionDataset.isValid())
224+
if (!scatterplotPlugin->getPositionDataset().isValid())
237225
return false;
238226

239-
const mv::Dataset<Points> candidatePoints(dataset);
240-
241-
if (candidatePoints->getNumPoints() != positionDataset->getNumPoints())
227+
if (dataset->getDataType() != PointType)
242228
return false;
243-
229+
244230
return true;
245231
});
246232

src/ScalarAction.cpp

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,25 @@ 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+
const auto numScalars = scalarSourcePointsDataset->getNumPoints();
28+
const auto numPositions = positionDataset->getNumPoints();
29+
30+
if (numScalars != numPositions) {
31+
emitSourceSelectionChanged = false;
32+
33+
scatterplotPlugin->addNotification(QString("The number of points in the scalar source dataset does not match the number of points in the position dataset. (numPositions=%1, numScalars:%2)").arg(QString::number(numPositions), QString::number(numScalars)));
34+
}
35+
}
36+
}
37+
38+
if (emitSourceSelectionChanged)
39+
emit sourceSelectionChanged(currentIndex);
2240
});
2341

2442
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)