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

#include <FunctionModel.h>

Inheritance diagram for MantidQt::MantidWidgets::FunctionModel:
MantidQt::MantidWidgets::IFunctionModel MantidQt::MantidWidgets::ConvolutionFunctionModel

Public Member Functions

void addConstraint (std::string const &functionIndex, std::string const &constraint) override
 
void addDatasets (const std::vector< std::string > &datasetNames)
 Adds datasets based on their workspace names.
 
void addFunction (std::string const &prefix, std::string const &funStr) override
 
void changeTie (std::string const &parameterName, std::string const &tie) override
 
int currentDomainIndex () const override
 
IFunction::Attribute getAttribute (std::string const &attrName) const
 
std::vector< std::string > getAttributeNames () const
 
IFunction_sptr getCurrentFunction () const override
 
std::vector< std::string > getDatasetDomainNames () const override
 Returns names for the domains of each dataset.
 
std::vector< std::string > getDatasetNames () const override
 Returns the workspace names of the datasets.
 
IFunction_sptr getFitFunction () const override
 
IFunction_sptr getFullFunction () const override
 
std::vector< std::string > getGlobalParameters () const override
 
std::string getLocalParameterConstraint (std::string const &parameterName, int i) const override
 
std::vector< std::string > getLocalParameters () const override
 
std::string getLocalParameterTie (std::string const &parameterName, int i) const override
 
double getLocalParameterValue (std::string const &parameterName, int i) const override
 
int getNumberDomains () const override
 
double getParameter (std::string const &parameterName) const override
 
std::string getParameterDescription (std::string const &parameterName) const override
 
double getParameterError (std::string const &parameterName) const override
 
std::vector< std::string > getParameterNames () const override
 
std::string getParameterTie (std::string const &parameterName) const
 
IFunction_sptr getSingleFunction (int index) const override
 
bool hasFunction () const override
 
bool isGlobal (std::string const &parameterName) const override
 
bool isLocalParameterFixed (std::string const &parameterName, int i) const override
 
bool isParameterFixed (std::string const &parameterName) const
 
void removeConstraint (std::string const &parameterName) override
 
