diff --git a/qt/scientific_interfaces/Inelastic/BayesFitting/BayesFitting.cpp b/qt/scientific_interfaces/Inelastic/BayesFitting/BayesFitting.cpp index 07f14bfe4e52..dc6f47bd9313 100644 --- a/qt/scientific_interfaces/Inelastic/BayesFitting/BayesFitting.cpp +++ b/qt/scientific_interfaces/Inelastic/BayesFitting/BayesFitting.cpp @@ -8,12 +8,10 @@ #include "MantidQtWidgets/Spectroscopy/SettingsWidget/Settings.h" #include "Quasi.h" #include "ResNormPresenter.h" -#include "Stretch.h" +#include "StretchPresenter.h" #include -using namespace MantidQt::CustomInterfaces; - namespace MantidQt::CustomInterfaces { DECLARE_SUBWINDOW(BayesFitting) @@ -25,17 +23,26 @@ BayesFitting::BayesFitting(QWidget *parent) // Connect Poco Notification Observer Mantid::Kernel::ConfigService::Instance().addObserver(m_changeObserver); - auto jobRunner = std::make_unique(true); - auto algorithmRunner = std::make_unique(std::move(jobRunner)); + auto resNormRunner = std::move(createAlgorithmRunner()); // insert each tab into the interface on creation auto resNormModel = std::make_unique(); auto resNormWidget = m_uiForm.bayesFittingTabs->widget(RES_NORM); - m_bayesTabs.emplace(RES_NORM, new ResNormPresenter(resNormWidget, std::move(algorithmRunner), std::move(resNormModel), + m_bayesTabs.emplace(RES_NORM, new ResNormPresenter(resNormWidget, std::move(resNormRunner), std::move(resNormModel), new ResNormView(resNormWidget))); m_bayesTabs.emplace(QUASI, new Quasi(m_uiForm.bayesFittingTabs->widget(QUASI))); - m_bayesTabs.emplace(STRETCH, new Stretch(m_uiForm.bayesFittingTabs->widget(STRETCH))); + + auto stretchRunner = std::move(createAlgorithmRunner()); + + auto tabContent = m_uiForm.bayesFittingTabs->widget(STRETCH); + m_bayesTabs.emplace(STRETCH, new StretchPresenter(tabContent, new StretchView(tabContent), + std::make_unique(), std::move(stretchRunner))); +} + +std::unique_ptr BayesFitting::createAlgorithmRunner() { + auto jobRunner = std::make_unique(true); + return std::make_unique(std::move(jobRunner)); } void BayesFitting::initLayout() { diff --git a/qt/scientific_interfaces/Inelastic/BayesFitting/BayesFitting.h b/qt/scientific_interfaces/Inelastic/BayesFitting/BayesFitting.h index 64ec3f104722..2e6187e629ac 100644 --- a/qt/scientific_interfaces/Inelastic/BayesFitting/BayesFitting.h +++ b/qt/scientific_interfaces/Inelastic/BayesFitting/BayesFitting.h @@ -45,6 +45,8 @@ class MANTIDQT_INELASTIC_DLL BayesFitting : public InelasticInterface { void initLayout() override; private: + std::unique_ptr createAlgorithmRunner(); + std::string documentationPage() const override; void applySettings(std::map const &settings) override; diff --git a/qt/scientific_interfaces/Inelastic/BayesFitting/CMakeLists.txt b/qt/scientific_interfaces/Inelastic/BayesFitting/CMakeLists.txt index 0b5eb2f4951c..bc2dda0b725d 100644 --- a/qt/scientific_interfaces/Inelastic/BayesFitting/CMakeLists.txt +++ b/qt/scientific_interfaces/Inelastic/BayesFitting/CMakeLists.txt @@ -7,12 +7,14 @@ set(SRC_FILES ResNormModel.cpp ResNormView.cpp ResNormPresenter.cpp - Stretch.cpp + StretchView.cpp + StretchPresenter.cpp + StretchModel.cpp ) -set(INC_FILES ResNormPresenter.h ResNormModel.h) +set(INC_FILES ResNormPresenter.h ResNormModel.h StretchPresenter.h StretchModel.h) -set(MOC_FILES BayesFitting.h BayesFittingTab.h Quasi.h ResNormView.h Stretch.h) +set(MOC_FILES BayesFitting.h BayesFittingTab.h Quasi.h ResNormView.h StretchView.h) set(UI_FILES BayesFitting.ui Quasi.ui ResNorm.ui Stretch.ui) @@ -29,7 +31,6 @@ set(ALL_INC_FILES ${ALL_INC_FILES} ${INC_FILES} PARENT_SCOPE ) - set(ALL_MOC_FILES ${ALL_MOC_FILES} ${MOC_FILES} PARENT_SCOPE diff --git a/qt/scientific_interfaces/Inelastic/BayesFitting/Stretch.cpp b/qt/scientific_interfaces/Inelastic/BayesFitting/Stretch.cpp deleted file mode 100644 index 6902b33f67b8..000000000000 --- a/qt/scientific_interfaces/Inelastic/BayesFitting/Stretch.cpp +++ /dev/null @@ -1,482 +0,0 @@ -// Mantid Repository : https://github.com/mantidproject/mantid -// -// Copyright © 2018 ISIS Rutherford Appleton Laboratory UKRI, -// NScD Oak Ridge National Laboratory, European Spallation Source, -// Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS -// SPDX - License - Identifier: GPL - 3.0 + -#include "Stretch.h" -#include "MantidAPI/AlgorithmManager.h" -#include "MantidQtWidgets/Common/UserInputValidator.h" -#include "MantidQtWidgets/Common/WorkspaceUtils.h" -#include "MantidQtWidgets/Spectroscopy/InterfaceUtils.h" -#include "MantidQtWidgets/Spectroscopy/RunWidget/RunView.h" -#include "MantidQtWidgets/Spectroscopy/SettingsWidget/SettingsHelper.h" - -using namespace Mantid::API; - -using namespace MantidQt::MantidWidgets::WorkspaceUtils; -using namespace MantidQt::CustomInterfaces::InterfaceUtils; - -namespace { -Mantid::Kernel::Logger g_log("Stretch"); -struct PlotType { - inline static const std::string ALL = "All"; - inline static const std::string SIGMA = "Sigma"; - inline static const std::string BETA = "Beta"; - inline static const std::string FWHM = "FWHM"; -}; -} // namespace - -namespace MantidQt::CustomInterfaces { -Stretch::Stretch(QWidget *parent, std::unique_ptr algorithmRunner) - : BayesFittingTab(parent, std::move(algorithmRunner)), m_previewSpec(0), m_save(false) { - m_uiForm.setupUi(parent); - - setRunWidgetPresenter(std::make_unique(this, m_uiForm.runWidget)); - - // Create range selector - auto eRangeSelector = m_uiForm.ppPlot->addRangeSelector("StretchERange"); - connect(eRangeSelector, &MantidWidgets::RangeSelector::minValueChanged, this, &Stretch::minValueChanged); - connect(eRangeSelector, &MantidWidgets::RangeSelector::maxValueChanged, this, &Stretch::maxValueChanged); - setupFitOptions(); - setupPropertyBrowser(); - setupPlotOptions(); - - // Connect the data selector for the sample to the mini plot - connect(m_uiForm.dsSample, &DataSelector::dataReady, this, &Stretch::handleSampleInputReady); - connect(m_uiForm.chkSequentialFit, &QCheckBox::toggled, m_uiForm.cbPlot, &QComboBox::setEnabled); - // Connect preview spectrum spinner to handler - connect(m_uiForm.spPreviewSpectrum, static_cast(&QSpinBox::valueChanged), this, - &Stretch::previewSpecChanged); - m_uiForm.spPreviewSpectrum->setMaximum(0); - - // Connect the plot and save push buttons - connect(m_uiForm.pbPlot, &QPushButton::clicked, this, &Stretch::plotWorkspaces); - connect(m_uiForm.pbPlotContour, &QPushButton::clicked, this, &Stretch::plotContourClicked); - connect(m_uiForm.pbSave, &QPushButton::clicked, this, &Stretch::saveWorkspaces); - connect(m_uiForm.pbPlotPreview, &QPushButton::clicked, this, &Stretch::plotCurrentPreview); - - // Allows empty workspace selector when initially selected - m_uiForm.dsSample->isOptional(true); - m_uiForm.dsResolution->isOptional(true); -} - -void Stretch::setFileExtensionsByName(bool filter) { - QStringList const noSuffixes{""}; - auto const tabName("Stretch"); - m_uiForm.dsSample->setFBSuffixes(filter ? getSampleFBSuffixes(tabName) : getExtensions(tabName)); - m_uiForm.dsSample->setWSSuffixes(filter ? getSampleWSSuffixes(tabName) : noSuffixes); - m_uiForm.dsResolution->setFBSuffixes(filter ? getResolutionFBSuffixes(tabName) : getExtensions(tabName)); - m_uiForm.dsResolution->setWSSuffixes(filter ? getResolutionWSSuffixes(tabName) : noSuffixes); -} - -void Stretch::setLoadHistory(bool doLoadHistory) { - m_uiForm.dsSample->setLoadProperty("LoadHistory", doLoadHistory); - m_uiForm.dsResolution->setLoadProperty("LoadHistory", doLoadHistory); -} - -void Stretch::handleValidation(IUserInputValidator *validator) const { - validator->checkDataSelectorIsValid("Sample", m_uiForm.dsSample); - validator->checkDataSelectorIsValid("Resolution", m_uiForm.dsResolution); -} - -void Stretch::handleRun() { - auto const saveDirectory = Mantid::Kernel::ConfigService::Instance().getString("defaultsave.directory"); - if (saveDirectory.empty()) { - int const result = displaySaveDirectoryMessage(); - if (result == QMessageBox::No) { - m_runPresenter->setRunEnabled(true); - return; - } - } - - m_uiForm.ppPlot->watchADS(false); - - // Workspace input - auto const sampleName = m_uiForm.dsSample->getCurrentDataName().toStdString(); - auto const resName = m_uiForm.dsResolution->getCurrentDataName().toStdString(); - - // Collect input from options section - auto const background = m_uiForm.cbBackground->currentText().toStdString(); - - // Collect input from the properties browser - auto const eMin = m_properties["EMin"]->valueText().toDouble(); - auto const eMax = m_properties["EMax"]->valueText().toDouble(); - auto const beta = m_properties["Beta"]->valueText().toInt(); - - // Bool options - auto const elasticPeak = m_uiForm.chkElasticPeak->isChecked(); - - // Construct OutputNames - auto const cutIndex = sampleName.find_last_of("_"); - auto const baseName = sampleName.substr(0, cutIndex); - m_fitWorkspaceName = baseName + "_Stretch_Fit"; - m_contourWorkspaceName = baseName + "_Stretch_Contour"; - - // Temporary developer flag to allow the testing of quickBayes in the Bayes fitting interface - auto const useQuickBayes = SettingsHelper::hasDevelopmentFlag("quickbayes"); - - std::string const algorithmName = useQuickBayes ? "BayesStretch2" : "BayesStretch"; - auto stretch = AlgorithmManager::Instance().create(algorithmName); - stretch->initialize(); - stretch->setProperty("SampleWorkspace", sampleName); - stretch->setProperty("ResolutionWorkspace", resName); - stretch->setProperty("EMin", eMin); - stretch->setProperty("EMax", eMax); - stretch->setProperty("NumberBeta", beta); - stretch->setProperty("Elastic", elasticPeak); - stretch->setProperty("OutputWorkspaceFit", m_fitWorkspaceName); - stretch->setProperty("OutputWorkspaceContour", m_contourWorkspaceName); - stretch->setProperty("Background", background); - if (!useQuickBayes) { - auto const sigma = m_properties["Sigma"]->valueText().toInt(); - auto const nBins = m_properties["SampleBinning"]->valueText().toInt(); - auto const sequence = m_uiForm.chkSequentialFit->isChecked(); - - stretch->setProperty("SampleBins", nBins); - stretch->setProperty("NumberSigma", sigma); - stretch->setProperty("Loop", sequence); - } - - m_batchAlgoRunner->addAlgorithm(stretch); - connect(m_batchAlgoRunner, &API::BatchAlgorithmRunner::batchComplete, this, &Stretch::algorithmComplete); - m_batchAlgoRunner->executeBatchAsync(); -} - -/** - * Handles the saving and plotting of workspaces after execution - */ -void Stretch::algorithmComplete(const bool &error) { - disconnect(m_batchAlgoRunner, &API::BatchAlgorithmRunner::batchComplete, this, &Stretch::algorithmComplete); - - m_runPresenter->setRunEnabled(true); - setPlotResultEnabled(!error); - setPlotContourEnabled(!error); - setSaveResultEnabled(!error); - if (!error) { - if (doesExistInADS(m_contourWorkspaceName)) - populateContourWorkspaceComboBox(); - else - setPlotContourEnabled(false); - - m_uiForm.ppPlot->watchADS(true); - } -} - -void Stretch::populateContourWorkspaceComboBox() { - m_uiForm.cbPlotContour->clear(); - auto const contourGroup = getADSWorkspace(m_contourWorkspaceName); - auto const contourNames = contourGroup->getNames(); - for (auto const &name : contourNames) - m_uiForm.cbPlotContour->addItem(QString::fromStdString(name)); -} - -/** - * Handles the saving of workspaces post algorithm completion - * when save button is clicked - */ -void Stretch::saveWorkspaces() { - - auto fitWorkspace = QString::fromStdString(m_fitWorkspaceName); - auto contourWorkspace = QString::fromStdString(m_contourWorkspaceName); - // Check workspaces exist - InelasticTab::checkADSForPlotSaveWorkspace(m_fitWorkspaceName, false); - InelasticTab::checkADSForPlotSaveWorkspace(m_contourWorkspaceName, false); - - const auto saveDir = - QString::fromStdString(Mantid::Kernel::ConfigService::Instance().getString("defaultsave.directory")); - // Check validity of save path - const auto fitFullPath = saveDir + fitWorkspace + QString::fromStdString(".nxs"); - const auto contourFullPath = saveDir + contourWorkspace + QString::fromStdString(".nxs"); - addSaveWorkspaceToQueue(fitWorkspace, fitFullPath); - addSaveWorkspaceToQueue(contourWorkspace, contourFullPath); - m_batchAlgoRunner->executeBatchAsync(); -} - -int Stretch::displaySaveDirectoryMessage() { - char const *textMessage = "BayesStretch requires a default save directory and " - "one is not currently set." - " If run, the algorithm will default to saving files " - "to the current working directory." - " Would you still like to run the algorithm?"; - return QMessageBox::question(nullptr, tr("Save Directory"), tr(textMessage), QMessageBox::Yes, QMessageBox::No, - QMessageBox::NoButton); -} - -/** - * Handles the plotting of workspace post algorithm completion - */ -void Stretch::plotWorkspaces() { - setPlotResultIsPlotting(true); - - std::string const plotType = m_uiForm.cbPlot->currentText().toStdString(); - auto const plotErrors = SettingsHelper::externalPlotErrorBars(); - auto const plotSigma = (plotType == "All" || plotType == "Sigma"); - auto const plotBeta = (plotType == "All" || plotType == "Beta"); - - auto const fitWorkspace = getADSWorkspace(m_fitWorkspaceName); - for (auto it = fitWorkspace->begin(); it < fitWorkspace->end(); ++it) { - auto const name = (*it)->getName(); - if (plotSigma && name.substr(name.length() - 5) == "Sigma") { - m_plotter->plotSpectra(name, "0", plotErrors); - } else if (plotBeta && name.substr(name.length() - 4) == "Beta") { - m_plotter->plotSpectra(name, "0", plotErrors); - } - } - setPlotResultIsPlotting(false); -} - -void Stretch::plotContourClicked() { - setPlotContourIsPlotting(true); - - auto const workspaceName = m_uiForm.cbPlotContour->currentText().toStdString(); - if (checkADSForPlotSaveWorkspace(workspaceName, true)) - m_plotter->plotContour(workspaceName); - - setPlotContourIsPlotting(false); -} - -/** - * Set the data selectors to use the default save directory - * when browsing for input files. - * - * @param settings :: The current settings - */ -void Stretch::loadSettings(const QSettings &settings) { - m_uiForm.dsSample->readSettings(settings.group()); - m_uiForm.dsResolution->readSettings(settings.group()); -} - -/** - * Get called whenever the settings are updated - * - * @param settings :: The current settings - */ -void Stretch::applySettings(std::map const &settings) { - setupFitOptions(); - setupPropertyBrowser(); - setupPlotOptions(); - setFileExtensionsByName(settings.at("RestrictInput").toBool()); - setLoadHistory(settings.at("LoadHistory").toBool()); -} - -/** - * Setup the fit options based on the algorithm used - * - */ -void Stretch::setupFitOptions() { - auto const useQuickBayes = SettingsHelper::hasDevelopmentFlag("quickbayes"); - m_uiForm.cbBackground->clear(); - if (useQuickBayes) { - m_uiForm.cbBackground->addItem(QString::fromStdString(BackgroundType::LINEAR)); - m_uiForm.cbBackground->addItem(QString::fromStdString(BackgroundType::FLAT)); - m_uiForm.cbBackground->addItem(QString::fromStdString(BackgroundType::ZERO)); - m_uiForm.chkSequentialFit->hide(); - } else { - m_uiForm.cbBackground->addItem(QString::fromStdString(BackgroundType::SLOPING)); - m_uiForm.cbBackground->addItem(QString::fromStdString(BackgroundType::FLAT)); - m_uiForm.cbBackground->addItem(QString::fromStdString(BackgroundType::ZERO)); - m_uiForm.chkSequentialFit->show(); - } -} - -/** - * Setup the property browser based on the algorithm used - * - */ -void Stretch::setupPropertyBrowser() { - auto const useQuickBayes = SettingsHelper::hasDevelopmentFlag("quickbayes"); - - m_properties.clear(); - m_dblManager->clear(); - m_propTree->clear(); - - m_uiForm.treeSpace->addWidget(m_propTree); - - m_properties["EMin"] = m_dblManager->addProperty("EMin"); - m_properties["EMax"] = m_dblManager->addProperty("EMax"); - m_properties["Beta"] = m_dblManager->addProperty("Beta"); - - m_dblManager->setDecimals(m_properties["EMin"], NUM_DECIMALS); - m_dblManager->setDecimals(m_properties["EMax"], NUM_DECIMALS); - m_dblManager->setDecimals(m_properties["Beta"], INT_DECIMALS); - - m_propTree->addProperty(m_properties["EMin"]); - m_propTree->addProperty(m_properties["EMax"]); - m_propTree->addProperty(m_properties["Beta"]); - - m_dblManager->setValue(m_properties["Beta"], 50); - m_dblManager->setMinimum(m_properties["Beta"], 1); - m_dblManager->setMaximum(m_properties["Beta"], 200); - - if (!useQuickBayes) { - m_properties["SampleBinning"] = m_dblManager->addProperty("Sample Binning"); - m_properties["Sigma"] = m_dblManager->addProperty("Sigma"); - - m_dblManager->setDecimals(m_properties["SampleBinning"], INT_DECIMALS); - m_dblManager->setDecimals(m_properties["Sigma"], INT_DECIMALS); - - m_propTree->addProperty(m_properties["SampleBinning"]); - m_propTree->addProperty(m_properties["Sigma"]); - - m_dblManager->setValue(m_properties["Sigma"], 50); - m_dblManager->setMinimum(m_properties["Sigma"], 1); - m_dblManager->setMaximum(m_properties["Sigma"], 200); - m_dblManager->setValue(m_properties["SampleBinning"], 1); - m_dblManager->setMinimum(m_properties["SampleBinning"], 1); - } - - formatTreeWidget(m_propTree, m_properties); -} - -/** - * Setup the plot options based on the algorithm used - * - */ -void Stretch::setupPlotOptions() { - auto const useQuickBayes = SettingsHelper::hasDevelopmentFlag("quickbayes"); - m_uiForm.cbPlot->clear(); - if (useQuickBayes) { - m_uiForm.cbPlot->addItem(QString::fromStdString(PlotType::ALL)); - m_uiForm.cbPlot->addItem(QString::fromStdString(PlotType::FWHM)); - m_uiForm.cbPlot->addItem(QString::fromStdString(PlotType::BETA)); - } else { - m_uiForm.cbPlot->addItem(QString::fromStdString(PlotType::ALL)); - m_uiForm.cbPlot->addItem(QString::fromStdString(PlotType::SIGMA)); - m_uiForm.cbPlot->addItem(QString::fromStdString(PlotType::BETA)); - } -} - -/** - * Plots the loaded file to the miniplot and sets the guides - * and the range - * - * @param filename :: The name of the workspace to plot - */ -void Stretch::handleSampleInputReady(const QString &filename) { - try { - m_uiForm.ppPlot->clear(); - m_uiForm.ppPlot->addSpectrum("Sample", filename, 0); - } catch (std::exception const &ex) { - g_log.warning(ex.what()); - return; - } - - // update the maximum and minimum range bar positions - auto const range = getXRangeFromWorkspace(filename.toStdString()); - auto eRangeSelector = m_uiForm.ppPlot->getRangeSelector("StretchERange"); - setRangeSelector(eRangeSelector, m_properties["EMin"], m_properties["EMax"], range); - setPlotPropertyRange(eRangeSelector, m_properties["EMin"], m_properties["EMax"], range); - // update the current positions of the range bars - eRangeSelector->setMinimum(range.first); - eRangeSelector->setMaximum(range.second); - - // set the max spectrum - MatrixWorkspace_const_sptr sampleWs = getADSWorkspace(filename.toStdString()); - const int spectra = static_cast(sampleWs->getNumberHistograms()); - m_uiForm.spPreviewSpectrum->setMaximum(spectra - 1); -} - -/** - * Sets a new preview spectrum for the mini plot. - * - * @param value workspace index - */ -void Stretch::previewSpecChanged(int value) { - m_previewSpec = value; - - if (!m_uiForm.dsSample->isValid()) - return; - - m_uiForm.ppPlot->clear(); - - auto const sampleName = m_uiForm.dsSample->getCurrentDataName(); - try { - m_uiForm.ppPlot->addSpectrum("Sample", sampleName, m_previewSpec); - } catch (std::exception const &ex) { - g_log.warning(ex.what()); - } -} - -/** - * plots the current miniplot preview - */ -void Stretch::plotCurrentPreview() { - if (m_uiForm.ppPlot->hasCurve("Sample")) { - m_plotter->plotSpectra(m_uiForm.dsSample->getCurrentDataName().toStdString(), std::to_string(m_previewSpec), - SettingsHelper::externalPlotErrorBars()); - } -} - -/** - * Updates the property manager when the lower guide is moved on the mini plot - * - * @param min :: The new value of the lower guide - */ -void Stretch::minValueChanged(double min) { - disconnect(m_dblManager, &QtDoublePropertyManager::valueChanged, this, &Stretch::updateProperties); - m_dblManager->setValue(m_properties["EMin"], min); - connect(m_dblManager, &QtDoublePropertyManager::valueChanged, this, &Stretch::updateProperties); -} - -/** - * Updates the property manager when the upper guide is moved on the mini plot - * - * @param max :: The new value of the upper guide - */ -void Stretch::maxValueChanged(double max) { - disconnect(m_dblManager, &QtDoublePropertyManager::valueChanged, this, &Stretch::updateProperties); - m_dblManager->setValue(m_properties["EMax"], max); - connect(m_dblManager, &QtDoublePropertyManager::valueChanged, this, &Stretch::updateProperties); -} - -/** - * Handles when properties in the property manager are updated. - * - * @param prop :: The property being updated - * @param val :: The new value for the property - */ -void Stretch::updateProperties(QtProperty *prop, double val) { - auto eRangeSelector = m_uiForm.ppPlot->getRangeSelector("StretchERange"); - - disconnect(m_dblManager, &QtDoublePropertyManager::valueChanged, this, &Stretch::updateProperties); - - if (prop == m_properties["EMin"]) { - setRangeSelectorMin(m_properties["EMin"], m_properties["EMax"], eRangeSelector, val); - } else if (prop == m_properties["EMax"]) { - setRangeSelectorMax(m_properties["EMin"], m_properties["EMax"], eRangeSelector, val); - } - - connect(m_dblManager, &QtDoublePropertyManager::valueChanged, this, &Stretch::updateProperties); -} - -void Stretch::setPlotResultEnabled(bool enabled) { - m_uiForm.pbPlot->setEnabled(enabled); - m_uiForm.cbPlot->setEnabled(enabled); -} - -void Stretch::setPlotContourEnabled(bool enabled) { - m_uiForm.pbPlotContour->setEnabled(enabled); - m_uiForm.cbPlotContour->setEnabled(enabled); -} - -void Stretch::setSaveResultEnabled(bool enabled) { m_uiForm.pbSave->setEnabled(enabled); } - -void Stretch::setButtonsEnabled(bool enabled) { - m_runPresenter->setRunEnabled(enabled); - setPlotResultEnabled(enabled); - setPlotContourEnabled(enabled); - setSaveResultEnabled(enabled); -} - -void Stretch::setPlotResultIsPlotting(bool plotting) { - m_uiForm.pbPlot->setText(plotting ? "Plotting..." : "Plot"); - setButtonsEnabled(!plotting); -} - -void Stretch::setPlotContourIsPlotting(bool plotting) { - m_uiForm.pbPlotContour->setText(plotting ? "Plotting..." : "Plot Contour"); - setButtonsEnabled(!plotting); -} - -} // namespace MantidQt::CustomInterfaces diff --git a/qt/scientific_interfaces/Inelastic/BayesFitting/Stretch.h b/qt/scientific_interfaces/Inelastic/BayesFitting/Stretch.h deleted file mode 100644 index 56bab13475ba..000000000000 --- a/qt/scientific_interfaces/Inelastic/BayesFitting/Stretch.h +++ /dev/null @@ -1,81 +0,0 @@ -// Mantid Repository : https://github.com/mantidproject/mantid -// -// Copyright © 2018 ISIS Rutherford Appleton Laboratory UKRI, -// NScD Oak Ridge National Laboratory, European Spallation Source, -// Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS -// SPDX - License - Identifier: GPL - 3.0 + -#pragma once - -#include "BayesFittingTab.h" -#include "DllConfig.h" -#include "MantidAPI/WorkspaceGroup_fwd.h" -#include "MantidQtWidgets/Spectroscopy/RunWidget/IRunSubscriber.h" -#include "ui_Stretch.h" - -namespace MantidQt { -namespace CustomInterfaces { -class MANTIDQT_INELASTIC_DLL Stretch : public BayesFittingTab, public IRunSubscriber { - Q_OBJECT - -public: - Stretch(QWidget *parent = nullptr, std::unique_ptr algorithmRunner = nullptr); - - /// Load default settings into the interface - void loadSettings(const QSettings &settings) override; - - void handleValidation(IUserInputValidator *validator) const override; - void handleRun() override; - const std::string getSubscriberName() const override { return "Stretch"; } - - // Slot for when settings are changed - void applySettings(std::map const &settings) override; - - // Setup fit options, property browser, and plot options ui elements - void setupFitOptions(); - void setupPropertyBrowser(); - void setupPlotOptions(); - -private slots: - /// Slot for when the min range on the range selector changes - void minValueChanged(double min); - /// Slot for when the min range on the range selector changes - void maxValueChanged(double max); - /// Slot to update the guides when the range properties change - void updateProperties(QtProperty *prop, double val) override; - /// Slot to handle when a new sample file is available - void handleSampleInputReady(const QString &filename); - /// Save the workspaces produces from the algorithm - void saveWorkspaces(); - - void plotWorkspaces(); - void plotContourClicked(); - void algorithmComplete(const bool &error); - void plotCurrentPreview(); - void previewSpecChanged(int value); - -private: - void setFileExtensionsByName(bool filter) override; - void setLoadHistory(bool doLoadHistory) override; - - void populateContourWorkspaceComboBox(); - int displaySaveDirectoryMessage(); - - void setPlotResultEnabled(bool enabled); - void setPlotContourEnabled(bool enabled); - void setSaveResultEnabled(bool enabled); - void setButtonsEnabled(bool enabled); - void setPlotResultIsPlotting(bool plotting); - void setPlotContourIsPlotting(bool plotting); - - /// Current preview spectrum - int m_previewSpec; - // The ui form - Ui::Stretch m_uiForm; - // Output Names - std::string m_fitWorkspaceName; - std::string m_contourWorkspaceName; - // state of plot and save when algorithm is run - bool m_save; -}; -} // namespace CustomInterfaces -} // namespace MantidQt diff --git a/qt/scientific_interfaces/Inelastic/BayesFitting/StretchData.h b/qt/scientific_interfaces/Inelastic/BayesFitting/StretchData.h index f6413bcbfdcf..d40e57a28d0e 100644 --- a/qt/scientific_interfaces/Inelastic/BayesFitting/StretchData.h +++ b/qt/scientific_interfaces/Inelastic/BayesFitting/StretchData.h @@ -30,7 +30,7 @@ struct CurrentPreviewData { const std::string sampleName; const bool hasSample; - CurrentPreviewData(const std::string sampleName, bool hasSample) : sampleName(sampleName), hasSample(hasSample) {} + CurrentPreviewData(const std::string &sampleName, bool hasSample) : sampleName(sampleName), hasSample(hasSample) {} }; } // namespace MantidQt::CustomInterfaces