Skip to content

Class QAccelPlot::DataPointStore

ClassList > QAccelPlot > DataPointStore

Holds the data points of one series and derives everything that depends only on them. More...

  • #include <DataPointStore.hpp>

Classes

Type Name
struct AttributeView
Read-only view over the float attributes of the stored data points.
struct DimensionState
Scale and viewport of one dimension, as its axis currently shows it.
struct Extent
Smallest and largest valid coordinate in one dimension.
struct Extents
Extents in both dimensions; a dimension without a valid coordinate has none.
struct Layout
Shape of a data point.
struct View
Read-only view over interleaved data points in float or double precision.
struct Viewport
Visible range of one dimension.

Public Types

Type Name
enum Dimension
Plot dimension a coordinate column belongs to.
enum RangeRule
Which coordinates count toward the extents.

Public Functions

Type Name
DataPointStore (Layout layout)
Creates an empty store whose data points have layout .
void append (const double * coordinates)
Appends one double data point of columnCount() coordinates; promotes float data first.
void assignFloat (const float * coordinates, int count)
Replaces the data points with count float data points copied from__coordinates , reusing the allocation.
void assignPrecise (const double * coordinates, int count)
Replaces the data points with count double data points copied from__coordinates .
float attribute (int index, int which=0) noexcept const
Returns attribute which of data point__index ; NaN without attributes.
AttributeView attributes () noexcept const
Returns the stored float attributes.
const std::vector< int > & categories () noexcept const
Returns the stored categories: empty, or one per data point.
void clear ()
Removes all data points, attributes, and categories.
void clearDrawn ()
Draws the stored data points again.
int columnCount () noexcept const
Returns the number of coordinate columns per data point.
int count () noexcept const
Returns the number of data points.
const DimensionState & dimensionState (Dimension dimension) noexcept const
Returns the scale and viewport last given for dimension .
View drawnView () const
Returns the data points that are drawn: the drawn ones, or the stored ones.
Extents extents (bool logScaleX, bool logScaleY, int first=0, int last=-1) const
Returns the extents of data points [ first _,_last ) under the layout's range rule.
bool hasAttributes () noexcept const
Returns whether the data points carry float attributes.
bool hasCategories () noexcept const
Returns whether the data points carry categories.
bool hasDrawn () noexcept const
Returns whether drawn data points replace the stored ones.
bool isPrecise () noexcept const
Returns whether the data points are stored as doubles.
const Layout & layout () noexcept const
Returns the data point layout.
void promoteToPrecise ()
Converts float data points to double, so later updates keep their precision. Does nothing for double data.
void remapColumns (std::vector< Dimension > columns)
Ties the coordinate columns to columns , one dimension per column, keeping the data points.
int renderCount () const
Returns the number of data points in the render data.
const std::vector< float > & renderData () const
Returns the float render data, rebuilding it first when stale.
double renderOrigin (Dimension dimension) const
Returns the render origin of dimension , rebuilding the render data first when stale.
std::uint64_t renderRevision () noexcept const
Returns a number that changes whenever the render data changes.
int renderStride () noexcept const
Returns the floats per data point in the render data.
View renderedView () const
Returns the data points the render data is built from: drawnView() , without the invalid data points whenskipInvalid() is set.
void setAttributes (std::vector< float > && attributes)
Replaces the float attributes: empty, or attributeCount floats per data point.
void setCategories (std::vector< int > && categories)
Replaces the categories: empty, or one per data point.
void setDimensionState (Dimension dimension, const DimensionState & state)
Updates the scale and viewport of dimension .
std::vector< double > setDrawn (std::vector< double > && dataPoints, int count)
Draws count data points moved from__dataPoints instead of the stored ones.
void setFloat (std::vector< float > && coordinates, int count, std::vector< float > && attributes={})
Replaces the data points with count float data points moved from__coordinates .
void setLayout (Layout layout)
Clears the store and switches to layout .
void setPrecise (std::vector< double > && coordinates, int count, std::vector< float > && attributes={})
Replaces the data points with count double data points moved from__coordinates .
void setSkipInvalid (bool skip)
Leaves invalid data points out of the render data and renderedView() .
bool skipInvalid () noexcept const
Returns whether invalid data points are left out of the render data.
double value (int index, int column) noexcept const
Returns coordinate column of stored data point__index .
View view () noexcept const
Returns the stored data points.

