26namespace MantidWidgets {
28class IFitScriptGeneratorPresenter;
44 void addWorkspaceDomain(std::string
const &workspaceName,
WorkspaceIndex workspaceIndex,
double startX,
45 double endX)
override;
46 [[nodiscard]]
bool hasWorkspaceDomain(std::string
const &workspaceName,
WorkspaceIndex workspaceIndex)
const override;
48 void renameWorkspace(std::string
const &workspaceName, std::string
const &newName)
override;
50 [[nodiscard]]
bool updateStartX(std::string
const &workspaceName,
WorkspaceIndex workspaceIndex,
51 double startX)
override;
52 [[nodiscard]]
bool updateEndX(std::string
const &workspaceName,
WorkspaceIndex workspaceIndex,
double endX)
override;
54 void removeFunction(std::string
const &workspaceName,
WorkspaceIndex workspaceIndex,
55 std::string
const &function)
override;
56 void addFunction(std::string
const &workspaceName,
WorkspaceIndex workspaceIndex,
57 std::string
const &function)
override;
58 void setFunction(std::string
const &workspaceName,
WorkspaceIndex workspaceIndex,
59 std::string
const &function)
override;
63 [[nodiscard]] std::string getEquivalentFunctionIndexForDomain(std::string
const &workspaceName,
65 std::string
const &functionIndex)
const override;
66 [[nodiscard]] std::string getEquivalentFunctionIndexForDomain(
FitDomainIndex domainIndex,
67 std::string
const &functionIndex)
const override;
68 [[nodiscard]] std::string getEquivalentParameterTieForDomain(std::string
const &workspaceName,
70 std::string
const &fullParameter,
71 std::string
const &fullTie)
const override;
72 [[nodiscard]] std::string getAdjustedFunctionIndex(std::string
const ¶meter)
const override;
73 [[nodiscard]] std::string getFullParameter(
FitDomainIndex domainIndex, std::string
const ¶meter)
const override;
74 [[nodiscard]] std::string getFullTie(
FitDomainIndex domainIndex, std::string
const &tie)
const override;
76 void updateParameterValue(std::string
const &workspaceName,
WorkspaceIndex workspaceIndex,
77 std::string
const &fullParameter,
double newValue)
override;
78 void updateAttributeValue(std::string
const &workspaceName,
WorkspaceIndex workspaceIndex,
79 std::string
const &fullAttribute,
82 void updateParameterTie(std::string
const &workspaceName,
WorkspaceIndex workspaceIndex,
83 std::string
const &fullParameter, std::string
const &tie)
override;
84 void removeParameterConstraint(std::string
const &workspaceName,
WorkspaceIndex workspaceIndex,
85 std::string
const &fullParameter)
override;
86 void updateParameterConstraint(std::string
const &workspaceName,
WorkspaceIndex workspaceIndex,
87 std::string
const &functionIndex, std::string
const &constraint)
override;
89 [[nodiscard]]
inline std::vector<GlobalTie>
getGlobalTies() const noexcept
override {
return m_globalTies; }
91 void setGlobalParameters(std::vector<std::string>
const ¶meters)
override;
94 return m_globalParameters;
97 void setOutputBaseName(std::string
const &outputBaseName)
override;
99 void setFittingMode(
FittingMode fittingMode)
override;
102 [[nodiscard]]
bool isSimultaneousMode()
const override;
104 [[nodiscard]]
bool hasParameter(
FitDomainIndex domainIndex, std::string
const &fullParameter)
const override;
106 void setParameterValue(
FitDomainIndex domainIndex, std::string
const &fullParameter,
double value)
override;
107 void setParameterFixed(
FitDomainIndex domainIndex, std::string
const &fullParameter,
bool fix)
override;
108 void setParameterTie(
FitDomainIndex domainIndex, std::string
const &fullParameter, std::string
const &tie)
override;
109 void setParameterConstraint(
FitDomainIndex domainIndex, std::string
const &fullParameter,
110 std::string
const &constraint)
override;
112 [[nodiscard]] std::string getDomainName(
FitDomainIndex domainIndex)
const override;
113 [[nodiscard]]
double getParameterValue(
FitDomainIndex domainIndex, std::string
const &fullParameter)
const override;
114 [[nodiscard]]
bool isParameterFixed(
FitDomainIndex domainIndex, std::string
const &fullParameter)
const override;
115 [[nodiscard]] std::string getParameterTie(
FitDomainIndex domainIndex,
116 std::string
const &fullParameter)
const override;
117 [[nodiscard]] std::string getParameterConstraint(
FitDomainIndex domainIndex,
118 std::string
const &fullParameter)
const override;
120 [[nodiscard]]
inline std::size_t
numberOfDomains() const noexcept
override {
return m_fitDomains.size(); }
122 std::tuple<bool, std::string> isValid()
const override;
124 std::string generatePythonFitScript(
125 std::tuple<std::string, std::string, std::string, std::string, std::string, bool>
const &fitOptions,
126 std::string
const &filepath =
"")
override;
130 [[nodiscard]] std::vector<std::unique_ptr<FitDomain>>::const_iterator
131 findWorkspaceDomain(std::string
const &workspaceName,
WorkspaceIndex workspaceIndex)
const;
133 [[nodiscard]] std::string getEquivalentParameterTieForDomain(
FitDomainIndex domainIndex,
134 std::string
const &fullParameter,
135 std::string
const &fullTie)
const;
137 void updateParameterTie(
FitDomainIndex domainIndex, std::string
const &fullParameter, std::string
const &fullTie);
138 void updateLocalParameterTie(
FitDomainIndex domainIndex, std::string
const &fullParameter,
139 std::string
const &fullTie);
140 void updateGlobalParameterTie(
FitDomainIndex domainIndex, std::string
const &fullParameter,
141 std::string
const &fullTie);
143 void updateParameterValuesWithLocalTieTo(
FitDomainIndex domainIndex, std::string
const ¶meter,
double newValue);
144 void updateParameterValuesWithGlobalTieTo(std::string
const &fullParameter,
double newValue);
145 void updateParameterValueInGlobalTie(
GlobalTie const &globalTie,
double newValue);
147 [[nodiscard]]
bool validParameter(std::string
const &fullParameter)
const;
148 [[nodiscard]]
bool validParameter(
FitDomainIndex domainIndex, std::string
const &fullParameter)
const;
149 [[nodiscard]]
bool validTie(std::string
const &fullTie)
const;
150 [[nodiscard]]
bool validGlobalTie(std::string
const &fullParameter, std::string
const &fullTie)
const;
152 [[nodiscard]]
bool isParameterValueWithinConstraints(
FitDomainIndex domainIndex, std::string
const &fullParameter,
155 void clearGlobalTie(std::string
const &fullParameter);
156 [[nodiscard]]
bool hasGlobalTie(std::string
const &fullParameter)
const;
157 [[nodiscard]] std::vector<GlobalTie>::const_iterator findGlobalTie(std::string
const &fullParameter)
const;
158 void checkGlobalTies();
160 void checkParameterIsInAllDomains(std::string
const &globalParameter)
const;
161 void checkGlobalParameterhasNoTies(std::string
const &globalParameter)
const;
162 void checkParameterIsNotGlobal(std::string
const &fullParameter)
const;
164 void tryToAdjustParameterInGlobalTieIfInvalidated(
GlobalTie &globalTie);
165 void tryToAdjustTieInGlobalTieIfInvalidated(
GlobalTie &globalTie);
167 template <
typename Getter>
168 auto getParameterProperty(Getter &&func,
FitDomainIndex domainIndex, std::string
const &fullParameter)
const;
170 [[nodiscard]]
bool checkFunctionExistsInAllDomains()
const;
171 [[nodiscard]]
bool checkFunctionIsSameForAllDomains()
const;
172 [[nodiscard]] std::string generatePermissibleWarnings()
const;
174 [[nodiscard]] std::vector<std::string> getInputWorkspaces()
const;
175 [[nodiscard]] std::vector<std::size_t> getWorkspaceIndices()
const;
176 [[nodiscard]] std::vector<double> getStartXs()
const;
177 [[nodiscard]] std::vector<double> getEndXs()
const;
179 template <
typename T,
typename Function> std::vector<T> transformDomains(Function
const &func)
const;
181 [[nodiscard]] std::string getFittingType()
const;
186 std::string constructGlobalParameterTie(
GlobalParameter const &globalParameter)
const;
200template <
typename Getter>
202 std::string
const &fullParameter)
const {
205 return std::invoke(std::forward<Getter>(func),
m_fitDomains[domainIndex.
value], parameter);
207 throw std::runtime_error(
"The domain index provided does not exist.");
#define EXPORT_OPT_MANTIDQT_COMMON
double value
The value of the point.
Attribute is a non-fitting parameter.
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
void renameWorkspace(const IAlgorithm_sptr &renamer, const Workspace_sptr &workspace, const std::string &newName)