OpenCurves  0.9
Expressions Class Reference

Maintains the current expressions available for generation and plotting. More...

#include <expressions.h>

Inheritance diagram for Expressions:

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 PlotFunctionRegisterfunctionRegister () 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.
 

Detailed Description

Maintains the current expressions available for generation and plotting.

This forms the model for use in the UI and for generating expressions from.

Constructor & Destructor Documentation

Expressions::Expressions ( QObject *  parent = nullptr)

Create an expressions data model object.

Parameters
parentThe owning object.

Member Function Documentation

void Expressions::addExpression ( PlotExpression expression)

Adds an expression.

Parameters
expressionThe expression to add.
void Expressions::clear ( bool  suppressSignals = true)

Delete all expressions optionally suppressing event signals.

Parameters
suppressSignalsTrue 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).

Returns
True if the pointer expression references a known expression.
void Expressions::expressionAdded ( PlotExpression expression)
signal

Raised when an expression is added.

Parameters
expressionThe added expression.
void Expressions::expressionRemoved ( const PlotExpression expression)
signal

Raised when an expression is removed.

Parameters
expressionThe removed expression. May be deleted if the signal is delayed.
const QList< PlotExpression * > & Expressions::expressions ( ) const
inline

Access the list of expressions.

Returns
The current expressions.
const PlotFunctionRegister & Expressions::functionRegister ( ) const
inline

Access the function register.

Returns
The function register.
void Expressions::functionRegistered ( const FunctionDefinition function)
signal

Raised when a function is successfully added via registerFunction().

Parameters
functionThe 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.

Parameters
settingsThe settings to load from.
delaySignalsTrue 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.

Parameters
functionDefThe definition of the function being registered.
takeOwnershiptrue 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.

Parameters
expressionThe expression to remove.
Returns
True if the expression was found and removed.
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.

Parameters
settingsThe settings to save to.

The documentation for this class was generated from the following file: