OpenCurves  0.9
plotexpressiongenerator.h
1 //
2 // author Kazys Stepanas
3 //
4 // Copyright (c) CSIRO 2015
5 //
6 #ifndef PLOTEXPRESSIONGENERATOR_H_
7 #define PLOTEXPRESSIONGENERATOR_H_
8 
9 #include "ocurvesconfig.h"
10 
11 #include "plotgenerator.h"
12 
13 class QMutex;
14 
47 {
48  Q_OBJECT
49 public:
63  PlotExpressionGenerator(Curves *curves, const QList<PlotExpression *> &expressions, const QStringList &sourceNames);
64 
66  PlotExpressionGenerator(Curves *curves, const QList<const PlotExpression *> &expressions, const QStringList &sourceNames);
67 
70 
73  {
83  };
84 
89  int addExpression(const PlotExpression *expression);
90 
95  int addExpressions(const QList<const PlotExpression *> &expressions);
96 
101  bool removeExpression(const PlotExpression *expression);
102 
103 protected:
105  void run() override;
106 
114  bool curveExists(const PlotInstance &curve) const;
115 
116 private:
125  template <typename T>
126  void init(Curves *curves, const QList<T *> &expressions, const QStringList &sourceNames);
127 
129  struct ExpressionPair
130  {
131  PlotExpression *expression;
132  const PlotExpression *original;
133 
134  inline bool operator == (const PlotExpression *exp) { return original == exp; }
135  };
136 
137  QVector<ExpressionPair> _expressions;
138  QList<PlotInstance *> _existingCurves;
139  QStringList _sourceNames;
140  struct GenerationMarker *_marker;
141 };
142 
143 #endif // PLOTEXPRESSIONGENERATOR_H_
bool removeExpression(const PlotExpression *expression)
Aborts generation of expression if it has yet to be generated.
AddExpressionResult
Return value sfor addExpression() and addExpressions().
Definition: plotexpressiongenerator.h:72
const Curves * curves() const
Access the curves model to load data into.
Definition: plotgenerator.h:105
Returned when some of the new expressions are successfully queued, while others have already been gen...
Definition: plotexpressiongenerator.h:76
Returned when all of the expression begin added have already been generated.
Definition: plotexpressiongenerator.h:80
Holds data for a single curve.
Definition: plotinstance.h:43
PlotExpressionGenerator(Curves *curves, const QList< PlotExpression * > &expressions, const QStringList &sourceNames)
Create an expression generator based on the given expressions and curves.
The data model for loaded plots and curves.
Definition: curves.h:36
int addExpression(const PlotExpression *expression)
Adds an expression to be generated even if already running.
int addExpressions(const QList< const PlotExpression * > &expressions)
Adds a set of expression to be generated even if already running.
~PlotExpressionGenerator()
Destructor.
Returned when all the new expressions are successfully queued and will be generated.
Definition: plotexpressiongenerator.h:82
A curve generation thread.
Definition: plotgenerator.h:84
A PlotGenerator which generated plots by evaluating PlotExpression objects.
Definition: plotexpressiongenerator.h:46
void run() override
Generation loop.
A PlotExpression represents an operation in a plot equation.
Definition: plotexpression.h:91
bool curveExists(const PlotInstance &curve) const
Check if the curve exists.