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 <QWidget>
14
15/* Forward declarations */
16class QtProperty;
17class QtTreePropertyBrowser;
18class QtDoublePropertyManager;
19class QtIntPropertyManager;
20class QtBoolPropertyManager;
21class QtStringPropertyManager;
22class QtEnumPropertyManager;
23class QtGroupPropertyManager;
24class QSettings;
25
26namespace Mantid {
27namespace Kernel {
28class Property;
29}
30namespace API {
31class IAlgorithm;
32}
33} // namespace Mantid
34
35namespace MantidQt {
36namespace MantidWidgets {
37
44 Q_OBJECT
45public:
46 FitOptionsBrowser(QWidget *parent = nullptr, FittingMode fitType = FittingMode::SIMULTANEOUS);
48 QString getProperty(const QString &name) const;
49 void setProperty(const QString &name, const QString &value);
50 void copyPropertiesToAlgorithm(Mantid::API::IAlgorithm &fit) const;
51 void saveSettings(QSettings &settings) const;
52 void loadSettings(const QSettings &settings);
53 FittingMode getCurrentFittingType() const;
54 void setCurrentFittingType(FittingMode fitType);
55 void lockCurrentFittingType(FittingMode fitType);
56 void unlockCurrentFittingType();
57 void setLogNames(const QStringList &logNames);
58 void setParameterNamesForPlotting(const QStringList &parNames);
59 QString getParameterToPlot() const;
60 bool addPropertyToBlacklist(const QString &);
61
62signals:
65 // emitted when m_doubleManager reports a change
66 void doublePropertyChanged(const QString &propertyName);
67
68protected:
69 QtProperty *addDoubleProperty(const QString &propertyName);
70 void displayProperty(const QString &propertyName, bool show = true);
71 void displaySequentialFitProperties();
72
73private slots:
74 void enumChanged(QtProperty * /*prop*/);
75 void doubleChanged(QtProperty *property);
76
77private:
78 void createBrowser();
79 void initFittingTypeProp();
80 void createProperties();
81 void createCommonProperties();
82 void createSimultaneousFitProperties();
83 void createSequentialFitProperties();
84 void updateMinimizer();
85 void switchFitType();
86 void displayNormalFitProperties();
87
88 QtProperty *createPropertyProperty(Mantid::Kernel::Property *prop);
89
90 void addProperty(const QString &name, QtProperty *prop, QString (FitOptionsBrowser::*getter)(QtProperty *) const,
91 void (FitOptionsBrowser::*setter)(QtProperty *, const QString &));
92
93 void removeProperty(const QString &name);
94
95 // Setters and getters
96 QString getMinimizer(QtProperty * /*unused*/) const;
97 void setMinimizer(QtProperty * /*unused*/, const QString & /*value*/);
98
99 QString getIntProperty(QtProperty * /*prop*/) const;
100 void setIntProperty(QtProperty * /*prop*/, const QString & /*value*/);
101 QString getDoubleProperty(QtProperty * /*prop*/) const;
102 void setDoubleProperty(QtProperty * /*prop*/, const QString & /*value*/);
103 QString getBoolProperty(QtProperty * /*prop*/) const;
104 void setBoolProperty(QtProperty * /*prop*/, const QString & /*value*/);
105 QString getStringEnumProperty(QtProperty * /*prop*/) const;
106 void setStringEnumProperty(QtProperty * /*prop*/, const QString & /*value*/);
107 QString getStringProperty(QtProperty * /*prop*/) const;
108 void setStringProperty(QtProperty * /*prop*/, const QString & /*value*/);
109
110 void setPropertyEnumValues(QtProperty *prop, const QStringList &values);
111
113 QtBoolPropertyManager *m_boolManager;
115 QtIntPropertyManager *m_intManager;
117 QtDoublePropertyManager *m_doubleManager;
119 QtStringPropertyManager *m_stringManager;
121 QtEnumPropertyManager *m_enumManager;
123 QtGroupPropertyManager *m_groupManager;
124
126 QtProperty *m_fittingTypeProp;
128 QtProperty *m_minimizerGroup;
130 QtProperty *m_minimizer;
132 QtProperty *m_costFunction;
134 QtProperty *m_maxIterations;
136 QtProperty *m_evaluationType;
138 QtProperty *m_peakRadius;
139
140 // Fit properties
142 QtProperty *m_output;
145
146 // PlotPeakByLogValue properties
152 QtProperty *m_outputWorkspace;
154 QtProperty *m_logValue;
157 QtProperty *m_plotParameter;
158
160 QtTreePropertyBrowser *m_browser;
161
164
165 using SetterType = void (FitOptionsBrowser::*)(QtProperty *, const QString &);
166 using GetterType = QString (FitOptionsBrowser::*)(QtProperty *) const;
168 QMap<QString, QtProperty *> m_propertyNameMap;
170 QMap<QtProperty *, SetterType> m_setters;
172 QMap<QtProperty *, GetterType> m_getters;
173
179};
180
181} // namespace MantidWidgets
182
183} // namespace MantidQt
#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.
QMap< QtProperty *, GetterType > m_getters
Store for the properties getter methods.
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.
FittingMode m_fittingType
The Fitting Type.
QtBoolPropertyManager * m_boolManager
Manager for bool properties.
QList< QtProperty * > m_simultaneousProperties
Store special properties of the normal Fit.
QMap< QtProperty *, SetterType > m_setters
Store for the properties setter methods.
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.
QtProperty * m_outputWorkspace
OutputWorkspace property.
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.