Mantid
|
A dialog for construction a user fitting function from existing components. More...
#include <UserFunctionDialog.h>
Public Member Functions | |
QStringList | categories () const |
QString | getFormula () const |
UserFunctionDialog (QWidget *parent=nullptr, const QString &formula="") | |
~UserFunctionDialog () override | |
Write saved functions in the destructor. More... | |
Private Slots | |
void | addExpression () |
Add selected expression to the user function. More... | |
void | helpClicked () |
Open the help wiki page in the web browser. More... | |
void | removeCurrentFunction () |
Remove the current function. More... | |
void | saveFunction () |
Save the constructed function for future use. More... | |
void | selectCategory (const QString &cat) |
Make a category current. More... | |
void | selectFunction (const QString &fun) |
Make a function current. More... | |
void | updateCategories () |
Update the GUI element displaying categories. More... | |
void | updateFunction () |
Updates the parameter list. More... | |
Private Member Functions | |
QSet< QString > | categoryNames () const |
Returns a list of category names. More... | |
void | checkParameters (QString &expr) |
Check an expression for name clashes with user function. More... | |
bool | eventFilter (QObject *obj, QEvent *ev) override |
QSet< QString > | functionNames (const QString &cat) const |
Returns function names in category cat. More... | |
QString | getComment (const QString &cat, const QString &fun) const |
Get the comment for saved function in category cat with name fun. More... | |
QString | getCurrentCategory () const |
Get the name of currently selected category. More... | |
QString | getFunction (const QString &cat, const QString &fun) const |
Get the expression for saved function in category cat with name fun. More... | |
bool | isBuiltin (const QString &cat) const |
Checks if a category is a buil-in one and cannot be changed. More... | |
void | loadFunctions () |
Load saved functions form Mantid(.user).properties file. More... | |
void | saveToFile () |
void | setFunction (const QString &cat, const QString &fun, const QString &expr, const QString &comment="") |
Set an expression to a new function in category cat and with name fun. More... | |
Private Attributes | |
QMap< QString, QString > | m_funs |
Container for prerecorded functions: key = category.name, value = formula Records with key = category.name.comment contain comments to corresponding functions. More... | |
Ui::UserFunctionDialog | m_uiForm |
User interface elements. More... | |
A dialog for construction a user fitting function from existing components.
Definition at line 24 of file UserFunctionDialog.h.
UserFunctionDialog::UserFunctionDialog | ( | QWidget * | parent = nullptr , |
const QString & | formula = "" |
||
) |
Definition at line 27 of file UserFunctionDialog.cpp.
References addExpression(), helpClicked(), loadFunctions(), m_uiForm, Mantid::Geometry::rect, removeCurrentFunction(), saveFunction(), selectCategory(), selectFunction(), updateCategories(), and updateFunction().
|
override |
Write saved functions in the destructor.
Definition at line 55 of file UserFunctionDialog.cpp.
References saveToFile().
|
privateslot |
Add selected expression to the user function.
Definition at line 164 of file UserFunctionDialog.cpp.
References checkParameters(), m_uiForm, and Mantid::Geometry::rect.
Referenced by UserFunctionDialog().
QStringList UserFunctionDialog::categories | ( | ) | const |
Definition at line 395 of file UserFunctionDialog.cpp.
References m_uiForm.
|
private |
Returns a list of category names.
Definition at line 271 of file UserFunctionDialog.cpp.
References m_funs.
Referenced by updateCategories().
|
private |
Check an expression for name clashes with user function.
expr | :: An expression prepared to be added to the user function. |
Definition at line 190 of file UserFunctionDialog.cpp.
References Mantid::API::Expression::getVariables(), m_uiForm, Mantid::API::Expression::parse(), Mantid::API::Expression::renameAll(), MantidQt::MantidWidgets::RenameParDialog::setOutput(), and Mantid::API::Expression::str().
Referenced by addExpression().
|
overrideprivate |
Definition at line 403 of file UserFunctionDialog.cpp.
References obj.
|
private |
Returns function names in category cat.
cat | :: The category for which functions will be returned. |
Definition at line 286 of file UserFunctionDialog.cpp.
References m_funs.
Referenced by saveFunction(), and selectCategory().
|
private |
Get the comment for saved function in category cat with name fun.
If any of the arguments are empty string or function does not exist return empty string.
cat | :: The category |
fun | :: The name of the function |
Definition at line 439 of file UserFunctionDialog.cpp.
References m_funs.
Referenced by selectFunction().
|
private |
Get the name of currently selected category.
If no category is selected returns empty string.
Definition at line 303 of file UserFunctionDialog.cpp.
References m_uiForm.
Referenced by saveFunction(), and updateCategories().
|
inline |
Definition at line 31 of file UserFunctionDialog.h.
|
private |
Get the expression for saved function in category cat with name fun.
If any of the arguments are empty string or function does not exist return empty string.
cat | :: The category |
fun | :: The name of the function |
Definition at line 423 of file UserFunctionDialog.cpp.
References m_funs.
Referenced by selectCategory(), and selectFunction().
|
privateslot |
Open the help wiki page in the web browser.
Definition at line 483 of file UserFunctionDialog.cpp.
References MantidQt::API::MantidDesktopServices::openUrl().
Referenced by UserFunctionDialog().
|
private |
Checks if a category is a buil-in one and cannot be changed.
Definition at line 478 of file UserFunctionDialog.cpp.
Referenced by removeCurrentFunction(), and selectCategory().
|
private |
Load saved functions form Mantid(.user).properties file.
Property: userfunctions.CategoryName.FunctionName = Expression-in-Mu Parser-format
Definition at line 62 of file UserFunctionDialog.cpp.
References Mantid::Kernel::SingletonHolder< T >::Instance(), m_funs, and setFunction().
Referenced by UserFunctionDialog().
|
privateslot |
Remove the current function.
Definition at line 372 of file UserFunctionDialog.cpp.
References isBuiltin(), m_funs, m_uiForm, saveToFile(), and selectCategory().
Referenced by UserFunctionDialog().
|
privateslot |
Save the constructed function for future use.
Definition at line 315 of file UserFunctionDialog.cpp.
References functionNames(), getCurrentCategory(), m_uiForm, saveToFile(), setFunction(), and updateCategories().
Referenced by UserFunctionDialog().
|
private |
Definition at line 354 of file UserFunctionDialog.cpp.
References Mantid::Kernel::SingletonHolder< T >::Instance(), and m_funs.
Referenced by removeCurrentFunction(), saveFunction(), and ~UserFunctionDialog().
|
privateslot |
Make a category current.
cat | :: The category to select |
Definition at line 123 of file UserFunctionDialog.cpp.
References functionNames(), getFunction(), isBuiltin(), m_uiForm, and value.
Referenced by removeCurrentFunction(), and UserFunctionDialog().
|
privateslot |
Make a function current.
fun | :: The function to select |
Definition at line 145 of file UserFunctionDialog.cpp.
References getComment(), getFunction(), m_uiForm, and value.
Referenced by UserFunctionDialog().
|
private |
Set an expression to a new function in category cat and with name fun.
If any of the arguments are empty string does nothing.
cat | :: The category |
fun | :: The name of the function |
expr | :: The expression |
comment | :: The comment |
Definition at line 457 of file UserFunctionDialog.cpp.
References m_funs.
Referenced by loadFunctions(), and saveFunction().
|
privateslot |
Update the GUI element displaying categories.
Definition at line 106 of file UserFunctionDialog.cpp.
References categoryNames(), getCurrentCategory(), and m_uiForm.
Referenced by saveFunction(), and UserFunctionDialog().
|
privateslot |
Updates the parameter list.
Definition at line 247 of file UserFunctionDialog.cpp.
References Mantid::API::Expression::getVariables(), m_uiForm, and Mantid::API::Expression::parse().
Referenced by UserFunctionDialog().
|
private |
Container for prerecorded functions: key = category.name, value = formula Records with key = category.name.comment contain comments to corresponding functions.
Definition at line 63 of file UserFunctionDialog.h.
Referenced by categoryNames(), functionNames(), getComment(), getFunction(), loadFunctions(), removeCurrentFunction(), saveToFile(), and setFunction().
|
private |
User interface elements.
Definition at line 58 of file UserFunctionDialog.h.
Referenced by addExpression(), categories(), checkParameters(), getCurrentCategory(), removeCurrentFunction(), saveFunction(), selectCategory(), selectFunction(), updateCategories(), updateFunction(), and UserFunctionDialog().