OpenCurves
0.9
|
Maintains the current expressions available for generation and plotting. More...
#include <expressions.h>
Signals | |
void | expressionAdded (PlotExpression *expression) |
Raised when an expression is added. More... | |
void | expressionRemoved (const PlotExpression *expression) |
Raised when an expression is removed. More... | |
void | functionRegistered (const FunctionDefinition *function) |
Raised when a function is successfully added via registerFunction() . More... | |
Public Member Functions | |
Expressions (QObject *parent=nullptr) | |
Create an expressions data model object. More... | |
~Expressions () | |
Destructor. | |
void | clear (bool suppressSignals=true) |
Delete all expressions optionally suppressing event signals. More... | |
void | loadExpressions (const QSettings &settings, bool delaySignals=true) |
Load expressions from the given settings. More... | |
void | saveExpressions (QSettings &settings) |
Save expressions to the given settings. More... | |
void | addExpression (PlotExpression *expression) |
Adds an expression. More... | |
bool | removeExpression (PlotExpression *expression) |
Remove expression if it is present. More... | |
bool | contains (const PlotExpression *expression) const |
Check if expression is a known expression (check by pointer). More... | |
const QList< PlotExpression * > & | expressions () const |
Access the list of expressions. More... | |
const PlotFunctionRegister & | functionRegister () const |
Access the function register. More... | |
bool | registerFunction (FunctionDefinition *functionDef, bool takeOwnership=true) |
Registers a function for use in expressions. More... | |
Static Public Attributes | |
static const unsigned | missingTolerance = 50 |
Internally used in settings serialisation. | |
Maintains the current expressions available for generation and plotting.
This forms the model for use in the UI and for generating expressions from.
Expressions::Expressions | ( | QObject * | parent = nullptr | ) |
Create an expressions data model object.
parent | The owning object. |
void Expressions::addExpression | ( | PlotExpression * | expression | ) |
Adds an expression.
expression | The expression to add. |
void Expressions::clear | ( | bool | suppressSignals = true | ) |
Delete all expressions optionally suppressing event signals.
suppressSignals | True to suppress the expressionRemoved() signal, false to allow it. |
bool Expressions::contains | ( | const PlotExpression * | expression | ) | const |
Check if expression
is a known expression (check by pointer).
expression
references a known expression.
|
signal |
Raised when an expression is added.
expression | The added expression. |
|
signal |
Raised when an expression is removed.
expression | The removed expression. May be deleted if the signal is delayed. |
|
inline |
Access the list of expressions.
|
inline |
Access the function register.
|
signal |
Raised when a function is successfully added via registerFunction()
.
function | The definition of the function added. |
void Expressions::loadExpressions | ( | const QSettings & | settings, |
bool | delaySignals = true |
||
) |
Load expressions from the given settings.
Expressions are loaded from the current group in settings, so it should be primed before calling this method.
settings | The settings to load from. |
delaySignals | True to delay the addExpression() and expressionRemoved() signals until done. |
bool Expressions::registerFunction | ( | FunctionDefinition * | functionDef, |
bool | takeOwnership = true |
||
) |
Registers a function for use in expressions.
See PlotFunction
.
This registers a function in the functionRegister()
if possible and raises functionRegistered()
on success.
functionDef | The definition of the function being registered. |
takeOwnership | true to take ownership of the functionDef . This allows it to be deleted by the function register on shutdown. |
bool Expressions::removeExpression | ( | PlotExpression * | expression | ) |
Remove expression
if it is present.
The caller takes ownership of expression
.
expression | The expression to remove. |
void Expressions::saveExpressions | ( | QSettings & | settings | ) |
Save expressions to the given settings.
Expressions are saved with the tag 'exp#' where '#' is the expression number, starting from 1. At most expressionCountLimit
expressions are stored. After writing existing expressions, the settings
are checked for additional, contiguous 'exp#' patterns, which are removed.
For example, we have three expressions, which are written as [ exp1, exp2, exp3 ]. The settings previously contained six expressions, adding [ exp4, exp5, exp6 ]. After saving three expressions, this function tests settings
for the existence of 'exp4' and remove it. It then tests for 'exp5', etc and removes the key until key is not found in settings
, in this case 'exp7'.
Expressions are saved to the current group in settings
.
settings | The settings to save to. |