From 1714539fae87b1f199db3ede084a3ac38d6b445a Mon Sep 17 00:00:00 2001 From: Gemma Guest <gemma.guest@stfc.ac.uk> Date: Mon, 1 Oct 2018 17:20:09 +0100 Subject: [PATCH] Make transmission overlap range optional The range is not set in the model if the user enters invalid values Re #22263 --- .../GUI/Experiment/ExperimentPresenter.cpp | 13 ++++++++----- .../GUI/Experiment/ExperimentPresenter.h | 2 +- .../GUI/Experiment/ExperimentPresenterFactory.h | 4 +--- .../ISISReflectometry/Reduction/Experiment.cpp | 6 ++---- .../ISISReflectometry/Reduction/Experiment.h | 7 +++---- 5 files changed, 15 insertions(+), 17 deletions(-) diff --git a/qt/scientific_interfaces/ISISReflectometry/GUI/Experiment/ExperimentPresenter.cpp b/qt/scientific_interfaces/ISISReflectometry/GUI/Experiment/ExperimentPresenter.cpp index 97584c917ed..682f8e9d68a 100644 --- a/qt/scientific_interfaces/ISISReflectometry/GUI/Experiment/ExperimentPresenter.cpp +++ b/qt/scientific_interfaces/ISISReflectometry/GUI/Experiment/ExperimentPresenter.cpp @@ -62,14 +62,17 @@ PolarizationCorrections ExperimentPresenter::polarizationCorrectionsFromView() { return PolarizationCorrections(cRho, cAlpha, cAp, cPp); } -RangeInLambda ExperimentPresenter::transmissionRunRangeFromView() { +boost::optional<RangeInLambda> +ExperimentPresenter::transmissionRunRangeFromView() { auto const range = RangeInLambda(m_view->getTransmissionStartOverlap(), m_view->getTransmissionEndOverlap()); - if (range.isValid()) + if (range.isValid()) { m_view->showTransmissionRangeValid(); - else - m_view->showTransmissionRangeInvalid(); - return range; + return range; + } + + m_view->showTransmissionRangeInvalid(); + return boost::none; } std::map<std::string, std::string> diff --git a/qt/scientific_interfaces/ISISReflectometry/GUI/Experiment/ExperimentPresenter.h b/qt/scientific_interfaces/ISISReflectometry/GUI/Experiment/ExperimentPresenter.h index b164fb94ec5..f7712b8e790 100644 --- a/qt/scientific_interfaces/ISISReflectometry/GUI/Experiment/ExperimentPresenter.h +++ b/qt/scientific_interfaces/ISISReflectometry/GUI/Experiment/ExperimentPresenter.h @@ -79,7 +79,7 @@ public: private: ExperimentValidationResult validateExperimentFromView(); PolarizationCorrections polarizationCorrectionsFromView(); - RangeInLambda transmissionRunRangeFromView(); + boost::optional<RangeInLambda> transmissionRunRangeFromView(); std::map<std::string, std::string> stitchParametersFromView(); ExperimentValidationResult updateModelFromView(); diff --git a/qt/scientific_interfaces/ISISReflectometry/GUI/Experiment/ExperimentPresenterFactory.h b/qt/scientific_interfaces/ISISReflectometry/GUI/Experiment/ExperimentPresenterFactory.h index 3ab051585f3..8ee7c1e1ed1 100644 --- a/qt/scientific_interfaces/ISISReflectometry/GUI/Experiment/ExperimentPresenterFactory.h +++ b/qt/scientific_interfaces/ISISReflectometry/GUI/Experiment/ExperimentPresenterFactory.h @@ -26,15 +26,13 @@ private: Experiment makeModel() { // TODO get defaults from algorithm auto polarizationCorrections = PolarizationCorrections(0.0, 0.0, 0.0, 0.0); - auto transmissionRunRange = RangeInLambda(0.0, 0.0); auto stitchParameters = std::map<std::string, std::string>(); auto perThetaDefaults = std::vector<PerThetaDefaults>( {PerThetaDefaults(boost::none, std::pair<std::string, std::string>(), boost::none, boost::none, ProcessingInstructions())}); return Experiment(AnalysisMode::PointDetector, ReductionType::Normal, SummationType::SumInLambda, - std::move(polarizationCorrections), - std::move(transmissionRunRange), + std::move(polarizationCorrections), boost::none, std::move(stitchParameters), std::move(perThetaDefaults)); } }; diff --git a/qt/scientific_interfaces/ISISReflectometry/Reduction/Experiment.cpp b/qt/scientific_interfaces/ISISReflectometry/Reduction/Experiment.cpp index 04ea1cc921b..810caca428c 100644 --- a/qt/scientific_interfaces/ISISReflectometry/Reduction/Experiment.cpp +++ b/qt/scientific_interfaces/ISISReflectometry/Reduction/Experiment.cpp @@ -8,7 +8,7 @@ namespace CustomInterfaces { Experiment::Experiment(AnalysisMode analysisMode, ReductionType reductionType, SummationType summationType, PolarizationCorrections polarizationCorrections, - RangeInLambda transmissionRunRange, + boost::optional<RangeInLambda> transmissionRunRange, std::map<std::string, std::string> stitchParameters, std::vector<PerThetaDefaults> perThetaDefaults) : m_analysisMode(analysisMode), m_reductionType(reductionType), @@ -25,9 +25,7 @@ PolarizationCorrections const &Experiment::polarizationCorrections() const { return m_polarizationCorrections; } -bool Experiment::isValid() const { return m_transmissionRunRange.isValid(); } - -RangeInLambda const &Experiment::transmissionRunRange() const { +boost::optional<RangeInLambda> Experiment::transmissionRunRange() const { return m_transmissionRunRange; } diff --git a/qt/scientific_interfaces/ISISReflectometry/Reduction/Experiment.h b/qt/scientific_interfaces/ISISReflectometry/Reduction/Experiment.h index 16b969ff2b9..e2a5380ea29 100644 --- a/qt/scientific_interfaces/ISISReflectometry/Reduction/Experiment.h +++ b/qt/scientific_interfaces/ISISReflectometry/Reduction/Experiment.h @@ -41,16 +41,15 @@ public: Experiment(AnalysisMode analysisMode, ReductionType reductionType, SummationType summationType, PolarizationCorrections polarizationCorrections, - RangeInLambda transmissionRunRange, + boost::optional<RangeInLambda> transmissionRunRange, std::map<std::string, std::string> stitchParameters, std::vector<PerThetaDefaults> perThetaDefaults); - bool isValid() const; AnalysisMode analysisMode() const; ReductionType reductionType() const; SummationType summationType() const; PolarizationCorrections const &polarizationCorrections() const; - RangeInLambda const &transmissionRunRange() const; + boost::optional<RangeInLambda> transmissionRunRange() const; std::map<std::string, std::string> stitchParameters() const; std::vector<PerThetaDefaults> const &perThetaDefaults() const; @@ -63,7 +62,7 @@ private: SummationType m_summationType; PolarizationCorrections m_polarizationCorrections; - RangeInLambda m_transmissionRunRange; + boost::optional<RangeInLambda> m_transmissionRunRange; std::map<std::string, std::string> m_stitchParameters; std::vector<PerThetaDefaults> m_perThetaDefaults; -- GitLab