OpenCurves
0.9
|
The slice expression supports taking a slice out of another expression. More...
#include <plotslice.h>
Public Member Functions | |
PlotSlice (PlotExpression *indexee, PlotExpression *indexerStart, PlotExpression *indexerEnd) | |
Defines the slice expression. More... | |
~PlotSlice () | |
Destructor. | |
const PlotExpression * | indexee () const |
Accessor for the indexee expression. More... | |
const PlotExpression * | indexerStart () const |
Accessor for the index start expression. More... | |
const PlotExpression * | indexerEnd () const |
Accessor for the index end expression. More... | |
double | sample (double sampleTime) const override |
Samples the indexee() at sampleTime . More... | |
BindResult | bind (const QList< PlotInstance * > &curves, PlotBindingTracker &bindTracker, PlotExpressionBindDomain &domain, bool repeatLastBinding=false) override |
Attempts to binds the slice expression. More... | |
void | unbind () override |
Unbinds the sampling state. | |
PlotExpression * | clone () const override |
Performs a deep clone. More... | |
bool | explicitTime () const override |
Is the generated expression sensitive to changes in the time domain? More... | |
![]() | |
PlotExpression () | |
Empty constructor. | |
virtual | ~PlotExpression () |
Empty, virtual destructor. | |
QString | toString () const |
Converts the PlotExpression into a parseable string form. More... | |
The slice expression supports taking a slice out of another expression.
A slice has indexer start and end expressions, both of which are optional, to define the slice range. While both are expressions, only one sample is ever requested from each one. This occurs at the time of binding. The results may modify the sampling range of the indexee expression.
In effect, plot binding is effected by first attempting normal binding on the indexee expression. If this succeeds, then the start and end expressions are check to try an restrict the sampling range of the indexee.
The index start expression limits the domain minimum. The minimum is defined by binding the index start expression, then sampling that expression at its domain minimum. This is illustrated by the pseudo code below, executed in the context of the bind()
method:
/// define startInfo as PlotExpressionBindInfo /// call indexerStart.bind(curves, startInfo) /// set startTime = indexerStart.sample(startInfo.domainMin) ///
Note now the indexer start expression is sampled only at its domain minimum. The slice domain minimum is then defined as the maximum of @c startTime (above) and the domain minimum of @c indexee, but the minimum of the result and the domain maximum of @c indexee. That is the domain minimum of the indexee is only modified if @c startTime is greater than its original minimum. The same process is used to modify the domain maximum, with the following changes: - Sample @c indexerEnd at its domain maximum instead of minimum. - Only modify the domain maximum of @c indexee if the end time is less. In some cases the resulting domain minimum and maximum may be invalid, with maximum having value less than the minimum. This is an error condition and binding fails. In practise, it is expected that in most cases the start and end expressions are restricted to time value literals (@c PlotConstant).
PlotSlice::PlotSlice | ( | PlotExpression * | indexee, |
PlotExpression * | indexerStart, | ||
PlotExpression * | indexerEnd | ||
) |
Defines the slice expression.
Start and end expressions are optional.
Note that defining a slice with no start or end expression is technically valid and essentially aliases the indexee
expression. However, it is expected that at least one or the other be set.
indexee | The expression to sample a slice of. Must not be null. |
indexerStart | The expression defining evaluation of the start time for the slice. May be null to use the start time of indexee . |
indexerEnd | The expression defining evaluation of the end time for the slice. May be null to use the end time of indexee . |
|
overridevirtual |
Attempts to binds the slice expression.
This binds the supporting expressions and determines the slice range. The range is set by modifying info
.
Binding fails if:
curves | The set of existing curves available for sampling. These are the curves which were loaded from the source named sourceFile . | |
bindTracker | Tracks the last binding on a per expression basis. | |
[out] | domain | To be populated with bound domain details if a successful binding can be made. |
repeatLastBinding | True to request that the function rebind whatever it bound last time it was called, according to the bindTracker . Bind the first possibility if there is no such last binding. |
Implements PlotExpression.
|
overridevirtual |
|
inlineoverridevirtual |
Is the generated expression sensitive to changes in the time domain?
Reimplemented from PlotExpression.
|
inline |
Accessor for the indexee expression.
|
inline |
Accessor for the index end expression.
|
inline |
Accessor for the index start expression.
|
overridevirtual |
Samples the indexee()
at sampleTime
.
sampleTime | The time to sample at. Expected to be in range. |
sampleTime
. Implements PlotExpression.