Public Member Functions | Static Private Member Functions | Private Attributes | Friends | Related Functions | List of all members
QCPDataSelection Class Reference

Describes a data set by holding multiple QCPDataRange instances. More...

#include <qcustomplot.h>

Public Member Functions

void addDataRange (const QCPDataRange &dataRange, bool simplify=true)
 
void clear ()
 
bool contains (const QCPDataSelection &other) const
 
int dataPointCount () const
 
QCPDataRange dataRange (int index=0) const
 
int dataRangeCount () const
 
QList< QCPDataRangedataRanges () const
 
void enforceType (QCP::SelectionType type)
 
QCPDataSelection intersection (const QCPDataRange &other) const
 
QCPDataSelection intersection (const QCPDataSelection &other) const
 
QCPDataSelection inverse (const QCPDataRange &outerRange) const
 
bool isEmpty () const
 
bool operator!= (const QCPDataSelection &other) const
 
QCPDataSelectionoperator+= (const QCPDataSelection &other)
 
QCPDataSelectionoperator+= (const QCPDataRange &other)
 
QCPDataSelectionoperator-= (const QCPDataSelection &other)
 
QCPDataSelectionoperator-= (const QCPDataRange &other)
 
bool operator== (const QCPDataSelection &other) const
 
 QCPDataSelection ()
 
 QCPDataSelection (const QCPDataRange &range)
 
void simplify ()
 
QCPDataRange span () const
 

Static Private Member Functions

static bool lessThanDataRangeBegin (const QCPDataRange &a, const QCPDataRange &b)
 

Private Attributes

QList< QCPDataRangemDataRanges
 

Friends

const QCPDataSelection operator+ (const QCPDataSelection &a, const QCPDataSelection &b)
 
const QCPDataSelection operator+ (const QCPDataRange &a, const QCPDataSelection &b)
 
const QCPDataSelection operator+ (const QCPDataSelection &a, const QCPDataRange &b)
 
const QCPDataSelection operator+ (const QCPDataRange &a, const QCPDataRange &b)
 
const QCPDataSelection operator- (const QCPDataSelection &a, const QCPDataSelection &b)
 
const QCPDataSelection operator- (const QCPDataRange &a, const QCPDataSelection &b)
 
const QCPDataSelection operator- (const QCPDataSelection &a, const QCPDataRange &b)
 
const QCPDataSelection operator- (const QCPDataRange &a, const QCPDataRange &b)
 

Related Functions

(Note that these are not member functions.)

QDebug operator<< (QDebug d, const QCPDataSelection &selection)
 

Detailed Description

Describes a data set by holding multiple QCPDataRange instances.

QCPDataSelection manages multiple instances of QCPDataRange in order to represent any (possibly disjoint) set of data selection.

The data selection can be modified with addition and subtraction operators which take QCPDataSelection and QCPDataRange instances, as well as methods such as addDataRange and clear. Read access is provided by dataRange, dataRanges, dataRangeCount, etc.

The method simplify is used to join directly adjacent or even overlapping QCPDataRange instances. QCPDataSelection automatically simplifies when using the addition/subtraction operators. The only case when simplify is left to the user, is when calling addDataRange, with the parameter simplify explicitly set to false. This is useful if many data ranges will be added to the selection successively and the overhead for simplifying after each iteration shall be avoided. In this case, you should make sure to call simplify after completing the operation.

Use enforceType to bring the data selection into a state complying with the constraints for selections defined in QCP::SelectionType.

QCustomPlot's data selection mechanism is based on QCPDataSelection and QCPDataRange.

Iterating over a data selection

As an example, the following code snippet calculates the average value of a graph's data selection:

Definition at line 932 of file qcustomplot.h.

Constructor & Destructor Documentation

◆ QCPDataSelection() [1/2]

QCPDataSelection::QCPDataSelection ( )
explicit

Creates an empty QCPDataSelection.

Definition at line 2388 of file qcustomplot.cpp.

◆ QCPDataSelection() [2/2]

QCPDataSelection::QCPDataSelection ( const QCPDataRange range)
explicit

Creates a QCPDataSelection containing the provided range.

Definition at line 2395 of file qcustomplot.cpp.

Member Function Documentation

◆ addDataRange()

void QCPDataSelection::addDataRange ( const QCPDataRange dataRange,
bool  simplify = true 
)

Adds the given dataRange to this data selection. This is equivalent to the += operator but allows disabling immediate simplification by setting simplify to false. This can improve performance if adding a very large amount of data ranges successively. In this case, make sure to call simplify manually, after the operation.

