diff --git a/Code/Mantid/MantidQt/MantidWidgets/src/FitPropertyBrowser.cpp b/Code/Mantid/MantidQt/MantidWidgets/src/FitPropertyBrowser.cpp index 326a6118e32b..a6c8262f346b 100644 --- a/Code/Mantid/MantidQt/MantidWidgets/src/FitPropertyBrowser.cpp +++ b/Code/Mantid/MantidQt/MantidWidgets/src/FitPropertyBrowser.cpp @@ -1868,14 +1868,19 @@ void FitPropertyBrowser::getFitResults() try { std::string name; - double value; - row >> name >> value; + double value, error; + row >> name >> value >> error; + // In case of a single function Fit doesn't create a CompositeFunction if (count() == 1) { name.insert(0,"f0."); } - compositeFunction()->setParameter(name,value); + + size_t paramIndex = compositeFunction()->parameterIndex(name); + + compositeFunction()->setParameter(paramIndex,value); + compositeFunction()->setError(paramIndex, error); } catch(...) { diff --git a/Code/Mantid/MantidQt/MantidWidgets/src/PropertyHandler.cpp b/Code/Mantid/MantidQt/MantidWidgets/src/PropertyHandler.cpp index d4a2d7a14467..2ef91719159f 100644 --- a/Code/Mantid/MantidQt/MantidWidgets/src/PropertyHandler.cpp +++ b/Code/Mantid/MantidQt/MantidWidgets/src/PropertyHandler.cpp @@ -928,9 +928,14 @@ void PropertyHandler::updateParameters() for(int i=0;ipropertyName().toStdString(); - double parValue = function()->getParameter(parName); - m_browser->m_parameterManager->setValue(prop,parValue); + + size_t parIndex = function()->parameterIndex(prop->propertyName().toStdString()); + + double parValue = function()->getParameter(parIndex); + m_browser->m_parameterManager->setValue(prop, parValue); + + double parError = function()->getError(parIndex); + m_browser->m_parameterManager->setError(prop, parError); } if (m_cf) { diff --git a/Code/Mantid/QtPropertyBrowser/src/ParameterPropertyManager.cpp b/Code/Mantid/QtPropertyBrowser/src/ParameterPropertyManager.cpp index 5f0c2561d122..92c5efbc1d1f 100644 --- a/Code/Mantid/QtPropertyBrowser/src/ParameterPropertyManager.cpp +++ b/Code/Mantid/QtPropertyBrowser/src/ParameterPropertyManager.cpp @@ -1,10 +1,44 @@ #include "ParameterPropertyManager.h" + #include "qtpropertymanager.h" +#include + ParameterPropertyManager::ParameterPropertyManager(QObject *parent) : QtDoublePropertyManager(parent) {} +/** + * Throws if property error is not set + * @param property :: Property to get error for + * @return Error value of the property + */ +double ParameterPropertyManager::error(const QtProperty* property) const +{ + if (!m_errors.contains(property)) + throw std::runtime_error("Parameter doesn't have error value set"); + + return m_errors[property]; +} + +/** + * @param property :: Property to check + * @return True if error was set for the property, false otherwise + */ +bool ParameterPropertyManager::isErrorSet(const QtProperty* property) const +{ + return m_errors.contains(property); +} + +/** + * @param property :: Property to set error for + * @param error :: Error value to set + */ +void ParameterPropertyManager::setError(const QtProperty* property, double error) +{ + m_errors[property] = error; +} + /** * Adds error parameter value to property display * @param property :: Property we want to display @@ -13,5 +47,18 @@ ParameterPropertyManager::ParameterPropertyManager(QObject *parent) */ QString ParameterPropertyManager::valueText(const QtProperty* property) const { - return QtDoublePropertyManager::valueText(property) + " (Error here)"; + QString originalValueText = QtDoublePropertyManager::valueText(property); + + if (isErrorSet(property)) + { + double propError = error(property); + int precision = decimals(property); + + return originalValueText + QString(" (%1)").arg(propError, 0, 'g', precision); + } + else + { + // No error set, so don't append error value + return originalValueText; + } } diff --git a/Code/Mantid/QtPropertyBrowser/src/ParameterPropertyManager.h b/Code/Mantid/QtPropertyBrowser/src/ParameterPropertyManager.h index 7ccf351e12c8..277aeab4cf7a 100644 --- a/Code/Mantid/QtPropertyBrowser/src/ParameterPropertyManager.h +++ b/Code/Mantid/QtPropertyBrowser/src/ParameterPropertyManager.h @@ -3,6 +3,8 @@ #include "qtpropertymanager.h" +#include + /** ParameterPropertyManager : specialized version of QtDoublePropertyManager for fitting parameters. Is capable to store/display parameter errors in addition to value. @@ -34,9 +36,23 @@ class ParameterPropertyManager : public QtDoublePropertyManager public: ParameterPropertyManager(QObject *parent = 0); + /// Get property error + double error(const QtProperty* property) const; + + /// Checks if given property has error value set + bool isErrorSet(const QtProperty* property) const; + +public Q_SLOTS: + /// Set property error + void setError(const QtProperty* property, double error); + protected: /// Text representation of the property - virtual QString valueText(const QtProperty *property) const; + virtual QString valueText(const QtProperty* property) const; + +private: + /// Property error values + QMap m_errors; }; #endif // PARAMETERPROPERTYMANAGER_H