diff --git a/Code/Mantid/MantidQt/MantidWidgets/inc/MantidQtMantidWidgets/FitPropertyBrowser.h b/Code/Mantid/MantidQt/MantidWidgets/inc/MantidQtMantidWidgets/FitPropertyBrowser.h index f3631e8047de..b22ca81cc849 100644 --- a/Code/Mantid/MantidQt/MantidWidgets/inc/MantidQtMantidWidgets/FitPropertyBrowser.h +++ b/Code/Mantid/MantidQt/MantidWidgets/inc/MantidQtMantidWidgets/FitPropertyBrowser.h @@ -90,7 +90,7 @@ class EXPORT_OPT_MANTIDQT_MANTIDWIDGETS FitPropertyBrowser: public QDockWidget, /// Get the current function boost::shared_ptr theFunction()const; /// Update the function parameters - void updateParameters(bool setErrors = false); + void updateParameters(); /// Get function parameter values QList getParameterValues() const; /// Get function parameter names diff --git a/Code/Mantid/MantidQt/MantidWidgets/inc/MantidQtMantidWidgets/PropertyHandler.h b/Code/Mantid/MantidQt/MantidWidgets/inc/MantidQtMantidWidgets/PropertyHandler.h index 8c59fcdc8e16..baf3c2ab74d8 100644 --- a/Code/Mantid/MantidQt/MantidWidgets/inc/MantidQtMantidWidgets/PropertyHandler.h +++ b/Code/Mantid/MantidQt/MantidWidgets/inc/MantidQtMantidWidgets/PropertyHandler.h @@ -127,8 +127,14 @@ class EXPORT_OPT_MANTIDQT_MANTIDWIDGETS PropertyHandler:public QObject, public M /// Set function vector attribute value void setVectorAttribute(QtProperty* prop); - /// Update the parameter properties - void updateParameters(bool setErrors = false); + /// Sync all parameter values with the manager + void updateParameters(); + + /// Set all parameter error values in the manager + void updateErrors(); + + /// Clear all parameter error values in the manager + void clearErrors(); // Get property for function parameter parName QtProperty* getParameterProperty(const QString& parName)const; @@ -212,6 +218,18 @@ protected slots: //mutable FunctionCurve* m_curve;//< the curve to plot the handled function mutable bool m_hasPlot; + /// Sync function parameter value with the manager + void updateParameter(QtProperty* prop); + + /// Set function parameter error in the manager + void updateError(QtProperty* prop); + + /// Clear function parameter error in the manager + void clearError(QtProperty* prop); + + /// Applies given function to all the parameter properties recursively + void applyToAllParameters(void (PropertyHandler::*func)(QtProperty*)); + friend class CreateAttributeProperty; }; diff --git a/Code/Mantid/MantidQt/MantidWidgets/src/FitPropertyBrowser.cpp b/Code/Mantid/MantidQt/MantidWidgets/src/FitPropertyBrowser.cpp index c0529332774c..74b45fbd66f9 100644 --- a/Code/Mantid/MantidQt/MantidWidgets/src/FitPropertyBrowser.cpp +++ b/Code/Mantid/MantidQt/MantidWidgets/src/FitPropertyBrowser.cpp @@ -1849,12 +1849,11 @@ void FitPropertyBrowser::vectorDoubleChanged(QtProperty *prop) } /** - * Update the function parameter properties. If isFitDone is true, set parameter errors as well. - * @param setErrors :: Whether errors should be set as well + * Update the function parameter properties */ -void FitPropertyBrowser::updateParameters(bool setErrors) +void FitPropertyBrowser::updateParameters() { - getHandler()->updateParameters(setErrors); + getHandler()->updateParameters(); } /** @@ -1913,7 +1912,8 @@ void FitPropertyBrowser::getFitResults() } } while(row.next()); - updateParameters(true); + updateParameters(); + getHandler()->updateErrors(); } } @@ -1929,6 +1929,7 @@ void FitPropertyBrowser::undoFit() compositeFunction()->setParameter(i,m_initialParameters[i]); } updateParameters(); + getHandler()->clearErrors(); } disableUndo(); } diff --git a/Code/Mantid/MantidQt/MantidWidgets/src/PropertyHandler.cpp b/Code/Mantid/MantidQt/MantidWidgets/src/PropertyHandler.cpp index ac54c7347965..f9bcc6ec346d 100644 --- a/Code/Mantid/MantidQt/MantidWidgets/src/PropertyHandler.cpp +++ b/Code/Mantid/MantidQt/MantidWidgets/src/PropertyHandler.cpp @@ -921,35 +921,68 @@ void PropertyHandler::setVectorAttribute(QtProperty *prop) } /** - * Update the parameter properties. If isFitDone is true, parameter errors are set as well. - * @param setErrors :: Whether errors should be set + * Applies given function to all the parameter properties recursively, within this context. + * @param func :: Function to apply */ -void PropertyHandler::updateParameters(bool setErrors) +void PropertyHandler::applyToAllParameters(void (PropertyHandler::*func)(QtProperty*)) { for(int i=0;iparameterIndex(prop->propertyName().toStdString()); - - double parValue = function()->getParameter(parIndex); - m_browser->m_parameterManager->setValue(prop, parValue); - - if (setErrors) - { - double parError = function()->getError(parIndex); - m_browser->m_parameterManager->setError(prop, parError); - } + (this->*(func))(prop); } + if (m_cf) { for(size_t i=0;inFunctions();i++) { - getHandler(i)->updateParameters(setErrors); + getHandler(i)->applyToAllParameters(func); } } } +void PropertyHandler::updateParameters() +{ + applyToAllParameters(&PropertyHandler::updateParameter); +} + +void PropertyHandler::updateErrors() +{ + applyToAllParameters(&PropertyHandler::updateError); +} + +void PropertyHandler::clearErrors() +{ + applyToAllParameters(&PropertyHandler::clearError); +} + +/** + * @param prop :: Property of the parameter + */ +void PropertyHandler::updateParameter(QtProperty* prop) +{ + double parValue = function()->getParameter(prop->propertyName().toStdString()); + m_browser->m_parameterManager->setValue(prop, parValue); +} + +/** + * @param prop :: Property of the parameter + */ +void PropertyHandler::updateError(QtProperty* prop) +{ + size_t index = function()->parameterIndex(prop->propertyName().toStdString()); + double error = function()->getError(index); + m_browser->m_parameterManager->setError(prop, error); +} + +/** + * @param prop :: Property of the parameter + */ +void PropertyHandler::clearError(QtProperty* prop) +{ + m_browser->m_parameterManager->clearError(prop); +} + /** * Change the type of the function (replace the function) * @param prop :: The "Type" property with new value diff --git a/Code/Mantid/QtPropertyBrowser/src/ParameterPropertyManager.cpp b/Code/Mantid/QtPropertyBrowser/src/ParameterPropertyManager.cpp index 43b25165ee11..3cbad7b66d3b 100644 --- a/Code/Mantid/QtPropertyBrowser/src/ParameterPropertyManager.cpp +++ b/Code/Mantid/QtPropertyBrowser/src/ParameterPropertyManager.cpp @@ -54,6 +54,7 @@ void ParameterPropertyManager::setError(QtProperty* property, double error) void ParameterPropertyManager::clearError(QtProperty* property) { m_errors.remove(property); + emit propertyChanged(property); } /**