Skip to content

Commit 10da2a4

Browse files
committed
Refactor: Group connections
1 parent 5e07e32 commit 10da2a4

File tree

1 file changed

+26
-27
lines changed

1 file changed

+26
-27
lines changed

src/ScatterplotPlugin.cpp

Lines changed: 26 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -341,15 +341,39 @@ void ScatterplotPlugin::init()
341341
connect(&_positionDataset, &Dataset<Points>::dataSelectionChanged, this, &ScatterplotPlugin::updateSelection);
342342
connect(&_positionDataset, &Dataset<>::guiNameChanged, this, &ScatterplotPlugin::updateHeadsUpDisplay);
343343

344-
_scatterPlotWidget->installEventFilter(this);
344+
const auto currentColorDatasetChanged = [this](Dataset<DatasetImpl> currentColorDataset) -> void {
345+
if (_colorDataset == currentColorDataset)
346+
return;
345347

346-
getLearningCenterAction().getViewPluginOverlayWidget()->setTargetWidget(_scatterPlotWidget);
348+
if (_colorDataset.isValid())
349+
disconnect(&_colorDataset, &Dataset<>::guiNameChanged, this, nullptr);
350+
351+
_colorDataset = currentColorDataset;
352+
353+
connect(&_colorDataset, &Dataset<>::guiNameChanged, this, &ScatterplotPlugin::updateHeadsUpDisplay);
354+
355+
updateHeadsUpDisplay();
356+
};
357+
358+
connect(&_settingsAction.getColoringAction(), &ColoringAction::currentColorDatasetChanged, this, currentColorDatasetChanged);
359+
connect(&_settingsAction.getColoringAction().getColorByAction(), &OptionAction::currentIndexChanged, this, [this, currentColorDatasetChanged](const std::int32_t& currentIndex) -> void {
360+
currentColorDatasetChanged(_settingsAction.getColoringAction().getCurrentColorDataset());
361+
});
362+
363+
connect(&_settingsAction.getPlotAction().getPointPlotAction().getSizeAction(), &ScalarAction::sourceDataChanged, this, &ScatterplotPlugin::updateHeadsUpDisplay);
364+
connect(&_settingsAction.getPlotAction().getPointPlotAction().getOpacityAction(), &ScalarAction::sourceDataChanged, this, &ScatterplotPlugin::updateHeadsUpDisplay);
365+
366+
connect(&_settingsAction.getMiscellaneousAction().getBackgroundColorAction(), &ColorAction::colorChanged, this, &ScatterplotPlugin::updateHeadsUpDisplayTextColor);
347367

348368
connect(&getScatterplotWidget().getPointRendererNavigator().getNavigationAction().getZoomSelectionAction(), &TriggerAction::triggered, this, [this]() -> void {
349369
if (_selectionBoundaries.isValid())
350370
_scatterPlotWidget->getPointRendererNavigator().setZoomRectangleWorld(_selectionBoundaries);
351371
});
352372

373+
_scatterPlotWidget->installEventFilter(this);
374+
375+
getLearningCenterAction().getViewPluginOverlayWidget()->setTargetWidget(_scatterPlotWidget);
376+
353377
#ifdef VIEW_SAMPLING_HTML
354378
getSamplerAction().setHtmlViewGeneratorFunction([this](const ViewPluginSamplerAction::SampleContext& toolTipContext) -> QString {
355379
QStringList localPointIndices, globalPointIndices;
@@ -395,32 +419,7 @@ void ScatterplotPlugin::init()
395419
#endif
396420

397421
updateHeadsUpDisplay();
398-
399-
const auto currentColorDatasetChanged = [this](Dataset<DatasetImpl> currentColorDataset) -> void {
400-
if (_colorDataset == currentColorDataset)
401-
return;
402-
403-
if (_colorDataset.isValid())
404-
disconnect(&_colorDataset, &Dataset<>::guiNameChanged, this, nullptr);
405-
406-
_colorDataset = currentColorDataset;
407-
408-
connect(&_colorDataset, &Dataset<>::guiNameChanged, this, &ScatterplotPlugin::updateHeadsUpDisplay);
409-
410-
updateHeadsUpDisplay();
411-
};
412-
413-
connect(&_settingsAction.getColoringAction(), &ColoringAction::currentColorDatasetChanged, this, currentColorDatasetChanged);
414-
connect(&_settingsAction.getColoringAction().getColorByAction(), &OptionAction::currentIndexChanged, this, [this, currentColorDatasetChanged](const std::int32_t& currentIndex) -> void {
415-
currentColorDatasetChanged(_settingsAction.getColoringAction().getCurrentColorDataset());
416-
});
417-
418-
connect(&_settingsAction.getPlotAction().getPointPlotAction().getSizeAction(), &ScalarAction::sourceDataChanged, this, &ScatterplotPlugin::updateHeadsUpDisplay);
419-
connect(&_settingsAction.getPlotAction().getPointPlotAction().getOpacityAction(), &ScalarAction::sourceDataChanged, this, &ScatterplotPlugin::updateHeadsUpDisplay);
420-
421422
updateHeadsUpDisplayTextColor();
422-
423-
connect(&_settingsAction.getMiscellaneousAction().getBackgroundColorAction(), &ColorAction::colorChanged, this, &ScatterplotPlugin::updateHeadsUpDisplayTextColor);
424423
}
425424

426425
void ScatterplotPlugin::loadData(const Datasets& datasets)

0 commit comments

Comments
 (0)