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

Add an MVP model for the Batch presenter

This contains the reduction configuration for a batch.
It currently uses default models created by the presenter factories, but eventually we will inject the models from the main window presenter containing defaults based on the reduction algorithm
parent 58e35638
No related branches found
No related tags found
No related merge requests found
Showing
with 107 additions and 28 deletions
......@@ -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)),
......
......@@ -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
......
......@@ -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:
......
......@@ -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;
......
......@@ -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
......
......@@ -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;
......
......@@ -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);
......
......@@ -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;
......
......@@ -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;
......
......@@ -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;
......
......@@ -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(
......
......@@ -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);
......
......@@ -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;
......
......@@ -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);
......
......@@ -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;
......
// Mantid Repository : https://github.com/mantidproject/mantid
//
// Copyright &copy; 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
// Mantid Repository : https://github.com/mantidproject/mantid
//
// Copyright &copy; 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_
......@@ -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
......
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