From 58b0e9c91b946d3ca99e40fc6b34b9287fe735e9 Mon Sep 17 00:00:00 2001 From: Roman Tolchenov <roman.tolchenov@stfc.ac.uk> Date: Tue, 22 Feb 2011 08:15:35 +0000 Subject: [PATCH] Added a switch to the fit browser. re #2301 --- .../src/Mantid/FitPropertyBrowser.cpp | 17 +++++++++++++++++ .../MantidPlot/src/Mantid/FitPropertyBrowser.h | 4 ++++ .../MantidPlot/src/Mantid/PeakPickerTool.cpp | 5 ++++- 3 files changed, 25 insertions(+), 1 deletion(-) diff --git a/Code/Mantid/MantidPlot/src/Mantid/FitPropertyBrowser.cpp b/Code/Mantid/MantidPlot/src/Mantid/FitPropertyBrowser.cpp index 37ec0e04123..f98d6cbf989 100644 --- a/Code/Mantid/MantidPlot/src/Mantid/FitPropertyBrowser.cpp +++ b/Code/Mantid/MantidPlot/src/Mantid/FitPropertyBrowser.cpp @@ -91,6 +91,9 @@ m_autoBgName(QString::fromStdString(Mantid::Kernel::ConfigService::Instance().ge m_autoBackground(NULL), m_decimals(-1) { + QSettings settings; + settings.beginGroup("Mantid/FitBrowser"); + // Make sure plugins are loaded std::string libpath = Mantid::Kernel::ConfigService::Instance().getString("plugins.directory"); if( !libpath.empty() ) @@ -179,6 +182,9 @@ m_decimals(-1) m_costFunctions << "Least squares" << "Ignore positive peaks"; m_enumManager->setEnumNames(m_costFunction,m_costFunctions); + m_plotDiff = m_boolManager->addProperty("Plot Difference"); + bool plotDiff = settings.value("Plot Difference",QVariant(true)).toBool(); + m_boolManager->setValue(m_plotDiff,plotDiff); settingsGroup->addSubProperty(m_workspace); settingsGroup->addSubProperty(m_workspaceIndex); @@ -187,6 +193,7 @@ m_decimals(-1) settingsGroup->addSubProperty(m_output); settingsGroup->addSubProperty(m_minimizer); settingsGroup->addSubProperty(m_costFunction); + settingsGroup->addSubProperty(m_plotDiff); /* Create editors and assign them to the managers */ @@ -264,6 +271,10 @@ m_decimals(-1) /// Destructor FitPropertyBrowser::~FitPropertyBrowser() { + QSettings settings; + settings.beginGroup("Mantid/FitBrowser"); + bool plotDiff = m_boolManager->value(m_plotDiff); + settings.setValue("Plot Difference",plotDiff); if (m_compositeFunction) delete m_compositeFunction; } @@ -2156,3 +2167,9 @@ void FitPropertyBrowser::setDecimals(int d) settings.setValue("decimals",d); updateDecimals(); } + +bool FitPropertyBrowser::plotDiff()const +{ + return m_boolManager->value(m_plotDiff); +} + diff --git a/Code/Mantid/MantidPlot/src/Mantid/FitPropertyBrowser.h b/Code/Mantid/MantidPlot/src/Mantid/FitPropertyBrowser.h index 80fd93c6cef..6bf18f063c3 100644 --- a/Code/Mantid/MantidPlot/src/Mantid/FitPropertyBrowser.h +++ b/Code/Mantid/MantidPlot/src/Mantid/FitPropertyBrowser.h @@ -170,6 +170,9 @@ public: int getDecimals()const{return m_decimals;} void setDecimals(int d); + /// Returns true if the difference plot should be drawn + bool plotDiff()const; + public slots: void fit(); void sequentialFit(); @@ -325,6 +328,7 @@ private: QtProperty *m_minimizer; QtProperty *m_costFunction; QtProperty *m_logValue; + QtProperty *m_plotDiff; /// A list of registered functions mutable QStringList m_registeredFunctions; diff --git a/Code/Mantid/MantidPlot/src/Mantid/PeakPickerTool.cpp b/Code/Mantid/MantidPlot/src/Mantid/PeakPickerTool.cpp index 3d7e0b791e9..6dfb3f20693 100644 --- a/Code/Mantid/MantidPlot/src/Mantid/PeakPickerTool.cpp +++ b/Code/Mantid/MantidPlot/src/Mantid/PeakPickerTool.cpp @@ -541,7 +541,10 @@ void PeakPickerTool::algorithmFinished(const QString& out) graph()->removeCurve(curveResName); new MantidCurve(curveFitName,out,graph(),"spectra",1,false); - new MantidCurve(curveResName,out,graph(),"spectra",2,false); + if (fitBrowser()->plotDiff()) + { + new MantidCurve(curveResName,out,graph(),"spectra",2,false); + } graph()->replot(); } -- GitLab