Detailed Description

A data point is a fixed number of coordinate columns, each tied to the X or Y dimension, plus optional float attributes and an optional integer category. The store keeps the coordinates at the precision they were given in and derives:

  • the extents of the valid coordinates under one of three range rules;
  • the float render data uploaded to the GPU. Float input is its own render data. Double input is uploaded relative to a render origin per dimension, which moves to the viewport center when the viewport gets too far from it. Logarithmic dimensions are never shifted.

Render data is rebuilt lazily, the first time it is read after something it depends on changed, so even its const readers may rebuild it. The store is not thread-safe: use it from the series' thread, or from updatePaintNode() while that thread is blocked.

Public Types Documentation

enum Dimension

Plot dimension a coordinate column belongs to.

enum QAccelPlot::DataPointStore::Dimension {
    X,
    Y
};


enum RangeRule

Which coordinates count toward the extents.

enum QAccelPlot::DataPointStore::RangeRule {
    EachCoordinate,
    WholeDataPoint,
    SkipOnNaN
};

A coordinate is valid when it is finite and, on a logarithmic dimension, positive.


Public Functions Documentation

function DataPointStore

Creates an empty store whose data points have layout .

explicit QAccelPlot::DataPointStore::DataPointStore (
    Layout layout
) 


function append

Appends one double data point of columnCount() coordinates; promotes float data first.

void QAccelPlot::DataPointStore::append (
    const double * coordinates
) 

The render data grows in place when nothing else it depends on has changed.


function assignFloat

Replaces the data points with count float data points copied from__coordinates , reusing the allocation.

void QAccelPlot::DataPointStore::assignFloat (
    const float * coordinates,
    int count
) 


function assignPrecise

Replaces the data points with count double data points copied from__coordinates .

void QAccelPlot::DataPointStore::assignPrecise (
    const double * coordinates,
    int count
) 


function attribute

Returns attribute which of data point__index ; NaN without attributes.

float QAccelPlot::DataPointStore::attribute (
    int index,
    int which=0
) noexcept const


function attributes

Returns the stored float attributes.

AttributeView QAccelPlot::DataPointStore::attributes () noexcept const


function categories

Returns the stored categories: empty, or one per data point.

const std::vector< int > & QAccelPlot::DataPointStore::categories () noexcept const


function clear

Removes all data points, attributes, and categories.

void QAccelPlot::DataPointStore::clear () 


function clearDrawn

Draws the stored data points again.

void QAccelPlot::DataPointStore::clearDrawn () 


function columnCount

Returns the number of coordinate columns per data point.

int QAccelPlot::DataPointStore::columnCount () noexcept const


function count

Returns the number of data points.

int QAccelPlot::DataPointStore::count () noexcept const


function dimensionState

Returns the scale and viewport last given for dimension .

const DimensionState & QAccelPlot::DataPointStore::dimensionState (
    Dimension dimension
) noexcept const


function drawnView

Returns the data points that are drawn: the drawn ones, or the stored ones.

View QAccelPlot::DataPointStore::drawnView () const


function extents

Returns the extents of data points [ first _,_last ) under the layout's range rule.

Extents QAccelPlot::DataPointStore::extents (
    bool logScaleX,
    bool logScaleY,
    int first=0,
    int last=-1
) const

last of -1 means the end. logScaleX and logScaleY decide which coordinates are valid.


function hasAttributes

Returns whether the data points carry float attributes.

bool QAccelPlot::DataPointStore::hasAttributes () noexcept const


function hasCategories

Returns whether the data points carry categories.

bool QAccelPlot::DataPointStore::hasCategories () noexcept const


function hasDrawn

Returns whether drawn data points replace the stored ones.

bool QAccelPlot::DataPointStore::hasDrawn () noexcept const


function isPrecise

Returns whether the data points are stored as doubles.

bool QAccelPlot::DataPointStore::isPrecise () noexcept const


