Mantid
Loading...
Searching...
No Matches
FunctionBrowser.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 "MantidAPI/IFunction.h"
14
15#include <QWidget>
16
17#include <memory>
18#include <optional>
19
20namespace Mantid {
21namespace API {
22class CompositeFunction;
23class Workspace;
24class ParameterTie;
25} // namespace API
26} // namespace Mantid
27
28namespace MantidQt {
29namespace MantidWidgets {
30
31class FunctionTreeView;
32class FunctionMultiDomainPresenter;
33
34using namespace Mantid::API;
35
41 Q_OBJECT
42public:
44 FunctionBrowser(QWidget *parent = nullptr, bool multi = false,
45 const std::vector<std::string> &categories = std::vector<std::string>());
47 virtual ~FunctionBrowser() override;
49 void clear() override;
51 void setFunction(std::string const &funStr) override;
53 void setFunction(IFunction_sptr fun);
55 std::string getFunctionString() override;
57 IFunction_sptr getFunction();
59 bool hasFunction() const;
61 IFunction_sptr getFunctionByIndex(std::string const &index);
63 std::optional<std::string> currentFunctionIndex();
65 void setParameter(std::string const &parameterName, double value);
67 void setParameterError(std::string const &parameterName, double error);
69 double getParameter(std::string const &parameterName) const;
71 void updateParameters(const IFunction &fun) override;
73 std::vector<std::string> getGlobalParameters() const;
74 void setGlobalParameters(std::vector<std::string> const &globals);
76 std::vector<std::string> getLocalParameters() const;
78 int getNumberOfDatasets() const override;
80 std::vector<std::string> getDatasetNames() const override;
82 std::vector<std::string> getDatasetDomainNames() const override;
84 double getLocalParameterValue(std::string const &parameterName, int i) const override;
86 void setLocalParameterValue(std::string const &parameterName, int i, double value) override;
88 void setLocalParameterValue(std::string const &parameterName, int i, double value, double error);
90 double getLocalParameterError(std::string const &parameterName, int i) const;
92 bool isLocalParameterFixed(std::string const &parameterName, int i) const override;
94 void setLocalParameterFixed(std::string const &parameterName, int i, bool fixed) override;
96 std::string getLocalParameterTie(std::string const &parameterName, int i) const override;
98 void setLocalParameterTie(std::string const &parameterName, int i, std::string const &tie) override;
100 IFunction_sptr getGlobalFunction() override;
102 void updateMultiDatasetParameters(const IFunction &fun) override;
104 void updateMultiDatasetAttributes(const IFunction &fun);
107 void updateMultiDatasetParameters(const ITableWorkspace &paramTable) override;
109 int getCurrentDataset() const override;
111 void setColumnSizes(int s0, int s1, int s2 = -1);
113 void setStretchLastColumn(bool stretch);
115 void setErrorsEnabled(bool enabled) override;
117 void clearErrors() override;
119 void setBackgroundA0(double value);
120 // hide the global options
121 void hideGlobalCheckbox();
122 // show the global options
123 void showGlobalCheckbox();
124
125signals:
126 void parameterChanged(std::string const &funcIndex, std::string const &paramName);
127 void attributeChanged(std::string const &attributeName);
131
133 void localParameterButtonClicked(std::string const &parName);
135
136public slots:
137
138 // Handling of multiple datasets
139 void setNumberOfDatasets(int n) override;
140 void setDatasets(const std::vector<std::string> &datasetNames) override;
141 void setDatasets(const QList<FunctionModelDataset> &datasets) override;
142 void resetLocalParameters();
143 void setCurrentDataset(int i) override;
144 void removeDatasets(const QList<int> &indices);
145 void addDatasets(const std::vector<std::string> &names);
146
147protected:
148 std::unique_ptr<FunctionMultiDomainPresenter> m_presenter;
149
150public:
151 // Intended for testing only
152 FunctionTreeView *view() const;
153 std::string getFitFunctionString() const;
154};
155
156} // namespace MantidWidgets
157} // namespace MantidQt
#define EXPORT_OPT_MANTIDQT_COMMON
Definition DllOption.h:15
double value
The value of the point.
Definition FitMW.cpp:51
double error
std::map< DeltaEMode::Type, std::string > index
Class FitPropertyBrowser implements QtPropertyBrowser to display and control fitting function paramet...
void attributeChanged(std::string const &attributeName)
void parameterChanged(std::string const &funcIndex, std::string const &paramName)
virtual ~FunctionBrowser() override
Destructor.
std::unique_ptr< FunctionMultiDomainPresenter > m_presenter
void currentFunctionChanged()
User selects a different function (or one of it's sub-properties)
void localParameterButtonClicked(std::string const &parName)
In multi-dataset context a button value editor was clicked.
Class FitPropertyBrowser implements QtPropertyBrowser to display and control fitting function paramet...
IFunctionBrowser: interface for FunctionBrowser.
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< IFunction > IFunction_sptr
shared pointer to the function base class
Definition IFunction.h:743
Helper class which provides the Collimation Length for SANS instruments.