diff --git a/qt/scientific_interfaces/ISISReflectometry/GUI/Batch/BatchPresenter.cpp b/qt/scientific_interfaces/ISISReflectometry/GUI/Batch/BatchPresenter.cpp index 3f890e0a8f67cbcb219440083981c26e5663536f..3f690ee3499d2ada796929610c4a2b1b25e04683 100644 --- a/qt/scientific_interfaces/ISISReflectometry/GUI/Batch/BatchPresenter.cpp +++ b/qt/scientific_interfaces/ISISReflectometry/GUI/Batch/BatchPresenter.cpp @@ -36,12 +36,14 @@ Mantid::Kernel::Logger g_log("Reflectometry GUI"); * @param savePresenter :: [input] A pointer to the 'Save ASCII' tab presenter */ BatchPresenter::BatchPresenter( - IBatchView *view, std::unique_ptr<IRunsPresenter> runsPresenter, + IBatchView *view, Batch model, + std::unique_ptr<IRunsPresenter> runsPresenter, std::unique_ptr<IEventPresenter> eventPresenter, std::unique_ptr<IExperimentPresenter> experimentPresenter, std::unique_ptr<IInstrumentPresenter> instrumentPresenter, std::unique_ptr<ISavePresenter> savePresenter) - : /*m_view(view),*/ m_runsPresenter(std::move(runsPresenter)), + : /*m_view(view),*/ m_model(std::move(model)), + m_runsPresenter(std::move(runsPresenter)), m_eventPresenter(std::move(eventPresenter)), m_experimentPresenter(std::move(experimentPresenter)), m_instrumentPresenter(std::move(instrumentPresenter)), diff --git a/qt/scientific_interfaces/ISISReflectometry/GUI/Batch/BatchPresenter.h b/qt/scientific_interfaces/ISISReflectometry/GUI/Batch/BatchPresenter.h index 69f6a364f3a6dc107414cee91eaef8592f02977d..6d6517d10205f7dde19ba2dd21182c91b023e1c7 100644 --- a/qt/scientific_interfaces/ISISReflectometry/GUI/Batch/BatchPresenter.h +++ b/qt/scientific_interfaces/ISISReflectometry/GUI/Batch/BatchPresenter.h @@ -15,6 +15,7 @@ #include "GUI/Save/ISavePresenter.h" #include "IBatchPresenter.h" #include "IBatchView.h" +#include "Reduction/Batch.h" #include <memory> namespace MantidQt { @@ -24,15 +25,15 @@ class IBatchView; /** @class BatchPresenter -BatchPresenter is the concrete main window presenter implementing the -functionality defined by the interface IBatchPresenter. + BatchPresenter is the concrete main window presenter implementing the + functionality defined by the interface IBatchPresenter. */ class MANTIDQT_ISISREFLECTOMETRY_DLL BatchPresenter : public IBatchPresenter, public BatchViewSubscriber { public: /// Constructor - BatchPresenter(IBatchView *view, + BatchPresenter(IBatchView *view, Batch model, std::unique_ptr<IRunsPresenter> runsPresenter, std::unique_ptr<IEventPresenter> eventPresenter, std::unique_ptr<IExperimentPresenter> experimentPresenter, @@ -74,20 +75,16 @@ private: void autoreductionCompleted(); void instrumentChanged(const std::string &instName); void settingsChanged(); - // The view we are handling (currently unused) + + Batch m_model; + // The view is currently unused /*IBatchView *m_view;*/ - /// The presenter of tab 'Runs' std::unique_ptr<IRunsPresenter> m_runsPresenter; - /// The presenter of tab 'Event Handling' std::unique_ptr<IEventPresenter> m_eventPresenter; - /// The presenter of tab 'Settings' std::unique_ptr<IExperimentPresenter> m_experimentPresenter; std::unique_ptr<IInstrumentPresenter> m_instrumentPresenter; - /// The presenter of tab 'Save ASCII' std::unique_ptr<ISavePresenter> m_savePresenter; - /// True if currently reducing runs bool m_isProcessing; - /// True if autoprocessing is currently running (i.e. polling for new runs) bool m_isAutoreducing; }; } // namespace CustomInterfaces diff --git a/qt/scientific_interfaces/ISISReflectometry/GUI/Batch/BatchPresenterFactory.h b/qt/scientific_interfaces/ISISReflectometry/GUI/Batch/BatchPresenterFactory.h index b5624136926a2b8aeb82d358a30703f957be11f4..84f9bc4c1f8fca046145900cd9b4d22b7b59828d 100644 --- a/qt/scientific_interfaces/ISISReflectometry/GUI/Batch/BatchPresenterFactory.h +++ b/qt/scientific_interfaces/ISISReflectometry/GUI/Batch/BatchPresenterFactory.h @@ -35,6 +35,7 @@ public: m_savePresenterFactory(std::move(savePresenterFactory)) {} std::unique_ptr<IBatchPresenter> make(IBatchView *view) { + /// TODO: inject models containing defaults from the reduction algorithm auto runsPresenter = m_runsPresenterFactory.make(view->runs()); auto eventPresenter = m_eventPresenterFactory.make(view->eventHandling()); auto experimentPresenter = @@ -43,10 +44,14 @@ public: m_instrumentPresenterFactory.make(view->instrument()); auto savePresenter = m_savePresenterFactory.make(view->save()); + auto model = Batch( + experimentPresenter->experiment(), instrumentPresenter->instrument(), + runsPresenter->reductionJobs(), eventPresenter->slicing()); + return std::make_unique<BatchPresenter>( - view, std::move(runsPresenter), std::move(eventPresenter), - std::move(experimentPresenter), std::move(instrumentPresenter), - std::move(savePresenter)); + view, std::move(model), std::move(runsPresenter), + std::move(eventPresenter), std::move(experimentPresenter), + std::move(instrumentPresenter), std::move(savePresenter)); } private: diff --git a/qt/scientific_interfaces/ISISReflectometry/GUI/Event/EventPresenter.h b/qt/scientific_interfaces/ISISReflectometry/GUI/Event/EventPresenter.h index 085d7b8da76d49374db53dc2ae2d9bb9c8f3282a..be2cc99bd37184985db96a9e087212926bfb4bcb 100644 --- a/qt/scientific_interfaces/ISISReflectometry/GUI/Event/EventPresenter.h +++ b/qt/scientific_interfaces/ISISReflectometry/GUI/Event/EventPresenter.h @@ -41,7 +41,7 @@ public: notifyLogSliceBreakpointsChanged(std::string logValueBreakpoints) override; void notifyLogBlockNameChanged(std::string blockName) override; - Slicing const &slicing() const; + Slicing const &slicing() const override; private: IBatchPresenter *m_mainPresenter; diff --git a/qt/scientific_interfaces/ISISReflectometry/GUI/Event/IEventPresenter.h b/qt/scientific_interfaces/ISISReflectometry/GUI/Event/IEventPresenter.h index 69283e0cf51e5677de25cc4ed7bbee8a9dd6e066..0a9e6e4c4d2b4e455c46542bf742eeb30d556792 100644 --- a/qt/scientific_interfaces/ISISReflectometry/GUI/Event/IEventPresenter.h +++ b/qt/scientific_interfaces/ISISReflectometry/GUI/Event/IEventPresenter.h @@ -8,6 +8,7 @@ #define MANTID_ISISREFLECTOMETRY_IREFLEVENTPRESENTER_H #include "GUI/Batch/IBatchPresenter.h" +#include "Reduction/Slicing.h" #include <string> namespace MantidQt { @@ -27,6 +28,7 @@ public: virtual void reductionResumed() = 0; virtual void autoreductionPaused() = 0; virtual void autoreductionResumed() = 0; + virtual Slicing const &slicing() const = 0; }; } // namespace CustomInterfaces } // namespace MantidQt diff --git a/qt/scientific_interfaces/ISISReflectometry/GUI/Experiment/ExperimentPresenter.h b/qt/scientific_interfaces/ISISReflectometry/GUI/Experiment/ExperimentPresenter.h index 79c7a59df771b95e4a69d3ecc2c501dc89651d5d..ee3d16cd36aade8c8b530f09fb4e815dbe09a5c3 100644 --- a/qt/scientific_interfaces/ISISReflectometry/GUI/Experiment/ExperimentPresenter.h +++ b/qt/scientific_interfaces/ISISReflectometry/GUI/Experiment/ExperimentPresenter.h @@ -45,12 +45,11 @@ class MANTIDQT_ISISREFLECTOMETRY_DLL ExperimentPresenter : public ExperimentViewSubscriber, public IExperimentPresenter { public: - // TODO Inject the Experiment model into the constructor. ExperimentPresenter(IExperimentView *view, Experiment experiment, double defaultsThetaTolerance); void acceptMainPresenter(IBatchPresenter *mainPresenter) override; - Experiment const &experiment() const; + Experiment const &experiment() const override; void notifySettingsChanged() override; void notifySummationTypeChanged() override; diff --git a/qt/scientific_interfaces/ISISReflectometry/GUI/Experiment/ExperimentPresenterFactory.h b/qt/scientific_interfaces/ISISReflectometry/GUI/Experiment/ExperimentPresenterFactory.h index f8027c6199b367a315a0bc3433b2e004cd17cc96..fa1ff6c068fa8ff81436507b3f8d237fbaa7b057 100644 --- a/qt/scientific_interfaces/ISISReflectometry/GUI/Experiment/ExperimentPresenterFactory.h +++ b/qt/scientific_interfaces/ISISReflectometry/GUI/Experiment/ExperimentPresenterFactory.h @@ -30,7 +30,7 @@ private: double m_thetaTolerance; Experiment makeModel() { - // TODO get defaults from algorithm + // TODO inject model instead of creating it here auto polarizationCorrections = PolarizationCorrections(PolarizationCorrectionType::None); auto floodCorrections(FloodCorrectionType::Workspace); diff --git a/qt/scientific_interfaces/ISISReflectometry/GUI/Experiment/IExperimentPresenter.h b/qt/scientific_interfaces/ISISReflectometry/GUI/Experiment/IExperimentPresenter.h index 112da3da432528a49bc65ad1e65d198f4f2e8219..8b4a8f6db2ebdf40ca14d2051cd9ed653adbb31e 100644 --- a/qt/scientific_interfaces/ISISReflectometry/GUI/Experiment/IExperimentPresenter.h +++ b/qt/scientific_interfaces/ISISReflectometry/GUI/Experiment/IExperimentPresenter.h @@ -8,6 +8,7 @@ #define MANTID_ISISREFLECTOMETRY_IEXPERIMENTPRESENTER_H #include "GUI/Batch/IBatchPresenter.h" +#include "Reduction/Experiment.h" #include <string> namespace MantidQt { @@ -17,6 +18,7 @@ public: virtual ~IExperimentPresenter() = default; virtual void acceptMainPresenter(IBatchPresenter *mainPresenter) = 0; + virtual Experiment const &experiment() const = 0; virtual void reductionPaused() = 0; virtual void reductionResumed() = 0; virtual void autoreductionPaused() = 0; diff --git a/qt/scientific_interfaces/ISISReflectometry/GUI/Instrument/IInstrumentPresenter.h b/qt/scientific_interfaces/ISISReflectometry/GUI/Instrument/IInstrumentPresenter.h index b8d90e201580c9e6d52b7eb40da6a5f3c48b767d..9a36b328c36f94082b8ff6bc265f09b207c92169 100644 --- a/qt/scientific_interfaces/ISISReflectometry/GUI/Instrument/IInstrumentPresenter.h +++ b/qt/scientific_interfaces/ISISReflectometry/GUI/Instrument/IInstrumentPresenter.h @@ -7,6 +7,7 @@ #ifndef MANTID_ISISREFLECTOMETRY_IINSTRUMENTPRESENTER_H #define MANTID_ISISREFLECTOMETRY_IINSTRUMENTPRESENTER_H +#include "Reduction/Instrument.h" #include <string> namespace MantidQt { @@ -24,6 +25,7 @@ public: virtual ~IInstrumentPresenter() = default; virtual void acceptMainPresenter(IBatchPresenter *mainPresenter) = 0; + virtual Instrument const &instrument() const = 0; virtual void reductionPaused() = 0; virtual void reductionResumed() = 0; virtual void autoreductionPaused() = 0; diff --git a/qt/scientific_interfaces/ISISReflectometry/GUI/Instrument/InstrumentPresenter.h b/qt/scientific_interfaces/ISISReflectometry/GUI/Instrument/InstrumentPresenter.h index babbd93b413c21642b4e34cda8f9fa28c689816c..b9bf7e4e25eacff31ecb931e2ba433e1e626c43c 100644 --- a/qt/scientific_interfaces/ISISReflectometry/GUI/Instrument/InstrumentPresenter.h +++ b/qt/scientific_interfaces/ISISReflectometry/GUI/Instrument/InstrumentPresenter.h @@ -25,9 +25,8 @@ class MANTIDQT_ISISREFLECTOMETRY_DLL InstrumentPresenter : public InstrumentViewSubscriber, public IInstrumentPresenter { public: - // TODO Inject the Instrument model into the constructor. InstrumentPresenter(IInstrumentView *view, Instrument instrument); - Instrument const &instrument() const; + Instrument const &instrument() const override; // IInstrumentPresenver overrides void acceptMainPresenter(IBatchPresenter *mainPresenter) override; diff --git a/qt/scientific_interfaces/ISISReflectometry/GUI/Instrument/InstrumentPresenterFactory.h b/qt/scientific_interfaces/ISISReflectometry/GUI/Instrument/InstrumentPresenterFactory.h index 89274e503ffd298b8c0b8b10c4155264954063e4..376615d7ba9901de6697509733e2d92f3194b2fd 100644 --- a/qt/scientific_interfaces/ISISReflectometry/GUI/Instrument/InstrumentPresenterFactory.h +++ b/qt/scientific_interfaces/ISISReflectometry/GUI/Instrument/InstrumentPresenterFactory.h @@ -25,7 +25,7 @@ public: } private: - // TODO get defaults from algorithm + // TODO inject model rather than creating it here Instrument makeModel() { auto wavelengthRange = RangeInLambda(0.0, 0.0); auto monitorCorrections = MonitorCorrections( diff --git a/qt/scientific_interfaces/ISISReflectometry/GUI/MainWindow/MainWindowPresenter.cpp b/qt/scientific_interfaces/ISISReflectometry/GUI/MainWindow/MainWindowPresenter.cpp index b53e5a7816b5354be3f4af37c0d40953164fde3c..b8d5fae2ab72dc210eb1013d2fbde00fd95acf00 100644 --- a/qt/scientific_interfaces/ISISReflectometry/GUI/MainWindow/MainWindowPresenter.cpp +++ b/qt/scientific_interfaces/ISISReflectometry/GUI/MainWindow/MainWindowPresenter.cpp @@ -8,6 +8,7 @@ #include "GUI/Runs/IRunsPresenter.h" #include "IMainWindowView.h" #include "MantidQtWidgets/Common/HelpWindow.h" +#include "Reduction/Batch.h" using namespace MantidQt::MantidWidgets::DataProcessor; @@ -40,7 +41,7 @@ void MainWindowPresenter::notifyCloseBatchRequested(int batchIndex) { } /** -Used by the view to tell the presenter something has changed + Used by the view to tell the presenter something has changed */ void MainWindowPresenter::notifyHelpPressed() { showHelp(); } @@ -58,10 +59,10 @@ void MainWindowPresenter::showHelp() { } /** -Tells the view to show the user the dialog for an algorithm -* @param pythonCode : [input] The algorithm as python code -* @return : Result of the execution -*/ + Tells the view to show the user the dialog for an algorithm + * @param pythonCode : [input] The algorithm as python code + * @return : Result of the execution + */ std::string MainWindowPresenter::runPythonAlgorithm(const std::string &pythonCode) { return m_view->runPythonAlgorithm(pythonCode); diff --git a/qt/scientific_interfaces/ISISReflectometry/GUI/Runs/IRunsPresenter.h b/qt/scientific_interfaces/ISISReflectometry/GUI/Runs/IRunsPresenter.h index e25f6c5ebfe629a25ed766225a04afea607857ba..25190b3fc6fe3efe50058b858f8e890ded918435 100644 --- a/qt/scientific_interfaces/ISISReflectometry/GUI/Runs/IRunsPresenter.h +++ b/qt/scientific_interfaces/ISISReflectometry/GUI/Runs/IRunsPresenter.h @@ -7,6 +7,7 @@ #ifndef MANTID_ISISREFLECTOMETRY_IREFLRUNSPRESENTER_H #define MANTID_ISISREFLECTOMETRY_IREFLRUNSPRESENTER_H +#include "Reduction/ReductionJobs.h" #include <string> namespace MantidQt { @@ -23,6 +24,7 @@ class IRunsPresenter { public: virtual ~IRunsPresenter() = default; virtual void acceptMainPresenter(IBatchPresenter *mainPresenter) = 0; + virtual ReductionJobs const &reductionJobs() const = 0; virtual void notifyInstrumentChanged(std::string const &instrumentName) = 0; virtual void notifyReductionResumed() = 0; diff --git a/qt/scientific_interfaces/ISISReflectometry/GUI/Runs/RunsPresenter.cpp b/qt/scientific_interfaces/ISISReflectometry/GUI/Runs/RunsPresenter.cpp index 8dfae517b7c88bf0f55cbbff8cca3da5f2c7ceb4..cbf3d313716761bd68b6629acce77c1c78433d50 100644 --- a/qt/scientific_interfaces/ISISReflectometry/GUI/Runs/RunsPresenter.cpp +++ b/qt/scientific_interfaces/ISISReflectometry/GUI/Runs/RunsPresenter.cpp @@ -114,6 +114,10 @@ void RunsPresenter::acceptMainPresenter(IBatchPresenter *mainPresenter) { // presenter. } +ReductionJobs const &RunsPresenter::reductionJobs() const { + return tablePresenter()->reductionJobs(); +} + /** Used by the view to tell the presenter something has changed */ @@ -428,7 +432,7 @@ void RunsPresenter::transfer(const std::set<int> &rowsToTransfer, UNUSED_ARG(matchType); if (validateRowsToTransfer(rowsToTransfer)) { auto progress = setupProgressBar(rowsToTransfer); - auto jobs = tablePresenter()->reductionJobs(); + auto jobs = reductionJobs(); for (auto rowIndex : rowsToTransfer) { auto &result = m_searchModel->getRowData(rowIndex); diff --git a/qt/scientific_interfaces/ISISReflectometry/GUI/Runs/RunsPresenter.h b/qt/scientific_interfaces/ISISReflectometry/GUI/Runs/RunsPresenter.h index 815ca297c3a52fbaf899e831b396799e90e4d64e..2d6ad4cf739cc079b81f8518573761a2d20d1200 100644 --- a/qt/scientific_interfaces/ISISReflectometry/GUI/Runs/RunsPresenter.h +++ b/qt/scientific_interfaces/ISISReflectometry/GUI/Runs/RunsPresenter.h @@ -69,6 +69,7 @@ public: // IRunsPresenter overrides void acceptMainPresenter(IBatchPresenter *mainPresenter) override; + ReductionJobs const &reductionJobs() const override; bool isProcessing() const override; bool isAutoreducing() const override; void notifyInstrumentChanged(std::string const &instrumentName) override; diff --git a/qt/scientific_interfaces/ISISReflectometry/Reduction/Batch.cpp b/qt/scientific_interfaces/ISISReflectometry/Reduction/Batch.cpp new file mode 100644 index 0000000000000000000000000000000000000000..9a5f198e1877d4f98630217b208095c82d3d3fa1 --- /dev/null +++ b/qt/scientific_interfaces/ISISReflectometry/Reduction/Batch.cpp @@ -0,0 +1,24 @@ +// Mantid Repository : https://github.com/mantidproject/mantid +// +// Copyright © 2018 ISIS Rutherford Appleton Laboratory UKRI, +// NScD Oak Ridge National Laboratory, European Spallation Source +// & Institut Laue - Langevin +// SPDX - License - Identifier: GPL - 3.0 + +#include "Batch.h" +namespace MantidQt { +namespace CustomInterfaces { + +Batch::Batch(Experiment const &experiment, Instrument const &instrument, + ReductionJobs const &reductionJobs, Slicing const &slicing) + : m_experiment(experiment), m_instrument(instrument), + m_reductionJobs(reductionJobs), m_slicing(slicing) {} + +Experiment const &Batch::experiment() const { return m_experiment; } + +Instrument const &Batch::instrument() const { return m_instrument; } + +ReductionJobs const &Batch::reductionJobs() const { return m_reductionJobs; } + +Slicing const &Batch::slicing() const { return m_slicing; } +} // namespace CustomInterfaces +} // namespace MantidQt diff --git a/qt/scientific_interfaces/ISISReflectometry/Reduction/Batch.h b/qt/scientific_interfaces/ISISReflectometry/Reduction/Batch.h new file mode 100644 index 0000000000000000000000000000000000000000..b9ae3f7982296f3312f103fcca17397d72414c8f --- /dev/null +++ b/qt/scientific_interfaces/ISISReflectometry/Reduction/Batch.h @@ -0,0 +1,37 @@ +// Mantid Repository : https://github.com/mantidproject/mantid +// +// Copyright © 2018 ISIS Rutherford Appleton Laboratory UKRI, +// NScD Oak Ridge National Laboratory, European Spallation Source +// & Institut Laue - Langevin +// SPDX - License - Identifier: GPL - 3.0 + +#ifndef MANTID_CUSTOMINTERFACES_BATCH_H_ +#define MANTID_CUSTOMINTERFACES_BATCH_H_ + +#include "Common/DllConfig.h" +#include "Experiment.h" +#include "Instrument.h" +#include "ReductionJobs.h" +#include "Slicing.h" + +namespace MantidQt { +namespace CustomInterfaces { + +class MANTIDQT_ISISREFLECTOMETRY_DLL Batch { +public: + Batch(Experiment const &experiment, Instrument const &instrument, + ReductionJobs const &reductionJobs, Slicing const &slicing); + + Experiment const &experiment() const; + Instrument const &instrument() const; + ReductionJobs const &reductionJobs() const; + Slicing const &slicing() const; + +private: + Experiment const &m_experiment; + Instrument const &m_instrument; + ReductionJobs const &m_reductionJobs; + Slicing const &m_slicing; +}; +} // namespace CustomInterfaces +} // namespace MantidQt +#endif // MANTID_CUSTOMINTERFACES_BATCH_H_ diff --git a/qt/scientific_interfaces/ISISReflectometry/Reduction/CMakeLists.txt b/qt/scientific_interfaces/ISISReflectometry/Reduction/CMakeLists.txt index 19a7f4d958b5c9f67c9f2ad8629a992342fff08f..9374c14fa527f90512e3559d10d689bbb6ccc02e 100644 --- a/qt/scientific_interfaces/ISISReflectometry/Reduction/CMakeLists.txt +++ b/qt/scientific_interfaces/ISISReflectometry/Reduction/CMakeLists.txt @@ -8,6 +8,7 @@ set ( REDUCTION_SRC_FILES Slicing.cpp ParseReflectometryStrings.cpp + Batch.cpp DetectorCorrections.cpp Experiment.cpp FloodCorrections.cpp @@ -34,6 +35,7 @@ set ( REDUCTION_INC_FILES ValidatePerThetaDefaults.h AnalysisMode.h + Batch.h DetectorCorrections.h Experiment.h FloodCorrections.h