diff --git a/docs/source/release/v3.14.0/indirect_inelastic.rst b/docs/source/release/v3.14.0/indirect_inelastic.rst index 38df5afb756980dfd8f7b7e03bc9df9d474fe99f..fd69d1e950e87059675838904f1d1992db9428fa 100644 --- a/docs/source/release/v3.14.0/indirect_inelastic.rst +++ b/docs/source/release/v3.14.0/indirect_inelastic.rst @@ -32,6 +32,8 @@ Improvements - When the InelasticDiffSphere, InelasticDiffRotDiscreteCircle, ElasticDiffSphere or ElasticDiffRotDiscreteCircle Fit Types are selected in the ConvFit Tab, the Q values are retrieved from the workspaces, preventing a crash when plotting a guess. +- The Plot Result buttons in MSDFit and F(Q)Fit are disabled after a Run when the result workspace only has one + data point to plot. - An option to skip the calculation of Monte Carlo Errors on the I(Q,t) Tab has been added. - During the calculation of Monte Carlo Errors, a progress bar is now shown. diff --git a/qt/scientific_interfaces/Indirect/ConvFit.h b/qt/scientific_interfaces/Indirect/ConvFit.h index 9a3a8477d284b4ff10fe9814381c3e8c20451789..ac58d9da5433f865f3c21f89ace1211c361a5880 100644 --- a/qt/scientific_interfaces/Indirect/ConvFit.h +++ b/qt/scientific_interfaces/Indirect/ConvFit.h @@ -19,6 +19,8 @@ public: ConvFit(QWidget *parent = nullptr); protected: + bool shouldEnablePlotResult() override { return true; }; + void setRunEnabled(bool enabled) override; void setPlotResultEnabled(bool enabled) override; void setSaveResultEnabled(bool enabled) override; diff --git a/qt/scientific_interfaces/Indirect/IndirectFitAnalysisTab.cpp b/qt/scientific_interfaces/Indirect/IndirectFitAnalysisTab.cpp index 521a8d3a07082ce357414c78128dce74de58807c..c7129acf28a27724d6024c550f3f450d8ad085ad 100644 --- a/qt/scientific_interfaces/Indirect/IndirectFitAnalysisTab.cpp +++ b/qt/scientific_interfaces/Indirect/IndirectFitAnalysisTab.cpp @@ -665,8 +665,8 @@ void IndirectFitAnalysisTab::updateSingleFitOutput(bool error) { */ void IndirectFitAnalysisTab::fitAlgorithmComplete(bool error) { setSaveResultEnabled(!error); - setPlotResultEnabled(!error); setRunEnabled(true); + enablePlotResult(error); updateParameterValues(); m_spectrumPresenter->enableView(); m_plotPresenter->updatePlots(); @@ -880,6 +880,10 @@ void IndirectFitAnalysisTab::updatePlotOptions(QComboBox *cbPlotType) { setPlotOptions(cbPlotType, m_fittingModel->getFitParameterNames()); } +void IndirectFitAnalysisTab::enablePlotResult(bool error) { + setPlotResultEnabled(!shouldEnablePlotResult() ? false : !error); +} + /** * Fills the specified combo box, with the specified parameters. * diff --git a/qt/scientific_interfaces/Indirect/IndirectFitAnalysisTab.h b/qt/scientific_interfaces/Indirect/IndirectFitAnalysisTab.h index 2e924f52492d676451e0308a75a82a8652a31f9a..eef03626afd4b1a3761f446729dde0f9ca13d964 100644 --- a/qt/scientific_interfaces/Indirect/IndirectFitAnalysisTab.h +++ b/qt/scientific_interfaces/Indirect/IndirectFitAnalysisTab.h @@ -128,6 +128,7 @@ protected: virtual void setupFit(Mantid::API::IAlgorithm_sptr fitAlgorithm); void updatePlotOptions(QComboBox *cbPlotType); + void enablePlotResult(bool error); void setPlotOptions(QComboBox *cbPlotType, const std::vector<std::string> ¶meters) const; @@ -135,6 +136,7 @@ protected: void setPlotOptions(QComboBox *cbPlotType, const QSet<QString> &options) const; + virtual bool shouldEnablePlotResult() = 0; virtual void setPlotResultEnabled(bool enabled) = 0; virtual void setSaveResultEnabled(bool enabled) = 0; diff --git a/qt/scientific_interfaces/Indirect/IqtFit.h b/qt/scientific_interfaces/Indirect/IqtFit.h index 58656aa3d81a1ff78ffddb0792b096e4bf167f2d..69c1a9ee03fefa8e4ace5daea56d046e87ddabb3 100644 --- a/qt/scientific_interfaces/Indirect/IqtFit.h +++ b/qt/scientific_interfaces/Indirect/IqtFit.h @@ -31,6 +31,8 @@ private: void setupFitTab() override; protected: + bool shouldEnablePlotResult() override { return true; }; + void setRunEnabled(bool enabled) override; void setPlotResultEnabled(bool enabled) override; void setSaveResultEnabled(bool enabled) override; diff --git a/qt/scientific_interfaces/Indirect/JumpFit.cpp b/qt/scientific_interfaces/Indirect/JumpFit.cpp index 52d9fd6fd410360f99d8fbc571ff86515a57d04a..910f9cec6578e70f57cd29e0d9af05f636038a98 100644 --- a/qt/scientific_interfaces/Indirect/JumpFit.cpp +++ b/qt/scientific_interfaces/Indirect/JumpFit.cpp @@ -78,6 +78,13 @@ void JumpFit::updatePlotOptions() { IndirectFitAnalysisTab::updatePlotOptions(m_uiForm->cbPlotType); } +bool JumpFit::shouldEnablePlotResult() { + for (auto i = 0u; i < m_jumpFittingModel->numberOfWorkspaces(); ++i) + if (m_jumpFittingModel->getNumberOfSpectra(i) != 1) + return true; + return false; +} + void JumpFit::setPlotResultEnabled(bool enabled) { m_uiForm->pbPlot->setEnabled(enabled); m_uiForm->cbPlotType->setEnabled(enabled); diff --git a/qt/scientific_interfaces/Indirect/JumpFit.h b/qt/scientific_interfaces/Indirect/JumpFit.h index 5575de512e316fd166e4a63f72363de0a06c69c9..f7dd8f9491499e8498175c6474893732f6b25d0b 100644 --- a/qt/scientific_interfaces/Indirect/JumpFit.h +++ b/qt/scientific_interfaces/Indirect/JumpFit.h @@ -26,6 +26,8 @@ protected slots: void runClicked(); protected: + bool shouldEnablePlotResult() override; + void setRunEnabled(bool enabled) override; void setPlotResultEnabled(bool enabled) override; void setSaveResultEnabled(bool enabled) override; diff --git a/qt/scientific_interfaces/Indirect/MSDFit.cpp b/qt/scientific_interfaces/Indirect/MSDFit.cpp index 892884be5d1439d9e4ff888e23a68c8fc8a164f8..f8ee8119f53d98d820618c01b078c5507bcbbbb2 100644 --- a/qt/scientific_interfaces/Indirect/MSDFit.cpp +++ b/qt/scientific_interfaces/Indirect/MSDFit.cpp @@ -62,6 +62,13 @@ void MSDFit::updatePlotOptions() {} void MSDFit::plotClicked() { IndirectFitAnalysisTab::plotResult("All"); } +bool MSDFit::shouldEnablePlotResult() { + for (auto i = 0u; i < m_msdFittingModel->numberOfWorkspaces(); ++i) + if (m_msdFittingModel->getNumberOfSpectra(i) != 1) + return true; + return false; +} + void MSDFit::setPlotResultEnabled(bool enabled) { m_uiForm->pbPlot->setEnabled(enabled); } diff --git a/qt/scientific_interfaces/Indirect/MSDFit.h b/qt/scientific_interfaces/Indirect/MSDFit.h index 27e82480ff64a903ce83c6a8b276e8ba7830f70e..4937eaba377350a3c6c12265002efa5640f18077 100644 --- a/qt/scientific_interfaces/Indirect/MSDFit.h +++ b/qt/scientific_interfaces/Indirect/MSDFit.h @@ -26,6 +26,8 @@ protected slots: void updateModelFitTypeString(); protected: + bool shouldEnablePlotResult() override; + void setRunEnabled(bool enabled) override; void setPlotResultEnabled(bool enabled) override; void setSaveResultEnabled(bool enabled) override;