Mantid
Loading...
Searching...
No Matches
UserFunctionDialog.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#include "ui_UserFunctionDialog.h"
11
12#include <QMap>
13#include <QSet>
14
15class QComboBox;
16class QLineEdit;
17class QTextEdit;
18
19namespace MantidQt {
20namespace MantidWidgets {
25 Q_OBJECT
26
27public:
28 UserFunctionDialog(QWidget *parent = nullptr, const QString &formula = "");
29 ~UserFunctionDialog() override;
30 QStringList categories() const;
31 QString getFormula() const { return m_uiForm.teUserFunction->toPlainText(); }
32
33private slots:
34 void selectCategory(const QString &cat);
35 void selectFunction(const QString &fun);
36 void addExpression();
37 void saveFunction();
38 void removeCurrentFunction();
39 void updateCategories();
40 void updateFunction();
41 void helpClicked();
42
43private:
44 bool eventFilter(QObject *obj, QEvent *ev) override;
45
46 void loadFunctions();
47 void checkParameters(QString &expr);
48 QSet<QString> categoryNames() const;
49 QSet<QString> functionNames(const QString &cat) const;
50 QString getCurrentCategory() const;
51 QString getFunction(const QString &cat, const QString &fun) const;
52 QString getComment(const QString &cat, const QString &fun) const;
53 void setFunction(const QString &cat, const QString &fun, const QString &expr, const QString &comment = "");
54 bool isBuiltin(const QString &cat) const;
55 void saveToFile();
56
58 Ui::UserFunctionDialog m_uiForm;
59
63 QMap<QString, QString> m_funs;
64};
65
69class InputFunctionNameDialog : public QDialog {
70 Q_OBJECT
71public:
72 InputFunctionNameDialog(QWidget *parent, const QString &category);
73 void getFunctionName(QString &category, QString &name, QString &comment);
74
75private:
76 QComboBox *m_category;
77 QLineEdit *m_name;
78 QTextEdit *m_comment;
79};
80} // namespace MantidWidgets
81} // namespace MantidQt
#define EXPORT_OPT_MANTIDQT_COMMON
Definition: DllOption.h:15
double obj
the value of the quadratic function
A dialog to enter a category and function name for a new function for saving.
void getFunctionName(QString &category, QString &name, QString &comment)
Return the entered category and function name and comment.
A dialog for construction a user fitting function from existing components.
QMap< QString, QString > m_funs
Container for prerecorded functions: key = category.name, value = formula Records with key = category...
Ui::UserFunctionDialog m_uiForm
User interface elements.
The AlgorithmProgressDialogPresenter keeps track of the running algorithms and displays a progress ba...