From 17786bbadb65345f89c5fb59f5d4c92898884d10 Mon Sep 17 00:00:00 2001 From: Raquel Alvarez Banos <raquel.alvarez.banos@gmail.com> Date: Tue, 19 Jul 2016 10:28:31 +0100 Subject: [PATCH] Re #16869 Added 'Settings' tab --- MantidQt/CustomInterfaces/CMakeLists.txt | 8 +- .../Reflectometry/IReflMainWindowPresenter.h | 14 +- .../Reflectometry/IReflMainWindowView.h | 6 +- .../Reflectometry/IReflRunsTabPresenter.h | 5 + .../Reflectometry/IReflRunsTabView.h | 5 +- .../Reflectometry/IReflSettingsTabPresenter.h | 50 ++++++ .../Reflectometry/IReflSettingsTabView.h | 57 +++++++ .../Reflectometry/QtReflMainWindowView.h | 23 ++- .../Reflectometry/QtReflRunsTabView.h | 13 +- .../Reflectometry/QtReflSettingsTabView.h | 64 +++++++ .../Reflectometry/ReflMainWindowPresenter.h | 27 ++- .../Reflectometry/ReflRunsTabPresenter.h | 28 +++- .../Reflectometry/ReflSettingsTabPresenter.h | 63 +++++++ .../Reflectometry/ReflSettingsTabWidget.ui | 157 ++++++++++++++++++ .../Reflectometry/QtReflMainWindowView.cpp | 33 +++- .../src/Reflectometry/QtReflRunsTabView.cpp | 38 +++-- .../Reflectometry/QtReflSettingsTabView.cpp | 53 ++++++ .../Reflectometry/ReflMainWindowPresenter.cpp | 58 +++++++ .../Reflectometry/ReflRunsTabPresenter.cpp | 48 +++++- .../ReflSettingsTabPresenter.cpp | 65 ++++++++ .../DataProcessorMainPresenter.h | 8 + .../GenericDataProcessorPresenter.cpp | 38 +++-- .../DataProcessorUI/QDataProcessorWidget.cpp | 2 + 23 files changed, 792 insertions(+), 71 deletions(-) create mode 100644 MantidQt/CustomInterfaces/inc/MantidQtCustomInterfaces/Reflectometry/IReflSettingsTabPresenter.h create mode 100644 MantidQt/CustomInterfaces/inc/MantidQtCustomInterfaces/Reflectometry/IReflSettingsTabView.h create mode 100644 MantidQt/CustomInterfaces/inc/MantidQtCustomInterfaces/Reflectometry/QtReflSettingsTabView.h create mode 100644 MantidQt/CustomInterfaces/inc/MantidQtCustomInterfaces/Reflectometry/ReflSettingsTabPresenter.h create mode 100644 MantidQt/CustomInterfaces/inc/MantidQtCustomInterfaces/Reflectometry/ReflSettingsTabWidget.ui create mode 100644 MantidQt/CustomInterfaces/src/Reflectometry/QtReflSettingsTabView.cpp create mode 100644 MantidQt/CustomInterfaces/src/Reflectometry/ReflSettingsTabPresenter.cpp diff --git a/MantidQt/CustomInterfaces/CMakeLists.txt b/MantidQt/CustomInterfaces/CMakeLists.txt index 29d403ade8b..9df3b315ab8 100644 --- a/MantidQt/CustomInterfaces/CMakeLists.txt +++ b/MantidQt/CustomInterfaces/CMakeLists.txt @@ -84,14 +84,16 @@ set ( SRC_FILES src/Reflectometry/MeasurementItem.cpp src/Reflectometry/QtReflMainWindowView.cpp src/Reflectometry/QtReflRunsTabView.cpp + src/Reflectometry/QtReflSettingsTabView.cpp src/Reflectometry/ReflCatalogSearcher.cpp src/Reflectometry/ReflGenericDataProcessorPresenterFactory.cpp src/Reflectometry/ReflLegacyTransferStrategy.cpp src/Reflectometry/ReflMainWindowPresenter.cpp - src/Reflectometry/ReflRunsTabPresenter.cpp src/Reflectometry/ReflMeasureTransferStrategy.cpp src/Reflectometry/ReflNexusMeasurementItemSource.cpp + src/Reflectometry/ReflRunsTabPresenter.cpp src/Reflectometry/ReflSearchModel.cpp + src/Reflectometry/ReflSettingsTabPresenter.cpp src/Reflectometry/ReflTableSchema.cpp src/Reflectometry/TransferResults.cpp src/SANSAddFiles.cpp @@ -228,6 +230,7 @@ set ( INC_FILES inc/MantidQtCustomInterfaces/Reflectometry/IReflMainWindowPresenter.h inc/MantidQtCustomInterfaces/Reflectometry/IReflRunsTabPresenter.h inc/MantidQtCustomInterfaces/Reflectometry/IReflSearcher.h + inc/MantidQtCustomInterfaces/Reflectometry/IReflSettingsTabPresenter.h inc/MantidQtCustomInterfaces/Reflectometry/MeasurementItem.h inc/MantidQtCustomInterfaces/Reflectometry/QtReflMainWindowView.h inc/MantidQtCustomInterfaces/Reflectometry/QtReflRunsTabView.h @@ -236,6 +239,7 @@ set ( INC_FILES inc/MantidQtCustomInterfaces/Reflectometry/ReflLegacyTransferStrategy.h inc/MantidQtCustomInterfaces/Reflectometry/IReflMainWindowView.h inc/MantidQtCustomInterfaces/Reflectometry/IReflRunsTabView.h + inc/MantidQtCustomInterfaces/Reflectometry/IReflSettingsTabView.h inc/MantidQtCustomInterfaces/Reflectometry/ReflMainWindowPresenter.h inc/MantidQtCustomInterfaces/Reflectometry/ReflRunsTabPresenter.h inc/MantidQtCustomInterfaces/Reflectometry/ReflMeasureTransferStrategy.h @@ -371,6 +375,7 @@ set ( MOC_FILES inc/MantidQtCustomInterfaces/Background.h inc/MantidQtCustomInterfaces/Muon/MuonAnalysisResultTableTab.h inc/MantidQtCustomInterfaces/Reflectometry/ReflSearchModel.h inc/MantidQtCustomInterfaces/Reflectometry/QtReflRunsTabView.h + inc/MantidQtCustomInterfaces/Reflectometry/QtReflSettingsTabView.h inc/MantidQtCustomInterfaces/SampleTransmission.h inc/MantidQtCustomInterfaces/SANSBackgroundCorrectionWidget.h inc/MantidQtCustomInterfaces/SANSAddFiles.h @@ -445,6 +450,7 @@ set ( UI_FILES inc/MantidQtCustomInterfaces/DataComparison.ui inc/MantidQtCustomInterfaces/Muon/MuonAnalysis.ui inc/MantidQtCustomInterfaces/Reflectometry/ReflMainWindowWidget.ui inc/MantidQtCustomInterfaces/Reflectometry/ReflRunsTabWidget.ui + inc/MantidQtCustomInterfaces/Reflectometry/ReflSettingsTabWidget.ui inc/MantidQtCustomInterfaces/Reflectometry/ReflWindow.ui inc/MantidQtCustomInterfaces/SampleTransmission.ui inc/MantidQtCustomInterfaces/SANSBackgroundCorrectionWidget.ui diff --git a/MantidQt/CustomInterfaces/inc/MantidQtCustomInterfaces/Reflectometry/IReflMainWindowPresenter.h b/MantidQt/CustomInterfaces/inc/MantidQtCustomInterfaces/Reflectometry/IReflMainWindowPresenter.h index cc5052af331..0059af2d68e 100644 --- a/MantidQt/CustomInterfaces/inc/MantidQtCustomInterfaces/Reflectometry/IReflMainWindowPresenter.h +++ b/MantidQt/CustomInterfaces/inc/MantidQtCustomInterfaces/Reflectometry/IReflMainWindowPresenter.h @@ -1,12 +1,17 @@ #ifndef MANTID_CUSTOMINTERFACES_IREFLMAINWINDOWPRESENTER_H #define MANTID_CUSTOMINTERFACES_IREFLMAINWINDOWPRESENTER_H +#include <map> +#include <string> + namespace MantidQt { namespace CustomInterfaces { + /** @class IReflMainWindowPresenter IReflMainWindowPresenter is the interface defining the functions that the main -window presenter needs to implement +window presenter needs to implement. This interface is used by tab presenters to +request information from other tabs. Copyright © 2011-14 ISIS Rutherford Appleton Laboratory, NScD Oak Ridge National Laboratory & European Spallation Source @@ -31,7 +36,14 @@ Code Documentation is available at: <http://doxygen.mantidproject.org> */ class IReflMainWindowPresenter { public: + /// Destructor virtual ~IReflMainWindowPresenter(){}; + /// Returns global pre-processing options + virtual std::map<std::string, std::string> getPreprocessingOptions() = 0; + /// Returns global processing options + virtual std::string getProcessingOptions() = 0; + /// Returns global post-processing options + virtual std::string getPostprocessingOptions() = 0; }; } } diff --git a/MantidQt/CustomInterfaces/inc/MantidQtCustomInterfaces/Reflectometry/IReflMainWindowView.h b/MantidQt/CustomInterfaces/inc/MantidQtCustomInterfaces/Reflectometry/IReflMainWindowView.h index 097e47dfd63..1fa09f344f8 100644 --- a/MantidQt/CustomInterfaces/inc/MantidQtCustomInterfaces/Reflectometry/IReflMainWindowView.h +++ b/MantidQt/CustomInterfaces/inc/MantidQtCustomInterfaces/Reflectometry/IReflMainWindowView.h @@ -3,10 +3,13 @@ namespace MantidQt { namespace CustomInterfaces { + /** @class IReflMainWindowView IReflMainWindowView is the interface defining the functions that the main -window view needs to implement +window view needs to implement. It is empty and not necessary at the moment, but +can be used in the future if widgets common to all tabs are added, for instance, +the help button. Copyright © 2011-14 ISIS Rutherford Appleton Laboratory, NScD Oak Ridge National Laboratory & European Spallation Source @@ -31,6 +34,7 @@ Code Documentation is available at: <http://doxygen.mantidproject.org> */ class IReflMainWindowView { public: + /// Destructor virtual ~IReflMainWindowView(){}; }; } diff --git a/MantidQt/CustomInterfaces/inc/MantidQtCustomInterfaces/Reflectometry/IReflRunsTabPresenter.h b/MantidQt/CustomInterfaces/inc/MantidQtCustomInterfaces/Reflectometry/IReflRunsTabPresenter.h index 098a818e0f3..a4687585855 100644 --- a/MantidQt/CustomInterfaces/inc/MantidQtCustomInterfaces/Reflectometry/IReflRunsTabPresenter.h +++ b/MantidQt/CustomInterfaces/inc/MantidQtCustomInterfaces/Reflectometry/IReflRunsTabPresenter.h @@ -3,6 +3,9 @@ namespace MantidQt { namespace CustomInterfaces { + +class IReflMainWindowPresenter; + /** @class IReflRunsTabPresenter IReflRunsTabPresenter is an interface which defines the functions any @@ -32,6 +35,8 @@ Code Documentation is available at: <http://doxygen.mantidproject.org> class IReflRunsTabPresenter { public: virtual ~IReflRunsTabPresenter(){}; + /// Accept a main presenter + virtual void acceptMainPresenter(IReflMainWindowPresenter *mainPresenter) = 0; enum Flag { SearchFlag, ICATSearchCompleteFlag, TransferFlag }; diff --git a/MantidQt/CustomInterfaces/inc/MantidQtCustomInterfaces/Reflectometry/IReflRunsTabView.h b/MantidQt/CustomInterfaces/inc/MantidQtCustomInterfaces/Reflectometry/IReflRunsTabView.h index 64bf16d0d90..aba2892ac06 100644 --- a/MantidQt/CustomInterfaces/inc/MantidQtCustomInterfaces/Reflectometry/IReflRunsTabView.h +++ b/MantidQt/CustomInterfaces/inc/MantidQtCustomInterfaces/Reflectometry/IReflRunsTabView.h @@ -23,8 +23,7 @@ class ReflSearchModel; /** @class IReflRunsTabView IReflRunsTabView is the base view class for the Reflectometry Interface. It -contains -no QT specific functionality as that should be handled by a subclass. +contains no QT specific functionality as that should be handled by a subclass. Copyright © 2011-14 ISIS Rutherford Appleton Laboratory, NScD Oak Ridge National Laboratory & European Spallation Source @@ -80,7 +79,7 @@ public: virtual std::string getSearchString() const = 0; virtual std::string getTransferMethod() const = 0; - virtual boost::shared_ptr<IReflRunsTabPresenter> getPresenter() const = 0; + virtual IReflRunsTabPresenter *getPresenter() const = 0; virtual boost::shared_ptr<MantidQt::API::AlgorithmRunner> getAlgorithmRunner() const = 0; }; diff --git a/MantidQt/CustomInterfaces/inc/MantidQtCustomInterfaces/Reflectometry/IReflSettingsTabPresenter.h b/MantidQt/CustomInterfaces/inc/MantidQtCustomInterfaces/Reflectometry/IReflSettingsTabPresenter.h new file mode 100644 index 00000000000..2dd7a11f0c8 --- /dev/null +++ b/MantidQt/CustomInterfaces/inc/MantidQtCustomInterfaces/Reflectometry/IReflSettingsTabPresenter.h @@ -0,0 +1,50 @@ +#ifndef MANTID_CUSTOMINTERFACES_IREFLSETTINGSTABPRESENTER_H +#define MANTID_CUSTOMINTERFACES_IREFLSETTINGSTABPRESENTER_H + +namespace MantidQt { +namespace CustomInterfaces { + +class IReflMainWindowPresenter; + +/** @class IReflSettingsTabPresenter + +IReflSettingsTabPresenter is an interface which defines the functions that need +to be implemented by a concrete 'Settings' tab presenter + +Copyright © 2011-14 ISIS Rutherford Appleton Laboratory, NScD Oak Ridge +National Laboratory & European Spallation Source + +This file is part of Mantid. + +Mantid is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 3 of the License, or +(at your option) any later version. + +Mantid is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see <http://www.gnu.org/licenses/>. + +File change history is stored at: <https://github.com/mantidproject/mantid>. +Code Documentation is available at: <http://doxygen.mantidproject.org> +*/ +class IReflSettingsTabPresenter { +public: + virtual ~IReflSettingsTabPresenter(){}; + /// Accept a main presenter + virtual void acceptMainPresenter(IReflMainWindowPresenter *mainPresenter) = 0; + /// Get global pre-processing options + virtual std::map<std::string, std::string> + getPreprocessingOptions() const = 0; + /// Get global processing options + virtual std::string getProcessingOptions() const = 0; + /// Get global post-processing options + virtual std::string getPostprocessingOptions() const = 0; +}; +} +} +#endif /* MANTID_CUSTOMINTERFACES_IREFLSETTINGSTABPRESENTER_H */ \ No newline at end of file diff --git a/MantidQt/CustomInterfaces/inc/MantidQtCustomInterfaces/Reflectometry/IReflSettingsTabView.h b/MantidQt/CustomInterfaces/inc/MantidQtCustomInterfaces/Reflectometry/IReflSettingsTabView.h new file mode 100644 index 00000000000..b330865bead --- /dev/null +++ b/MantidQt/CustomInterfaces/inc/MantidQtCustomInterfaces/Reflectometry/IReflSettingsTabView.h @@ -0,0 +1,57 @@ +#ifndef MANTID_CUSTOMINTERFACES_IREFLSETTINGSTABVIEW_H +#define MANTID_CUSTOMINTERFACES_IREFLSETTINGSTABVIEW_H + +namespace MantidQt { + +namespace CustomInterfaces { + +class IReflSettingsTabPresenter; + +/** @class IReflSettingsTabView + +IReflSettingsTabView is the base view class for the Reflectometry Interface. It +contains +no QT specific functionality as that should be handled by a subclass. + +Copyright © 2011-14 ISIS Rutherford Appleton Laboratory, NScD Oak Ridge +National Laboratory & European Spallation Source + +This file is part of Mantid. + +Mantid is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 3 of the License, or +(at your option) any later version. + +Mantid is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see <http://www.gnu.org/licenses/>. + +File change history is stored at: <https://github.com/mantidproject/mantid>. +Code Documentation is available at: <http://doxygen.mantidproject.org> +*/ + +class DLLExport IReflSettingsTabView { +public: + /// Constructor + IReflSettingsTabView(){}; + /// Destructor + virtual ~IReflSettingsTabView(){}; + /// Returns the presenter managing this view + virtual IReflSettingsTabPresenter *getPresenter() const = 0; + + /// Processing + /// Returns selected analysis mode + virtual std::string getAnalysisMode() const = 0; + + /// Post-processing + /// Returns selected resolution (dQ/Q) + virtual std::string getResolution() const = 0; +}; +} +} +#endif /* MANTID_CUSTOMINTERFACES_IREFLRUNSTABVIEW_H */ \ No newline at end of file diff --git a/MantidQt/CustomInterfaces/inc/MantidQtCustomInterfaces/Reflectometry/QtReflMainWindowView.h b/MantidQt/CustomInterfaces/inc/MantidQtCustomInterfaces/Reflectometry/QtReflMainWindowView.h index 3b2d86c1d46..24b4f7f4a16 100644 --- a/MantidQt/CustomInterfaces/inc/MantidQtCustomInterfaces/Reflectometry/QtReflMainWindowView.h +++ b/MantidQt/CustomInterfaces/inc/MantidQtCustomInterfaces/Reflectometry/QtReflMainWindowView.h @@ -4,11 +4,14 @@ #include "MantidQtAPI/UserSubWindow.h" #include "MantidQtCustomInterfaces/Reflectometry/IReflMainWindowView.h" #include "ui_ReflMainWindowWidget.h" -#include "ui_ReflRunsTabWidget.h" namespace MantidQt { namespace CustomInterfaces { +class IReflMainWindowPresenter; +class IReflRunsTabPresenter; +class IReflSettingsTabPresenter; + /** @class ReflMainWindowView ReflMainWindowView is the concrete main window view implementing the @@ -38,21 +41,27 @@ Code Documentation is available at: <http://doxygen.mantidproject.org> class QtReflMainWindowView : public MantidQt::API::UserSubWindow, public IReflMainWindowView { public: - /// Constructor + /// Constructor QtReflMainWindowView(QWidget *parent = 0); - /// Destructor + /// Destructor ~QtReflMainWindowView() override; /// Name of the interface static std::string name() { return "ISIS Reflectometry (Polref) 2"; } /// This interface's categories. static QString categoryInfo() { return "Reflectometry"; } - /// Initialise the interface - void initLayout() override; + private: + /// Initializes the interface + void initLayout() override; + /// Creates the 'Runs' tab + IReflRunsTabPresenter *createRunsTab(); + /// Creates the 'Settings' tab + IReflSettingsTabPresenter *createSettingsTab(); + /// Interface definition with widgets for the main interface window Ui::RelMainWindowWidget m_ui; - /// 'Runs' tab - Ui::ReflRunsTabWidget m_uiRunsTab; + /// The presenter handling this view + IReflMainWindowPresenter *m_presenter; }; } } diff --git a/MantidQt/CustomInterfaces/inc/MantidQtCustomInterfaces/Reflectometry/QtReflRunsTabView.h b/MantidQt/CustomInterfaces/inc/MantidQtCustomInterfaces/Reflectometry/QtReflRunsTabView.h index f9daf05eba9..cfd01bb951c 100644 --- a/MantidQt/CustomInterfaces/inc/MantidQtCustomInterfaces/Reflectometry/QtReflRunsTabView.h +++ b/MantidQt/CustomInterfaces/inc/MantidQtCustomInterfaces/Reflectometry/QtReflRunsTabView.h @@ -6,6 +6,7 @@ #include "MantidQtCustomInterfaces/DllConfig.h" #include "MantidQtCustomInterfaces/Reflectometry/IReflRunsTabView.h" #include "MantidQtMantidWidgets/ProgressableView.h" + #include "ui_ReflRunsTabWidget.h" namespace MantidQt { @@ -64,12 +65,6 @@ public: QtReflRunsTabView(QWidget *parent = 0); /// Destructor ~QtReflRunsTabView() override; - /// initialise the interface - void initLayout(); - /// Name of the interface - static std::string name() { return "ISIS Reflectometry (Polref)"; } - // This interface's categories. - static QString categoryInfo() { return "Reflectometry"; } // Connect the model void showSearch(boost::shared_ptr<ReflSearchModel> model) override; @@ -101,18 +96,20 @@ public: std::string getSearchString() const override; std::string getTransferMethod() const override; - boost::shared_ptr<IReflRunsTabPresenter> getPresenter() const override; + IReflRunsTabPresenter *getPresenter() const override; boost::shared_ptr<MantidQt::API::AlgorithmRunner> getAlgorithmRunner() const override; private: + /// initialise the interface + void initLayout(); // Adds an action (command) to a menu void addToMenu(QMenu *menu, std::unique_ptr<DataProcessorCommand> command); boost::shared_ptr<MantidQt::API::AlgorithmRunner> m_algoRunner; // the presenter - boost::shared_ptr<IReflRunsTabPresenter> m_presenter; + IReflRunsTabPresenter *m_presenter; // the search model boost::shared_ptr<ReflSearchModel> m_searchModel; // the interface diff --git a/MantidQt/CustomInterfaces/inc/MantidQtCustomInterfaces/Reflectometry/QtReflSettingsTabView.h b/MantidQt/CustomInterfaces/inc/MantidQtCustomInterfaces/Reflectometry/QtReflSettingsTabView.h new file mode 100644 index 00000000000..14b06c3d0e8 --- /dev/null +++ b/MantidQt/CustomInterfaces/inc/MantidQtCustomInterfaces/Reflectometry/QtReflSettingsTabView.h @@ -0,0 +1,64 @@ +#ifndef MANTID_CUSTOMINTERFACES_QTREFLSETTINGSTABVIEW_H_ +#define MANTID_CUSTOMINTERFACES_QTREFLSETTINGSTABVIEW_H_ + +#include "MantidQtCustomInterfaces/Reflectometry/IReflSettingsTabView.h" +#include "ui_ReflSettingsTabWidget.h" + +namespace MantidQt { +namespace CustomInterfaces { + +// Forward decs +class IReflSettingsTabPresenter; + +/** QtReflSettingsTabView : Provides an interface for the "Settings" tab in the +Reflectometry (Polref) interface. + +Copyright © 2014 ISIS Rutherford Appleton Laboratory, NScD Oak Ridge +National Laboratory & European Spallation Source + +This file is part of Mantid. + +Mantid is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 3 of the License, or +(at your option) any later version. + +Mantid is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see <http://www.gnu.org/licenses/>. + +File change history is stored at: <https://github.com/mantidproject/mantid> +Code Documentation is available at: <http://doxygen.mantidproject.org> +*/ +class QtReflSettingsTabView : public QWidget, public IReflSettingsTabView { + Q_OBJECT +public: + /// Constructor + QtReflSettingsTabView(QWidget *parent = 0); + /// Destructor + ~QtReflSettingsTabView() override; + /// Returns the presenter managing this view + IReflSettingsTabPresenter *getPresenter() const; + /// Returns selected analysis mode + std::string getAnalysisMode() const override; + /// Returns selected resolution (dQ/Q) + std::string getResolution() const override; + +private: + /// Initialise the interface + void initLayout(); + + /// The widget + Ui::ReflSettingsTabWidget m_ui; + /// The presenter + IReflSettingsTabPresenter *m_presenter; +}; + +} // namespace Mantid +} // namespace CustomInterfaces + +#endif /* MANTID_CUSTOMINTERFACES_QTREFLSETTINGSTABVIEW_H_ */ diff --git a/MantidQt/CustomInterfaces/inc/MantidQtCustomInterfaces/Reflectometry/ReflMainWindowPresenter.h b/MantidQt/CustomInterfaces/inc/MantidQtCustomInterfaces/Reflectometry/ReflMainWindowPresenter.h index a800620b1f5..fbbcfe0d77a 100644 --- a/MantidQt/CustomInterfaces/inc/MantidQtCustomInterfaces/Reflectometry/ReflMainWindowPresenter.h +++ b/MantidQt/CustomInterfaces/inc/MantidQtCustomInterfaces/Reflectometry/ReflMainWindowPresenter.h @@ -6,10 +6,14 @@ namespace MantidQt { namespace CustomInterfaces { +class IReflMainWindowView; +class IReflRunsTabPresenter; +class IReflSettingsTabPresenter; + /** @class ReflMainWindowPresenter ReflMainWindowPresenter is the concrete main window presenter implementing the -functionality defined by the interface IReflMainWindowPresenter +functionality defined by the interface IReflMainWindowPresenter. Copyright © 2011-14 ISIS Rutherford Appleton Laboratory, NScD Oak Ridge National Laboratory & European Spallation Source @@ -32,9 +36,28 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. File change history is stored at: <https://github.com/mantidproject/mantid>. Code Documentation is available at: <http://doxygen.mantidproject.org> */ -class ReflMainWindowPresenter : public IReflMainWindowPresenter{ +class ReflMainWindowPresenter : public IReflMainWindowPresenter { public: + /// Constructor + ReflMainWindowPresenter(IReflMainWindowView *view, + IReflRunsTabPresenter *runsPresenter, + IReflSettingsTabPresenter *settingsPresenter); + /// Destructor ~ReflMainWindowPresenter() override; + /// Returns global pre-processing options + std::map<std::string, std::string> getPreprocessingOptions() override; + /// Returns global processing options + std::string getProcessingOptions() override; + /// Returns global post-processing options + std::string getPostprocessingOptions() override; + +private: + /// The view we are handling + IReflMainWindowView *m_view; + /// The presenter of tab 'Runs' + IReflRunsTabPresenter *m_runsPresenter; + /// The presenter of tab 'Settings' + IReflSettingsTabPresenter *m_settingsPresenter; }; } } diff --git a/MantidQt/CustomInterfaces/inc/MantidQtCustomInterfaces/Reflectometry/ReflRunsTabPresenter.h b/MantidQt/CustomInterfaces/inc/MantidQtCustomInterfaces/Reflectometry/ReflRunsTabPresenter.h index 2c0ca9b2bb7..9ed2da44f3a 100644 --- a/MantidQt/CustomInterfaces/inc/MantidQtCustomInterfaces/Reflectometry/ReflRunsTabPresenter.h +++ b/MantidQt/CustomInterfaces/inc/MantidQtCustomInterfaces/Reflectometry/ReflRunsTabPresenter.h @@ -18,9 +18,10 @@ class DataProcessorPresenter; namespace CustomInterfaces { // Forward decs +class IReflMainWindowPresenter; class IReflRunsTabView; -class ReflSearchModel; class IReflSearcher; +class ReflSearchModel; class ReflTransferStrategy; using MantidWidgets::DataProcessorPresenter; @@ -62,27 +63,38 @@ public: boost::shared_ptr<IReflSearcher> searcher = boost::shared_ptr<IReflSearcher>()); ~ReflRunsTabPresenter() override; + void acceptMainPresenter(IReflMainWindowPresenter *mainPresenter) override; void notify(IReflRunsTabPresenter::Flag flag) override; void notify(DataProcessorMainPresenter::Flag flag) override; protected: - // the search model + /// The search model boost::shared_ptr<ReflSearchModel> m_searchModel; - // the main view we're managing + /// The main view we're managing IReflRunsTabView *m_view; - // The table view's presenter - boost::shared_ptr<DataProcessorPresenter> m_tablePresenter; - // The progress view + /// The progress view ProgressableView *m_progressView; - // the search implementation + /// The data processor presenter + boost::shared_ptr<DataProcessorPresenter> m_tablePresenter; + /// The main presenter + IReflMainWindowPresenter *m_mainPresenter; + /// The search implementation boost::shared_ptr<IReflSearcher> m_searcher; - // searching + /// searching void search(); void populateSearch(Mantid::API::IAlgorithm_sptr searchAlg); void transfer(); void pushCommands(); private: + /// Methods inherited from DataProcessorMainPresenter + /// Request global options for pre-processing + std::map<std::string, std::string> getPreprocessingOptions() const override; + /// Request global options for processing + std::string getProcessingOptions() const override; + /// Request global options for post-processing + std::string getPostprocessingOptions() const override; + static const std::string LegacyTransferMethod; static const std::string MeasureTransferMethod; diff --git a/MantidQt/CustomInterfaces/inc/MantidQtCustomInterfaces/Reflectometry/ReflSettingsTabPresenter.h b/MantidQt/CustomInterfaces/inc/MantidQtCustomInterfaces/Reflectometry/ReflSettingsTabPresenter.h new file mode 100644 index 00000000000..f7284f6d24e --- /dev/null +++ b/MantidQt/CustomInterfaces/inc/MantidQtCustomInterfaces/Reflectometry/ReflSettingsTabPresenter.h @@ -0,0 +1,63 @@ +#ifndef MANTID_CUSTOMINTERFACES_REFLSETTINGSTABPRESENTER_H +#define MANTID_CUSTOMINTERFACES_REFLSETTINGSTABPRESENTER_H + +#include "MantidQtCustomInterfaces/Reflectometry/IReflSettingsTabPresenter.h" + +namespace MantidQt { +namespace CustomInterfaces { + +// Forward decs +class IReflMainWindowPresenter; +class IReflSettingsTabView; + +/** @class ReflSettingsTabPresenter + +ReflSettingsTabPresenter is a presenter class for the tab 'Settings' in the +Reflectometry (Polref) Interface. + +Copyright © 2011-14 ISIS Rutherford Appleton Laboratory, NScD Oak Ridge +National Laboratory & European Spallation Source + +This file is part of Mantid. + +Mantid is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 3 of the License, or +(at your option) any later version. + +Mantid is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see <http://www.gnu.org/licenses/>. + +File change history is stored at: <https://github.com/mantidproject/mantid>. +Code Documentation is available at: <http://doxygen.mantidproject.org> +*/ +class ReflSettingsTabPresenter : public IReflSettingsTabPresenter { +public: + /// Constructor + ReflSettingsTabPresenter(IReflSettingsTabView *view); + /// Destructor + ~ReflSettingsTabPresenter() override; + /// Accept a main presenter + void acceptMainPresenter(IReflMainWindowPresenter *mainPresenter) override; + + /// Get global pre-processing options + std::map<std::string, std::string> getPreprocessingOptions() const override; + /// Get global processing options + std::string getProcessingOptions() const override; + /// Get global post-processing options + std::string getPostprocessingOptions() const override; + +protected: + /// The view we are managing + IReflSettingsTabView *m_view; + /// The main presenter + IReflMainWindowPresenter *m_mainPresenter; +}; +} +} +#endif /* MANTID_CUSTOMINTERFACES_REFLSETTINGSTABPRESENTER_H */ diff --git a/MantidQt/CustomInterfaces/inc/MantidQtCustomInterfaces/Reflectometry/ReflSettingsTabWidget.ui b/MantidQt/CustomInterfaces/inc/MantidQtCustomInterfaces/Reflectometry/ReflSettingsTabWidget.ui new file mode 100644 index 00000000000..0476cd6c1e4 --- /dev/null +++ b/MantidQt/CustomInterfaces/inc/MantidQtCustomInterfaces/Reflectometry/ReflSettingsTabWidget.ui @@ -0,0 +1,157 @@ +<?xml version="1.0" encoding="UTF-8"?> +<ui version="4.0"> + <class>ReflSettingsTabWidget</class> + <widget class="QWidget" name="ReflSettingsTabWidget"> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>959</width> + <height>346</height> + </rect> + </property> + <property name="windowTitle"> + <string>Settings Tab</string> + </property> + <layout class="QVBoxLayout" name="settingsMainLayout"> + <property name="margin"> + <number>5</number> + </property> + <item> + <widget class="QGroupBox" name="expSettingsGroup"> + <property name="title"> + <string>Experiment Settings</string> + </property> + <property name="checkable"> + <bool>true</bool> + </property> + <layout class="QGridLayout" name="expSettingsLayout"> + <property name="margin"> + <number>10</number> + </property> + <item row="0" column="0"> + <widget class="QLabel" name="analysisModeLabel"> + <property name="text"> + <string>Analysis Mode</string> + </property> + </widget> + </item> + <item row="0" column="1"> + <widget class="QComboBox" name="analysisModeComboBox"> + <item> + <property name="text"> + <string>MultiDetectorAnalysis</string> + </property> + </item> + <item> + <property name="text"> + <string>PointDetectorAnalysis</string> + </property> + </item> + </widget> + </item> + <item row="0" column="2"> + <spacer name="instSettingsSpacer"> + <property name="orientation"> + <enum>Qt::Horizontal</enum> + </property> + <property name="sizeHint" stdset="0"> + <size> + <width>40</width> + <height>20</height> + </size> + </property> + </spacer> + </item> + <item row="1" column="0"> + <widget class="QLabel" name="expSettingsCRhoLabel"> + <property name="text"> + <string>CRho</string> + </property> + </widget> + </item> + <item row="1" column="1"> + <widget class="QLineEdit" name="expSettingsCRhoEdit"/> + </item> + <item row="2" column="0"> + <widget class="QLabel" name="expSettingsCAlphaLabel"> + <property name="text"> + <string>CAlpha</string> + </property> + </widget> + </item> + <item row="2" column="1"> + <widget class="QLineEdit" name="expSettingsCAlphaEdit"/> + </item> + <item row="3" column="0"> + <widget class="QLabel" name="expSettingsCApLabel"> + <property name="text"> + <string>CAp</string> + </property> + </widget> + </item> + <item row="3" column="1"> + <widget class="QLineEdit" name="expSettingsCApEdit"/> + </item> + <item row="4" column="0"> + <widget class="QLabel" name="expSettingsCPpLabel"> + <property name="text"> + <string>CPp</string> + </property> + </widget> + </item> + <item row="4" column="1"> + <widget class="QLineEdit" name="expSettingsCPpEdit"/> + </item> + </layout> + </widget> + </item> + <item> + <widget class="QGroupBox" name="instSettingsGroup"> + <property name="title"> + <string>Instrument Settings</string> + </property> + <property name="checkable"> + <bool>true</bool> + </property> + <layout class="QGridLayout" name="instSettingsLayout"> + <property name="margin"> + <number>10</number> + </property> + <item row="0" column="0"> + <widget class="QLabel" name="resolutionLabel"> + <property name="text"> + <string>Resolution (dQ/Q)</string> + </property> + </widget> + </item> + <item row="0" column="1"> + <widget class="QLineEdit" name="resolutionLineEdit"> + <property name="text"> + <string>-0.04</string> + </property> + </widget> + </item> + <item row="0" column="2"> + <spacer name="expSettingsSpacer"> + <property name="orientation"> + <enum>Qt::Horizontal</enum> + </property> + <property name="sizeHint" stdset="0"> + <size> + <width>40</width> + <height>20</height> + </size> + </property> + </spacer> + </item> + </layout> + </widget> + </item> + </layout> + </widget> + <tabstops/> + <customwidgets/> + <resources/> + <connections/> +</ui> diff --git a/MantidQt/CustomInterfaces/src/Reflectometry/QtReflMainWindowView.cpp b/MantidQt/CustomInterfaces/src/Reflectometry/QtReflMainWindowView.cpp index 8ba0368dd12..91899643d97 100644 --- a/MantidQt/CustomInterfaces/src/Reflectometry/QtReflMainWindowView.cpp +++ b/MantidQt/CustomInterfaces/src/Reflectometry/QtReflMainWindowView.cpp @@ -1,5 +1,7 @@ #include "MantidQtCustomInterfaces/Reflectometry/QtReflMainWindowView.h" #include "MantidQtCustomInterfaces/Reflectometry/QtReflRunsTabView.h" +#include "MantidQtCustomInterfaces/Reflectometry/QtReflSettingsTabView.h" +#include "MantidQtCustomInterfaces/Reflectometry/ReflMainWindowPresenter.h" namespace MantidQt { namespace CustomInterfaces { @@ -15,7 +17,7 @@ QtReflMainWindowView::QtReflMainWindowView(QWidget *parent) //---------------------------------------------------------------------------------------------- /** Destructor */ -QtReflMainWindowView::~QtReflMainWindowView() {} +QtReflMainWindowView::~QtReflMainWindowView() { delete m_presenter; } /** Initialise the Interface @@ -23,18 +25,41 @@ Initialise the Interface void QtReflMainWindowView::initLayout() { m_ui.setupUi(this); - // Add tabs + // Create the tabs + auto runsPresenter = createRunsTab(); + auto settingsPresenter = createSettingsTab(); - // 'Runs' tab + // Create the presenter + m_presenter = + new ReflMainWindowPresenter(this, runsPresenter, settingsPresenter); +} + +/** Creates the 'Runs' tab and returns a pointer to its presenter +* @return :: A pointer to the presenter managing the 'Runs' tab +*/ +IReflRunsTabPresenter *QtReflMainWindowView::createRunsTab() { QtReflRunsTabView *runsTab = new QtReflRunsTabView(this); - runsTab->initLayout(); m_ui.mainTab->addTab(runsTab, QString("Runs")); // This tab may need to run python code (to import/export TBL and to search // the ICAT). The corresponding signal needs to be re-emitted by this widget + // so the python code is executed connect(runsTab, SIGNAL(runAsPythonScript(const QString &, bool)), this, SIGNAL(runAsPythonScript(const QString &, bool))); + + return runsTab->getPresenter(); +} + +/** Creates the 'Settings' tab and returns a pointer to its presenter +* @return :: A pointer to the presenter managing the 'Settings' tab +*/ +IReflSettingsTabPresenter *QtReflMainWindowView::createSettingsTab() { + + QtReflSettingsTabView *settingsTab = new QtReflSettingsTabView(this); + m_ui.mainTab->addTab(settingsTab, QString("Settings")); + + return settingsTab->getPresenter(); } } } diff --git a/MantidQt/CustomInterfaces/src/Reflectometry/QtReflRunsTabView.cpp b/MantidQt/CustomInterfaces/src/Reflectometry/QtReflRunsTabView.cpp index 0cf5f810d0e..8d74e3484d9 100644 --- a/MantidQt/CustomInterfaces/src/Reflectometry/QtReflRunsTabView.cpp +++ b/MantidQt/CustomInterfaces/src/Reflectometry/QtReflRunsTabView.cpp @@ -9,6 +9,7 @@ #include "MantidQtCustomInterfaces/Reflectometry/ReflRunsTabPresenter.h" #include "MantidQtCustomInterfaces/Reflectometry/ReflSearchModel.h" #include "MantidQtMantidWidgets/DataProcessorUI/DataProcessorCommandAdapter.h" +#include "MantidQtMantidWidgets/DataProcessorUI/DataProcessorPresenter.h" #include "MantidQtMantidWidgets/DataProcessorUI/QDataProcessorWidget.h" #include "MantidQtMantidWidgets/HintingLineEditFactory.h" #include "MantidQtMantidWidgets/SlitCalculator.h" @@ -22,14 +23,18 @@ using namespace MantidQt::MantidWidgets; //---------------------------------------------------------------------------------------------- /** Constructor +* @param parent :: The parent of this view */ QtReflRunsTabView::QtReflRunsTabView(QWidget *parent) - : m_calculator(new SlitCalculator(this)) {} + : m_presenter(), m_calculator(new SlitCalculator(this)) { + + initLayout(); +} //---------------------------------------------------------------------------------------------- /** Destructor */ -QtReflRunsTabView::~QtReflRunsTabView() {} +QtReflRunsTabView::~QtReflRunsTabView() { delete m_presenter; } /** Initialise the Interface @@ -43,10 +48,9 @@ void QtReflRunsTabView::initLayout() { ui.splitterTables->setStretchFactor(0, 0); ui.splitterTables->setStretchFactor(1, 1); + // Create the DataProcessor presenter ReflGenericDataProcessorPresenterFactory presenterFactory; - - boost::shared_ptr<DataProcessorPresenter> processorPresenter = - presenterFactory.create(); + auto processorPresenter = presenterFactory.create(); QDataProcessorWidget *qDataProcessorWidget = new QDataProcessorWidget(processorPresenter, this); @@ -74,10 +78,11 @@ void QtReflRunsTabView::initLayout() { SIGNAL(runAsPythonScript(const QString &, bool)), this, SIGNAL(runAsPythonScript(const QString &, bool))); - m_presenter = boost::make_shared<ReflRunsTabPresenter>( - this /*main view*/, - this /*currently this concrete view is also responsibile for prog reporting*/, - processorPresenter /*the table presenter*/); + // Create the presenter + m_presenter = new ReflRunsTabPresenter( + this /* main view */, + this /* Currently this concrete view is also responsible for prog reporting */, + processorPresenter /* The data processor presenter */); m_algoRunner = boost::make_shared<MantidQt::API::AlgorithmRunner>(this); } @@ -86,7 +91,8 @@ void QtReflRunsTabView::initLayout() { * @param menu : [input] The menu where actions will be added * @param command : [input] The command (action) to add */ -void QtReflRunsTabView::addToMenu(QMenu *menu, DataProcessorCommand_uptr command) { +void QtReflRunsTabView::addToMenu(QMenu *menu, + DataProcessorCommand_uptr command) { m_commands.push_back(Mantid::Kernel::make_unique<DataProcessorCommandAdapter>( menu, std::move(command))); @@ -134,7 +140,8 @@ void QtReflRunsTabView::clearCommands() { m_commands.clear(); } * Set all possible tranfer methods * @param methods : All possible transfer methods. */ -void QtReflRunsTabView::setTransferMethods(const std::set<std::string> &methods) { +void QtReflRunsTabView::setTransferMethods( + const std::set<std::string> &methods) { for (auto method = methods.begin(); method != methods.end(); ++method) { ui.comboTransferMethod->addItem((*method).c_str()); } @@ -265,7 +272,8 @@ Show an critical error dialog @param prompt : The prompt to appear on the dialog @param title : The text for the title bar of the dialog */ -void QtReflRunsTabView::giveUserCritical(std::string prompt, std::string title) { +void QtReflRunsTabView::giveUserCritical(std::string prompt, + std::string title) { QMessageBox::critical(this, QString(title.c_str()), QString(prompt.c_str()), QMessageBox::Ok, QMessageBox::Ok); } @@ -278,8 +286,8 @@ Ask the user to enter a string. @returns The user's string if submitted, or an empty string */ std::string QtReflRunsTabView::askUserString(const std::string &prompt, - const std::string &title, - const std::string &defaultValue) { + const std::string &title, + const std::string &defaultValue) { bool ok; QString text = QInputDialog::getText( this, QString::fromStdString(title), QString::fromStdString(prompt), @@ -328,7 +336,7 @@ std::set<int> QtReflRunsTabView::getSelectedSearchRows() const { Get a pointer to the presenter that's currently controlling this view. @returns A pointer to the presenter */ -boost::shared_ptr<IReflRunsTabPresenter> QtReflRunsTabView::getPresenter() const { +IReflRunsTabPresenter *QtReflRunsTabView::getPresenter() const { return m_presenter; } diff --git a/MantidQt/CustomInterfaces/src/Reflectometry/QtReflSettingsTabView.cpp b/MantidQt/CustomInterfaces/src/Reflectometry/QtReflSettingsTabView.cpp new file mode 100644 index 00000000000..963e4933c5e --- /dev/null +++ b/MantidQt/CustomInterfaces/src/Reflectometry/QtReflSettingsTabView.cpp @@ -0,0 +1,53 @@ +#include "MantidQtCustomInterfaces/Reflectometry/QtReflSettingsTabView.h" +#include "MantidQtCustomInterfaces/Reflectometry/ReflSettingsTabPresenter.h" + +namespace MantidQt { +namespace CustomInterfaces { + +//---------------------------------------------------------------------------------------------- +/** Constructor +* @param parent :: [input] The parent of this widget +*/ +QtReflSettingsTabView::QtReflSettingsTabView(QWidget *parent) { + + initLayout(); + + m_presenter = new ReflSettingsTabPresenter(this); +} + +//---------------------------------------------------------------------------------------------- +/** Destructor +*/ +QtReflSettingsTabView::~QtReflSettingsTabView() { delete m_presenter; } + +/** +Initialise the Interface +*/ +void QtReflSettingsTabView::initLayout() { m_ui.setupUi(this); } + +/** Returns the presenter managing this view +* @return :: A pointer to the presenter +*/ +IReflSettingsTabPresenter *QtReflSettingsTabView::getPresenter() const { + + return m_presenter; +} + +/** Retuns the selected analysis mode +* @return :: Selected analysis mode +*/ +std::string QtReflSettingsTabView::getAnalysisMode() const { + + return m_ui.analysisModeComboBox->currentText().toStdString(); +} + +/** Returns selected resolution (dQ/Q) +* @return :: Resolution as a string +*/ +std::string QtReflSettingsTabView::getResolution() const { + + return m_ui.resolutionLineEdit->text().toStdString(); +} + +} // namespace CustomInterfaces +} // namespace Mantid diff --git a/MantidQt/CustomInterfaces/src/Reflectometry/ReflMainWindowPresenter.cpp b/MantidQt/CustomInterfaces/src/Reflectometry/ReflMainWindowPresenter.cpp index 8b137891791..aee4f792e17 100644 --- a/MantidQt/CustomInterfaces/src/Reflectometry/ReflMainWindowPresenter.cpp +++ b/MantidQt/CustomInterfaces/src/Reflectometry/ReflMainWindowPresenter.cpp @@ -1 +1,59 @@ +#include "MantidQtCustomInterfaces/Reflectometry/ReflMainWindowPresenter.h" +#include "MantidQtCustomInterfaces/Reflectometry/IReflMainWindowView.h" +#include "MantidQtCustomInterfaces/Reflectometry/IReflRunsTabPresenter.h" +#include "MantidQtCustomInterfaces/Reflectometry/IReflSettingsTabPresenter.h" +namespace MantidQt { +namespace CustomInterfaces { + +/** Constructor +* @param view :: [input] The view we are managing +* @param runsPresenter :: [input] A pointer to the 'Runs' tab presenter +* @param settingsPresenter :: [input] A pointer to the 'Settings' tab presenter +*/ +ReflMainWindowPresenter::ReflMainWindowPresenter( + IReflMainWindowView *view, IReflRunsTabPresenter *runsPresenter, + IReflSettingsTabPresenter *settingsPresenter) + : m_view(view), m_runsPresenter(runsPresenter), + m_settingsPresenter(settingsPresenter) { + + // Tell the tab presenters that this is going to be the main presenter + m_runsPresenter->acceptMainPresenter(this); + m_settingsPresenter->acceptMainPresenter(this); +} + +/** Destructor +*/ +ReflMainWindowPresenter::~ReflMainWindowPresenter() {} + +/** Returns global pre-processing options +* @return :: Global pre-processing options +*/ +std::map<std::string, std::string> +ReflMainWindowPresenter::getPreprocessingOptions() { + + // Empty map at present + // Options to 'CreateTransmissionWorkspaceAuto' are likely to be added + // in the future + return std::map<std::string, std::string>(); +} + +/** Returns global processing options +* @return :: Global processing options +*/ +std::string ReflMainWindowPresenter::getProcessingOptions() { + + // Request global processing options to 'Settings' presenter + return m_settingsPresenter->getProcessingOptions(); +} + +/** Returns global post-processing options +* @return :: Global post-processing options +*/ +std::string ReflMainWindowPresenter::getPostprocessingOptions() { + + // Request global post-processing options to 'Settings' presenter + return m_settingsPresenter->getPostprocessingOptions(); +} +} +} \ No newline at end of file diff --git a/MantidQt/CustomInterfaces/src/Reflectometry/ReflRunsTabPresenter.cpp b/MantidQt/CustomInterfaces/src/Reflectometry/ReflRunsTabPresenter.cpp index 63a4c24cdb7..6a7e218188b 100644 --- a/MantidQt/CustomInterfaces/src/Reflectometry/ReflRunsTabPresenter.cpp +++ b/MantidQt/CustomInterfaces/src/Reflectometry/ReflRunsTabPresenter.cpp @@ -7,6 +7,7 @@ #include "MantidKernel/FacilityInfo.h" #include "MantidKernel/UserCatalogInfo.h" #include "MantidQtAPI/AlgorithmRunner.h" +#include "MantidQtCustomInterfaces/Reflectometry/IReflMainWindowPresenter.h" #include "MantidQtCustomInterfaces/Reflectometry/IReflRunsTabView.h" #include "MantidQtCustomInterfaces/Reflectometry/ReflCatalogSearcher.h" #include "MantidQtCustomInterfaces/Reflectometry/ReflLegacyTransferStrategy.h" @@ -29,12 +30,19 @@ using namespace MantidQt::MantidWidgets; namespace MantidQt { namespace CustomInterfaces { + +/** Constructor +* @param mainView :: [input] The view we're managing +* @param progressableView :: [input] The view reporting progress +* @param tablePresenter :: [input] The data processor presenter +* @param searcher :: [input] The search implementation +*/ ReflRunsTabPresenter::ReflRunsTabPresenter( - IReflRunsTabView *mainView, ProgressableView *progressView, + IReflRunsTabView *mainView, ProgressableView *progressableView, boost::shared_ptr<DataProcessorPresenter> tablePresenter, boost::shared_ptr<IReflSearcher> searcher) - : m_view(mainView), m_tablePresenter(tablePresenter), - m_progressView(progressView), m_searcher(searcher) { + : m_view(mainView), m_tablePresenter(tablePresenter), m_mainPresenter(), + m_searcher(searcher) { // Register this presenter as the workspace receiver // When doing so, the inner presenter will notify this @@ -83,6 +91,15 @@ ReflRunsTabPresenter::ReflRunsTabPresenter( ReflRunsTabPresenter::~ReflRunsTabPresenter() {} +/** Accept a main presenter +* @param mainPresenter :: [input] A main presenter +*/ +void ReflRunsTabPresenter::acceptMainPresenter( + IReflMainWindowPresenter *mainPresenter) { + + m_mainPresenter = mainPresenter; +} + /** Used by the view to tell the presenter something has changed */ @@ -305,6 +322,31 @@ void ReflRunsTabPresenter::notify(DataProcessorMainPresenter::Flag flag) { // a flag we aren't handling. } +/** Requests global pre-processing options. Options are supplied by the main +* presenter +* @return :: Global pre-processing options +*/ +std::map<std::string, std::string> +ReflRunsTabPresenter::getPreprocessingOptions() const { + return m_mainPresenter->getPreprocessingOptions(); +} + +/** Requests global pre-processing options. Options are supplied by the main +* presenter +* @return :: Global pre-processing options +*/ +std::string ReflRunsTabPresenter::getProcessingOptions() const { + return m_mainPresenter->getProcessingOptions(); +} + +/** Requests global pre-processing options. Options are supplied by the main +* presenter +* @return :: Global pre-processing options +*/ +std::string ReflRunsTabPresenter::getPostprocessingOptions() const { + return m_mainPresenter->getPostprocessingOptions(); +} + const std::string ReflRunsTabPresenter::MeasureTransferMethod = "Measurement"; const std::string ReflRunsTabPresenter::LegacyTransferMethod = "Description"; } diff --git a/MantidQt/CustomInterfaces/src/Reflectometry/ReflSettingsTabPresenter.cpp b/MantidQt/CustomInterfaces/src/Reflectometry/ReflSettingsTabPresenter.cpp new file mode 100644 index 00000000000..bba464ae6f8 --- /dev/null +++ b/MantidQt/CustomInterfaces/src/Reflectometry/ReflSettingsTabPresenter.cpp @@ -0,0 +1,65 @@ +#include "MantidQtCustomInterfaces/Reflectometry/ReflSettingsTabPresenter.h" +#include "MantidQtCustomInterfaces/Reflectometry/IReflMainWindowPresenter.h" +#include "MantidQtCustomInterfaces/Reflectometry/IReflSettingsTabView.h" + +#include <boost/algorithm/string.hpp> + +namespace MantidQt { +namespace CustomInterfaces { + +/** Constructor +* @param view :: The view we are handling +*/ +ReflSettingsTabPresenter::ReflSettingsTabPresenter(IReflSettingsTabView *view) + : m_view(view), m_mainPresenter() {} + +/** Destructor +*/ +ReflSettingsTabPresenter::~ReflSettingsTabPresenter() {} + +/** Accept a main presenter +* @param mainPresenter :: [input] The main presenter +*/ +void ReflSettingsTabPresenter::acceptMainPresenter( + IReflMainWindowPresenter *mainPresenter) { + m_mainPresenter = mainPresenter; +} + +/** Get global pre-processing options +* @return :: Pre-processing options as a map where keys are column names that +* need pre-processing and values pre-processing options +*/ +std::map<std::string, std::string> +ReflSettingsTabPresenter::getPreprocessingOptions() const { + + // For the moment, return emtpy map + return std::map<std::string, std::string>(); +} + +/** Get global processing options +* @return :: Processing options as a string +*/ +std::string ReflSettingsTabPresenter::getProcessingOptions() const { + + std::vector<std::string> options; + + // Analysis mode + options.push_back("AnalysisMode=" + m_view->getAnalysisMode()); + + return boost::algorithm::join(options, ","); +} + +/** Get global post-processing options +* @return :: Post-processing options as a string +*/ +std::string ReflSettingsTabPresenter::getPostprocessingOptions() const { + + std::vector<std::string> options; + + // Resolution (dQ/Q) + options.push_back("Params=\"" + m_view->getResolution()); + + return boost::algorithm::join(options, ","); +} +} +} \ No newline at end of file diff --git a/MantidQt/MantidWidgets/inc/MantidQtMantidWidgets/DataProcessorUI/DataProcessorMainPresenter.h b/MantidQt/MantidWidgets/inc/MantidQtMantidWidgets/DataProcessorUI/DataProcessorMainPresenter.h index 9818e509d7e..535e80e1407 100644 --- a/MantidQt/MantidWidgets/inc/MantidQtMantidWidgets/DataProcessorUI/DataProcessorMainPresenter.h +++ b/MantidQt/MantidWidgets/inc/MantidQtMantidWidgets/DataProcessorUI/DataProcessorMainPresenter.h @@ -43,6 +43,14 @@ public: // Notify this receiver that something changed in the ADS virtual void notify(DataProcessorMainPresenter::Flag flag) = 0; + + // Return global options for pre-processing + virtual std::map<std::string, std::string> + getPreprocessingOptions() const = 0; + // Return global options for reduction + virtual std::string getProcessingOptions() const = 0; + // Return global options for post-processing + virtual std::string getPostprocessingOptions() const = 0; }; } } diff --git a/MantidQt/MantidWidgets/src/DataProcessorUI/GenericDataProcessorPresenter.cpp b/MantidQt/MantidWidgets/src/DataProcessorUI/GenericDataProcessorPresenter.cpp index f21e8eba9d5..d82d581faff 100644 --- a/MantidQt/MantidWidgets/src/DataProcessorUI/GenericDataProcessorPresenter.cpp +++ b/MantidQt/MantidWidgets/src/DataProcessorUI/GenericDataProcessorPresenter.cpp @@ -23,6 +23,7 @@ #include "MantidQtMantidWidgets/DataProcessorUI/DataProcessorGenerateNotebook.h" #include "MantidQtMantidWidgets/DataProcessorUI/DataProcessorGroupRowsCommand.h" #include "MantidQtMantidWidgets/DataProcessorUI/DataProcessorImportTableCommand.h" +#include "MantidQtMantidWidgets/DataProcessorUI/DataProcessorMainPresenter.h" #include "MantidQtMantidWidgets/DataProcessorUI/DataProcessorNewTableCommand.h" #include "MantidQtMantidWidgets/DataProcessorUI/DataProcessorOpenTableCommand.h" #include "MantidQtMantidWidgets/DataProcessorUI/DataProcessorOptionsCommand.h" @@ -35,7 +36,6 @@ #include "MantidQtMantidWidgets/DataProcessorUI/DataProcessorSeparatorCommand.h" #include "MantidQtMantidWidgets/DataProcessorUI/DataProcessorView.h" #include "MantidQtMantidWidgets/DataProcessorUI/DataProcessorWorkspaceCommand.h" -#include "MantidQtMantidWidgets/DataProcessorUI/DataProcessorMainPresenter.h" #include "MantidQtMantidWidgets/DataProcessorUI/ParseKeyValueString.h" #include "MantidQtMantidWidgets/DataProcessorUI/QDataProcessorTreeModel.h" #include "MantidQtMantidWidgets/DataProcessorUI/QtDataProcessorOptionsDialog.h" @@ -71,8 +71,8 @@ GenericDataProcessorPresenter::GenericDataProcessorPresenter( const DataProcessorPostprocessingAlgorithm &postprocessor) : WorkspaceObserver(), m_view(nullptr), m_progressView(nullptr), m_whitelist(whitelist), m_preprocessMap(preprocessMap), - m_processor(processor), m_postprocessor(postprocessor), - m_mainPresenter(), m_tableDirty(false), m_colGroup(0) { + m_processor(processor), m_postprocessor(postprocessor), m_mainPresenter(), + m_tableDirty(false), m_colGroup(0) { // Column Options must be added to the whitelist m_whitelist.addElement("Options", "Options", @@ -303,15 +303,15 @@ void GenericDataProcessorPresenter::saveNotebook( return; } - // Get all the options used for the reduction from the view - - // TODO : get global pre-processing options as a map where keys are column + // Global pre-processing options as a map where keys are column // name and values are pre-processing options as a string - const std::map<std::string, std::string> preprocessingOptionsMap; - // TODO : get global processing options as a string - const std::string processingOptions; - // TODO : get global post-processing options as a string - const std::string postprocessingOptions; + const std::map<std::string, std::string> preprocessingOptionsMap = + m_mainPresenter->getPreprocessingOptions(); + // Global processing options as a string + const std::string processingOptions = m_mainPresenter->getProcessingOptions(); + // Global post-processing options as a string + const std::string postprocessingOptions = + m_mainPresenter->getPostprocessingOptions(); auto notebook = Mantid::Kernel::make_unique<DataProcessorGenerateNotebook>( m_wsName, m_model, m_view->getProcessInstrument(), m_whitelist, @@ -370,8 +370,8 @@ void GenericDataProcessorPresenter::postProcessGroup( alg->setProperty(m_postprocessor.inputProperty(), inputWSNames); alg->setProperty(m_postprocessor.outputProperty(), outputWSName); - // TODO : get global post-processing options - const std::string options; + // Global post-processing options + const std::string options = m_mainPresenter->getPostprocessingOptions(); auto optionsMap = parseKeyValueString(options); for (auto kvp = optionsMap.begin(); kvp != optionsMap.end(); ++kvp) { @@ -712,6 +712,9 @@ void GenericDataProcessorPresenter::reduceRow(int groupNo, int rowNo) { /* Read input properties from the table */ /* excluding 'Group' and 'Options' */ + // Global pre-processing options as a map + auto globalOptions = m_mainPresenter->getPreprocessingOptions(); + // Loop over all columns in the whitelist except 'Options' for (int i = 0; i < m_columns - 1; i++) { @@ -732,9 +735,8 @@ void GenericDataProcessorPresenter::reduceRow(int groupNo, int rowNo) { auto preprocessor = m_preprocessMap[columnName]; - // TODO : get global pre-processing options for this algorithm as a - // string - const std::string options; + // Global pre-processing options for this algorithm as a string + const std::string options = globalOptions[columnName]; auto optionsMap = parseKeyValueString(options); auto runWS = prepareRunWorkspace(runStr, preprocessor, optionsMap); @@ -751,8 +753,8 @@ void GenericDataProcessorPresenter::reduceRow(int groupNo, int rowNo) { } } - // TODO : get global processing options as a string - std::string options; + // Global processing options as a string + std::string options = m_mainPresenter->getProcessingOptions(); // Parse and set any user-specified options auto optionsMap = parseKeyValueString(options); diff --git a/MantidQt/MantidWidgets/src/DataProcessorUI/QDataProcessorWidget.cpp b/MantidQt/MantidWidgets/src/DataProcessorUI/QDataProcessorWidget.cpp index 4a31657e558..a0e6c5702b5 100644 --- a/MantidQt/MantidWidgets/src/DataProcessorUI/QDataProcessorWidget.cpp +++ b/MantidQt/MantidWidgets/src/DataProcessorUI/QDataProcessorWidget.cpp @@ -18,6 +18,8 @@ using namespace Mantid::API; //---------------------------------------------------------------------------------------------- /** Constructor +* @param presenter :: [input] A unique ptr to the presenter +* @param parent :: [input] The parent of this view */ QDataProcessorWidget::QDataProcessorWidget( boost::shared_ptr<DataProcessorPresenter> presenter, QWidget *parent) -- GitLab