function layout

Returns the data point layout.

const Layout & QAccelPlot::DataPointStore::layout () noexcept const


function promoteToPrecise

Converts float data points to double, so later updates keep their precision. Does nothing for double data.

void QAccelPlot::DataPointStore::promoteToPrecise () 


function remapColumns

Ties the coordinate columns to columns , one dimension per column, keeping the data points.

void QAccelPlot::DataPointStore::remapColumns (
    std::vector< Dimension > columns
) 


function renderCount

Returns the number of data points in the render data.

int QAccelPlot::DataPointStore::renderCount () const


function renderData

Returns the float render data, rebuilding it first when stale.

const std::vector< float > & QAccelPlot::DataPointStore::renderData () const

Each data point is its coordinates relative to renderOrigin(), then its attributes.


function renderOrigin

Returns the render origin of dimension , rebuilding the render data first when stale.

double QAccelPlot::DataPointStore::renderOrigin (
    Dimension dimension
) const

It is 0 for float data and logarithmic dimensions.


function renderRevision

Returns a number that changes whenever the render data changes.

std::uint64_t QAccelPlot::DataPointStore::renderRevision () noexcept const


function renderStride

Returns the floats per data point in the render data.

int QAccelPlot::DataPointStore::renderStride () noexcept const


function renderedView

Returns the data points the render data is built from: drawnView() , without the invalid data points whenskipInvalid() is set.

View QAccelPlot::DataPointStore::renderedView () const


function setAttributes

Replaces the float attributes: empty, or attributeCount floats per data point.

void QAccelPlot::DataPointStore::setAttributes (
    std::vector< float > && attributes
) 


function setCategories

Replaces the categories: empty, or one per data point.

void QAccelPlot::DataPointStore::setCategories (
    std::vector< int > && categories
) 

Replacing the data points drops the categories; appending gives the new data point -1.


function setDimensionState

Updates the scale and viewport of dimension .

void QAccelPlot::DataPointStore::setDimensionState (
    Dimension dimension,
    const DimensionState & state
) 

Marks the render data stale when the scale changes, or when the viewport moves too far from the render origin to keep float precision.


function setDrawn

Draws count data points moved from__dataPoints instead of the stored ones.

std::vector< double > QAccelPlot::DataPointStore::setDrawn (
    std::vector< double > && dataPoints,
    int count
) 

Used by a running transition for the frame it shows. dataPoints holds columnCount() coordinates per data point, followed by attributeCount attributes when the stored data points have attributes. The stored data points, their extents, and view() are unchanged. Returns the previous drawn buffer, so a caller drawing frame after frame reuses its allocation. Replacing the stored data points with ones of another stride draws them again.


function setFloat

Replaces the data points with count float data points moved from__coordinates .

void QAccelPlot::DataPointStore::setFloat (
    std::vector< float > && coordinates,
    int count,
    std::vector< float > && attributes={}
) 

Without attributes the moved buffer becomes the render data as is. With attributes, it is interleaved with them once.


function setLayout

Clears the store and switches to layout .

void QAccelPlot::DataPointStore::setLayout (
    Layout layout
) 


function setPrecise

Replaces the data points with count double data points moved from__coordinates .

void QAccelPlot::DataPointStore::setPrecise (
    std::vector< double > && coordinates,
    int count,
    std::vector< float > && attributes={}
) 

attributes is empty, or holds attributeCount floats per data point. The sizes must match.


function setSkipInvalid

Leaves invalid data points out of the render data and renderedView() .

void QAccelPlot::DataPointStore::setSkipInvalid (
    bool skip
) 

A data point is invalid when any coordinate is invalid on the current scale.


function skipInvalid

Returns whether invalid data points are left out of the render data.

bool QAccelPlot::DataPointStore::skipInvalid () noexcept const


function value

Returns coordinate column of stored data point__index .

double QAccelPlot::DataPointStore::value (
    int index,
    int column
) noexcept const


function view

Returns the stored data points.

View QAccelPlot::DataPointStore::view () noexcept const



The documentation for this class was generated from the following file QAccelPlot/src/QAccelPlot/series/DataPointStore.hpp