Mantid
Loading...
Searching...
No Matches
Public Slots | Signals | Public Member Functions | Protected Attributes | List of all members
MantidQt::MantidWidgets::FunctionBrowser Class Reference

Class FitPropertyBrowser implements QtPropertyBrowser to display and control fitting function parameters and settings. More...

#include <FunctionBrowser.h>

Inheritance diagram for MantidQt::MantidWidgets::FunctionBrowser:
MantidQt::MantidWidgets::IFunctionBrowser MantidQt::MantidWidgets::MuonFunctionBrowser

Public Slots

void addDatasets (const std::vector< std::string > &names)
 Add some datasets to those already set.
 
void removeDatasets (const QList< int > &indices)
 Remove local parameter values for a number of datasets.
 
void resetLocalParameters ()
 
void setCurrentDataset (int i) override
 Set current dataset.
 
void setDatasets (const QList< FunctionModelDataset > &datasets) override
 Sets the datasets being fitted.
 
void setDatasets (const std::vector< std::string > &datasetNames) override
 Sets the datasets being fitted.
 
void setNumberOfDatasets (int n) override
 Set new number of the datasets.
 

Signals

void attributeChanged (std::string const &attributeName)
 
void currentFunctionChanged ()
 User selects a different function (or one of it's sub-properties)
 
void functionStructureChanged ()
 
void globalsChanged ()
 
void localParameterButtonClicked (std::string const &parName)
 In multi-dataset context a button value editor was clicked.
 
void parameterChanged (std::string const &funcIndex, std::string const &paramName)
 

Public Member Functions

void clear () override
 Clear the contents.
 
void clearErrors () override
 Clear all errors.
 
std::optional< std::string > currentFunctionIndex ()
 Return index of the current function, if one is selected.
 
 FunctionBrowser (QWidget *parent=nullptr, bool multi=false, const std::vector< std::string > &categories=std::vector< std::string >())
 Constructor.
 
int getCurrentDataset () const override
 Get the index of the current dataset.
 
std::vector< std::string > getDatasetDomainNames () const override
 Get the names of the dataset domains.
 
std::vector< std::string > getDatasetNames () const override
 Get the names of datasets.
 
std::string getFitFunctionString () const
 
IFunction_sptr getFunction ()
 Return the function.
 
IFunction_sptr getFunctionByIndex (std::string const &index)
 Return a function with specified index.
 
std::string getFunctionString () override
 Return FunctionFactory function string.
 
IFunction_sptr getGlobalFunction () override
 Return the multidomain function if number of datasets is greater than 1.
 
std::vector< std::string > getGlobalParameters () const
 Get a list of names of global parameters.
 
double getLocalParameterError (std::string const &parameterName, int i) const
 Get error of a local parameter.
 
std::vector< std::string > getLocalParameters () const
 Get a list of names of local parameters.
 
std::string getLocalParameterTie (std::string const &parameterName, int i) const override
 Get the tie for a local parameter.
 
double getLocalParameterValue (std::string const &parameterName, int i) const override
 Get value of a local parameter.
 
int getNumberOfDatasets () const override
 Get the number of datasets.
 
double getParameter (std::string const &parameterName) const
 Get a value of a parameter.
 
bool hasFunction () const
 Check if a function is set.
 
void hideGlobalCheckbox ()
 
bool isLocalParameterFixed (std::string const &parameterName, int i) const override
 Check if a local parameter is fixed.
 
void setBackgroundA0 (double value)
 Set a parameter that is responsible for the background level.
 
void setColumnSizes (int s0, int s1, int s2=-1)
 Resize the browser's columns.
 
void setErrorsEnabled (bool enabled) override
 Set error display on/off.
 
void setFunction (IFunction_sptr fun)
 Set the function in the browser.
 
void setFunction (std::string const &funStr) override
 Set the function in the browser.
 
void setGlobalParameters (std::vector< std::string > const &globals)
 
void setLocalParameterFixed (std::string const &parameterName, int i, bool fixed) override
 Fix/unfix local parameter.
 
void setLocalParameterTie (std::string const &parameterName, int i, std::string const &tie) override
 Set a tie for a local parameter.
 
void setLocalParameterValue (std::string const &parameterName, int i, double value) override
 Set value of a local parameter.
 
void setLocalParameterValue (std::string const &parameterName, int i, double value, double error)
 Set value and error of a local parameter.
 
void setParameter (std::string const &parameterName, double value)
 Update the function parameter value.
 
void setParameterError (std::string const &parameterName, double error)
 Update the function parameter error.
 
void setStretchLastColumn (bool stretch)
 Set the last column to stretch.
 
void showGlobalCheckbox ()
 
void updateMultiDatasetAttributes (const IFunction &fun)
 Update parameter values in the browser to match those of a function.
 
void updateMultiDatasetParameters (const IFunction &fun) override
 Update parameter values in the browser to match those of a function.
 
void updateMultiDatasetParameters (const ITableWorkspace &paramTable) override
 Update parameter values in the browser to match those in a table workspace.
 
void updateParameters (const IFunction &fun) override
 Update parameter values in the browser to match those of a function.
 
FunctionTreeViewview () const
 
virtual ~FunctionBrowser () override
 Destructor.
 
- Public Member Functions inherited from MantidQt::MantidWidgets::IFunctionBrowser
virtual void setCurrentDataset (int i)=0
 
virtual void setDatasets (const QList< FunctionModelDataset > &datasets)=0
 
virtual void setDatasets (const std::vector< std::string > &datasetNames)=0
 
virtual void setNumberOfDatasets (int n)=0
 
virtual ~IFunctionBrowser ()=default
 

Protected Attributes

std::unique_ptr< FunctionMultiDomainPresenterm_presenter
 

Detailed Description

Class FitPropertyBrowser implements QtPropertyBrowser to display and control fitting function parameters and settings.

Definition at line 40 of file FunctionBrowser.h.

Constructor & Destructor Documentation

◆ FunctionBrowser()

MantidQt::MantidWidgets::FunctionBrowser::FunctionBrowser ( QWidget *  parent = nullptr,
bool  multi = false,
const std::vector< std::string > &  categories = std::vector<std::string>() 
)

Constructor.

Parameters
parent:: The parent widget.
multi:: Option to use the browser for multi-dataset fitting.
categories:: Function categories to be included to the Add Function dialog. An empty vector means include all available categories.

Definition at line 46 of file FunctionBrowser.cpp.

References attributeChanged(), functionStructureChanged(), m_presenter, and parameterChanged().

◆ ~FunctionBrowser()

MantidQt::MantidWidgets::FunctionBrowser::~FunctionBrowser ( )
overridevirtualdefault

Destructor.

Member Function Documentation

◆ addDatasets

void MantidQt::MantidWidgets::FunctionBrowser::addDatasets ( const std::vector< std::string > &  names)
slot

Add some datasets to those already set.

Parameters
names:: A list of names for the new datasets.

Definition at line 190 of file FunctionBrowser.cpp.

References m_presenter.

◆ attributeChanged

void MantidQt::MantidWidgets::FunctionBrowser::attributeChanged ( std::string const &  attributeName)
signal

Referenced by FunctionBrowser().

◆ clear()

void MantidQt::MantidWidgets::FunctionBrowser::clear ( )
overridevirtual

Clear the contents.

Implements MantidQt::MantidWidgets::IFunctionBrowser.

Definition at line 68 of file FunctionBrowser.cpp.

References m_presenter.

◆ clearErrors()

void MantidQt::MantidWidgets::FunctionBrowser::clearErrors ( )
overridevirtual

Clear all errors.

Clear all errors, if they are set.

Implements MantidQt::MantidWidgets::IFunctionBrowser.

Definition at line 289 of file FunctionBrowser.cpp.

References m_presenter.

◆ currentFunctionChanged

void MantidQt::MantidWidgets::FunctionBrowser::currentFunctionChanged ( )
signal

User selects a different function (or one of it's sub-properties)

◆ currentFunctionIndex()

std::optional< std::string > MantidQt::MantidWidgets::FunctionBrowser::currentFunctionIndex ( )

Return index of the current function, if one is selected.

Definition at line 299 of file FunctionBrowser.cpp.

References m_presenter.

◆ functionStructureChanged

void MantidQt::MantidWidgets::FunctionBrowser::functionStructureChanged ( )
signal

Referenced by FunctionBrowser().

◆ getCurrentDataset()

int MantidQt::MantidWidgets::FunctionBrowser::getCurrentDataset ( ) const
overridevirtual

Get the index of the current dataset.

Implements MantidQt::MantidWidgets::IFunctionBrowser.

Definition at line 266 of file FunctionBrowser.cpp.

References m_presenter.

Referenced by updateMultiDatasetParameters().

◆ getDatasetDomainNames()

std::vector< std::string > MantidQt::MantidWidgets::FunctionBrowser::getDatasetDomainNames ( ) const
overridevirtual

Get the names of the dataset domains.

Implements MantidQt::MantidWidgets::IFunctionBrowser.

Definition at line 139 of file FunctionBrowser.cpp.

References m_presenter.

◆ getDatasetNames()

std::vector< std::string > MantidQt::MantidWidgets::FunctionBrowser::getDatasetNames ( ) const
overridevirtual

Get the names of datasets.

Implements MantidQt::MantidWidgets::IFunctionBrowser.

Definition at line 136 of file FunctionBrowser.cpp.

References m_presenter.

◆ getFitFunctionString()

std::string MantidQt::MantidWidgets::FunctionBrowser::getFitFunctionString ( ) const

Definition at line 303 of file FunctionBrowser.cpp.

References m_presenter.

◆ getFunction()

Mantid::API::IFunction_sptr MantidQt::MantidWidgets::FunctionBrowser::getFunction ( )

Return the function.

Definition at line 128 of file FunctionBrowser.cpp.

References m_presenter.

◆ getFunctionByIndex()

IFunction_sptr MantidQt::MantidWidgets::FunctionBrowser::getFunctionByIndex ( std::string const &  index)

Return a function with specified index.

Return function at specified function index (e.g.

f0.)

Parameters
index:: Index of the function, or empty string for top-level function
Returns
Function at index, or null pointer if not found

Definition at line 87 of file FunctionBrowser.cpp.

References index, and m_presenter.

◆ getFunctionString()

std::string MantidQt::MantidWidgets::FunctionBrowser::getFunctionString ( )
overridevirtual

Return FunctionFactory function string.

Implements MantidQt::MantidWidgets::IFunctionBrowser.

Definition at line 126 of file FunctionBrowser.cpp.

References m_presenter.

◆ getGlobalFunction()

IFunction_sptr MantidQt::MantidWidgets::FunctionBrowser::getGlobalFunction ( )
overridevirtual

Return the multidomain function if number of datasets is greater than 1.

Return the multidomain function for multi-dataset fitting.

Implements MantidQt::MantidWidgets::IFunctionBrowser.

Definition at line 193 of file FunctionBrowser.cpp.

References m_presenter.

Referenced by MantidQt::MantidWidgets::MuonFitPropertyBrowser::doTFAsymmFit().

◆ getGlobalParameters()

std::vector< std::string > MantidQt::MantidWidgets::FunctionBrowser::getGlobalParameters ( ) const

Get a list of names of global parameters.

Definition at line 291 of file FunctionBrowser.cpp.

References m_presenter.

Referenced by updateMultiDatasetParameters().

◆ getLocalParameterError()

double MantidQt::MantidWidgets::FunctionBrowser::getLocalParameterError ( std::string const &  parameterName,
int  i 
) const

Get error of a local parameter.

Definition at line 175 of file FunctionBrowser.cpp.

References m_presenter.

◆ getLocalParameters()

std::vector< std::string > MantidQt::MantidWidgets::FunctionBrowser::getLocalParameters ( ) const

Get a list of names of local parameters.

Definition at line 293 of file FunctionBrowser.cpp.

References m_presenter.

Referenced by updateMultiDatasetParameters().

◆ getLocalParameterTie()

std::string MantidQt::MantidWidgets::FunctionBrowser::getLocalParameterTie ( std::string const &  parameterName,
int  i 
) const
overridevirtual

Get the tie for a local parameter.

Parameters
parameterName:: Parameter name
i:: Index of a dataset.

Implements MantidQt::MantidWidgets::IFunctionBrowser.

Definition at line 213 of file FunctionBrowser.cpp.

References m_presenter.

◆ getLocalParameterValue()

double MantidQt::MantidWidgets::FunctionBrowser::getLocalParameterValue ( std::string const &  parameterName,
int  i 
) const
overridevirtual

Get value of a local parameter.

Parameters
parameterName:: Name of a parameter.
i:: Data set index.

Implements MantidQt::MantidWidgets::IFunctionBrowser.

Definition at line 162 of file FunctionBrowser.cpp.

References m_presenter.

◆ getNumberOfDatasets()

int MantidQt::MantidWidgets::FunctionBrowser::getNumberOfDatasets ( ) const
overridevirtual

Get the number of datasets.

Implements MantidQt::MantidWidgets::IFunctionBrowser.

Definition at line 133 of file FunctionBrowser.cpp.

References m_presenter.

◆ getParameter()

double MantidQt::MantidWidgets::FunctionBrowser::getParameter ( std::string const &  parameterName) const

Get a value of a parameter.

Parameters
parameterName:: Fully qualified parameter name (includes function index)

Definition at line 112 of file FunctionBrowser.cpp.

References m_presenter.

◆ globalsChanged

void MantidQt::MantidWidgets::FunctionBrowser::globalsChanged ( )
signal

◆ hasFunction()

bool MantidQt::MantidWidgets::FunctionBrowser::hasFunction ( ) const

Check if a function is set.

Definition at line 130 of file FunctionBrowser.cpp.

References m_presenter.

◆ hideGlobalCheckbox()

void MantidQt::MantidWidgets::FunctionBrowser::hideGlobalCheckbox ( )

◆ isLocalParameterFixed()

bool MantidQt::MantidWidgets::FunctionBrowser::isLocalParameterFixed ( std::string const &  parameterName,
int  i 
) const
overridevirtual

Check if a local parameter is fixed.

Parameters
parameterName:: Parameter name
i:: Index of a dataset.

Implements MantidQt::MantidWidgets::IFunctionBrowser.

Definition at line 206 of file FunctionBrowser.cpp.

References m_presenter.

◆ localParameterButtonClicked

void MantidQt::MantidWidgets::FunctionBrowser::localParameterButtonClicked ( std::string const &  parName)
signal

In multi-dataset context a button value editor was clicked.

◆ parameterChanged

void MantidQt::MantidWidgets::FunctionBrowser::parameterChanged ( std::string const &  funcIndex,
std::string const &  paramName 
)
signal

Referenced by FunctionBrowser().

◆ removeDatasets

void MantidQt::MantidWidgets::FunctionBrowser::removeDatasets ( const QList< int > &  indices)
slot

Remove local parameter values for a number of datasets.

Parameters
indices:: A list of indices of datasets to remove.

Definition at line 186 of file FunctionBrowser.cpp.

References m_presenter.

◆ resetLocalParameters

void MantidQt::MantidWidgets::FunctionBrowser::resetLocalParameters ( )
slot

Definition at line 179 of file FunctionBrowser.cpp.

◆ setBackgroundA0()

void MantidQt::MantidWidgets::FunctionBrowser::setBackgroundA0 ( double  value)

Set a parameter that is responsible for the background level.

Definition at line 305 of file FunctionBrowser.cpp.

References m_presenter, and value.

◆ setColumnSizes()

void MantidQt::MantidWidgets::FunctionBrowser::setColumnSizes ( int  s0,
int  s1,
int  s2 = -1 
)

Resize the browser's columns.

Parameters
s0:: New size for the first column (Parameter).
s1:: New size for the second column (Value).
s2:: New size for the third optional column (Global).

Definition at line 272 of file FunctionBrowser.cpp.

References m_presenter.

◆ setCurrentDataset

void MantidQt::MantidWidgets::FunctionBrowser::setCurrentDataset ( int  i)
overrideslot

Set current dataset.

Definition at line 182 of file FunctionBrowser.cpp.

References m_presenter.

◆ setDatasets [1/2]

void MantidQt::MantidWidgets::FunctionBrowser::setDatasets ( const QList< FunctionModelDataset > &  datasets)
overrideslot

Sets the datasets being fitted.

They will be displayed by the local parameter editing dialog.

Parameters
datasets:: Names of workspaces to be fitted maped to a spectra list.

Definition at line 155 of file FunctionBrowser.cpp.

References m_presenter.

◆ setDatasets [2/2]

void MantidQt::MantidWidgets::FunctionBrowser::setDatasets ( const std::vector< std::string > &  datasetNames)
overrideslot

Sets the datasets being fitted.

They will be displayed by the local parameter editing dialog.

Parameters
datasetNames:: Names of the datasets

Definition at line 148 of file FunctionBrowser.cpp.

References m_presenter.

◆ setErrorsEnabled()

void MantidQt::MantidWidgets::FunctionBrowser::setErrorsEnabled ( bool  enabled)
overridevirtual

Set error display on/off.

Set display of parameter errors on/off.

Parameters
enabled:: [input] On/off display of errors

Implements MantidQt::MantidWidgets::IFunctionBrowser.

Definition at line 284 of file FunctionBrowser.cpp.

References m_presenter.

◆ setFunction() [1/2]

void MantidQt::MantidWidgets::FunctionBrowser::setFunction ( IFunction_sptr  fun)

Set the function in the browser.

Parameters
fun:: A function

Definition at line 80 of file FunctionBrowser.cpp.

References m_presenter.

◆ setFunction() [2/2]

void MantidQt::MantidWidgets::FunctionBrowser::setFunction ( std::string const &  funStr)
overridevirtual

Set the function in the browser.

Parameters
funStr:: FunctionFactory function creation string

Implements MantidQt::MantidWidgets::IFunctionBrowser.

Definition at line 74 of file FunctionBrowser.cpp.

References m_presenter.

◆ setGlobalParameters()

void MantidQt::MantidWidgets::FunctionBrowser::setGlobalParameters ( std::vector< std::string > const &  globals)

Definition at line 295 of file FunctionBrowser.cpp.

References m_presenter.

◆ setLocalParameterFixed()

void MantidQt::MantidWidgets::FunctionBrowser::setLocalParameterFixed ( std::string const &  parameterName,
int  i,
bool  fixed 
)
overridevirtual

Fix/unfix local parameter.

Fix/unfix a local parameter.

Parameters
parameterName:: Parameter name
i:: Index of a dataset.
fixed:: Make it fixed (true) or free (false)

Implements MantidQt::MantidWidgets::IFunctionBrowser.

Definition at line 199 of file FunctionBrowser.cpp.

References m_presenter.

◆ setLocalParameterTie()

void MantidQt::MantidWidgets::FunctionBrowser::setLocalParameterTie ( std::string const &  parameterName,
int  i,
std::string const &  tie 
)
overridevirtual

Set a tie for a local parameter.

Parameters
parameterName:: Parameter name
i:: Index of a dataset.
tie:: A tie string.

Implements MantidQt::MantidWidgets::IFunctionBrowser.

Definition at line 221 of file FunctionBrowser.cpp.

References m_presenter.

◆ setLocalParameterValue() [1/2]

void MantidQt::MantidWidgets::FunctionBrowser::setLocalParameterValue ( std::string const &  parameterName,
int  i,
double  value 
)
overridevirtual

Set value of a local parameter.

Implements MantidQt::MantidWidgets::IFunctionBrowser.

Definition at line 166 of file FunctionBrowser.cpp.

References m_presenter, and value.

Referenced by updateMultiDatasetParameters().

◆ setLocalParameterValue() [2/2]

void MantidQt::MantidWidgets::FunctionBrowser::setLocalParameterValue ( std::string const &  parameterName,
int  i,
double  value,
double  error 
)

Set value and error of a local parameter.

Definition at line 170 of file FunctionBrowser.cpp.

References error, m_presenter, and value.

◆ setNumberOfDatasets

void MantidQt::MantidWidgets::FunctionBrowser::setNumberOfDatasets ( int  n)
overrideslot

Set new number of the datasets.

Parameters
n:: New value for the number of datasets.

Definition at line 143 of file FunctionBrowser.cpp.

References m_presenter, and n.

◆ setParameter()

void MantidQt::MantidWidgets::FunctionBrowser::setParameter ( std::string const &  parameterName,
double  value 
)

Update the function parameter value.

Updates the function parameter value.

Parameters
parameterName:: Fully qualified parameter name (includes function index)
value:: New value

Definition at line 95 of file FunctionBrowser.cpp.

References m_presenter, and value.

Referenced by updateMultiDatasetParameters().

◆ setParameterError()

void MantidQt::MantidWidgets::FunctionBrowser::setParameterError ( std::string const &  parameterName,
double  error 
)

Update the function parameter error.

Updates the function parameter error.

Parameters
parameterName:: Fully qualified parameter name (includes function index)
error:: New error

Definition at line 104 of file FunctionBrowser.cpp.

References error, and m_presenter.

Referenced by updateMultiDatasetParameters().

◆ setStretchLastColumn()

void MantidQt::MantidWidgets::FunctionBrowser::setStretchLastColumn ( bool  stretch)

Set the last column to stretch.

This avoids a vertical scroll bar.

Parameters
stretch:: A bool whether or not to stretch the last column.

Definition at line 278 of file FunctionBrowser.cpp.

References m_presenter.

◆ showGlobalCheckbox()

void MantidQt::MantidWidgets::FunctionBrowser::showGlobalCheckbox ( )

Definition at line 309 of file FunctionBrowser.cpp.

References m_presenter.

◆ updateMultiDatasetAttributes()

void MantidQt::MantidWidgets::FunctionBrowser::updateMultiDatasetAttributes ( const IFunction fun)

Update parameter values in the browser to match those of a function.

Update the interface to have the same attribute values as in a function.

Parameters
fun:: A function to get attribute values from.

Definition at line 233 of file FunctionBrowser.cpp.

References m_presenter.

◆ updateMultiDatasetParameters() [1/2]

void MantidQt::MantidWidgets::FunctionBrowser::updateMultiDatasetParameters ( const IFunction fun)
overridevirtual

Update parameter values in the browser to match those of a function.

Update the interface to have the same parameter values as in a function.

Parameters
fun:: A function to get parameter values from.

Implements MantidQt::MantidWidgets::IFunctionBrowser.

Definition at line 227 of file FunctionBrowser.cpp.

References m_presenter.

◆ updateMultiDatasetParameters() [2/2]

void MantidQt::MantidWidgets::FunctionBrowser::updateMultiDatasetParameters ( const ITableWorkspace paramTable)
overridevirtual

◆ updateParameters()

void MantidQt::MantidWidgets::FunctionBrowser::updateParameters ( const IFunction fun)
overridevirtual

Update parameter values in the browser to match those of a function.

Parameters
fun:: A function to copy the values from. It must have the same type (composition) as the function in the browser.

Implements MantidQt::MantidWidgets::IFunctionBrowser.

Definition at line 121 of file FunctionBrowser.cpp.

References m_presenter.

◆ view()

FunctionTreeView * MantidQt::MantidWidgets::FunctionBrowser::view ( ) const

Definition at line 301 of file FunctionBrowser.cpp.

References m_presenter.

Member Data Documentation

◆ m_presenter

std::unique_ptr<FunctionMultiDomainPresenter> MantidQt::MantidWidgets::FunctionBrowser::m_presenter
protected

The documentation for this class was generated from the following files: