OpenCurves
0.9
|
A PlotGenerator
which generated plots by evaluating PlotExpression
objects.
More...
#include <plotexpressiongenerator.h>
Public Types | |
enum | AddExpressionResult { AER_QueuedPartial = -1, AER_AlreadyComplete, AER_Queued } |
Return value sfor addExpression() and addExpressions() . More... | |
![]() | |
enum | ControlFlag { None = 0, RelativeTime = (1 << 0) } |
Plot generation control flags. Must be set before execution. More... | |
Public Member Functions | |
PlotExpressionGenerator (Curves *curves, const QList< PlotExpression * > &expressions, const QStringList &sourceNames) | |
Create an expression generator based on the given expressions and curves. More... | |
PlotExpressionGenerator (Curves *curves, const QList< const PlotExpression * > &expressions, const QStringList &sourceNames) | |
~PlotExpressionGenerator () | |
Destructor. | |
int | addExpression (const PlotExpression *expression) |
Adds an expression to be generated even if already running. More... | |
int | addExpressions (const QList< const PlotExpression * > &expressions) |
Adds a set of expression to be generated even if already running. More... | |
bool | removeExpression (const PlotExpression *expression) |
Aborts generation of expression if it has yet to be generated. More... | |
![]() | |
PlotGenerator (Curves *curves) | |
Instantiate the generator thread to load data into curves . More... | |
virtual | ~PlotGenerator () |
Destructor. The thread should generally be stopped before destructing. | |
const Curves * | curves () const |
Access the curves model to load data into. | |
void | setTimeColumn (uint number) |
Set the expected time column for all curves created by this generator. More... | |
uint | timeColumn () const |
The time column value in used. More... | |
void | setTimeScale (double scale) |
Set the scale factor applied to all curves created by this generator. More... | |
double | timeScale () const |
Access the time scale used by this generator. More... | |
void | setControlFlags (uint flags) |
Sets ControlFlag values for this generator. More... | |
void | setControlFlags (uint flags, bool on) |
Set the state of subset of ControlFlag values without affecting other flags. More... | |
uint | controlFlags () const |
Access the current ControlFlag values. | |
void | quit () |
Call to request the generator terminate operation. | |
virtual bool | isFileLoad () const |
True if this is a file loader. More... | |
Protected Member Functions | |
void | run () override |
Generation loop. | |
bool | curveExists (const PlotInstance &curve) const |
Check if the curve exists. More... | |
Additional Inherited Members | |
![]() | |
void | abortLoad () |
Request loading abort. | |
![]() | |
void | itemName (const QString &name) |
Signal the current item name. More... | |
void | itemProgress (int current) |
Update progress through the current item. More... | |
void | overallProgress (int current, int total) |
This signal reports overall progress. More... | |
void | beginNewCurves () |
Begin the addition of new curves via Curves::newCurve() Block notification occurs at a per PlotSource level. More... | |
void | endNewCurves () |
End notification of new curves via Curves::newCurve() . More... | |
void | loadComplete (int curveCount) |
Notify completion of curve generation. More... | |
![]() | |
Curves * | _curves |
Curves data model. | |
QMutex * | _dataMutex |
Data mutex. | |
uint | _controlFlags |
ControlFlag values affecting generation. | |
uint | _timeColumn |
Index of the time column, zero for none. | |
double | _timeScale |
Time scaling factor. | |
bool | _abortFlag |
Abort requested? | |
A PlotGenerator
which generated plots by evaluating PlotExpression
objects.
The generator is designed to run asynchronously. As such, it makes copies of the data on which to operate in case these are destroyed. However, the PlotInstance::expression
member is always set as the original expression, not the internal copy.
More explicitly, plots generated herein refer to the original PlotExpression
objects, but internal calculations use a copy of the expressions for thread safety. The original expressions should remain valid and unmodified while the generator executes, but failure to do so will not result in a failure within the generator object. Instead, generated plots may be out of date or reference an invalid expression.
Plot binding is exhaustive, supporting regular expression based PlotExpression
trees. However, this can lead to multiple bindings of the same data when referencing regular expressions from different plots. For example, the expression:
/// r'samples-.*'|'value' - r'samples-.*'|'value' ///
Consider where we have two files loaded 'samples-a' and 'samples-b'. This expression will bind the following:
PlotSource
for PlotInstance
objects generated here is the same as the original source. Expression curves can be distinguished by the fact that PlotInstance::expression()
is not null. Return value sfor addExpression()
and addExpressions()
.
PlotExpressionGenerator::PlotExpressionGenerator | ( | Curves * | curves, |
const QList< PlotExpression * > & | expressions, | ||
const QStringList & | sourceNames | ||
) |
Create an expression generator based on the given expressions and curves.
The generator makes copies of the PlotExpression
and PlotInstance
objects for internal calculations. However, a copy of the original expression list is maintained so that the original expression objects are assigned to generated PlotInstance
objects. See class comments.
curves | The Curves model containing existing curves from which to generate new ones. New curves are added to this model. |
expressions | The expressions to generate new curves from. These objects must remain valid until the generator completes. |
sourceNames | List of all the source files from which curves were loaded. |
PlotExpressionGenerator::PlotExpressionGenerator | ( | Curves * | curves, |
const QList< const PlotExpression * > & | expressions, | ||
const QStringList & | sourceNames | ||
) |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
int PlotExpressionGenerator::addExpression | ( | const PlotExpression * | expression | ) |
Adds an expression to be generated even if already running.
Thread-safe.
The caller retains ownership of expression
.
AddExpressionResult
. Does not return AER_QueuedPartial
. int PlotExpressionGenerator::addExpressions | ( | const QList< const PlotExpression * > & | expressions | ) |
Adds a set of expression to be generated even if already running.
Thread-safe.
The caller retains ownership of expression
.
AddExpressionResult
.
|
protected |
Check if the curve exists.
This is used to duplicate binding.
Looks in _existingCurves
for an item with the same PlotSource::name()
and PlotInstance::name()
.
curve | The curve to look for a duplicate of. |
bool PlotExpressionGenerator::removeExpression | ( | const PlotExpression * | expression | ) |
Aborts generation of expression
if it has yet to be generated.
Thread-safe.