Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 5 additions & 19 deletions src/DatasetsAction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -172,17 +172,10 @@ void DatasetsAction::setupPointSizeDatasetPickerAction(ScatterplotPlugin* scatte
auto& pointSizeAction = pointPlotAction.getSizeAction();

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

const auto positionDataset = scatterplotPlugin->getPositionDataset();

if (!positionDataset.isValid())
return false;

const mv::Dataset<Points> candidatePoints(dataset);

if (candidatePoints->getNumPoints() != positionDataset->getNumPoints())
if (dataset->getDataType() != PointType)
return false;

return true;
Expand Down Expand Up @@ -219,19 +212,12 @@ void DatasetsAction::setupPointOpacityDatasetPickerAction(ScatterplotPlugin* sca
auto& pointOpacityAction = pointPlotAction.getOpacityAction();

_pointOpacityDatasetPickerAction.setFilterFunction([this, scatterplotPlugin](mv::Dataset<DatasetImpl> dataset) -> bool {
if (dataset->getDataType() != PointType)
return false;

const auto positionDataset = scatterplotPlugin->getPositionDataset();

if (!positionDataset.isValid())
if (!scatterplotPlugin->getPositionDataset().isValid())
return false;

const mv::Dataset<Points> candidatePoints(dataset);

if (candidatePoints->getNumPoints() != positionDataset->getNumPoints())
if (dataset->getDataType() != PointType)
return false;

return true;
});

Expand Down
20 changes: 19 additions & 1 deletion src/ScalarAction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,25 @@ ScalarAction::ScalarAction(QObject* parent, const QString& title, const float& m
addAction(&_sourceAction);

connect(&_sourceAction.getPickerAction(), &OptionAction::currentIndexChanged, this, [this](const std::uint32_t& currentIndex) {
emit sourceSelectionChanged(currentIndex);
bool emitSourceSelectionChanged = true;

if (currentIndex >= ScalarSourceModel::DefaultRow::DatasetStart) {
if (auto scatterplotPlugin = dynamic_cast<ScatterplotPlugin*>(findPluginAncestor())) {
auto positionDataset = scatterplotPlugin->getPositionDataset();
auto scalarSourcePointsDataset = Dataset<Points>(getCurrentDataset());
const auto numScalars = scalarSourcePointsDataset->getNumPoints();
const auto numPositions = positionDataset->getNumPoints();

if (numScalars != numPositions) {
emitSourceSelectionChanged = false;

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)));
}
}
}

if (emitSourceSelectionChanged)
emit sourceSelectionChanged(currentIndex);
});

connect(&_magnitudeAction, &DecimalAction::valueChanged, this, [this](const float& value) {
Expand Down
2 changes: 1 addition & 1 deletion src/ScalarSourceAction.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ class ScalarSourceAction : public GroupAction

/**
* Load widget action from variant map
* @param Variant map representation of the widget action
* @param variantMap Variant map representation of the widget action
*/
void fromVariantMap(const QVariantMap& variantMap) override;

Expand Down