Skip to content
Snippets Groups Projects
Commit 0db8ae22 authored by Pranav Bahuguna's avatar Pranav Bahuguna
Browse files

Re #18227 Added functions to access number of time slices

parent 70334537
No related branches found
No related tags found
No related merge requests found
Showing
with 111 additions and 13 deletions
......@@ -37,6 +37,8 @@ Code Documentation is available at: <http://doxygen.mantidproject.org>
class IReflEventPresenter {
public:
virtual ~IReflEventPresenter(){};
/// Time-slicing options
virtual std::string getTimeSlicingOptions() const = 0;
};
}
}
......
......@@ -35,6 +35,8 @@ Code Documentation is available at: <http://doxygen.mantidproject.org>
class IReflEventTabPresenter {
public:
virtual ~IReflEventTabPresenter(){};
/// Time-slicing
virtual std::string getTimeSlicingOptions(int group) const = 0;
};
}
}
......
......@@ -44,6 +44,8 @@ public:
virtual ~IReflEventView(){};
/// Returns the presenter managing this view
virtual IReflEventPresenter *getPresenter() const = 0;
virtual std::string getNumTimeSlices() const = 0;
};
}
}
......
......@@ -44,6 +44,8 @@ public:
virtual std::string getReductionOptions(int group) const = 0;
/// Post-processing
virtual std::string getStitchOptions(int group) const = 0;
/// Time-slicing
virtual std::string getTimeSlicingOptions(int group) const = 0;
/// Dialog/Prompt methods
virtual std::string askUserString(const std::string &prompt,
const std::string &title,
......
......@@ -45,6 +45,9 @@ public:
/// Returns the presenter managing this view
IReflEventPresenter *getPresenter() const override;
/// Returns the number of time slices
std::string getNumTimeSlices() const override;
private:
/// Initialise the interface
void initLayout();
......
......@@ -44,6 +44,9 @@ public:
/// Destructor
~ReflEventPresenter() override;
/// Returns global options for time slicing
std::string getTimeSlicingOptions() const override;
private:
/// The view we are managing
IReflEventView *m_view;
......
......@@ -45,6 +45,9 @@ public:
/// Destructor
~ReflEventTabPresenter() override;
/// Returns global options for time-slicing
std::string getTimeSlicingOptions(int group) const override;
private:
/// The presenters for each group as a vector
std::vector<IReflEventPresenter *> m_eventPresenters;
......
......@@ -9,6 +9,7 @@ namespace CustomInterfaces {
class IReflMainWindowView;
class IReflRunsTabPresenter;
class IReflEventTabPresenter;
class IReflSettingsTabPresenter;
class IReflSaveTabPresenter;
......@@ -44,6 +45,7 @@ public:
/// Constructor
ReflMainWindowPresenter(IReflMainWindowView *view,
IReflRunsTabPresenter *runsPresenter,
IReflEventTabPresenter *eventPresenter,
IReflSettingsTabPresenter *settingsPresenter,
IReflSaveTabPresenter *savePresenter);
/// Destructor
......@@ -54,6 +56,8 @@ public:
std::string getReductionOptions(int group) const override;
/// Returns global options for 'Stitch1DMany'
std::string getStitchOptions(int group) const override;
/// Returns global options for time-slicing
std::string getTimeSlicingOptions(int group) const override;
/// Dialog/Prompt methods
std::string askUserString(const std::string &prompt, const std::string &title,
......@@ -70,12 +74,16 @@ public:
void setInstrumentName(const std::string &instName) const override;
private:
/// Check for null pointer
void checkPtrValid(IReflSettingsTabPresenter *pointer) const;
/// Check for Settings Tab null pointer
void checkSettingsPtrValid(IReflSettingsTabPresenter *pointer) const;
/// Check for Event Handling Tab null pointer
void checkEventPtrValid(IReflEventTabPresenter *pointer) const;
/// The view we are handling
IReflMainWindowView *m_view;
/// The presenter of tab 'Runs'
IReflRunsTabPresenter *m_runsPresenter;
/// The presenter of tab 'Event Handling'
IReflEventTabPresenter *m_eventPresenter;
/// The presenter of tab 'Settings'
IReflSettingsTabPresenter *m_settingsPresenter;
/// The presenter of tab 'Save ASCII'
......
......@@ -77,6 +77,7 @@ public:
std::map<std::string, std::string> getPreprocessingOptions() const override;
std::string getProcessingOptions() const override;
std::string getPostprocessingOptions() const override;
std::string getTimeSlicingOptions() const override;
protected:
/// The search model
......
......@@ -34,5 +34,13 @@ IReflEventPresenter *QtReflEventView::getPresenter() const {
return m_presenter.get();
}
/** Returns the number of time slices
* @return :: The number of time slices
*/
std::string QtReflEventView::getNumTimeSlices() const {
return m_ui.evenTimeSlicesEdit->text().toStdString();
}
} // namespace CustomInterfaces
} // namespace Mantid
......@@ -38,7 +38,7 @@ void QtReflMainWindowView::initLayout() {
// Create the presenter
m_presenter.reset(new ReflMainWindowPresenter(
this, runsPresenter, settingsPresenter, savePresenter));
this, runsPresenter, eventPresenter, settingsPresenter, savePresenter));
}
/** Creates the 'Runs' tab and returns a pointer to its presenter
......
......@@ -2,6 +2,8 @@
#include "MantidQtCustomInterfaces/Reflectometry/IReflEventTabPresenter.h"
#include "MantidQtCustomInterfaces/Reflectometry/IReflEventView.h"
#include <boost/algorithm/string.hpp>
namespace MantidQt {
namespace CustomInterfaces {
......@@ -13,5 +15,20 @@ ReflEventPresenter::ReflEventPresenter(IReflEventView *view) : m_view(view) {}
/** Destructor
*/
ReflEventPresenter::~ReflEventPresenter() {}
/** Returns the time-slicing options
* @return :: The time-slicing options
*/
std::string ReflEventPresenter::getTimeSlicingOptions() const {
std::vector<std::string> options;
// Add number of time slices
auto numTimeSlices = m_view->getNumTimeSlices();
if (!numTimeSlices.empty())
options.push_back("NumTimeSlices=" + numTimeSlices);
return boost::algorithm::join(options, ",");
}
}
}
\ No newline at end of file
......@@ -17,5 +17,16 @@ ReflEventTabPresenter::ReflEventTabPresenter(
*
*/
ReflEventTabPresenter::~ReflEventTabPresenter() {}
/** Returns global options for time-slicing for 'ReflectometryReductionOneAuto'
*
* @param group :: The group from which to get the options
* @return :: Global options for 'ReflectometryReductionOneAuto'
*/
std::string ReflEventTabPresenter::getTimeSlicingOptions(int group) const {
return m_eventPresenters.at(group)->getTimeSlicingOptions();
}
}
}
\ No newline at end of file
#include "MantidQtCustomInterfaces/Reflectometry/ReflMainWindowPresenter.h"
#include "MantidQtCustomInterfaces/Reflectometry/IReflMainWindowView.h"
#include "MantidQtCustomInterfaces/Reflectometry/IReflRunsTabPresenter.h"
#include "MantidQtCustomInterfaces/Reflectometry/IReflEventTabPresenter.h"
#include "MantidQtCustomInterfaces/Reflectometry/IReflSettingsTabPresenter.h"
#include "MantidQtCustomInterfaces/Reflectometry/IReflSaveTabPresenter.h"
......@@ -15,10 +16,12 @@ namespace CustomInterfaces {
*/
ReflMainWindowPresenter::ReflMainWindowPresenter(
IReflMainWindowView *view, IReflRunsTabPresenter *runsPresenter,
IReflEventTabPresenter *eventPresenter,
IReflSettingsTabPresenter *settingsPresenter,
IReflSaveTabPresenter *savePresenter)
: m_view(view), m_runsPresenter(runsPresenter),
m_settingsPresenter(settingsPresenter), m_savePresenter(savePresenter) {
m_eventPresenter(eventPresenter), m_settingsPresenter(settingsPresenter),
m_savePresenter(savePresenter) {
// Tell the tab presenters that this is going to be the main presenter
m_runsPresenter->acceptMainPresenter(this);
......@@ -41,7 +44,7 @@ ReflMainWindowPresenter::~ReflMainWindowPresenter() {}
*/
std::string ReflMainWindowPresenter::getTransmissionOptions(int group) const {
checkPtrValid(m_settingsPresenter);
checkSettingsPtrValid(m_settingsPresenter);
return m_settingsPresenter->getTransmissionOptions(group);
}
......@@ -54,7 +57,7 @@ std::string ReflMainWindowPresenter::getTransmissionOptions(int group) const {
*/
std::string ReflMainWindowPresenter::getReductionOptions(int group) const {
checkPtrValid(m_settingsPresenter);
checkSettingsPtrValid(m_settingsPresenter);
// Request global processing options to 'Settings' presenter
return m_settingsPresenter->getReductionOptions(group);
......@@ -68,12 +71,26 @@ std::string ReflMainWindowPresenter::getReductionOptions(int group) const {
*/
std::string ReflMainWindowPresenter::getStitchOptions(int group) const {
checkPtrValid(m_settingsPresenter);
checkSettingsPtrValid(m_settingsPresenter);
// Request global post-processing options to 'Settings' presenter
return m_settingsPresenter->getStitchOptions(group);
}
/** Returns global time-slicing options
*
* @param group :: Index of the group in 'Event Handling' tab from which to get
*the options
* @return :: Global time-slicing options
*/
std::string ReflMainWindowPresenter::getTimeSlicingOptions(int group) const {
checkEventPtrValid(m_eventPresenter);
// Request global time-slicing options to 'Event Handling' presenter
return m_eventPresenter->getTimeSlicingOptions(group);
}
/**
Tells the view to show an critical error dialog
@param prompt : The prompt to appear on the dialog
......@@ -155,13 +172,22 @@ void ReflMainWindowPresenter::setInstrumentName(
m_settingsPresenter->setInstrumentName(instName);
}
/** Checks for null pointer
/** Checks for Settings Tab null pointer
* @param pointer :: The pointer
*/
void ReflMainWindowPresenter::checkPtrValid(
void ReflMainWindowPresenter::checkSettingsPtrValid(
IReflSettingsTabPresenter *pointer) const {
if (pointer == nullptr)
throw std::invalid_argument("Could not read settings");
}
/** Checks for Event Handling Tab null pointer
* @param pointer :: The pointer
*/
void ReflMainWindowPresenter::checkEventPtrValid(
IReflEventTabPresenter *pointer) const {
if (pointer == nullptr)
throw std::invalid_argument("Could not read event handling");
}
}
}
......@@ -366,22 +366,30 @@ ReflRunsTabPresenter::getPreprocessingOptions() const {
return options;
}
/** Requests global pre-processing options. Options are supplied by the main
/** Requests global processing options. Options are supplied by the main
* presenter
* @return :: Global pre-processing options
* @return :: Global processing options
*/
std::string ReflRunsTabPresenter::getProcessingOptions() const {
return m_mainPresenter->getReductionOptions(m_view->getSelectedGroup());
}
/** Requests global pre-processing options. Options are supplied by the main
/** Requests global post-processing options. Options are supplied by the main
* presenter
* @return :: Global pre-processing options
* @return :: Global post-processing options
*/
std::string ReflRunsTabPresenter::getPostprocessingOptions() const {
return m_mainPresenter->getStitchOptions(m_view->getSelectedGroup());
}
/** Requests global time-slicing options. Options are supplied by the main
* presenter
* @return :: Global time-slicing options
*/
std::string ReflRunsTabPresenter::getTimeSlicingOptions() const {
return m_mainPresenter->getTimeSlicingOptions(m_view->getSelectedGroup());
}
/**
Tells the view to show an critical error dialog
@param prompt : The prompt to appear on the dialog
......
......@@ -60,6 +60,8 @@ public:
virtual std::string getProcessingOptions() const = 0;
/// Return global options for post-processing
virtual std::string getPostprocessingOptions() const = 0;
/// Return global options for time-slicing
virtual std::string getTimeSlicingOptions() const = 0;
};
}
}
......
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