OpenCurves  0.9
expressions.h
1 //
2 // author Kazys Stepanas
3 //
4 // Copyright (c) CSIRO 2015
5 //
6 #ifndef EXPRESSIONS_H_
7 #define EXPRESSIONS_H_
8 
9 #include "ocurvesconfig.h"
10 
11 #include <QObject>
12 #include <QList>
13 
14 #include "expr/functiondefinition.h"
15 #include "expr/plotexpression.h"
16 
18 class QSettings;
19 
20 Q_DECLARE_METATYPE(PlotExpression *);
21 Q_DECLARE_METATYPE(FunctionDefinition *);
22 
27 class Expressions : public QObject
28 {
29  Q_OBJECT
30 public:
32  static const unsigned missingTolerance = 50;
33 
36  Expressions(QObject *parent = nullptr);
37 
39  ~Expressions();
40 
44  void clear(bool suppressSignals = true);
45 
54  void loadExpressions(const QSettings &settings, bool delaySignals = true);
55 
72  void saveExpressions(QSettings &settings);
73 
76  void addExpression(PlotExpression *expression);
77 
81  bool removeExpression(PlotExpression *expression);
82 
85  bool contains(const PlotExpression *expression) const;
86 
89  const QList<PlotExpression *> &expressions() const;
90 
94 
103  bool registerFunction(FunctionDefinition *functionDef, bool takeOwnership = true);
104 
105 signals:
108  void expressionAdded(PlotExpression *expression);
111  void expressionRemoved(const PlotExpression *expression);
114  void functionRegistered(const FunctionDefinition *function);
115 
116 private:
117  QList<PlotExpression *> _expressions;
118  PlotFunctionRegister *_functionRegister;
119 };
120 
121 inline const QList<PlotExpression *> &Expressions::expressions() const
122 {
123  return _expressions;
124 }
125 
126 
128 {
129  return *_functionRegister;
130 }
131 
132 
133 #endif // EXPRESSIONS_H_
const PlotFunctionRegister & functionRegister() const
Access the function register.
Definition: expressions.h:127
void functionRegistered(const FunctionDefinition *function)
Raised when a function is successfully added via registerFunction().
void expressionRemoved(const PlotExpression *expression)
Raised when an expression is removed.
void saveExpressions(QSettings &settings)
Save expressions to the given settings.
void clear(bool suppressSignals=true)
Delete all expressions optionally suppressing event signals.
Expressions(QObject *parent=nullptr)
Create an expressions data model object.
const QList< PlotExpression * > & expressions() const
Access the list of expressions.
Definition: expressions.h:121
~Expressions()
Destructor.
bool registerFunction(FunctionDefinition *functionDef, bool takeOwnership=true)
Registers a function for use in expressions.
A PlotFunctionRegister stores function implementations to expose to the plot expression generator...
Definition: plotfunctionregister.h:26
void addExpression(PlotExpression *expression)
Adds an expression.
void loadExpressions(const QSettings &settings, bool delaySignals=true)
Load expressions from the given settings.
void expressionAdded(PlotExpression *expression)
Raised when an expression is added.
Defines a function which can be used with the FunctionRegister.
Definition: functiondefinition.h:34
bool contains(const PlotExpression *expression) const
Check if expression is a known expression (check by pointer).
Maintains the current expressions available for generation and plotting.
Definition: expressions.h:27
bool removeExpression(PlotExpression *expression)
Remove expression if it is present.
A PlotExpression represents an operation in a plot equation.
Definition: plotexpression.h:91
static const unsigned missingTolerance
Internally used in settings serialisation.
Definition: expressions.h:32