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;
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;
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;
112 void setGroupNames(const std::vector<std::string> groupNames);
114 void setAllGroupsOrPairs(const bool isItGroup);
115 void clearChosenPeriods() const;
116 void setChosenGroup(const QString &group);
118 void setChosenPeriods(const QString &period);
119 void setSingleFitLabel(const std::string &name);
120 void setNormalization(const std::string &name);
122public slots:
124 void fit() override;
126 void sequentialFit() override;
127
128 void executeFitMenu(const QString &item) override;
133 void setNumPeriods(size_t numPeriods);
134 void addPeriodCheckboxToMap(const QString &name);
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;
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);
178 void setTFAsymmMode(bool state);
180 void addGroupCheckbox(const QString &name);
186 void setChosenPeriods(const QStringList &chosenPeriods);
188 void addPeriodCheckbox(const QString &name);
189 void updatePeriods(const int j);
190 bool isPeriodValid(const QString &name);
191 std::string TFExtension() const;
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
std::string name
Definition Run.cpp:60
#define EXPORT_OPT_MANTIDQT_COMMON
Definition DllOption.h:15
std::map< DeltaEMode::Type, std::string > index
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 setAvailablePeriods(const QStringList &periods)
void setGroupNames(const std::vector< std::string > groupNames)
void boolChanged(QtProperty *prop) override
void doubleChanged(QtProperty *prop) override
void workspacesToFitChanged(int n) override
Emitted when number of workspaces to fit is changed.
void executeFitMenu(const QString &item) override
QMap< QString, QtProperty * > m_periodBoxes
Map of group names to checkboxes.
void functionUpdateRequested() override
Emitted when function should be updated.
void sequentialFit() override
Open sequential fit dialog.
void fit() override
Perform the fit algorithm.
void functionUpdateAndFitRequested(bool sequential) override
Emitted when a fit or sequential fit is requested.
bool hasGuess() const override
Whether a guess is plotted or not.
void populateFunctionNames() override
Get the registered function names.
void setNormalization(const std::string &name)
void fitRawDataClicked(bool enabled) override
Emitted when "fit to raw data" is changed.
void addFitBrowserWidget(QWidget *widget, MantidQt::MantidWidgets::FunctionBrowser *functionBrowser)
void clearChosenGroups() const
Clear list of selected groups.
std::string getUnnormName(const std::string wsName)
void doPlotGuess() override
Plot a guess function.
void finishAfterSimultaneousFit(const Mantid::API::IAlgorithm *fitAlg, const int nWorkspaces) const
After a simultaneous fit, add information to results table and group workspaces.
void runSequentialFit() override
Run a sequential fit.
void init() override
Initialise the layout.
bool isWorkspaceValid(Mantid::API::Workspace_sptr) const override
Check if the workspace can be used in the fit.
void setMultiFittingMode(bool enabled) override
Set multiple fitting mode on or off.
void userChangedDatasetIndex(int index) override
Emitted when dataset index to fit is changed.
void finishHandle(const Mantid::API::IAlgorithm *alg) override
Called when the fit is finished.
void setAvailableGroups(const QStringList &groups)
virtual void setFitEnabled(bool yes) override
Enable/disable the Fit button;.
void runFit() override
Run a non-sequential fit.
void setWorkspaceNames(const QStringList &wsNames) override
Set list of workspaces to fit.
void finishAfterTFSimultaneousFit(const Mantid::API::IAlgorithm *alg, const std::string &baseName) const
void sequentialFitRequested()
Emitted when sequential fit is requested by user.
MantidQt::MantidWidgets::FunctionBrowser * m_functionBrowser
bool isMultiFittingMode() const override
returns true if the browser is set to multi fitting mode
void setSingleFitLabel(const std::string &name)
void preFitChecksRequested(bool sequential) override
Emitted when fit is about to be run.
std::string m_simultaneousLabel
Label to use for simultaneous fits.
void setAllGroupsOrPairs(const bool isItGroup)
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.
std::string outputName() const override
Get output name.
static const std::string SIMULTANEOUS_PREFIX
Prefix for simultaneous fit results.
void finishHandleNormal(const Mantid::API::IAlgorithm *alg)
void addPeriodCheckboxToMap(const QString &name)
void setFunction(const Mantid::API::IFunction_sptr func) override
Set function externally.
void enumChanged(QtProperty *prop) override
std::vector< std::string > m_workspacesToFit
Names of workspaces to fit.
void addExtraWidget(QWidget *widget)
Add an extra widget into the browser.
void setFitWorkspaces(const std::string &input)
void finishHandleTF(const Mantid::API::IAlgorithm *alg)
void setChosenPeriods(const QStringList &chosenPeriods)
void continueAfterChecks(bool sequential) override
After fit checks done, continue.
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 setWorkspaceName(const QString &wsName) override
Set the input workspace name.
void setSimultaneousLabel(const std::string &label) override
Set label for simultaneous fit results.
void setChosenPeriods(const QString &period)
MuonFitPropertyBrowser(QWidget *parent=nullptr, QObject *mantidui=nullptr)
Constructor.
IAlgorithm is the interface implemented by the Algorithm base class.
Definition IAlgorithm.h:45
std::map< std::string, double > readMultipleNormalization()
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
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.