diff --git a/qt/scientific_interfaces/ISISReflectometry/GUI/Instrument/IInstrumentView.h b/qt/scientific_interfaces/ISISReflectometry/GUI/Instrument/IInstrumentView.h index 4b915d2c19ae647f8cb25df12fd0591964310787..ad71e20a225b6f1e293fbe767c01f112be02a5c0 100644 --- a/qt/scientific_interfaces/ISISReflectometry/GUI/Instrument/IInstrumentView.h +++ b/qt/scientific_interfaces/ISISReflectometry/GUI/Instrument/IInstrumentView.h @@ -70,6 +70,8 @@ public: virtual void disableAll() = 0; virtual void enableAll() = 0; + virtual void enableDetectorCorrectionType() = 0; + virtual void disableDetectorCorrectionType() = 0; }; } // namespace CustomInterfaces } // namespace MantidQt diff --git a/qt/scientific_interfaces/ISISReflectometry/GUI/Instrument/InstrumentPresenter.cpp b/qt/scientific_interfaces/ISISReflectometry/GUI/Instrument/InstrumentPresenter.cpp index cbee08b980857af75c7b3fca381035bd61e5b790..340c4750605c269f6ec52ff21488d6c084d72c75 100644 --- a/qt/scientific_interfaces/ISISReflectometry/GUI/Instrument/InstrumentPresenter.cpp +++ b/qt/scientific_interfaces/ISISReflectometry/GUI/Instrument/InstrumentPresenter.cpp @@ -87,6 +87,10 @@ DetectorCorrectionType InstrumentPresenter::detectorCorrectionTypeFromView() { DetectorCorrections InstrumentPresenter::detectorCorrectionsFromView() { auto const correctPositions = m_view->getCorrectDetectors(); auto const correctionType = detectorCorrectionTypeFromView(); + if (correctPositions) + m_view->enableDetectorCorrectionType(); + else + m_view->disableDetectorCorrectionType(); return DetectorCorrections(correctPositions, correctionType); } diff --git a/qt/scientific_interfaces/ISISReflectometry/GUI/Instrument/InstrumentView.cpp b/qt/scientific_interfaces/ISISReflectometry/GUI/Instrument/InstrumentView.cpp index 63feb810743b94c8bd120fd79cc521f13945e17b..d860df330504d9a39e52259d30033d7f44d1f007 100644 --- a/qt/scientific_interfaces/ISISReflectometry/GUI/Instrument/InstrumentView.cpp +++ b/qt/scientific_interfaces/ISISReflectometry/GUI/Instrument/InstrumentView.cpp @@ -90,6 +90,14 @@ void InstrumentView::disableAll() { m_ui.instSettingsGroup->setEnabled(false); } void InstrumentView::enableAll() { m_ui.instSettingsGroup->setEnabled(true); } +void InstrumentView::enableDetectorCorrectionType() { + m_ui.detectorCorrectionTypeComboBox->setEnabled(true); +} + +void InstrumentView::disableDetectorCorrectionType() { + m_ui.detectorCorrectionTypeComboBox->setEnabled(false); +} + void InstrumentView::registerSettingsWidgets(Mantid::API::IAlgorithm_sptr alg) { registerInstrumentSettingsWidgets(alg); } diff --git a/qt/scientific_interfaces/ISISReflectometry/GUI/Instrument/InstrumentView.h b/qt/scientific_interfaces/ISISReflectometry/GUI/Instrument/InstrumentView.h index 1aac787d29a0ed9263406c8dee268565574f5215..3027d84bc0e9e0f2cb3dfd58d38bb942478e8757 100644 --- a/qt/scientific_interfaces/ISISReflectometry/GUI/Instrument/InstrumentView.h +++ b/qt/scientific_interfaces/ISISReflectometry/GUI/Instrument/InstrumentView.h @@ -66,6 +66,8 @@ public: void disableAll() override; void enableAll() override; + void enableDetectorCorrectionType() override; + void disableDetectorCorrectionType() override; public slots: void onSettingsChanged(); diff --git a/qt/scientific_interfaces/test/ISISReflectometry/Instrument/InstrumentPresenterTest.h b/qt/scientific_interfaces/test/ISISReflectometry/Instrument/InstrumentPresenterTest.h index ea0fdf334e9e4fffe63c9591cadfeded9fe17022..07b372641981efbb8d1f16f120fc70007b4737b4 100644 --- a/qt/scientific_interfaces/test/ISISReflectometry/Instrument/InstrumentPresenterTest.h +++ b/qt/scientific_interfaces/test/ISISReflectometry/Instrument/InstrumentPresenterTest.h @@ -137,7 +137,7 @@ public: runTestForValidMonitorBackgroundRange(range, boost::none); } - void testCorrectDetectorsToggled() { + void testCorrectDetectorsToggledUpdatesModel() { auto presenter = makePresenter(); auto const correctDetectors = !presenter.instrument().correctDetectors(); @@ -150,7 +150,27 @@ public: verifyAndClear(); } - void testSetDetectorCorrectionType() { + void testEnablingCorrectDetectorsEnablesCorrectionType() { + auto presenter = makePresenter(); + + EXPECT_CALL(m_view, getCorrectDetectors()).WillOnce(Return(true)); + EXPECT_CALL(m_view, enableDetectorCorrectionType()).Times(1); + presenter.notifySettingsChanged(); + + verifyAndClear(); + } + + void testDiablingCorrectDetectorsDisablesCorrectionType() { + auto presenter = makePresenter(); + + EXPECT_CALL(m_view, getCorrectDetectors()).WillOnce(Return(false)); + EXPECT_CALL(m_view, disableDetectorCorrectionType()).Times(1); + presenter.notifySettingsChanged(); + + verifyAndClear(); + } + + void testSetDetectorCorrectionTypeUpdatesModel() { auto presenter = makePresenter(); EXPECT_CALL(m_view, getDetectorCorrectionType()) diff --git a/qt/scientific_interfaces/test/ISISReflectometry/Instrument/MockInstrumentView.h b/qt/scientific_interfaces/test/ISISReflectometry/Instrument/MockInstrumentView.h index 631914875a709136d881c0e70a0e2fd63ad552cd..5e3956a8236fcbe9eb5e911f74e3f2183b21fe1d 100644 --- a/qt/scientific_interfaces/test/ISISReflectometry/Instrument/MockInstrumentView.h +++ b/qt/scientific_interfaces/test/ISISReflectometry/Instrument/MockInstrumentView.h @@ -28,6 +28,8 @@ public: MOCK_CONST_METHOD0(getDetectorCorrectionType, std::string()); MOCK_METHOD0(disableAll, void()); MOCK_METHOD0(enableAll, void()); + MOCK_METHOD0(enableDetectorCorrectionType, void()); + MOCK_METHOD0(disableDetectorCorrectionType, void()); }; } // namespace CustomInterfaces } // namespace MantidQt