Skip to content

Commit

Permalink
Refs #6616. Specialized property manager for parameters
Browse files Browse the repository at this point in the history
It is currently a regular QtDoublePropertyManager, so nothing the fit
browser should still work correctly. It gives me a way of overriding the
manager for parameter properties only, leaving other double properties
alone.
  • Loading branch information
arturbekasov committed Mar 7, 2014
1 parent 132dda5 commit 62ba1c1
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 5 deletions.
Expand Up @@ -360,6 +360,7 @@ private slots:
QtGroupPropertyManager *m_vectorManager;
QtIntPropertyManager *m_vectorSizeManager;
QtDoublePropertyManager *m_vectorDoubleManager;
QtDoublePropertyManager *m_parameterManager;

QtProperty *m_workspace;
QtProperty *m_workspaceIndex;
Expand Down
3 changes: 3 additions & 0 deletions Code/Mantid/MantidQt/MantidWidgets/src/FitPropertyBrowser.cpp
Expand Up @@ -185,6 +185,7 @@ m_mantidui(mantidui)
m_vectorManager = new QtGroupPropertyManager(w);
m_vectorSizeManager = new QtIntPropertyManager(w);
m_vectorDoubleManager = new QtDoublePropertyManager(w);
m_parameterManager = new QtDoublePropertyManager(w);
}


Expand Down Expand Up @@ -298,6 +299,7 @@ void FitPropertyBrowser::initLayout(QWidget *w)
connect(m_formulaManager,SIGNAL(propertyChanged(QtProperty*)),this,SLOT(stringChanged(QtProperty*)));
connect(m_columnManager,SIGNAL(propertyChanged(QtProperty*)),this,SLOT(columnChanged(QtProperty*)));
connect(m_vectorDoubleManager,SIGNAL(propertyChanged(QtProperty*)),this,SLOT(vectorDoubleChanged(QtProperty*)));
connect(m_parameterManager,SIGNAL(propertyChanged(QtProperty*)), this, SLOT(doubleChanged(QtProperty*)));

QVBoxLayout* layout = new QVBoxLayout(w);
QGridLayout* buttonsLayout = new QGridLayout();
Expand Down Expand Up @@ -447,6 +449,7 @@ void FitPropertyBrowser::createEditors(QWidget *w)
m_browser->setFactoryForManager(m_columnManager, comboBoxFactory);
m_browser->setFactoryForManager(m_vectorSizeManager, spinBoxFactory);
m_browser->setFactoryForManager(m_vectorDoubleManager, doubleEditorFactory);
m_browser->setFactoryForManager(m_parameterManager, doubleEditorFactory);
}


Expand Down
10 changes: 5 additions & 5 deletions Code/Mantid/MantidQt/MantidWidgets/src/PropertyHandler.cpp
Expand Up @@ -247,13 +247,13 @@ void PropertyHandler::initParameters()
{
QString parName = QString::fromStdString(function()->parameterName(i));
if (parName.contains('.')) continue;
QtProperty* prop = m_browser->addDoubleProperty(parName);
QtProperty* prop = m_browser->addDoubleProperty(parName, m_browser->m_parameterManager);
QString toolTip = QString::fromStdString(function()->parameterDescription(i));
if (!toolTip.isEmpty())
{
prop->setToolTip(toolTip);
}
m_browser->m_doubleManager->setValue(prop,function()->getParameter(i));
m_browser->m_parameterManager->setValue(prop,function()->getParameter(i));
m_item->property()->addSubProperty(prop);
m_parameters << prop;
// add tie property if this parameter has a tie
Expand Down Expand Up @@ -682,7 +682,7 @@ bool PropertyHandler::setParameter(QtProperty* prop)
if (m_parameters.contains(prop))
{
std::string parName = prop->propertyName().toStdString();
double parValue = m_browser->m_doubleManager->value(prop);
double parValue = m_browser->m_parameterManager->value(prop);
m_fun->setParameter(parName,parValue);
m_browser->sendParameterChanged(m_fun.get());
return true;
Expand Down Expand Up @@ -929,7 +929,7 @@ void PropertyHandler::updateParameters()
QtProperty* prop = m_parameters[i];
std::string parName = prop->propertyName().toStdString();
double parValue = function()->getParameter(parName);
m_browser->m_doubleManager->setValue(prop,parValue);
m_browser->m_parameterManager->setValue(prop,parValue);
}
if (m_cf)
{
Expand Down Expand Up @@ -1117,7 +1117,7 @@ void PropertyHandler::fix(const QString& parName)
{
QtProperty* parProp = getParameterProperty(parName);
if (!parProp) return;
QString parValue = QString::number(m_browser->m_doubleManager->value(parProp));
QString parValue = QString::number(m_browser->m_parameterManager->value(parProp));
try
{
m_fun->tie(parName.toStdString(),parValue.toStdString());
Expand Down

0 comments on commit 62ba1c1

Please sign in to comment.