diff --git a/MantidQt/CustomInterfaces/inc/MantidQtCustomInterfaces/Reflectometry/IReflMainWindowPresenter.h b/MantidQt/CustomInterfaces/inc/MantidQtCustomInterfaces/Reflectometry/IReflMainWindowPresenter.h index 9f0442ad9fd66aa506055dd0886064f65b431120..e3c84ecf44274434ffa031361594b6614f4abd2d 100644 --- a/MantidQt/CustomInterfaces/inc/MantidQtCustomInterfaces/Reflectometry/IReflMainWindowPresenter.h +++ b/MantidQt/CustomInterfaces/inc/MantidQtCustomInterfaces/Reflectometry/IReflMainWindowPresenter.h @@ -57,7 +57,7 @@ public: virtual void giveUserInfo(const std::string &prompt, const std::string &title) = 0; virtual std::string runPythonAlgorithm(const std::string &pythonCode) = 0; - virtual std::string getInstrumentName() const = 0; + virtual void setInstrumentName(const std::string &instName) const = 0; }; } } diff --git a/MantidQt/CustomInterfaces/inc/MantidQtCustomInterfaces/Reflectometry/IReflRunsTabPresenter.h b/MantidQt/CustomInterfaces/inc/MantidQtCustomInterfaces/Reflectometry/IReflRunsTabPresenter.h index 34d1e53beace24099620b40aa7d6aa7f9666142d..6dd9da7265e00570fd2656f1d92c6e6fefd2ad08 100644 --- a/MantidQt/CustomInterfaces/inc/MantidQtCustomInterfaces/Reflectometry/IReflRunsTabPresenter.h +++ b/MantidQt/CustomInterfaces/inc/MantidQtCustomInterfaces/Reflectometry/IReflRunsTabPresenter.h @@ -38,13 +38,10 @@ public: /// Accept a main presenter virtual void acceptMainPresenter(IReflMainWindowPresenter *mainPresenter) = 0; - enum Flag { SearchFlag, ICATSearchCompleteFlag, TransferFlag }; + enum Flag { SearchFlag, ICATSearchCompleteFlag, TransferFlag, InstrumentChangedFlag }; // Tell the presenter something happened virtual void notify(IReflRunsTabPresenter::Flag flag) = 0; - - // Get current instrument name - virtual std::string getCurrentInstrumentName() const = 0; }; } } diff --git a/MantidQt/CustomInterfaces/inc/MantidQtCustomInterfaces/Reflectometry/IReflSettingsTabPresenter.h b/MantidQt/CustomInterfaces/inc/MantidQtCustomInterfaces/Reflectometry/IReflSettingsTabPresenter.h index 754a8753ff409e17581a7396aa387330a2281917..f00b18d1476ff9d35ae313d8849add441d4d74fc 100644 --- a/MantidQt/CustomInterfaces/inc/MantidQtCustomInterfaces/Reflectometry/IReflSettingsTabPresenter.h +++ b/MantidQt/CustomInterfaces/inc/MantidQtCustomInterfaces/Reflectometry/IReflSettingsTabPresenter.h @@ -48,8 +48,10 @@ public: enum Flag { ExpDefaultsFlag, InstDefaultsFlag }; - // Tell the presenter something happened + /// Tell the presenter something happened virtual void notify(IReflSettingsTabPresenter::Flag flag) = 0; + /// Set current instrument name + virtual void setInstrumentName(const std::string instName) = 0; }; } } diff --git a/MantidQt/CustomInterfaces/inc/MantidQtCustomInterfaces/Reflectometry/IReflSettingsTabView.h b/MantidQt/CustomInterfaces/inc/MantidQtCustomInterfaces/Reflectometry/IReflSettingsTabView.h index e2f2b4fc7a2279fc816e0f76fba2acd6847755d6..797e61cf681a84d4d5aecd0e27dd026907272949 100644 --- a/MantidQt/CustomInterfaces/inc/MantidQtCustomInterfaces/Reflectometry/IReflSettingsTabView.h +++ b/MantidQt/CustomInterfaces/inc/MantidQtCustomInterfaces/Reflectometry/IReflSettingsTabView.h @@ -78,6 +78,10 @@ public: /// Set default values for settings virtual void setExpDefaults(const std::vector<std::string> &) const = 0; virtual void setInstDefaults(const std::vector<double> &) const = 0; + + /// Set accessibility for polarisation corrections + virtual void setPolarisationCorrectionsAccessibility( + const std::string &) const = 0; }; } } diff --git a/MantidQt/CustomInterfaces/inc/MantidQtCustomInterfaces/Reflectometry/QtReflSettingsTabView.h b/MantidQt/CustomInterfaces/inc/MantidQtCustomInterfaces/Reflectometry/QtReflSettingsTabView.h index 89fc4de39276a8577cc1b5b7f15e70991696afb8..421d4b398f539480a5798567d68c1b2c2231a126 100644 --- a/MantidQt/CustomInterfaces/inc/MantidQtCustomInterfaces/Reflectometry/QtReflSettingsTabView.h +++ b/MantidQt/CustomInterfaces/inc/MantidQtCustomInterfaces/Reflectometry/QtReflSettingsTabView.h @@ -91,6 +91,9 @@ public: /// Creates hints for 'Stitch1DMany' void createStitchHints(const std::map<std::string, std::string> &hints) override; + /// Sets accessibility status for polarisation corrections option + void setPolarisationCorrectionsAccessibility( + const std::string &instName) const override; public slots: /// Request presenter to obtain default values for settings diff --git a/MantidQt/CustomInterfaces/inc/MantidQtCustomInterfaces/Reflectometry/ReflMainWindowPresenter.h b/MantidQt/CustomInterfaces/inc/MantidQtCustomInterfaces/Reflectometry/ReflMainWindowPresenter.h index db32f8e4037dc13a4ea05a82bf10bf49206107db..91d82d57f2b6ed55fd028717d0dac78ae38a60bb 100644 --- a/MantidQt/CustomInterfaces/inc/MantidQtCustomInterfaces/Reflectometry/ReflMainWindowPresenter.h +++ b/MantidQt/CustomInterfaces/inc/MantidQtCustomInterfaces/Reflectometry/ReflMainWindowPresenter.h @@ -52,8 +52,6 @@ public: std::string getReductionOptions() const override; /// Returns global options for 'Stitch1DMany' std::string getStitchOptions() const override; - /// Returns instrument name - std::string getInstrumentName() const override; /// Dialog/Prompt methods std::string askUserString(const std::string &prompt, const std::string &title, @@ -67,6 +65,7 @@ public: void giveUserInfo(const std::string &prompt, const std::string &title) override; std::string runPythonAlgorithm(const std::string &pythonCode) override; + void setInstrumentName(const std::string &instName) const override; private: /// Check for null pointer diff --git a/MantidQt/CustomInterfaces/inc/MantidQtCustomInterfaces/Reflectometry/ReflRunsTabPresenter.h b/MantidQt/CustomInterfaces/inc/MantidQtCustomInterfaces/Reflectometry/ReflRunsTabPresenter.h index 9791de9e884cb9490b8c59077cae61df1161c629..4c859f25e3068f75f33a4ca7169b4283537dc60e 100644 --- a/MantidQt/CustomInterfaces/inc/MantidQtCustomInterfaces/Reflectometry/ReflRunsTabPresenter.h +++ b/MantidQt/CustomInterfaces/inc/MantidQtCustomInterfaces/Reflectometry/ReflRunsTabPresenter.h @@ -77,8 +77,6 @@ public: std::map<std::string, std::string> getPreprocessingOptions() const override; std::string getProcessingOptions() const override; std::string getPostprocessingOptions() const override; - /// Get current instrument name - std::string getCurrentInstrumentName() const override; protected: /// The search model diff --git a/MantidQt/CustomInterfaces/inc/MantidQtCustomInterfaces/Reflectometry/ReflSettingsTabPresenter.h b/MantidQt/CustomInterfaces/inc/MantidQtCustomInterfaces/Reflectometry/ReflSettingsTabPresenter.h index a7e8ed7eec7c8f53fd170da53d590ca50df8c7b2..49ac28b44f0173a6ea36520b4296ad2b4567e836 100644 --- a/MantidQt/CustomInterfaces/inc/MantidQtCustomInterfaces/Reflectometry/ReflSettingsTabPresenter.h +++ b/MantidQt/CustomInterfaces/inc/MantidQtCustomInterfaces/Reflectometry/ReflSettingsTabPresenter.h @@ -52,6 +52,7 @@ public: /// Accept a main presenter void acceptMainPresenter(IReflMainWindowPresenter *mainPresenter) override; void notify(IReflSettingsTabPresenter::Flag flag) override; + void setInstrumentName(const std::string instName) override; /// Returns global options for 'CreateTransmissionWorkspaceAuto' std::string getTransmissionOptions() const override; @@ -72,6 +73,8 @@ private: IReflSettingsTabView *m_view; /// The main presenter IReflMainWindowPresenter *m_mainPresenter; + /// Name of the current instrument in use + std::string currentInstrumentName; }; } } diff --git a/MantidQt/CustomInterfaces/src/Reflectometry/QtReflRunsTabView.cpp b/MantidQt/CustomInterfaces/src/Reflectometry/QtReflRunsTabView.cpp index dda395776770d90249b1582776922fe752c51bd3..fef3bc979ba73c865a6fd10369dca0bf3d3cb663 100644 --- a/MantidQt/CustomInterfaces/src/Reflectometry/QtReflRunsTabView.cpp +++ b/MantidQt/CustomInterfaces/src/Reflectometry/QtReflRunsTabView.cpp @@ -54,6 +54,13 @@ void QtReflRunsTabView::initLayout() { std::unique_ptr<DataProcessorPresenter>(presenterFactory.create()), this); ui.layoutProcessPane->addWidget(qDataProcessorWidget); + // Create the presenter + m_presenter = std::make_shared<ReflRunsTabPresenter>( + this /* main view */, + this /* Currently this concrete view is also responsible for prog reporting */, + qDataProcessorWidget->getPresenter() /* The data processor presenter */); + m_algoRunner = boost::make_shared<MantidQt::API::AlgorithmRunner>(this); + // Custom context menu for table connect(ui.tableSearchResults, SIGNAL(customContextMenuRequested(const QPoint &)), this, @@ -71,13 +78,6 @@ void QtReflRunsTabView::initLayout() { connect(qDataProcessorWidget, SIGNAL(comboProcessInstrument_currentIndexChanged(int)), this, SLOT(instrumentChanged(int))); - - // Create the presenter - m_presenter = std::make_shared<ReflRunsTabPresenter>( - this /* main view */, - this /* Currently this concrete view is also responsible for prog reporting */, - qDataProcessorWidget->getPresenter() /* The data processor presenter */); - m_algoRunner = boost::make_shared<MantidQt::API::AlgorithmRunner>(this); } /** @@ -241,15 +241,18 @@ void QtReflRunsTabView::showSearchContextMenu(const QPoint &pos) { } /** This is slot is triggered when any of the instrument combo boxes changes. It - * is used to update the Slit Calculator + * notifies the main presenter and updates the Slit Calculator * @param index : The index of the combo box */ void QtReflRunsTabView::instrumentChanged(int index) { m_calculator->setCurrentInstrumentName( ui.comboSearchInstrument->itemText(index).toStdString()); m_calculator->processInstrumentHasBeenChanged(); + m_presenter->notify(IReflRunsTabPresenter::InstrumentChangedFlag); } +/** Notifies + /** Get the selected instrument for searching @returns the selected instrument to search for diff --git a/MantidQt/CustomInterfaces/src/Reflectometry/QtReflSettingsTabView.cpp b/MantidQt/CustomInterfaces/src/Reflectometry/QtReflSettingsTabView.cpp index 1eca6096759a1a156f536808ecfa06f7b9212583..9793a2c97e9a1947b9bc56e5dd687dc5dfbab72e 100644 --- a/MantidQt/CustomInterfaces/src/Reflectometry/QtReflSettingsTabView.cpp +++ b/MantidQt/CustomInterfaces/src/Reflectometry/QtReflSettingsTabView.cpp @@ -99,6 +99,22 @@ void QtReflSettingsTabView::setInstDefaults( m_ui.I0MonIndexEdit->setText(QString::number(defaults[7])); } +/* Sets the accessibility status of the polarisation corrections option based +* upon the name of the instrument currently being used +* @param instName :: [input] The name of the instrument being used +*/ +void QtReflSettingsTabView::setPolarisationCorrectionsAccessibility( + const std::string &instName) const { + bool isAccessible = (instName != "INTER" && instName != "SURF"); + m_ui.polCorrComboBox->setEnabled(isAccessible); + // Set text to 'None' if inaccessible + if (!isAccessible) { + int noneIndex = m_ui.polCorrComboBox->findText("None"); + if (noneIndex != -1) + m_ui.polCorrComboBox->setCurrentIndex(noneIndex); + } +} + /** Returns global options for 'Stitch1DMany' * @return :: Global options for 'Stitch1DMany' */ diff --git a/MantidQt/CustomInterfaces/src/Reflectometry/ReflMainWindowPresenter.cpp b/MantidQt/CustomInterfaces/src/Reflectometry/ReflMainWindowPresenter.cpp index 1be09ba73165ee4d836235f856be496255e05687..5b61e4037e897a96ede93d695af541344f02953d 100644 --- a/MantidQt/CustomInterfaces/src/Reflectometry/ReflMainWindowPresenter.cpp +++ b/MantidQt/CustomInterfaces/src/Reflectometry/ReflMainWindowPresenter.cpp @@ -20,6 +20,9 @@ ReflMainWindowPresenter::ReflMainWindowPresenter( // Tell the tab presenters that this is going to be the main presenter m_runsPresenter->acceptMainPresenter(this); m_settingsPresenter->acceptMainPresenter(this); + + // Trigger the setting of the current instrument name in settings tab + m_runsPresenter->notify(IReflRunsTabPresenter::InstrumentChangedFlag); } /** Destructor @@ -129,9 +132,13 @@ ReflMainWindowPresenter::runPythonAlgorithm(const std::string &pythonCode) { return m_view->runPythonAlgorithm(pythonCode); } -std::string ReflMainWindowPresenter::getInstrumentName() const { +/** +Tells the setting tab presenter what to set its current instrument name to +* @param instName : The name of the instrument to be set +*/ +void ReflMainWindowPresenter::setInstrumentName(const std::string &instName) const { - return m_runsPresenter->getCurrentInstrumentName(); + m_settingsPresenter->setInstrumentName(instName); } /** Checks for null pointer diff --git a/MantidQt/CustomInterfaces/src/Reflectometry/ReflRunsTabPresenter.cpp b/MantidQt/CustomInterfaces/src/Reflectometry/ReflRunsTabPresenter.cpp index 0655c790f188ac18b96db93d528b8a0a18e59429..1c0addb7f876cff44388053c50847e192a662fd8 100644 --- a/MantidQt/CustomInterfaces/src/Reflectometry/ReflRunsTabPresenter.cpp +++ b/MantidQt/CustomInterfaces/src/Reflectometry/ReflRunsTabPresenter.cpp @@ -50,14 +50,6 @@ ReflRunsTabPresenter::ReflRunsTabPresenter( // presenter with the list of commands m_tablePresenter->accept(this); - // TODO. Select strategy. - /* - std::unique_ptr<CatalogConfigService> catConfigService( - makeCatalogConfigServiceAdapter(ConfigService::Instance())); - UserCatalogInfo catalogInfo( - ConfigService::Instance().getFacility().catalogInfo(), *catConfigService); - */ - // If we don't have a searcher yet, use ReflCatalogSearcher if (!m_searcher) m_searcher.reset(new ReflCatalogSearcher()); @@ -113,10 +105,14 @@ void ReflRunsTabPresenter::notify(IReflRunsTabPresenter::Flag flag) { auto algRunner = m_view->getAlgorithmRunner(); IAlgorithm_sptr searchAlg = algRunner->getAlgorithm(); populateSearch(searchAlg); - } break; + break; + } case IReflRunsTabPresenter::TransferFlag: transfer(); break; + case IReflRunsTabPresenter::InstrumentChangedFlag: + m_mainPresenter->setInstrumentName(m_view->getSearchInstrument()); + break; } // Not having a 'default' case is deliberate. gcc issues a warning if there's // a flag we aren't handling. @@ -202,7 +198,7 @@ void ReflRunsTabPresenter::populateSearch(IAlgorithm_sptr searchAlg) { if (searchAlg->isExecuted()) { ITableWorkspace_sptr results = searchAlg->getProperty("OutputWorkspace"); m_searchModel = ReflSearchModel_sptr(new ReflSearchModel( - *getTransferStrategy(), results, getCurrentInstrumentName())); + *getTransferStrategy(), results, m_view->getSearchInstrument())); m_view->showSearch(m_searchModel); } } @@ -362,14 +358,6 @@ std::string ReflRunsTabPresenter::getPostprocessingOptions() const { return m_mainPresenter->getStitchOptions(); } -/** -Gets the currently selected (or default) instrument -* @return : The current instrument -*/ -std::string ReflRunsTabPresenter::getCurrentInstrumentName() const { - return m_view->getSearchInstrument(); -} - /** Tells the view to show an critical error dialog @param prompt : The prompt to appear on the dialog diff --git a/MantidQt/CustomInterfaces/src/Reflectometry/ReflSettingsTabPresenter.cpp b/MantidQt/CustomInterfaces/src/Reflectometry/ReflSettingsTabPresenter.cpp index 19393b7b24d29a2f685b4f69b615f7b0da720968..d5069c15dce85e1b6eab1c5719a78465a71c4cff 100644 --- a/MantidQt/CustomInterfaces/src/Reflectometry/ReflSettingsTabPresenter.cpp +++ b/MantidQt/CustomInterfaces/src/Reflectometry/ReflSettingsTabPresenter.cpp @@ -49,6 +49,15 @@ void ReflSettingsTabPresenter::notify(IReflSettingsTabPresenter::Flag flag) { // a flag we aren't handling. } +/** Sets the current instrument name and changes accessibility status of +* the polarisation corrections option in the view accordingly +* @param instName :: [input] The name of the instrument to set to +*/ +void ReflSettingsTabPresenter::setInstrumentName(const std::string instName) { + currentInstrumentName = instName; + m_view->setPolarisationCorrectionsAccessibility(currentInstrumentName); +} + /** Returns global options for 'CreateTransmissionWorkspaceAuto' * @return :: Global options for 'CreateTransmissionWorkspaceAuto' */ @@ -275,7 +284,7 @@ void ReflSettingsTabPresenter::createStitchHints() { void ReflSettingsTabPresenter::getExpDefaults() { // Algorithm and instrument auto alg = createReductionAlg(); - auto inst = createEmptyInstrument(m_mainPresenter->getInstrumentName()); + auto inst = createEmptyInstrument(currentInstrumentName); // Collect all default values and set them in view std::vector<std::string> defaults(7); @@ -308,7 +317,7 @@ void ReflSettingsTabPresenter::getExpDefaults() { void ReflSettingsTabPresenter::getInstDefaults() { // Algorithm and instrument auto alg = createReductionAlg(); - auto inst = createEmptyInstrument(m_mainPresenter->getInstrumentName()); + auto inst = createEmptyInstrument(currentInstrumentName); // Collect all default values std::vector<double> defaults(8);