Definition at line 2547 of file qcustomplot.cpp.

◆ clear()

void QCPDataSelection::clear ( )

Removes all data ranges. The data selection then contains no data points.

isEmpty

Definition at line 2559 of file qcustomplot.cpp.

◆ contains()

bool QCPDataSelection::contains ( const QCPDataSelection other) const

Returns true if the data selection other is contained entirely in this data selection, i.e. all data point indices that are in other are also in this data selection.

See also
QCPDataRange::contains

Definition at line 2657 of file qcustomplot.cpp.

◆ dataPointCount()

int QCPDataSelection::dataPointCount ( ) const

Returns the total number of data points contained in all data ranges that make up this data selection.

Definition at line 2501 of file qcustomplot.cpp.

◆ dataRange()

QCPDataRange QCPDataSelection::dataRange ( int  index = 0) const

Returns the data range with the specified index.

If the data selection is simplified (the usual state of the selection, see simplify), the ranges are sorted by ascending data point index.

See also
dataRangeCount

Definition at line 2517 of file qcustomplot.cpp.

◆ dataRangeCount()

int QCPDataSelection::dataRangeCount ( ) const
inline

Returns the number of ranges that make up the data selection. The ranges can be accessed by dataRange via their index.

See also
dataRange, dataPointCount

Definition at line 954 of file qcustomplot.h.

◆ dataRanges()

QList< QCPDataRange > QCPDataSelection::dataRanges ( ) const
inline

Returns all data ranges that make up the data selection. If the data selection is simplified (the usual state of the selection, see simplify), the ranges are sorted by ascending data point index.

See also
dataRange

Definition at line 957 of file qcustomplot.h.

◆ enforceType()

void QCPDataSelection::enforceType ( QCP::SelectionType  type)

Makes sure this data selection conforms to the specified type selection type. Before the type is enforced, simplify is called.

Depending on type, enforcing means adding new data points that were previously not part of the selection, or removing data points from the selection. If the current selection already conforms to type, the data selection is not changed.

See also
QCP::SelectionType

Definition at line 2610 of file qcustomplot.cpp.

◆ intersection() [1/2]

QCPDataSelection QCPDataSelection::intersection ( const QCPDataRange other) const

Returns a data selection containing the points which are both in this data selection and in the data range other.

A common use case is to limit an unknown data selection to the valid range of a data container, using QCPDataContainer::dataRange as other. One can then safely iterate over the returned data selection without exceeding the data container's bounds.

Definition at line 2681 of file qcustomplot.cpp.

◆ intersection() [2/2]

QCPDataSelection QCPDataSelection::intersection ( const QCPDataSelection other) const

Returns a data selection containing the points which are both in this data selection and in the data selection other.

Definition at line 2694 of file qcustomplot.cpp.

◆ inverse()

QCPDataSelection QCPDataSelection::inverse ( const QCPDataRange outerRange) const

Returns a data selection which is the exact inverse of this data selection, with outerRange defining the base range on which to invert. If outerRange is smaller than the span of this data selection, it is expanded accordingly.

For example, this method can be used to retrieve all unselected segments by setting outerRange to the full data range of the plottable, and calling this method on a data selection holding the selected segments.

Definition at line 2712 of file qcustomplot.cpp.

◆ isEmpty()

bool QCPDataSelection::isEmpty ( ) const
inline

Returns true if there are no data ranges, and thus no data points, in this QCPDataSelection instance.

See also
dataRangeCount

Definition at line 963 of file qcustomplot.h.

◆ lessThanDataRangeBegin()

static bool QCPDataSelection::lessThanDataRangeBegin ( const QCPDataRange a,
const QCPDataRange b 
)
inlinestaticprivate

Definition at line 975 of file qcustomplot.h.

◆ operator!=()

bool QCPDataSelection::operator!= ( const QCPDataSelection other) const
inline

Definition at line 939 of file qcustomplot.h.

◆ operator+=() [1/2]

QCPDataSelection & QCPDataSelection::operator+= ( const QCPDataSelection other)

Adds the data selection of other to this data selection, and then simplifies this data selection (see simplify).

Definition at line 2423 of file qcustomplot.cpp.

◆ operator+=() [2/2]

QCPDataSelection & QCPDataSelection::operator+= ( const QCPDataRange other)

Adds the data range other to this data selection, and then simplifies this data selection (see simplify).

