OpenCurves  0.9
PlotSlice Class Reference

The slice expression supports taking a slice out of another expression. More...

#include <plotslice.h>

Inheritance diagram for PlotSlice:
PlotExpression

Public Member Functions

 PlotSlice (PlotExpression *indexee, PlotExpression *indexerStart, PlotExpression *indexerEnd)
 Defines the slice expression. More...
 
 ~PlotSlice ()
 Destructor.
 
const PlotExpressionindexee () const
 Accessor for the indexee expression. More...
 
const PlotExpressionindexerStart () const
 Accessor for the index start expression. More...
 
const PlotExpressionindexerEnd () 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.
 
PlotExpressionclone () const override
 Performs a deep clone. More...
 
bool explicitTime () const override
 Is the generated expression sensitive to changes in the time domain? More...
 
- Public Member Functions inherited from PlotExpression
 PlotExpression ()
 Empty constructor.
 
virtual ~PlotExpression ()
 Empty, virtual destructor.
 
QString toString () const
 Converts the PlotExpression into a parseable string form. More...
 

Detailed Description

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

Constructor & Destructor Documentation

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.

Parameters
indexeeThe expression to sample a slice of. Must not be null.
indexerStartThe expression defining evaluation of the start time for the slice. May be null to use the start time of indexee.
indexerEndThe expression defining evaluation of the end time for the slice. May be null to use the end time of indexee.

Member Function Documentation

BindResult PlotSlice::bind ( const QList< PlotInstance * > &  curves,
PlotBindingTracker bindTracker,
PlotExpressionBindDomain domain,
bool  repeatLastBinding = false 
)
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:

  • Any of the three (non-null) expressions fails to bind.
  • The calculated domain minimum is greater than the domain maximum.
Parameters
curvesThe set of existing curves available for sampling. These are the curves which were loaded from the source named sourceFile.
bindTrackerTracks the last binding on a per expression basis.
[out]domainTo be populated with bound domain details if a successful binding can be made.
repeatLastBindingTrue 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.
Returns
True if binding is successful.

Implements PlotExpression.

PlotExpression* PlotSlice::clone ( ) const
overridevirtual

Performs a deep clone.

Returns
A clone of the expression.

Implements PlotExpression.

bool PlotSlice::explicitTime ( ) const
inlineoverridevirtual

Is the generated expression sensitive to changes in the time domain?

Returns
True

Reimplemented from PlotExpression.

const PlotExpression* PlotSlice::indexee ( ) const
inline

Accessor for the indexee expression.

Returns
The expression from which a slice is being taken.
const PlotExpression* PlotSlice::indexerEnd ( ) const
inline

Accessor for the index end expression.

Returns
The expression used to calculate the end time. May be null.
const PlotExpression* PlotSlice::indexerStart ( ) const
inline

Accessor for the index start expression.

Returns
The expression used to calculate the start time. May be null.
double PlotSlice::sample ( double  sampleTime) const
overridevirtual

Samples the indexee() at sampleTime.

Parameters
sampleTimeThe time to sample at. Expected to be in range.
Returns
The sample at sampleTime.

Implements PlotExpression.


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