void removeDatasets (QList< int > &indices)
 Removes datasets (i.e.
 
void removeFunction (std::string const &functionIndex) override
 
void setAttribute (std::string const &attrName, const IFunction::Attribute &val)
 
std::string setBackgroundA0 (double value) override
 
void setCurrentDomainIndex (int) override
 
void setDatasets (const QList< FunctionModelDataset > &datasets) override
 Sets the datasets using a map of <workspace name, spectra list>.
 
void setDatasets (const std::vector< std::string > &datasetNames)
 Sets the datasets based on their workspace names.
 
void setFunction (IFunction_sptr) override
 
virtual void setGlobal (std::string const &parameterName, bool on) override
 
void setGlobalParameters (const std::vector< std::string > &globals) override
 
void setGlobalParameterValue (std::string const &parameterName, double value) override
 
void setLocalParameterConstraint (std::string const &parameterName, int i, std::string const &constraint) override
 
void setLocalParameterFixed (std::string const &parameterName, int i, bool fixed) override
 
void setLocalParameterTie (std::string const &parameterName, int i, std::string const &tie) override
 
void setLocalParameterValue (std::string const &parameterName, int i, double value) override
 
void setLocalParameterValue (std::string const &parameterName, int i, double value, double error) override
 
void setNumberDomains (int) override
 
void setParameter (std::string const &parameterName, double value) override
 
void setParameterError (std::string const &parameterName, double value) override
 
void setParameterFixed (std::string const &parameterName, bool fixed)
 
void setParameterTie (std::string const &parameterName, std::string const &tie)
 
void setQValues (const std::vector< double > &qValues) override
 
void setResolution (const std::vector< std::pair< std::string, size_t > > &fitResolutions) override
 
void updateMultiDatasetAttributes (const IFunction &fun)
 
void updateMultiDatasetParameters (const IFunction &fun) override
 
void updateMultiDatasetParameters (const ITableWorkspace &paramTable) override
 
void updateParameters (const IFunction &fun) override
 
- Public Member Functions inherited from MantidQt::MantidWidgets::IFunctionModel
void clear ()
 
std::string getFitFunctionString () const
 
std::string getFunctionString () const
 
int getNumberLocalFunctions () const
 
void setFunctionString (std::string const &funStr)
 
virtual ~IFunctionModel ()=default
 

Protected Attributes

MultiDomainFunction_sptr m_function
 
size_t m_numberDomains = 0
 

Private Member Functions

void checkDatasets ()
 Check that the number of domains is correct for m_datasets.
 
bool checkIndex (int const index) const
 
void checkNumberOfDomains (const QList< FunctionModelDataset > &datasets) const
 Check that the datasets supplied have the expected total number of domains.
 
IFunction_sptr getFitFunctionWithGlobals (std::size_t const &index) const
 
int numberOfDomains (const QList< FunctionModelDataset > &datasets) const
 
void setResolutionFromWorkspace (const IFunction_sptr &fun)
 
void setResolutionFromWorkspace (const IFunction_sptr &fun, const MatrixWorkspace_sptr &workspace)
 
void updateGlobals ()
 

Private Attributes

size_t m_currentDomainIndex = 0
 
QList< FunctionModelDatasetm_datasets
 
std::vector< std::string > m_globalParameterNames
 

Additional Inherited Members

- Protected Member Functions inherited from MantidQt::MantidWidgets::IFunctionModel
void copyParametersAndErrorsToAllLocalFunctions (const IFunction &fun)
 
- Static Protected Member Functions inherited from MantidQt::MantidWidgets::IFunctionModel
static void copyParametersAndErrors (const IFunction &funFrom, IFunction &funTo)
 

Detailed Description

Definition at line 23 of file FunctionModel.h.

Member Function Documentation

◆ addConstraint()

void MantidQt::MantidWidgets::FunctionModel::addConstraint ( std::string const &  functionIndex,
std::string const &  constraint 
)
overridevirtual

◆ addDatasets()

void MantidQt::MantidWidgets::FunctionModel::addDatasets ( const std::vector< std::string > &  datasetNames)

Adds datasets based on their workspace names.

This assumes there is only a single spectrum in the added workspaces.

Parameters
datasetNames:: Names of the workspaces to be added.

Definition at line 296 of file FunctionModel.cpp.

References m_datasets, numberOfDomains(), and setNumberDomains().

◆ addFunction()

void MantidQt::MantidWidgets::FunctionModel::addFunction ( std::string const &  prefix,
std::string const &  funStr 
)
overridevirtual

◆ changeTie()

void MantidQt::MantidWidgets::FunctionModel::changeTie ( std::string const &  parameterName,
std::string const &  tie 
)
overridevirtual

◆ checkDatasets()

void MantidQt::MantidWidgets::FunctionModel::checkDatasets ( )
private

Check that the number of domains is correct for m_datasets.

Definition at line 500 of file FunctionModel.cpp.

References m_datasets, m_numberDomains, numberOfDomains(), and std::to_string().

Referenced by removeDatasets().

◆ checkIndex()

bool MantidQt::MantidWidgets::FunctionModel::checkIndex ( int const  index) const
private

Definition at line 521 of file FunctionModel.cpp.

References getNumberDomains(), and index.

Referenced by getSingleFunction(), and setCurrentDomainIndex().

◆ checkNumberOfDomains()

void MantidQt::MantidWidgets::FunctionModel::checkNumberOfDomains ( const QList< FunctionModelDataset > &  datasets) const
private

Check that the datasets supplied have the expected total number of domains.

Definition at line 509 of file FunctionModel.cpp.

References m_numberDomains, and numberOfDomains().

Referenced by setDatasets().

◆ currentDomainIndex()

int MantidQt::MantidWidgets::FunctionModel::currentDomainIndex ( ) const
overridevirtual

◆ getAttribute()

IFunction::Attribute MantidQt::MantidWidgets::FunctionModel::getAttribute ( std::string const &  attrName) const

Definition at line 181 of file FunctionModel.cpp.

References getCurrentFunction().

◆ getAttributeNames()

std::vector< std::string > MantidQt::MantidWidgets::FunctionModel::getAttributeNames ( ) const

Definition at line 218 of file FunctionModel.cpp.

References getCurrentFunction(), and hasFunction().

◆ getCurrentFunction()

IFunction_sptr MantidQt::MantidWidgets::FunctionModel::getCurrentFunction ( ) const
overridevirtual

◆ getDatasetDomainNames()

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

Returns names for the domains of each dataset.

If a dataset has multiple spectra, then a domain name will include the spectrum number of a domain in a workspace. This is required for EditLocalParameterDialog.

Implements MantidQt::MantidWidgets::IFunctionModel.

Definition at line 340 of file FunctionModel.cpp.

References m_datasets.

◆ getDatasetNames()

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

Returns the workspace names of the datasets.

If a dataset has N spectra, then the workspace name is multiplied by N. This is required for EditLocalParameterDialog.

Implements MantidQt::MantidWidgets::IFunctionModel.

Definition at line 327 of file FunctionModel.cpp.

References m_datasets, and UNUSED_ARG.

◆ getFitFunction()

IFunction_sptr MantidQt::MantidWidgets::FunctionModel::getFitFunction ( ) const
overridevirtual

◆ getFitFunctionWithGlobals()

IFunction_sptr MantidQt::MantidWidgets::FunctionModel::getFitFunctionWithGlobals ( std::size_t const &  index) const
private

Definition at line 74 of file FunctionModel.cpp.

References index, m_function, and m_globalParameterNames.

Referenced by getFitFunction().

◆ getFullFunction()

IFunction_sptr MantidQt::MantidWidgets::FunctionModel::getFullFunction ( ) const
overridevirtual

Implements MantidQt::MantidWidgets::IFunctionModel.

Definition at line 47 of file FunctionModel.cpp.

References m_function.

◆ getGlobalParameters()

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

◆ getLocalParameterConstraint()

std::string MantidQt::MantidWidgets::FunctionModel::getLocalParameterConstraint ( std::string const &  parameterName,
int  i 
) const
overridevirtual

Implements MantidQt::MantidWidgets::IFunctionModel.

Definition at line 380 of file FunctionModel.cpp.

References getSingleFunction().

◆ getLocalParameters()

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

Implements MantidQt::MantidWidgets::IFunctionModel.

Definition at line 491 of file FunctionModel.cpp.

References getParameterNames().

Referenced by updateMultiDatasetParameters().

◆ getLocalParameterTie()

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

Implements MantidQt::MantidWidgets::IFunctionModel.

Definition at line 369 of file FunctionModel.cpp.

References getSingleFunction().

Referenced by getParameterTie().

◆ getLocalParameterValue()

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

Implements MantidQt::MantidWidgets::IFunctionModel.

Definition at line 359 of file FunctionModel.cpp.

References getSingleFunction().

◆ getNumberDomains()

int MantidQt::MantidWidgets::FunctionModel::getNumberDomains ( ) const
overridevirtual

Implements MantidQt::MantidWidgets::IFunctionModel.

Definition at line 349 of file FunctionModel.cpp.

References m_numberDomains.

Referenced by checkIndex(), and setGlobalParameterValue().

◆ getParameter()

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

Implements MantidQt::MantidWidgets::IFunctionModel.

Definition at line 176 of file FunctionModel.cpp.

References getCurrentFunction().

◆ getParameterDescription()

std::string MantidQt::MantidWidgets::FunctionModel::getParameterDescription ( std::string const &  parameterName) const
overridevirtual

Implements MantidQt::MantidWidgets::IFunctionModel.

Definition at line 191 of file FunctionModel.cpp.

References getCurrentFunction().

◆ getParameterError()

double MantidQt::MantidWidgets::FunctionModel::getParameterError ( std::string const &  parameterName) const
overridevirtual

Implements MantidQt::MantidWidgets::IFunctionModel.

Definition at line 186 of file FunctionModel.cpp.

References getCurrentFunction().

◆ getParameterNames()

std::vector< std::string > MantidQt::MantidWidgets::FunctionModel::getParameterNames ( ) const
overridevirtual

Implements MantidQt::MantidWidgets::IFunctionModel.

Definition at line 212 of file FunctionModel.cpp.

References getCurrentFunction(), and hasFunction().

Referenced by getLocalParameters().

◆ getParameterTie()

std::string MantidQt::MantidWidgets::FunctionModel::getParameterTie ( std::string const &  parameterName) const

Definition at line 200 of file FunctionModel.cpp.

References getLocalParameterTie(), and m_currentDomainIndex.

◆ getSingleFunction()

IFunction_sptr MantidQt::MantidWidgets::FunctionModel::getSingleFunction ( int  index) const
overridevirtual

◆ hasFunction()

bool MantidQt::MantidWidgets::FunctionModel::hasFunction ( ) const
overridevirtual

◆ isGlobal()

bool MantidQt::MantidWidgets::FunctionModel::isGlobal ( std::string const &  parameterName) const
overridevirtual

◆ isLocalParameterFixed()

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

Implements MantidQt::MantidWidgets::IFunctionModel.

Definition at line 363 of file FunctionModel.cpp.

References getSingleFunction().

Referenced by isParameterFixed().

◆ isParameterFixed()

bool MantidQt::MantidWidgets::FunctionModel::isParameterFixed ( std::string const &  parameterName) const

Definition at line 196 of file FunctionModel.cpp.

References isLocalParameterFixed(), and m_currentDomainIndex.

◆ numberOfDomains()

int MantidQt::MantidWidgets::FunctionModel::numberOfDomains ( const QList< FunctionModelDataset > &  datasets) const
private

◆ removeConstraint()

void MantidQt::MantidWidgets::FunctionModel::removeConstraint ( std::string const &  parameterName)
overridevirtual

Implements MantidQt::MantidWidgets::IFunctionModel.

Definition at line 469 of file FunctionModel.cpp.

References getCurrentFunction().

◆ removeDatasets()

void MantidQt::MantidWidgets::FunctionModel::removeDatasets ( QList< int > &  indices)

Removes datasets (i.e.

workspaces) from the Function model based on the index of the dataset in the QList.

Definition at line 305 of file FunctionModel.cpp.

References checkDatasets(), currentDomainIndex(), m_datasets, numberOfDomains(), setCurrentDomainIndex(), and setNumberDomains().

◆ removeFunction()

void MantidQt::MantidWidgets::FunctionModel::removeFunction ( std::string const &  functionIndex)
overridevirtual

◆ setAttribute()

void MantidQt::MantidWidgets::FunctionModel::setAttribute ( std::string const &  attrName,
const IFunction::Attribute val 
)

Definition at line 160 of file FunctionModel.cpp.

References getCurrentFunction(), and value.

◆ setBackgroundA0()

std::string MantidQt::MantidWidgets::FunctionModel::setBackgroundA0 ( double  value)
overridevirtual

◆ setCurrentDomainIndex()

void MantidQt::MantidWidgets::FunctionModel::setCurrentDomainIndex ( int  index)
overridevirtual

Implements MantidQt::MantidWidgets::IFunctionModel.

Definition at line 353 of file FunctionModel.cpp.

References checkIndex(), index, and m_currentDomainIndex.

Referenced by removeDatasets().

◆ setDatasets() [1/2]

void MantidQt::MantidWidgets::FunctionModel::setDatasets ( const QList< FunctionModelDataset > &  datasets)
overridevirtual

Sets the datasets using a map of <workspace name, spectra list>.

This should be used when the workspaces being fitted have multiple spectra.

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

Implements MantidQt::MantidWidgets::IFunctionModel.

Definition at line 288 of file FunctionModel.cpp.

References checkNumberOfDomains(), and m_datasets.

◆ setDatasets() [2/2]

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

Sets the datasets based on their workspace names.

This assumes there is only a single spectrum in the workspaces being fitted.

Parameters
datasetNames:: Names of the workspaces to be fitted.

Definition at line 276 of file FunctionModel.cpp.

References setDatasets().

Referenced by setDatasets().

◆ setFunction()

void MantidQt::MantidWidgets::FunctionModel::setFunction ( IFunction_sptr  fun)
overridevirtual

◆ setGlobal()

void MantidQt::MantidWidgets::FunctionModel::setGlobal ( std::string const &  parameterName,
bool  on 
)
overridevirtual

Implements MantidQt::MantidWidgets::IFunctionModel.

Definition at line 475 of file FunctionModel.cpp.

References m_globalParameterNames.

◆ setGlobalParameters()

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

Implements MantidQt::MantidWidgets::IFunctionModel.

Definition at line 489 of file FunctionModel.cpp.

References m_globalParameterNames.

◆ setGlobalParameterValue()

void MantidQt::MantidWidgets::FunctionModel::setGlobalParameterValue ( std::string const &  parameterName,
double  value 
)
overridevirtual

◆ setLocalParameterConstraint()

void MantidQt::MantidWidgets::FunctionModel::setLocalParameterConstraint ( std::string const &  parameterName,
int  i,
std::string const &  constraint 
)
overridevirtual

◆ setLocalParameterFixed()

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

Implements MantidQt::MantidWidgets::IFunctionModel.

Definition at line 401 of file FunctionModel.cpp.

References getSingleFunction().

Referenced by setParameterFixed().

◆ setLocalParameterTie()

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

◆ setLocalParameterValue() [1/2]

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

◆ setLocalParameterValue() [2/2]

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

Implements MantidQt::MantidWidgets::IFunctionModel.

Definition at line 394 of file FunctionModel.cpp.

References error, getSingleFunction(), and value.

◆ setNumberDomains()

void MantidQt::MantidWidgets::FunctionModel::setNumberDomains ( int  nDomains)
overridevirtual

◆ setParameter()

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

◆ setParameterError()

void MantidQt::MantidWidgets::FunctionModel::setParameterError ( std::string const &  parameterName,
double  value 
)
overridevirtual

Implements MantidQt::MantidWidgets::IFunctionModel.

Definition at line 170 of file FunctionModel.cpp.

References getCurrentFunction(), index, and value.

Referenced by updateMultiDatasetParameters().

◆ setParameterFixed()

void MantidQt::MantidWidgets::FunctionModel::setParameterFixed ( std::string const &  parameterName,
bool  fixed 
)

Definition at line 204 of file FunctionModel.cpp.

References m_currentDomainIndex, and setLocalParameterFixed().

◆ setParameterTie()

void MantidQt::MantidWidgets::FunctionModel::setParameterTie ( std::string const &  parameterName,
std::string const &  tie 
)

Definition at line 208 of file FunctionModel.cpp.

References m_currentDomainIndex, and setLocalParameterTie().

◆ setQValues()

void MantidQt::MantidWidgets::FunctionModel::setQValues ( const std::vector< double > &  qValues)
overridevirtual

Implements MantidQt::MantidWidgets::IFunctionModel.

Definition at line 659 of file FunctionModel.cpp.

◆ setResolution()

void MantidQt::MantidWidgets::FunctionModel::setResolution ( const std::vector< std::pair< std::string, size_t > > &  fitResolutions)
overridevirtual

Implements MantidQt::MantidWidgets::IFunctionModel.

Definition at line 655 of file FunctionModel.cpp.

◆ setResolutionFromWorkspace() [1/2]

void MantidQt::MantidWidgets::FunctionModel::setResolutionFromWorkspace ( const IFunction_sptr fun)
private

Definition at line 593 of file FunctionModel.cpp.

References index, n, and setResolutionFromWorkspace().

Referenced by setFunction(), and setResolutionFromWorkspace().

◆ setResolutionFromWorkspace() [2/2]

void MantidQt::MantidWidgets::FunctionModel::setResolutionFromWorkspace ( const IFunction_sptr fun,
const MatrixWorkspace_sptr workspace 
)
private

Definition at line 610 of file FunctionModel.cpp.

References workspace.

◆ updateGlobals()

void MantidQt::MantidWidgets::FunctionModel::updateGlobals ( )
private

Definition at line 582 of file FunctionModel.cpp.

References getCurrentFunction(), and m_globalParameterNames.

Referenced by addFunction(), and removeFunction().

◆ updateMultiDatasetAttributes()

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

◆ updateMultiDatasetParameters() [1/2]

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

◆ updateMultiDatasetParameters() [2/2]

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

◆ updateParameters()

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

Member Data Documentation

◆ m_currentDomainIndex

size_t MantidQt::MantidWidgets::FunctionModel::m_currentDomainIndex = 0
private

◆ m_datasets

QList<FunctionModelDataset> MantidQt::MantidWidgets::FunctionModel::m_datasets
mutableprivate

◆ m_function

MultiDomainFunction_sptr MantidQt::MantidWidgets::FunctionModel::m_function
protected

◆ m_globalParameterNames

std::vector<std::string> MantidQt::MantidWidgets::FunctionModel::m_globalParameterNames
mutableprivate

◆ m_numberDomains

size_t MantidQt::MantidWidgets::FunctionModel::m_numberDomains = 0
protected

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