Mantid
Loading...
Searching...
No Matches
FitOptionsBrowser.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"
11
12#include <QMap>
13#include <QStringList>
14#include <QWidget>
15
16/* Forward declarations */
17class QtProperty;
18class QtTreePropertyBrowser;
19class QtDoublePropertyManager;
20class QtIntPropertyManager;
21class QtBoolPropertyManager;
22class QtStringPropertyManager;
23class QtEnumPropertyManager;
24class QtGroupPropertyManager;
25class QSettings;
26
27namespace Mantid {
28namespace Kernel {
29class Property;
30}
31namespace API {
32class IAlgorithm;
33}
34} // namespace Mantid
35
36namespace MantidQt {
37namespace MantidWidgets {
38
40public:
41 explicit FitOptionsBrowserSettings(QMap<QString, QString> propertyValues = {});
42
43 [[nodiscard]] const QMap<QString, QString> &values() const;
44
46 [[nodiscard]] static FitOptionsBrowserSettings readSettings(const QSettings &settings,
47 const QStringList &propertyNames);
49 static void saveSettings(QSettings &settings, const FitOptionsBrowserSettings &snapshot);
50
51private:
52 QMap<QString, QString> m_values;
53};
54
61 Q_OBJECT
62public:
63 FitOptionsBrowser(QWidget *parent = nullptr, FittingMode fitType = FittingMode::SIMULTANEOUS);
65 QString getProperty(const QString &name) const;
66 void setProperty(const QString &name, const QString &value);
67 void copyPropertiesToAlgorithm(Mantid::API::IAlgorithm &fit) const;
69 [[nodiscard]] FitOptionsBrowserSettings readSettings(const QSettings &settings) const;
71 void restoreSettings(const FitOptionsBrowserSettings &settings);
73 [[nodiscard]] FitOptionsBrowserSettings captureSettings() const;
74 FittingMode getCurrentFittingType() const;
75 void setCurrentFittingType(FittingMode fitType);
76 void lockCurrentFittingType(FittingMode fitType);
77 void unlockCurrentFittingType();
78 void setLogNames(const QStringList &logNames);
79 void setParameterNamesForPlotting(const QStringList &parNames);
80 QString getParameterToPlot() const;
81 bool addPropertyToBlacklist(const QString &);
82
83signals:
86 // emitted when m_doubleManager reports a change
87 void doublePropertyChanged(const QString &propertyName);
88
89protected:
90 QtProperty *addDoubleProperty(const QString &propertyName);
91 void displayProperty(const QString &propertyName, bool show = true);
92 void displaySequentialFitProperties();
93
94private slots:
95 void enumChanged(QtProperty * /*prop*/);
96 void doubleChanged(QtProperty *property);
97
98private:
99 void createBrowser();
100 void initFittingTypeProp();
101 void createProperties();
102 void createCommonProperties();
103 void createSimultaneousFitProperties();
104 void createSequentialFitProperties();
105 void updateMinimizer();
106 void switchFitType();
107 void displayNormalFitProperties();
108
109 QtProperty *createPropertyProperty(Mantid::Kernel::Property *prop);
110
111 void addProperty(const QString &name, QtProperty *prop, QString (FitOptionsBrowser::*getter)(QtProperty *) const,
112 void (FitOptionsBrowser::*setter)(QtProperty *, const QString &));
113
114 void removeProperty(const QString &name);
115
116 // Setters and getters
117 QString getMinimizer(QtProperty * /*unused*/) const;
118 void setMinimizer(QtProperty * /*unused*/, const QString & /*value*/);
119
120 QString getIntProperty(QtProperty * /*prop*/) const;
121 void setIntProperty(QtProperty * /*prop*/, const QString & /*value*/);
122 QString getDoubleProperty(QtProperty * /*prop*/) const;
123 void setDoubleProperty(QtProperty * /*prop*/, const QString & /*value*/);
124 QString getBoolProperty(QtProperty * /*prop*/) const;
125 void setBoolProperty(QtProperty * /*prop*/, const QString & /*value*/);
126 QString getStringEnumProperty(QtProperty * /*prop*/) const;
127 void setStringEnumProperty(QtProperty * /*prop*/, const QString & /*value*/);
128 QString getStringProperty(QtProperty * /*prop*/) const;
129 void setStringProperty(QtProperty * /*prop*/, const QString & /*value*/);
130
131 void setPropertyEnumValues(QtProperty *prop, const QStringList &values);
132
134 QtBoolPropertyManager *m_boolManager;
136 QtIntPropertyManager *m_intManager;
138 QtDoublePropertyManager *m_doubleManager;
140 QtStringPropertyManager *m_stringManager;
142 QtEnumPropertyManager *m_enumManager;
144 QtGroupPropertyManager *m_groupManager;
145
147 QtProperty *m_fittingTypeProp;
149 QtProperty *m_minimizerGroup;
151 QtProperty *m_minimizer;
153 QtProperty *m_costFunction;
155 QtProperty *m_maxIterations;
157 QtProperty *m_evaluationType;
159 QtProperty *m_peakRadius;
160
161 // Fit properties
163 QtProperty *m_output;
166
167 // PlotPeakByLogValue properties
173 QtProperty *m_outputWorkspace;
175 QtProperty *m_logValue;
178 QtProperty *m_plotParameter;
179
181 QtTreePropertyBrowser *m_browser;
182
185
186 using SetterType = void (FitOptionsBrowser::*)(QtProperty *, const QString &);
187 using GetterType = QString (FitOptionsBrowser::*)(QtProperty *) const;
189 QMap<QString, QtProperty *> m_propertyNameMap;
191 QMap<QtProperty const *, SetterType> m_setters;
193 QMap<QtProperty const *, GetterType> m_getters;
194
200};
201
202} // namespace MantidWidgets
203
204} // namespace MantidQt
std::string name
Definition Run.cpp:60
#define EXPORT_OPT_MANTIDQT_COMMON
Definition DllOption.h:15
double value
The value of the point.
Definition FitMW.cpp:51
Class FitOptionsBrowser implements QtPropertyBrowser to display and set properties of Fit algorithm (...
QtProperty * m_evaluationType
EvaluationType property.
QtProperty * m_ignoreInvalidData
IgnoreInvalidData property.
QtStringPropertyManager * m_stringManager
Manager for string properties.
QtProperty * m_plotPeakByLogValueFitType
PlotPeakByLogValue FitType property.
QtProperty * m_minimizerGroup
Minimizer group property.
QtDoublePropertyManager * m_doubleManager
Manager for double properties.
QMap< QString, QtProperty * > m_propertyNameMap
Maps algorithm property name to the QtProperty.
QString(FitOptionsBrowser::*)(QtProperty *) const GetterType
void doublePropertyChanged(const QString &propertyName)
void(FitOptionsBrowser::*)(QtProperty *, const QString &) SetterType
int m_decimals
Precision of doubles in m_doubleManager.
QtProperty * m_logValue
LogValue property.
QtProperty * m_maxIterations
MaxIterations property.
QtProperty * m_plotParameter
Property for a name of a parameter to plot against LogValue.
QtBoolPropertyManager * m_boolManager
Manager for bool properties.
QList< QtProperty * > m_simultaneousProperties
Store special properties of the normal Fit.
QtProperty * m_minimizer
Minimizer property.
QtEnumPropertyManager * m_enumManager
Manager for the string list properties.
QtGroupPropertyManager * m_groupManager
Manager for groups of properties.
QList< QtProperty * > m_sequentialProperties
Store special properties of the sequential Fit.
QtTreePropertyBrowser * m_browser
Qt property browser which displays properties.
QtIntPropertyManager * m_intManager
Manager for int properties.
QMap< QtProperty const *, SetterType > m_setters
Store for the properties setter methods.
QtProperty * m_outputWorkspace
OutputWorkspace property.
QMap< QtProperty const *, GetterType > m_getters
Store for the properties getter methods.
QtProperty * m_fittingTypeProp
FitType property.
QtProperty * m_peakRadius
Peak radius property.
QtProperty * m_costFunction
CostFunction property.
IAlgorithm is the interface implemented by the Algorithm base class.
Definition IAlgorithm.h:45
Base class for properties.
Definition Property.h:94
The AlgorithmProgressDialogPresenter keeps track of the running algorithms and displays a progress ba...
Helper class which provides the Collimation Length for SANS instruments.