Definition at line 2434 of file qcustomplot.cpp.

◆ operator-=() [1/2]

QCPDataSelection & QCPDataSelection::operator-= ( const QCPDataSelection other)

Removes all data point indices that are described by other from this data selection.

Definition at line 2443 of file qcustomplot.cpp.

◆ operator-=() [2/2]

QCPDataSelection & QCPDataSelection::operator-= ( const QCPDataRange other)

Removes all data point indices that are described by other from this data selection.

Definition at line 2454 of file qcustomplot.cpp.

◆ operator==()

bool QCPDataSelection::operator== ( const QCPDataSelection other) const

Returns true if this selection is identical (contains the same data ranges with the same begin and end indices) to other.

Note that both data selections must be in simplified state (the usual state of the selection, see simplify) for this operator to return correct results.

Definition at line 2407 of file qcustomplot.cpp.

◆ simplify()

void QCPDataSelection::simplify ( )

Sorts all data ranges by range begin index in ascending order, and then joins directly adjacent or overlapping ranges. This can reduce the number of individual data ranges in the selection, and prevents possible double-counting when iterating over the data points held by the data ranges.

This method is automatically called when using the addition/subtraction operators. The only case when simplify is left to the user, is when calling addDataRange, with the parameter simplify explicitly set to false.

Definition at line 2573 of file qcustomplot.cpp.

◆ span()

QCPDataRange QCPDataSelection::span ( ) const

Returns a QCPDataRange which spans the entire data selection, including possible intermediate segments which are not part of the original data selection.

Definition at line 2533 of file qcustomplot.cpp.

Friends And Related Function Documentation

◆ operator+ [1/4]

const QCPDataSelection operator+ ( const QCPDataSelection a,
const QCPDataSelection b 
)
friend

Return a QCPDataSelection with the data points in a joined with the data points in b. The resulting data selection is already simplified (see QCPDataSelection::simplify).

Definition at line 984 of file qcustomplot.h.

◆ operator+ [2/4]

const QCPDataSelection operator+ ( const QCPDataRange a,
const QCPDataSelection b 
)
friend

Return a QCPDataSelection with the data points in a joined with the data points in b. The resulting data selection is already simplified (see QCPDataSelection::simplify).

Definition at line 995 of file qcustomplot.h.

◆ operator+ [3/4]

const QCPDataSelection operator+ ( const QCPDataSelection a,
const QCPDataRange b 
)
friend

Return a QCPDataSelection with the data points in a joined with the data points in b. The resulting data selection is already simplified (see QCPDataSelection::simplify).

Definition at line 1006 of file qcustomplot.h.

◆ operator+ [4/4]

const QCPDataSelection operator+ ( const QCPDataRange a,
const QCPDataRange b 
)
friend

Return a QCPDataSelection with the data points in a joined with the data points in b. The resulting data selection is already simplified (see QCPDataSelection::simplify).

Definition at line 1017 of file qcustomplot.h.

◆ operator- [1/4]

const QCPDataSelection operator- ( const QCPDataSelection a,
const QCPDataSelection b 
)
friend

Return a QCPDataSelection with the data points which are in a but not in b.

Definition at line 1027 of file qcustomplot.h.

◆ operator- [2/4]

const QCPDataSelection operator- ( const QCPDataRange a,
const QCPDataSelection b 
)
friend

Return a QCPDataSelection with the data points which are in a but not in b.

Definition at line 1037 of file qcustomplot.h.

◆ operator- [3/4]

const QCPDataSelection operator- ( const QCPDataSelection a,
const QCPDataRange b 
)
friend

Return a QCPDataSelection with the data points which are in a but not in b.

Definition at line 1047 of file qcustomplot.h.

◆ operator- [4/4]

const QCPDataSelection operator- ( const QCPDataRange a,
const QCPDataRange b 
)
friend

Return a QCPDataSelection with the data points which are in a but not in b.

Definition at line 1057 of file qcustomplot.h.

◆ operator<<()

QDebug operator<< ( QDebug  d,
const QCPDataSelection selection 
)
related

Prints selection in a human readable format to the qDebug output.

Definition at line 1078 of file qcustomplot.h.

Member Data Documentation

◆ mDataRanges

QList<QCPDataRange> QCPDataSelection::mDataRanges
private

Definition at line 973 of file qcustomplot.h.


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


graph_rviz_plugin
Author(s): Édouard Pronier, Victor Lamoine - Institut Maupertuis
autogenerated on Mon Feb 28 2022 22:27:31