Mantid
Loading...
Searching...
No Matches
FunctionModel.h
Go to the documentation of this file.
1// Mantid Repository : https://github.com/mantidproject/mantid
2//
3// Copyright © 2018 ISIS Rutherford Appleton Laboratory UKRI,
4// NScD Oak Ridge National Laboratory, European Spallation Source,
5// Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS
6// SPDX - License - Identifier: GPL - 3.0 +
7#pragma once
8
9#include "DllOption.h"
10
11#include "IFunctionModel.h"
12#include "MantidAPI/IFunction.h"
14
15#include <QString>
16#include <QStringList>
17
18namespace MantidQt {
19namespace MantidWidgets {
20
21using namespace Mantid::API;
22
24public:
25 void setFunction(IFunction_sptr) override;
26 IFunction_sptr getFullFunction() const override;
27 IFunction_sptr getFitFunction() const override;
28 bool hasFunction() const override;
29 void addFunction(std::string const &prefix, std::string const &funStr) override;
30 void removeFunction(std::string const &functionIndex) override;
31 void setParameter(std::string const &parameterName, double value) override;
32 void setAttribute(std::string const &attrName, const IFunction::Attribute &val);
33 void setParameterError(std::string const &parameterName, double value) override;
34 double getParameter(std::string const &parameterName) const override;
35 double getParameterError(std::string const &parameterName) const override;
36 IFunction::Attribute getAttribute(std::string const &attrName) const;
37 std::string getParameterDescription(std::string const &parameterName) const override;
38 bool isParameterFixed(std::string const &parameterName) const;
39 std::string getParameterTie(std::string const &parameterName) const;
40 void setParameterFixed(std::string const &parameterName, bool fixed);
41 void setParameterTie(std::string const &parameterName, std::string const &tie);
42 std::vector<std::string> getParameterNames() const override;
43 std::vector<std::string> getAttributeNames() const;
44 IFunction_sptr getSingleFunction(int index) const override;
45 IFunction_sptr getCurrentFunction() const override;
46 void setNumberDomains(int) override;
47 void setDatasets(const std::vector<std::string> &datasetNames);
48 void setDatasets(const QList<FunctionModelDataset> &datasets) override;
49 void addDatasets(const std::vector<std::string> &datasetNames);
50 void removeDatasets(QList<int> &indices);
51 std::vector<std::string> getDatasetNames() const override;
52 std::vector<std::string> getDatasetDomainNames() const override;
53 int getNumberDomains() const override;
54 int currentDomainIndex() const override;
55 void setCurrentDomainIndex(int) override;
56 double getLocalParameterValue(std::string const &parameterName, int i) const override;
57 bool isLocalParameterFixed(std::string const &parameterName, int i) const override;
58 std::string getLocalParameterTie(std::string const &parameterName, int i) const override;
59 std::string getLocalParameterConstraint(std::string const &parameterName, int i) const override;
60 void setLocalParameterValue(std::string const &parameterName, int i, double value) override;
61 void setLocalParameterValue(std::string const &parameterName, int i, double value, double error) override;
62 void setLocalParameterFixed(std::string const &parameterName, int i, bool fixed) override;
63 void setLocalParameterTie(std::string const &parameterName, int i, std::string const &tie) override;
64 void setLocalParameterConstraint(std::string const &parameterName, int i, std::string const &constraint) override;
65 void setGlobalParameterValue(std::string const &parameterName, double value) override;
66 void changeTie(std::string const &parameterName, std::string const &tie) override;
67 void addConstraint(std::string const &functionIndex, std::string const &constraint) override;
68 void removeConstraint(std::string const &parameterName) override;
69 std::vector<std::string> getGlobalParameters() const override;
70 virtual void setGlobal(std::string const &parameterName, bool on) override;
71 void setGlobalParameters(const std::vector<std::string> &globals) override;
72 bool isGlobal(std::string const &parameterName) const override;
73 std::vector<std::string> getLocalParameters() const override;
74 void updateMultiDatasetParameters(const IFunction &fun) override;
75 void updateMultiDatasetParameters(const ITableWorkspace &paramTable) override;
76 void updateMultiDatasetAttributes(const IFunction &fun);
77 void updateParameters(const IFunction &fun) override;
78 std::string setBackgroundA0(double value) override;
79 void setResolution(const std::vector<std::pair<std::string, size_t>> &fitResolutions) override;
80 void setQValues(const std::vector<double> &qValues) override;
81
82protected:
83 size_t m_numberDomains = 0;
85
86private:
87 IFunction_sptr getFitFunctionWithGlobals(std::size_t const &index) const;
88
89 void checkDatasets();
90 void checkNumberOfDomains(const QList<FunctionModelDataset> &datasets) const;
91 int numberOfDomains(const QList<FunctionModelDataset> &datasets) const;
92 [[nodiscard]] bool checkIndex(int const index) const;
93 void updateGlobals();
94 void setResolutionFromWorkspace(const IFunction_sptr &fun);
95 void setResolutionFromWorkspace(const IFunction_sptr &fun, const MatrixWorkspace_sptr &workspace);
96 size_t m_currentDomainIndex = 0;
97 // The datasets being fitted. A list of workspace names paired to lists of
98 // spectra.
100 mutable std::vector<std::string> m_globalParameterNames;
101};
102
103} // namespace MantidWidgets
104} // namespace MantidQt
#define EXPORT_OPT_MANTIDQT_COMMON
Definition DllOption.h:15
double value
The value of the point.
Definition FitMW.cpp:51
double error
IPeaksWorkspace_sptr workspace
std::map< DeltaEMode::Type, std::string > index
MultiDomainFunction_sptr m_function
std::vector< std::string > m_globalParameterNames
QList< FunctionModelDataset > m_datasets
Attribute is a non-fitting parameter.
Definition IFunction.h:285
This is an interface to a fitting function - a semi-abstarct class.
Definition IFunction.h:166
ITableWorkspace is an implementation of Workspace in which the data are organised in columns of same ...
The AlgorithmProgressDialogPresenter keeps track of the running algorithms and displays a progress ba...
std::shared_ptr< MultiDomainFunction > MultiDomainFunction_sptr
Shared pointer to Mantid::API::MultiDomainFunction.
std::shared_ptr< IFunction > IFunction_sptr
shared pointer to the function base class
Definition IFunction.h:743
std::shared_ptr< MatrixWorkspace > MatrixWorkspace_sptr
shared pointer to the matrix workspace base class