Skip to content
Snippets Groups Projects
Commit d25e1e09 authored by Gemma Guest's avatar Gemma Guest
Browse files

Correction type enabled/disabled according to check box

Detector correction type is only applicable if CorrectDetectors is checked, so disable it if it's not checked

Re #22263
parent aae34f55
No related merge requests found
......@@ -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
......
......@@ -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);
}
......
......@@ -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);
}
......
......@@ -66,6 +66,8 @@ public:
void disableAll() override;
void enableAll() override;
void enableDetectorCorrectionType() override;
void disableDetectorCorrectionType() override;
public slots:
void onSettingsChanged();
......
......@@ -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())
......
......@@ -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
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment