Mantid
Loading...
Searching...
No Matches
MuonFitPropertyBrowser.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
13#include <QMap>
14/* Forward declarations */
15class QDockWidget;
16class QLabel;
17class QPushButton;
18class QCheckBox;
19class QMenu;
20class QSignalMapper;
21class QtTreePropertyBrowser;
22class QtGroupPropertyManager;
23class QtDoublePropertyManager;
24class QtIntPropertyManager;
25class QtBoolPropertyManager;
26class QtStringPropertyManager;
27class QtEnumPropertyManager;
28class QtProperty;
29class QtBrowserItem;
30class QVBoxLayout;
31class QGroupBox;
32class QSplitter;
33class QWidget;
34
35namespace Mantid {
36namespace API {
37class IFitFunction;
38class IPeakFunction;
39class CompositeFunction;
40} // namespace API
41} // namespace Mantid
42
43namespace MantidQt {
44namespace MantidWidgets {
45class PropertyHandler;
46
49 public IMuonFitDataModel {
50 Q_OBJECT
51
52public:
54 MuonFitPropertyBrowser(QWidget *parent = nullptr, QObject *mantidui = nullptr);
56 void init() override;
58 void setWorkspaceName(const QString &wsName) override;
60 void finishHandle(const Mantid::API::IAlgorithm *alg) override;
61 void finishHandleTF(const Mantid::API::IAlgorithm *alg);
62 void finishHandleNormal(const Mantid::API::IAlgorithm *alg);
64 void addExtraWidget(QWidget *widget);
65 void addFitBrowserWidget(QWidget *widget, MantidQt::MantidWidgets::FunctionBrowser *functionBrowser);
67 void setFunction(const Mantid::API::IFunction_sptr func) override;
69 void runFit() override;
71 void runSequentialFit() override;
73 Mantid::API::IFunction_sptr getFunction() const override { return getFittingFunction(); }
75 void setWorkspaceNames(const QStringList &wsNames) override;
77 std::string outputName() const override;
79 static const std::string SIMULTANEOUS_PREFIX;
81 void setSimultaneousLabel(const std::string &label) override { m_simultaneousLabel = label; }
83 std::vector<std::string> getWorkspaceNamesToFit() const override { return m_workspacesToFit; }
85 void userChangedDataset(int index) override { emit userChangedDatasetIndex(index); }
87 void setMultiFittingMode(bool enabled) override;
89 bool isMultiFittingMode() const override;
90
92 void continueAfterChecks(bool sequential) override;
94 void doRemoveGuess() override { emit removeGuess(); }
96 void doPlotGuess() override { emit plotGuess(); }
98 bool hasGuess() const override;
99
101 virtual void setFitEnabled(bool yes) override;
102 void doTFAsymmFit();
103 void setAvailableGroups(const QStringList &groups);
104 void setAvailablePeriods(const QStringList &periods);
105
106 QStringList getChosenGroups() const;
107 QStringList getChosenPeriods() const;
108 void setTFAsymm(bool state);
110 void clearChosenGroups() const;
111 void setAllGroups();
112 void setGroupNames(const std::vector<std::string> groupNames);
113 void setAllPairs();
114 void setAllGroupsOrPairs(const bool isItGroup);
115 void clearChosenPeriods() const;
116 void setChosenGroup(const QString &group);
117 void setAllPeriods();
118 void setChosenPeriods(const QString &period);
119 void setSingleFitLabel(const std::string &name);
120 void setNormalization(const std::string &name);
121 void checkFitEnabled();
122public slots:
124 void fit() override;
126 void sequentialFit() override;
127
128 void executeFitMenu(const QString &item) override;
129 void groupBtnPressed();
130 void periodBtnPressed();
131 void generateBtnPressed();
132 void combineBtnPressed();
133 void setNumPeriods(size_t numPeriods);
134 void addPeriodCheckboxToMap(const QString &name);
135 void updatePeriods();
136
137signals:
141 void functionUpdateRequested() override;
143 void functionUpdateAndFitRequested(bool sequential) override;
145 void workspacesToFitChanged(int n) override;
147 void userChangedDatasetIndex(int index) override;
149 void fitRawDataClicked(bool enabled) override;
152 void reselctGroupClicked(bool enabled);
154 void preFitChecksRequested(bool sequential) override;
155 void TFPlot(QString wsName);
156
157protected:
158 void showEvent(QShowEvent *e) override;
159 void setNormalization();
160
161private slots:
162 void doubleChanged(QtProperty *prop) override;
163 void boolChanged(QtProperty *prop) override;
164 void enumChanged(QtProperty *prop) override;
165
166private:
168 void populateFunctionNames() override;
170 bool isWorkspaceValid(Mantid::API::Workspace_sptr /*unused*/) const override;
173 void finishAfterSimultaneousFit(const Mantid::API::IAlgorithm *fitAlg, const int nWorkspaces) const;
174 void finishAfterTFSimultaneousFit(const Mantid::API::IAlgorithm *alg, const std::string &baseName) const;
175 void setFitWorkspaces(const std::string &input);
176 std::string getUnnormName(const std::string wsName);
177 void ConvertFitFunctionForMuonTFAsymmetry(bool enabled);
178 void setTFAsymmMode(bool state);
179 void clearGroupCheckboxes();
180 void addGroupCheckbox(const QString &name);
181 void genGroupWindow();
182 void genPeriodWindow();
183 void genCombinePeriodWindow();
184 void updateGroupDisplay();
185 void updatePeriodDisplay();
186 void setChosenPeriods(const QStringList &chosenPeriods);
187 void clearPeriodCheckboxes();
188 void addPeriodCheckbox(const QString &name);
189 void updatePeriods(const int j);
190 bool isPeriodValid(const QString &name);
191 std::string TFExtension() const;
192 void updateTFPlot();
194 QSplitter *m_widgetSplitter, *m_mainSplitter;
196 std::vector<std::string> m_workspacesToFit;
199 QtProperty *m_normalization;
201 QtProperty *m_keepNorm;
202 QtProperty *m_TFAsymmMode;
204 QtProperty *m_groupsToFit;
207 QMap<QString, QtProperty *> m_groupBoxes;
208 QtProperty *m_showGroup;
209 QStringList m_showGroupValue;
210
211 QtProperty *m_periodsToFit;
214 QMap<QString, QtProperty *> m_periodBoxes;
215 QtProperty *m_showPeriods;
216 QStringList m_showPeriodValue;
217 QLineEdit *m_positiveCombo;
218 QLineEdit *m_negativeCombo;
219
220 QPushButton *m_reselectGroupBtn;
222 QPushButton *m_generateBtn;
223 QGroupBox *m_btnGroup;
228 std::vector<std::string> m_groupsList;
229
230 // stores if this is in multi fitting mode
232
234};
235
236std::map<std::string, double> readMultipleNormalization();
237} // namespace MantidWidgets
238} // namespace MantidQt
#define EXPORT_OPT_MANTIDQT_COMMON
Definition: DllOption.h:15
std::map< DeltaEMode::Type, std::string > index
Definition: DeltaEMode.cpp:19
Class FitPropertyBrowser implements QtPropertyBrowser to display and control fitting function paramet...
Class FitPropertyBrowser implements QtPropertyBrowser to display and control fitting function paramet...
IMuonFitDataModel: set data to fit for a muon fit property browser.
IMuonFitFunctionModel: set function to fit for a muon fit property browser.
void workspacesToFitChanged(int n) override
Emitted when number of workspaces to fit is changed.
QMap< QString, QtProperty * > m_periodBoxes
Map of group names to checkboxes.
void functionUpdateRequested() override
Emitted when function should be updated.
void functionUpdateAndFitRequested(bool sequential) override
Emitted when a fit or sequential fit is requested.
void fitRawDataClicked(bool enabled) override
Emitted when "fit to raw data" is changed.
void doPlotGuess() override
Plot a guess function.
void userChangedDatasetIndex(int index) override
Emitted when dataset index to fit is changed.
void sequentialFitRequested()
Emitted when sequential fit is requested by user.
MantidQt::MantidWidgets::FunctionBrowser * m_functionBrowser
void preFitChecksRequested(bool sequential) override
Emitted when fit is about to be run.
std::string m_simultaneousLabel
Label to use for simultaneous fits.
void doRemoveGuess() override
Remove a plotted guess.
void userChangedDataset(int index) override
User changed dataset index to fit.
QMap< QString, QtProperty * > m_groupBoxes
Map of group names to checkboxes.
static const std::string SIMULTANEOUS_PREFIX
Prefix for simultaneous fit results.
std::vector< std::string > m_workspacesToFit
Names of workspaces to fit.
Mantid::API::IFunction_sptr getFunction() const override
Get the fitting function.
std::vector< std::string > getWorkspaceNamesToFit() const override
Get names of workspaces that are set to be fitted.
void setSimultaneousLabel(const std::string &label) override
Set label for simultaneous fit results.
IAlgorithm is the interface implemented by the Algorithm base class.
Definition: IAlgorithm.h:45
std::map< std::string, double > readMultipleNormalization()
Reads the normalization constants and which WS they belong to.
The AlgorithmProgressDialogPresenter keeps track of the running algorithms and displays a progress ba...
std::shared_ptr< Workspace > Workspace_sptr
shared pointer to Mantid::API::Workspace
Definition: Workspace_fwd.h:20
std::shared_ptr< IFunction > IFunction_sptr
shared pointer to the function base class
Definition: IFunction.h:732
Helper class which provides the Collimation Length for SANS instruments.