Mantid
Loading...
Searching...
No Matches
FitDomain.h
Go to the documentation of this file.
1// Mantid Repository : https://github.com/mantidproject/mantid
2//
3// Copyright © 2020 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"
11#include "MantidAPI/IFunction.h"
14
15#include <string>
16#include <utility>
17#include <vector>
18
19namespace MantidQt {
20namespace MantidWidgets {
21
28
29public:
30 FitDomain(std::string workspaceName, WorkspaceIndex workspaceIndex, double startX, double endX);
31
32 void setWorkspaceName(std::string const &workspaceName);
33
34 [[nodiscard]] std::string domainName() const;
35 [[nodiscard]] std::string workspaceName() const noexcept { return m_workspaceName; }
36 [[nodiscard]] WorkspaceIndex workspaceIndex() const noexcept { return m_workspaceIndex; }
37
38 [[nodiscard]] bool setStartX(double startX);
39 [[nodiscard]] bool setEndX(double startX);
40
41 [[nodiscard]] double startX() const noexcept { return m_startX; }
42 [[nodiscard]] double endX() const noexcept { return m_endX; }
43
44 void setFunction(Mantid::API::IFunction_sptr const &function);
45 [[nodiscard]] Mantid::API::IFunction_sptr getFunctionCopy() const;
46 void removeFunction(std::string const &function);
47 void addFunction(Mantid::API::IFunction_sptr const &function);
48
49 void setParameterValue(std::string const &parameter, double newValue);
50 [[nodiscard]] double getParameterValue(std::string const &parameter) const;
51
52 void setParameterFixed(std::string const &parameter, bool fix) const;
53 [[nodiscard]] bool isParameterFixed(std::string const &parameter) const;
54
55 void setAttributeValue(std::string const &attribute, const Mantid::API::IFunction::Attribute &newValue);
56 [[nodiscard]] Mantid::API::IFunction::Attribute getAttributeValue(std::string const &attribute) const;
57
58 [[nodiscard]] bool hasParameter(std::string const &parameter) const;
59 [[nodiscard]] bool isParameterActive(std::string const &parameter) const;
60 [[nodiscard]] std::string getParameterTie(std::string const &parameter) const;
61 [[nodiscard]] std::string getParameterConstraint(std::string const &parameter) const;
62
63 void clearParameterTie(std::string const &parameter);
64 [[nodiscard]] bool updateParameterTie(std::string const &parameter, std::string const &tie);
65
66 void removeParameterConstraint(std::string const &parameter);
67 void updateParameterConstraint(std::string const &functionIndex, std::string const &parameter,
68 std::string const &constraint);
69
70 [[nodiscard]] std::vector<std::string> getParametersTiedTo(std::string const &parameter) const;
71
72 [[nodiscard]] bool isParameterValueWithinConstraints(std::string const &parameter, double value) const;
73
74private:
75 [[nodiscard]] bool setParameterTie(std::string const &parameter, std::string const &tie);
76
77 [[nodiscard]] double getTieValue(std::string const &tie) const;
78
79 [[nodiscard]] bool isValidParameterTie(std::string const &parameter, std::string const &tie) const;
80 [[nodiscard]] bool isValidParameterConstraint(std::string const &parameter, std::string const &constraint) const;
81
82 [[nodiscard]] bool isValidStartX(double startX) const;
83 [[nodiscard]] bool isValidEndX(double endX) const;
84 [[nodiscard]] std::pair<double, double> xLimits() const;
85 [[nodiscard]] std::pair<double, double> xLimits(Mantid::API::MatrixWorkspace_const_sptr const &workspace,
86 WorkspaceIndex workspaceIndex) const;
87
88 void removeFunctionFromIFunction(std::string const &function, Mantid::API::IFunction_sptr &iFunction);
89 void removeFunctionFromComposite(std::string const &function, Mantid::API::CompositeFunction_sptr &composite);
90 void addFunctionToExisting(Mantid::API::IFunction_sptr const &function);
91
92 void updateParameterConstraint(Mantid::API::CompositeFunction_sptr &composite, std::string const &functionIndex,
93 std::string const &parameter, std::string const &constraint);
94
95 void appendParametersTiedTo(std::vector<std::string> &tiedParameters, std::string const &parameter,
96 std::size_t const &parameterIndex) const;
97
98 void removeInvalidatedTies();
99
100 std::string m_workspaceName;
102 double m_startX;
103 double m_endX;
105};
106
107} // namespace MantidWidgets
108} // namespace MantidQt
#define EXPORT_OPT_MANTIDQT_COMMON
Definition: DllOption.h:15
double value
The value of the point.
Definition: FitMW.cpp:51
IPeaksWorkspace_sptr workspace
Definition: IndexPeaks.cpp:114
This class is used to store all data relating to a single domain to be fitted.
Definition: FitDomain.h:27
std::string workspaceName() const noexcept
Definition: FitDomain.h:35
double endX() const noexcept
Definition: FitDomain.h:42
Mantid::API::IFunction_sptr m_function
Definition: FitDomain.h:104
WorkspaceIndex workspaceIndex() const noexcept
Definition: FitDomain.h:36
double startX() const noexcept
Definition: FitDomain.h:41
Attribute is a non-fitting parameter.
Definition: IFunction.h:282
The AlgorithmProgressDialogPresenter keeps track of the running algorithms and displays a progress ba...
std::shared_ptr< const MatrixWorkspace > MatrixWorkspace_const_sptr
shared pointer to the matrix workspace base class (const version)
std::shared_ptr< IFunction > IFunction_sptr
shared pointer to the function base class
Definition: IFunction.h:732
std::shared_ptr< CompositeFunction > CompositeFunction_sptr
shared pointer to the composite function base class