From 0a0964cf716e5dc1dbdc2c1eaff926bbd9102595 Mon Sep 17 00:00:00 2001 From: Gemma Guest <gemma.guest@stfc.ac.uk> Date: Thu, 28 Feb 2019 15:39:54 +0000 Subject: [PATCH] Update widget enabled state after setting defaults Re #23051 --- .../GUI/Experiment/ExperimentPresenter.cpp | 47 +++++++++++++++---- .../GUI/Experiment/ExperimentPresenter.h | 6 ++- .../GUI/Instrument/InstrumentPresenter.cpp | 5 ++ 3 files changed, 48 insertions(+), 10 deletions(-) diff --git a/qt/scientific_interfaces/ISISReflectometry/GUI/Experiment/ExperimentPresenter.cpp b/qt/scientific_interfaces/ISISReflectometry/GUI/Experiment/ExperimentPresenter.cpp index 6663d504ecf..0908adb222d 100644 --- a/qt/scientific_interfaces/ISISReflectometry/GUI/Experiment/ExperimentPresenter.cpp +++ b/qt/scientific_interfaces/ISISReflectometry/GUI/Experiment/ExperimentPresenter.cpp @@ -44,6 +44,10 @@ void ExperimentPresenter::notifyRestoreDefaultsRequested() { void ExperimentPresenter::notifySummationTypeChanged() { notifySettingsChanged(); + updateSummationTypeEnabledState(); +} + +void ExperimentPresenter::updateSummationTypeEnabledState() { if (m_model.summationType() == SummationType::SumInQ) { m_view->enableReductionType(); m_view->enableIncludePartialBins(); @@ -85,20 +89,25 @@ bool ExperimentPresenter::isAutoreducing() const { /** Tells the view to update the enabled/disabled state of all relevant * widgets based on whether processing is in progress or not. */ -void ExperimentPresenter::updateWidgetEnabledState() const { - if (isProcessing() || isAutoreducing()) +void ExperimentPresenter::updateDisplayState() { + if (isProcessing() || isAutoreducing()) { m_view->disableAll(); - else - m_view->enableAll(); + return; + } + + m_view->enableAll(); + updateSummationTypeEnabledState(); + updatePolarizationCorrectionEnabledState(); + updateFloodCorrectionEnabledState(); } -void ExperimentPresenter::reductionPaused() { updateWidgetEnabledState(); } +void ExperimentPresenter::reductionPaused() { updateDisplayState(); } -void ExperimentPresenter::reductionResumed() { updateWidgetEnabledState(); } +void ExperimentPresenter::reductionResumed() { updateDisplayState(); } -void ExperimentPresenter::autoreductionPaused() { updateWidgetEnabledState(); } +void ExperimentPresenter::autoreductionPaused() { updateDisplayState(); } -void ExperimentPresenter::autoreductionResumed() { updateWidgetEnabledState(); } +void ExperimentPresenter::autoreductionResumed() { updateDisplayState(); } void ExperimentPresenter::instrumentChanged( std::string const &instrumentName, @@ -123,6 +132,14 @@ PolarizationCorrections ExperimentPresenter::polarizationCorrectionsFromView() { return PolarizationCorrections(correctionType); } +void ExperimentPresenter::updatePolarizationCorrectionEnabledState() { + if (polarizationCorrectionRequiresInputs( + m_model.polarizationCorrections().correctionType())) + m_view->enablePolarizationCorrectionInputs(); + else + m_view->disablePolarizationCorrectionInputs(); +} + FloodCorrections ExperimentPresenter::floodCorrectionsFromView() { auto const correctionType = floodCorrectionTypeFromString(m_view->getFloodCorrectionType()); @@ -136,6 +153,14 @@ FloodCorrections ExperimentPresenter::floodCorrectionsFromView() { return FloodCorrections(correctionType); } +void ExperimentPresenter::updateFloodCorrectionEnabledState() { + if (floodCorrectionRequiresInputs( + m_model.floodCorrections().correctionType())) + m_view->enableFloodCorrectionInputs(); + else + m_view->disableFloodCorrectionInputs(); +} + boost::optional<RangeInLambda> ExperimentPresenter::transmissionRunRangeFromView() { auto const range = RangeInLambda(m_view->getTransmissionStartOverlap(), @@ -194,8 +219,10 @@ ExperimentValidationResult ExperimentPresenter::validateExperimentFromView() { ExperimentValidationResult ExperimentPresenter::updateModelFromView() { auto validationResult = validateExperimentFromView(); - if (validationResult.isValid()) + if (validationResult.isValid()) { m_model = validationResult.assertValid(); + updateDisplayState(); + } return validationResult; } @@ -240,6 +267,8 @@ void ExperimentPresenter::updateViewFromModel() { if (m_model.floodCorrections().workspace()) m_view->setFloodWorkspace(m_model.floodCorrections().workspace().get()); + updateDisplayState(); + // Reconnect settings change notifications m_view->connectExperimentSettingsWidgets(); } diff --git a/qt/scientific_interfaces/ISISReflectometry/GUI/Experiment/ExperimentPresenter.h b/qt/scientific_interfaces/ISISReflectometry/GUI/Experiment/ExperimentPresenter.h index d8516224d60..e55f7a6c76c 100644 --- a/qt/scientific_interfaces/ISISReflectometry/GUI/Experiment/ExperimentPresenter.h +++ b/qt/scientific_interfaces/ISISReflectometry/GUI/Experiment/ExperimentPresenter.h @@ -81,7 +81,11 @@ private: void showPerThetaTableErrors(PerThetaDefaultsTableValidationError const &errors); - void updateWidgetEnabledState() const; + void updateDisplayState(); + void updateSummationTypeEnabledState(); + void updatePolarizationCorrectionEnabledState(); + void updateFloodCorrectionEnabledState(); + bool isProcessing() const; bool isAutoreducing() const; diff --git a/qt/scientific_interfaces/ISISReflectometry/GUI/Instrument/InstrumentPresenter.cpp b/qt/scientific_interfaces/ISISReflectometry/GUI/Instrument/InstrumentPresenter.cpp index 0c57de2bc3b..3e7d1a2a8dc 100644 --- a/qt/scientific_interfaces/ISISReflectometry/GUI/Instrument/InstrumentPresenter.cpp +++ b/qt/scientific_interfaces/ISISReflectometry/GUI/Instrument/InstrumentPresenter.cpp @@ -176,6 +176,11 @@ void InstrumentPresenter::updateViewFromModel() { m_view->setDetectorCorrectionType( detectorCorrectionTypeToString(m_model.detectorCorrectionType())); + if (m_model.detectorCorrections().correctPositions()) + m_view->enableDetectorCorrectionType(); + else + m_view->disableDetectorCorrectionType(); + // Reconnect settings change notifications m_view->connectInstrumentSettingsWidgets(); } -- GitLab