diff --git a/MantidPlot/src/Mantid/PeakPickerTool.cpp b/MantidPlot/src/Mantid/PeakPickerTool.cpp index 84b0d4fd1ba42049fbde5f65d96dc532f31c441d..0e512086ce754bcba0a0c15853b7f6bdd2b2a808 100644 --- a/MantidPlot/src/Mantid/PeakPickerTool.cpp +++ b/MantidPlot/src/Mantid/PeakPickerTool.cpp @@ -553,8 +553,11 @@ void PeakPickerTool::functionRemoved() */ void PeakPickerTool::algorithmFinished(const QString& out) { - // Remove old curves first - removeFitCurves(); + // Remove old curves first, unless this is muon data + // (muon scientists want to keep old fits until cleared manually) + if (!isMuonData()) { + removeFitCurves(); + } // If style needs to be changed from default, signal pair second will be true and change to line. auto * curve = new MantidMatrixCurve("",out,graph(),1,MantidMatrixCurve::Spectrum, false, m_shouldBeNormalised, Graph::Line); @@ -1069,7 +1072,7 @@ void PeakPickerTool::removeFitCurves() /** * Called from constructor. - * Sets up tool based on curves in graph. + * Sets up tool based on the given curve. * @param curve :: [input] Curve to use for initialization * @returns :: success or failure */ @@ -1084,10 +1087,17 @@ bool PeakPickerTool::initializeFromCurve(PlotCurve *curve) { } else { MantidMatrixCurve *mcurve = dynamic_cast<MantidMatrixCurve *>(curve); if (mcurve) { - m_wsName = mcurve->workspaceName(); - m_spec = mcurve->workspaceIndex(); - m_shouldBeNormalised = - mcurve->isDistribution() && mcurve->isNormalizable(); + const QString title = mcurve->title().text(); + if (title.contains("Workspace-Calc")) { + // Don't set up from a fit curve + return false; + } else { + // Set up the tool from this curve + m_wsName = mcurve->workspaceName(); + m_spec = mcurve->workspaceIndex(); + m_shouldBeNormalised = + mcurve->isDistribution() && mcurve->isNormalizable(); + } } else { return false; } @@ -1120,3 +1130,15 @@ void PeakPickerTool::addExistingFitsAndGuess(const QStringList &curvesList) { : "Plot guess"); } } + +/** + * Tests if the peak picker tool is connected to a MuonFitPropertyBrowser or a + * regular FitPropertyBrowser. + * @returns :: True for muon data, false otherwise + */ +bool PeakPickerTool::isMuonData() const { + const auto muonBrowser = + dynamic_cast<MantidQt::MantidWidgets::MuonFitPropertyBrowser *>( + m_fitPropertyBrowser); + return (muonBrowser != nullptr); +} diff --git a/MantidPlot/src/Mantid/PeakPickerTool.h b/MantidPlot/src/Mantid/PeakPickerTool.h index 9837e15474ba00a64a11efb58a0693404571dc70..8f1f9ca19d0579a916c578c3beb1801d0b44ddcd 100644 --- a/MantidPlot/src/Mantid/PeakPickerTool.h +++ b/MantidPlot/src/Mantid/PeakPickerTool.h @@ -191,6 +191,8 @@ private: bool initializeFromCurve(PlotCurve *curve); // Set up - add names of existing fit curves and plot guess status void addExistingFitsAndGuess(const QStringList &curvesList); + // Test if we are fitting muon data + bool isMuonData() const; /// Creates a pointer to fitPropertyBrowser MantidQt::MantidWidgets::FitPropertyBrowser* m_fitPropertyBrowser; diff --git a/docs/source/release/v3.7.0/muon.rst b/docs/source/release/v3.7.0/muon.rst index 47165f098c026a85912b8024026d0b29725dfa9d..d3774632773c6a352b2f8c727566d5e9f798e834 100644 --- a/docs/source/release/v3.7.0/muon.rst +++ b/docs/source/release/v3.7.0/muon.rst @@ -35,6 +35,7 @@ Muon Analysis - When the window is resized, all widgets within the window should now resize with it. This enables the interface to be used on smaller screens. `#15382 <https://github.com/mantidproject/mantid/pull/15832>`_ - "Plot/Remove guess" now deals correctly with the case when a new run is loaded. `#15872 <https://github.com/mantidproject/mantid/pull/15872>`_ +- When plotting data from a new run in the same window as the previous plot, previous fits now remain on the graph, to enable easy comparison between datasets. They can be removed with the "Clear fit curves" option. `#16018 <https://github.com/mantidproject/mantid/pull/16018>`_ Algorithms ----------