diff --git a/Code/Mantid/MantidQt/MantidWidgets/inc/MantidQtMantidWidgets/FunctionBrowser.h b/Code/Mantid/MantidQt/MantidWidgets/inc/MantidQtMantidWidgets/FunctionBrowser.h index 1f2b9aba85fc93265981ab8a6cd13ccd17ae6d40..ebe50da848b75cf8bc808f672ff9ba6ebe403231 100644 --- a/Code/Mantid/MantidQt/MantidWidgets/inc/MantidQtMantidWidgets/FunctionBrowser.h +++ b/Code/Mantid/MantidQt/MantidWidgets/inc/MantidQtMantidWidgets/FunctionBrowser.h @@ -21,6 +21,7 @@ class QtStringPropertyManager; class QtEnumPropertyManager; class QtProperty; class QtBrowserItem; +class ParameterPropertyManager; class QPushButton; class QLabel; @@ -108,10 +109,14 @@ public: /// Update the function parameter value void setParameter(const QString& funcIndex, const QString& paramName, double value); + /// Update the function parameter error + void setParamError(const QString& funcIndex, const QString& paramName, double error); /// Get a value of a parameter double getParameter(const QString& funcIndex, const QString& paramName) const; /// Update the function parameter value void setParameter(const QString& paramName, double value); + /// Update the function parameter error + void setParamError(const QString& paramName, double error); /// Get a value of a parameter double getParameter(const QString& paramName) const; /// Update parameter values in the browser to match those of a function. @@ -147,7 +152,7 @@ protected: /// Add a function property AProperty addFunctionProperty(QtProperty* parent, QString funName); /// Add a parameter property - AProperty addParameterProperty(QtProperty* parent, QString paramName, double paramValue); + AProperty addParameterProperty(QtProperty* parent, QString paramName, QString paramDesc, double paramValue); /// Add a attribute property AProperty addAttributeProperty(QtProperty* parent, QString attName, const Mantid::API::IFunction::Attribute& att); /// Add attribute and parameter properties to a function property @@ -249,7 +254,7 @@ protected: /// Manager for function group properties QtGroupPropertyManager *m_functionManager; /// Manager for function parameter properties - QtDoublePropertyManager *m_parameterManager; + ParameterPropertyManager *m_parameterManager; /// Manager for function string attribute properties QtStringPropertyManager *m_attributeStringManager; /// Manager for function double attribute properties diff --git a/Code/Mantid/MantidQt/MantidWidgets/src/FunctionBrowser.cpp b/Code/Mantid/MantidQt/MantidWidgets/src/FunctionBrowser.cpp index 874e0423532f04af14b9dda86758be24108fb236..7804ff7052dc75226a4567738d3b0e49b88513e3 100644 --- a/Code/Mantid/MantidQt/MantidWidgets/src/FunctionBrowser.cpp +++ b/Code/Mantid/MantidQt/MantidWidgets/src/FunctionBrowser.cpp @@ -115,7 +115,7 @@ void FunctionBrowser::createBrowser() /* Create property managers: they create, own properties, get and set values */ m_functionManager = new QtGroupPropertyManager(this); - m_parameterManager = new QtDoublePropertyManager(this); + m_parameterManager = new ParameterPropertyManager(this); m_attributeStringManager = new QtStringPropertyManager(this); m_attributeDoubleManager = new QtDoublePropertyManager(this); m_attributeIntManager = new QtIntPropertyManager(this); @@ -133,19 +133,20 @@ void FunctionBrowser::createBrowser() // create editor factories QtSpinBoxFactory *spinBoxFactory = new QtSpinBoxFactory(this); DoubleEditorFactory *doubleEditorFactory = new DoubleEditorFactory(this); + ParameterEditorFactory *paramEditorFactory = new ParameterEditorFactory(this); - QtAbstractEditorFactory<QtDoublePropertyManager> *parameterEditorFactory(NULL); + QtAbstractEditorFactory<ParameterPropertyManager> *parameterEditorFactory(NULL); if ( m_multiDataset ) { auto buttonFactory = new DoubleButtonEditorFactory(this); - auto compositeFactory = new CompositeEditorFactory<QtDoublePropertyManager>(this,buttonFactory); - compositeFactory->setSecondaryFactory(globalOptionName, doubleEditorFactory); + auto compositeFactory = new CompositeEditorFactory<ParameterPropertyManager>(this,buttonFactory); + compositeFactory->setSecondaryFactory(globalOptionName, paramEditorFactory); parameterEditorFactory = compositeFactory; connect(buttonFactory,SIGNAL(buttonClicked(QtProperty*)), this,SLOT(parameterButtonClicked(QtProperty*))); } else { - parameterEditorFactory = doubleEditorFactory; + parameterEditorFactory = paramEditorFactory; } QtLineEditFactory *lineEditFactory = new QtLineEditFactory(this); @@ -185,6 +186,7 @@ void FunctionBrowser::createBrowser() SLOT(parameterChanged(QtProperty*))); connect(m_browser, SIGNAL(currentItemChanged(QtBrowserItem*)), SLOT(updateCurrentFunctionIndex())); + } /** @@ -227,6 +229,8 @@ void FunctionBrowser::createActions() m_actionRemoveConstraint = new QAction("Remove",this); connect(m_actionRemoveConstraint,SIGNAL(triggered()),this,SLOT(removeConstraint())); + + m_parameterManager->setErrorsEnabled(true); } /** @@ -396,9 +400,10 @@ FunctionBrowser::AProperty FunctionBrowser::addFunctionProperty(QtProperty* pare * Add a parameter property * @param parent :: Parent function property * @param paramName :: Parameter name + * @param paramDesc :: Parameter description * @param paramValue :: Parameter value */ -FunctionBrowser::AProperty FunctionBrowser::addParameterProperty(QtProperty* parent, QString paramName, double paramValue) +FunctionBrowser::AProperty FunctionBrowser::addParameterProperty(QtProperty* parent, QString paramName, QString paramDesc, double paramValue) { // check that parent is a function property if (!parent || dynamic_cast<QtAbstractPropertyManager*>(m_functionManager) != parent->propertyManager()) @@ -408,6 +413,8 @@ FunctionBrowser::AProperty FunctionBrowser::addParameterProperty(QtProperty* par QtProperty* prop = m_parameterManager->addProperty(paramName); m_parameterManager->setDecimals(prop,6); m_parameterManager->setValue(prop,paramValue); + m_parameterManager->setDescription(prop,paramDesc.toStdString()); + if ( m_multiDataset ) { prop->setOption(globalOptionName,false); @@ -667,8 +674,9 @@ void FunctionBrowser::addAttributeAndParameterProperties(QtProperty* prop, Manti for(size_t i = 0; i < fun->nParams(); ++i) { QString name = QString::fromStdString(fun->parameterName(i)); + QString desc = QString::fromStdString(fun->parameterDescription(i)); double value = fun->getParameter(i); - AProperty ap = addParameterProperty(prop, name, value); + AProperty ap = addParameterProperty(prop, name, desc, value); // if parameter has a tie if (fun->isFixed(i)) { @@ -1511,6 +1519,29 @@ void FunctionBrowser::setParameter(const QString& funcIndex, const QString& para } } +/** + * Updates the function parameter error + * @param funcIndex :: Index of the function + * @param paramName :: Parameter name + * @param error :: New error + */ +void FunctionBrowser::setParamError(const QString& funcIndex, const QString& paramName, double error) +{ + if (auto prop = getFunctionProperty(funcIndex)) + { + auto children = prop->subProperties(); + foreach(QtProperty* child, children) + { + if (isParameter(child) && child->propertyName() == paramName) + { +// m_parameterManager->setDescription(child,""); + m_parameterManager->setError(child, error); + break; + } + } + } +} + /** * Get a value of a parameter * @param funcIndex :: Index of the function @@ -1565,6 +1596,17 @@ void FunctionBrowser::setParameter(const QString& paramName, double value) setParameter(name[0],name[1],value); } +/** + * Updates the function parameter error + * @param paramName :: Fully qualified parameter name (includes function index) + * @param error :: New error + */ +void FunctionBrowser::setParamError(const QString& paramName, double error) +{ + QStringList name = splitParameterName(paramName); + setParamError(name[0],name[1],error); +} + /** * Get a value of a parameter * @param paramName :: Fully qualified parameter name (includes function index) diff --git a/Code/Mantid/QtPropertyBrowser/src/ButtonEditorFactory.h b/Code/Mantid/QtPropertyBrowser/src/ButtonEditorFactory.h index 5377cf692879688e245cffffb3c0e317619f4930..2f70a74e6244967b0523ccf2c0f565902f5fb422 100644 --- a/Code/Mantid/QtPropertyBrowser/src/ButtonEditorFactory.h +++ b/Code/Mantid/QtPropertyBrowser/src/ButtonEditorFactory.h @@ -1,6 +1,7 @@ #ifndef BUTTONEDITORFACTORY_H #define BUTTONEDITORFACTORY_H +#include "ParameterPropertyManager.h" #include "qtpropertymanager.h" #include <QPushButton> @@ -57,12 +58,12 @@ protected: } }; -class QT_QTPROPERTYBROWSER_EXPORT DoubleButtonEditorFactory: public ButtonEditorFactory<QtDoublePropertyManager> +class QT_QTPROPERTYBROWSER_EXPORT DoubleButtonEditorFactory: public ButtonEditorFactory<ParameterPropertyManager> { Q_OBJECT public: - DoubleButtonEditorFactory(QObject *parent):ButtonEditorFactory<QtDoublePropertyManager>(parent){} + DoubleButtonEditorFactory(QObject *parent):ButtonEditorFactory<ParameterPropertyManager>(parent){} Q_SIGNALS: void buttonClicked(QtProperty *);