Skip to content

Commit dc8d623

Browse files
committed
Clear color dataset and refresh dependent pickers
When the position dataset changes, clear the current color dataset and refresh dependent dataset pickers (color, point size, point opacity). Mark the position picker as Clearable, connect its datasetPicked signal to invalidate the other pickers, and invalidate them initially. Update filter callbacks to require a valid position dataset (and replace getPositionSourceDataset() calls with getPositionDataset()). This ensures pickers reflect the current position dataset and prevents stale/invalid color selections after position changes.
1 parent ede22db commit dc8d623

File tree

2 files changed

+28
-7
lines changed

2 files changed

+28
-7
lines changed

src/DatasetsAction.cpp

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ DatasetsAction::DatasetsAction(QObject* parent, const QString& title) :
2828
addAction(&_pointSizeDatasetPickerAction);
2929
addAction(&_pointOpacityDatasetPickerAction);
3030

31+
_positionDatasetPickerAction.setDefaultWidgetFlag(OptionAction::Clearable);
3132
_colorDatasetPickerAction.setDefaultWidgetFlag(OptionAction::Clearable);
3233
_pointSizeDatasetPickerAction.setDefaultWidgetFlag(OptionAction::Clearable);
3334
_pointOpacityDatasetPickerAction.setDefaultWidgetFlag(OptionAction::Clearable);
@@ -40,6 +41,16 @@ DatasetsAction::DatasetsAction(QObject* parent, const QString& title) :
4041
return;
4142

4243
setupDatasetPickerActions(scatterplotPlugin);
44+
45+
connect(&_positionDatasetPickerAction, &DatasetPickerAction::datasetPicked, [this, scatterplotPlugin](Dataset<DatasetImpl> pickedDataset) -> void {
46+
_colorDatasetPickerAction.invalidateFilter();
47+
_pointSizeDatasetPickerAction.invalidateFilter();
48+
_pointOpacityDatasetPickerAction.invalidateFilter();
49+
});
50+
51+
_colorDatasetPickerAction.invalidateFilter();
52+
_pointSizeDatasetPickerAction.invalidateFilter();
53+
_pointOpacityDatasetPickerAction.invalidateFilter();
4354
}
4455

4556
void DatasetsAction::connectToPublicAction(WidgetAction* publicAction, bool recursive)
@@ -121,8 +132,16 @@ void DatasetsAction::setupColorDatasetPickerAction(ScatterplotPlugin* scatterplo
121132
{
122133
auto& settingsAction = scatterplotPlugin->getSettingsAction();
123134

124-
_colorDatasetPickerAction.setFilterFunction([this](mv::Dataset<DatasetImpl> dataset) -> bool {
125-
return (dataset->getDataType() == PointType || dataset->getDataType() == ColorType || dataset->getDataType() == ClusterType);
135+
_colorDatasetPickerAction.setFilterFunction([this, scatterplotPlugin](mv::Dataset<DatasetImpl> dataset) -> bool {
136+
if (!(dataset->getDataType() == PointType || dataset->getDataType() == ColorType || dataset->getDataType() == ClusterType))
137+
return false;
138+
139+
const auto positionDataset = scatterplotPlugin->getPositionDataset();
140+
141+
if (!positionDataset.isValid())
142+
return false;
143+
144+
return true;
126145
});
127146

128147
auto& coloringAction = settingsAction.getColoringAction();
@@ -157,7 +176,7 @@ void DatasetsAction::setupPointSizeDatasetPickerAction(ScatterplotPlugin* scatte
157176
return false;
158177

159178
qDebug() << dataset->getGuiName() << "A";
160-
const auto positionDataset = scatterplotPlugin->getPositionSourceDataset();
179+
const auto positionDataset = scatterplotPlugin->getPositionDataset();
161180

162181
if (!positionDataset.isValid())
163182
return false;
@@ -208,7 +227,7 @@ void DatasetsAction::setupPointOpacityDatasetPickerAction(ScatterplotPlugin* sca
208227
if (dataset->getDataType() != PointType)
209228
return false;
210229

211-
const auto positionDataset = scatterplotPlugin->getPositionSourceDataset();
230+
const auto positionDataset = scatterplotPlugin->getPositionDataset();
212231

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

src/ScatterplotPlugin.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -165,16 +165,18 @@ ScatterplotPlugin::ScatterplotPlugin(const PluginFactory* factory) :
165165
// Load as point positions when no dataset is currently loaded
166166
dropRegions << new DropWidget::DropRegion(this, "Point position", description, "map-marker-alt", true, [this, candidateDataset]() {
167167
_positionDataset = candidateDataset;
168-
});
168+
_settingsAction.getColoringAction().setCurrentColorDataset(nullptr);
169+
});
169170
}
170171
else {
171172
if (_positionDataset != candidateDataset && candidateDataset->getNumDimensions() >= 2) {
172173

173174
// The number of points is equal, so offer the option to replace the existing points dataset
174175
dropRegions << new DropWidget::DropRegion(this, "Point position", description, "map-marker-alt", true, [this, candidateDataset]() {
175176
_positionDataset = candidateDataset;
176-
});
177-
}
177+
_settingsAction.getColoringAction().setCurrentColorDataset(nullptr);
178+
});
179+
}
178180

179181
// Accept for recoloring:
180182
// 1. data with the same number of points

0 commit comments

Comments
 (0)