Gra zręcznościowa „Straszna Epidemia"  V1.2
Projekt Wizualizacja Danych Sensorycznych Kewin Gałuszka rok akademicki 2019/2020
Dokumentacja szablonu klasy QCPDataContainer< DataType >

The generic data container for one-dimensional plottables. Więcej...

#include <qcustomplot.h>

Typy publiczne

typedef QVector< DataType >::const_iterator const_iterator
 
typedef QVector< DataType >::iterator iterator
 

Metody publiczne

 QCPDataContainer ()
 
int size () const
 
bool isEmpty () const
 
bool autoSqueeze () const
 
void setAutoSqueeze (bool enabled)
 
void set (const QCPDataContainer< DataType > &data)
 
void set (const QVector< DataType > &data, bool alreadySorted=false)
 
void add (const QCPDataContainer< DataType > &data)
 
void add (const QVector< DataType > &data, bool alreadySorted=false)
 
void add (const DataType &data)
 
void removeBefore (double sortKey)
 
void removeAfter (double sortKey)
 
void remove (double sortKeyFrom, double sortKeyTo)
 
void remove (double sortKey)
 
void clear ()
 
void sort ()
 
void squeeze (bool preAllocation=true, bool postAllocation=true)
 
const_iterator constBegin () const
 
const_iterator constEnd () const
 
iterator begin ()
 
iterator end ()
 
const_iterator findBegin (double sortKey, bool expandedRange=true) const
 
const_iterator findEnd (double sortKey, bool expandedRange=true) const
 
const_iterator at (int index) const
 
QCPRange keyRange (bool &foundRange, QCP::SignDomain signDomain=QCP::sdBoth)
 
QCPRange valueRange (bool &foundRange, QCP::SignDomain signDomain=QCP::sdBoth, const QCPRange &inKeyRange=QCPRange())
 
QCPDataRange dataRange () const
 
void limitIteratorsToDataRange (const_iterator &begin, const_iterator &end, const QCPDataRange &dataRange) const
 

Metody chronione

void preallocateGrow (int minimumPreallocSize)
 
void performAutoSqueeze ()
 

Atrybuty chronione

bool mAutoSqueeze
 
QVector< DataType > mData
 
int mPreallocSize
 
int mPreallocIteration
 

Funkcje powiązane

(Zauważ, że to nie są metody klas.)

template<class DataType >
bool qcpLessThanSortKey (const DataType &a, const DataType &b)
 

Opis szczegółowy

template<class DataType>
class QCPDataContainer< DataType >

The generic data container for one-dimensional plottables.

This class template provides a fast container for data storage of one-dimensional data. The data type is specified as template parameter (called DataType in the following) and must provide some methods as described in the next section.

The data is stored in a sorted fashion, which allows very quick lookups by the sorted key as well as retrieval of ranges (see findBegin, findEnd, keyRange) using binary search. The container uses a preallocation and a postallocation scheme, such that appending and prepending data (with respect to the sort key) is very fast and minimizes reallocations. If data is added which needs to be inserted between existing keys, the merge usually can be done quickly too, using the fact that existing data is always sorted. The user can further improve performance by specifying that added data is already itself sorted by key, if he can guarantee that this is the case (see for example add(const QVector<DataType> &data, bool alreadySorted)).

The data can be accessed with the provided const iterators (constBegin, constEnd). If it is necessary to alter existing data in-place, the non-const iterators can be used (begin, end). Changing data members that are not the sort key (for most data types called key) is safe from the container's perspective.

Great care must be taken however if the sort key is modified through the non-const iterators. For performance reasons, the iterators don't automatically cause a re-sorting upon their manipulation. It is thus the responsibility of the user to leave the container in a sorted state when finished with the data manipulation, before calling any other methods on the container. A complete re-sort (e.g. after finishing all sort key manipulation) can be done by calling sort. Failing to do so can not be detected by the container efficiently and will cause both rendering artifacts and potential data loss.

Implementing one-dimensional plottables that make use of a QCPDataContainer<T> is usually done by subclassing from QCPAbstractPlottable1D<T>, which introduces an according mDataContainer member and some convenience methods.

Requirements for the DataType template parameter

The template parameter DataType is the type of the stored data points. It must be trivially copyable and have the following public methods, preferably inline:

  • double sortKey() const
    Returns the member variable of this data point that is the sort key, defining the ordering in the container. Often this variable is simply called key.
  • static DataType fromSortKey(double sortKey)
    Returns a new instance of the data type initialized with its sort key set to sortKey.
  • static bool sortKeyIsMainKey()
    Returns true if the sort key is equal to the main key (see method mainKey below). For most plottables this is the case. It is not the case for example for QCPCurve, which uses t as sort key and key as main key. This is the reason why QCPCurve unlike QCPGraph can display parametric curves with loops.
  • double mainKey() const
    Returns the variable of this data point considered the main key. This is commonly the variable that is used as the coordinate of this data point on the key axis of the plottable. This method is used for example when determining the automatic axis rescaling of key axes (QCPAxis::rescale).
  • double mainValue() const
    Returns the variable of this data point considered the main value. This is commonly the variable that is used as the coordinate of this data point on the value axis of the plottable.
  • QCPRange valueRange() const
    Returns the range this data point spans in the value axis coordinate. If the data is single-valued (e.g. QCPGraphData), this is simply a range with both lower and upper set to the main data point value. However if the data points can represent multiple values at once (e.g QCPFinancialData with its high, low, open and close values at each key) this method should return the range those values span. This method is used for example when determining the automatic axis rescaling of value axes (QCPAxis::rescale).

Definicja w linii 2412 pliku qcustomplot.h.

Dokumentacja składowych definicji typu

◆ const_iterator

template<class DataType >
typedef QVector<DataType>::const_iterator QCPDataContainer< DataType >::const_iterator

Definicja w linii 2415 pliku qcustomplot.h.

◆ iterator

template<class DataType >
typedef QVector<DataType>::iterator QCPDataContainer< DataType >::iterator

Definicja w linii 2416 pliku qcustomplot.h.

Dokumentacja konstruktora i destruktora

◆ QCPDataContainer()

template<class DataType >
QCPDataContainer< DataType >::QCPDataContainer

Constructs a QCPDataContainer used for plottable classes that represent a series of key-sorted data

Definicja w linii 2607 pliku qcustomplot.h.

Dokumentacja funkcji składowych

◆ add() [1/3]

template<class DataType >
void QCPDataContainer< DataType >::add ( const DataType &  data)

To jest metoda przeciążona, udostępniona dla wygody. Różni się od powyższej metody tylko zestawem akceptowanych argumentów.

Adds the provided single data point to the current data.

Zobacz również
remove

Definicja w linii 2741 pliku qcustomplot.h.

◆ add() [2/3]

template<class DataType >
void QCPDataContainer< DataType >::add ( const QCPDataContainer< DataType > &  data)

To jest metoda przeciążona, udostępniona dla wygody. Różni się od powyższej metody tylko zestawem akceptowanych argumentów.

Adds the provided data to the current data in this container.

Zobacz również
set, remove

Definicja w linii 2672 pliku qcustomplot.h.

Oto graf wywołań dla tej funkcji:

◆ add() [3/3]

template<class DataType >
void QCPDataContainer< DataType >::add ( const QVector< DataType > &  data,
bool  alreadySorted = false 
)

Adds the provided data points in data to the current data.

If you can guarantee that the data points in data have ascending order with respect to the DataType's sort key, set alreadySorted to true to avoid an unnecessary sorting run.

Zobacz również
set, remove

Definicja w linii 2704 pliku qcustomplot.h.

◆ at()

template<class DataType >
QCPDataContainer::const_iterator QCPDataContainer< DataType >::at ( int  index) const
inline

Returns a const iterator to the element with the specified index. If index points beyond the available elements in this container, returns constEnd, i.e. an iterator past the last valid element.

You can use this method to easily obtain iterators from a QCPDataRange, see the data selection page for an example.

Definicja w linii 2448 pliku qcustomplot.h.

◆ autoSqueeze()

template<class DataType >
bool QCPDataContainer< DataType >::autoSqueeze ( ) const
inline

Definicja w linii 2423 pliku qcustomplot.h.

◆ begin()

template<class DataType >
QCPDataContainer::iterator QCPDataContainer< DataType >::begin ( )
inline

Returns a non-const iterator to the first data point in this container.

You can manipulate the data points in-place through the non-const iterators, but great care must be taken when manipulating the sort key of a data point, see sort, or the detailed description of this class.

Definicja w linii 2444 pliku qcustomplot.h.

◆ clear()

template<class DataType >
void QCPDataContainer< DataType >::clear

Removes all data points.

Zobacz również
remove, removeAfter, removeBefore

Definicja w linii 2839 pliku qcustomplot.h.

◆ constBegin()

template<class DataType >
QCPDataContainer::const_iterator QCPDataContainer< DataType >::constBegin ( ) const
inline

Returns a const iterator to the first data point in this container.

Definicja w linii 2442 pliku qcustomplot.h.

Oto graf wywoływań tej funkcji:

◆ constEnd()

template<class DataType >
QCPDataContainer::const_iterator QCPDataContainer< DataType >::constEnd ( ) const
inline

Returns a const iterator to the element past the last data point in this container.

Definicja w linii 2443 pliku qcustomplot.h.

Oto graf wywoływań tej funkcji:

◆ dataRange()

template<class DataType >
QCPDataRange QCPDataContainer< DataType >::dataRange ( ) const
inline

Returns a QCPDataRange encompassing the entire data set of this container. This means the begin index of the returned range is 0, and the end index is size.

Definicja w linii 2451 pliku qcustomplot.h.

◆ end()

template<class DataType >
QCPDataContainer::iterator QCPDataContainer< DataType >::end ( )
inline

Returns a non-const iterator to the element past the last data point in this container.

You can manipulate the data points in-place through the non-const iterators, but great care must be taken when manipulating the sort key of a data point, see sort, or the detailed description of this class.

Definicja w linii 2445 pliku qcustomplot.h.

◆ findBegin()

template<class DataType >
QCPDataContainer< DataType >::const_iterator QCPDataContainer< DataType >::findBegin ( double  sortKey,
bool  expandedRange = true 
) const

Returns an iterator to the data point with a (sort-)key that is equal to, just below, or just above sortKey. If expandedRange is true, the data point just below sortKey will be considered, otherwise the one just above.

This can be used in conjunction with findEnd to iterate over data points within a given key range, including or excluding the bounding data points that are just beyond the specified range.

If expandedRange is true but there are no data points below sortKey, constBegin is returned.

If the container is empty, returns constEnd.

Zobacz również
findEnd, QCPPlottableInterface1D::findBegin

Definicja w linii 2906 pliku qcustomplot.h.

Oto graf wywoływań tej funkcji:

◆ findEnd()

template<class DataType >
QCPDataContainer< DataType >::const_iterator QCPDataContainer< DataType >::findEnd ( double  sortKey,
bool  expandedRange = true 
) const

Returns an iterator to the element after the data point with a (sort-)key that is equal to, just above or just below sortKey. If expandedRange is true, the data point just above sortKey will be considered, otherwise the one just below.

This can be used in conjunction with findBegin to iterate over data points within a given key range, including the bounding data points that are just below and above the specified range.

If expandedRange is true but there are no data points above sortKey, constEnd is returned.

If the container is empty, constEnd is returned.

Zobacz również
findBegin, QCPPlottableInterface1D::findEnd

Definicja w linii 2933 pliku qcustomplot.h.

Oto graf wywoływań tej funkcji:

◆ isEmpty()

template<class DataType >
bool QCPDataContainer< DataType >::isEmpty ( ) const
inline

Returns whether this container holds no data points.

Definicja w linii 2422 pliku qcustomplot.h.

Oto graf wywoływań tej funkcji:

◆ keyRange()

template<class DataType >
QCPRange QCPDataContainer< DataType >::keyRange ( bool &  foundRange,
QCP::SignDomain  signDomain = QCP::sdBoth 
)

Returns the range encompassed by the (main-)key coordinate of all data points. The output parameter foundRange indicates whether a sensible range was found. If this is false, you should not use the returned QCPRange (e.g. the data container is empty or all points have the same key).

Use signDomain to control which sign of the key coordinates should be considered. This is relevant e.g. for logarithmic plots which can mathematically only display one sign domain at a time.

If the DataType reports that its main key is equal to the sort key (sortKeyIsMainKey), as is the case for most plottables, this method uses this fact and finds the range very quickly.

Zobacz również
valueRange

Definicja w linii 2960 pliku qcustomplot.h.

◆ limitIteratorsToDataRange()

template<class DataType >
void QCPDataContainer< DataType >::limitIteratorsToDataRange ( const_iterator begin,
const_iterator end,
const QCPDataRange dataRange 
) const

Makes sure begin and end mark a data range that is both within the bounds of this data container's data, as well as within the specified dataRange. The initial range described by the passed iterators begin and end is never expanded, only contracted if necessary.

This function doesn't require for dataRange to be within the bounds of this data container's valid range.

Definicja w linii 3171 pliku qcustomplot.h.

Oto graf wywołań dla tej funkcji:

◆ performAutoSqueeze()

template<class DataType >
void QCPDataContainer< DataType >::performAutoSqueeze
protected

Definicja w linii 3219 pliku qcustomplot.h.

◆ preallocateGrow()

template<class DataType >
void QCPDataContainer< DataType >::preallocateGrow ( int  minimumPreallocSize)
protected

Definicja w linii 3189 pliku qcustomplot.h.

◆ remove() [1/2]

template<class DataType >
void QCPDataContainer< DataType >::remove ( double  sortKey)

To jest metoda przeciążona, udostępniona dla wygody. Różni się od powyższej metody tylko zestawem akceptowanych argumentów.

Removes a single data point at sortKey. If the position is not known with absolute (binary) precision, consider using remove(double sortKeyFrom, double sortKeyTo) with a small fuzziness interval around the suspected position, depeding on the precision with which the (sort-)key is known.

Zobacz również
removeBefore, removeAfter, clear

Definicja w linii 2819 pliku qcustomplot.h.

◆ remove() [2/2]

template<class DataType >
void QCPDataContainer< DataType >::remove ( double  sortKeyFrom,
double  sortKeyTo 
)

Removes all data points with (sort-)keys between sortKeyFrom and sortKeyTo. if sortKeyFrom is greater or equal to sortKeyTo, the function does nothing. To remove a single data point with known (sort-)key, use remove(double sortKey).

Zobacz również
removeBefore, removeAfter, clear

Definicja w linii 2797 pliku qcustomplot.h.

◆ removeAfter()

template<class DataType >
void QCPDataContainer< DataType >::removeAfter ( double  sortKey)

Removes all data points with (sort-)keys greater than or equal to sortKey.

Zobacz również
removeBefore, remove, clear

Definicja w linii 2780 pliku qcustomplot.h.

◆ removeBefore()

template<class DataType >
void QCPDataContainer< DataType >::removeBefore ( double  sortKey)

Removes all data points with (sort-)keys smaller than or equal to sortKey.

Zobacz również
removeAfter, remove, clear

Definicja w linii 2765 pliku qcustomplot.h.

◆ set() [1/2]

template<class DataType >
void QCPDataContainer< DataType >::set ( const QCPDataContainer< DataType > &  data)

To jest metoda przeciążona, udostępniona dla wygody. Różni się od powyższej metody tylko zestawem akceptowanych argumentów.

Replaces the current data in this container with the provided data.

Zobacz również
add, remove

Definicja w linii 2640 pliku qcustomplot.h.

◆ set() [2/2]

template<class DataType >
void QCPDataContainer< DataType >::set ( const QVector< DataType > &  data,
bool  alreadySorted = false 
)

To jest metoda przeciążona, udostępniona dla wygody. Różni się od powyższej metody tylko zestawem akceptowanych argumentów.

Replaces the current data in this container with the provided data

If you can guarantee that the data points in data have ascending order with respect to the DataType's sort key, set alreadySorted to true to avoid an unnecessary sorting run.

Zobacz również
add, remove

Definicja w linii 2656 pliku qcustomplot.h.

◆ setAutoSqueeze()

template<class DataType >
void QCPDataContainer< DataType >::setAutoSqueeze ( bool  enabled)

Sets whether the container automatically decides when to release memory from its post- and preallocation pools when data points are removed. By default this is enabled and for typical applications shouldn't be changed.

If auto squeeze is disabled, you can manually decide when to release pre-/postallocation with squeeze.

Definicja w linii 2623 pliku qcustomplot.h.

◆ size()

template<class DataType >
int QCPDataContainer< DataType >::size ( ) const
inline

Returns the number of data points in the container.

Definicja w linii 2421 pliku qcustomplot.h.

Oto graf wywoływań tej funkcji:

◆ sort()

template<class DataType >
void QCPDataContainer< DataType >::sort

Re-sorts all data points in the container by their sort key.

When setting, adding or removing points using the QCPDataContainer interface (set, add, remove, etc.), the container makes sure to always stay in a sorted state such that a full resort is never necessary. However, if you choose to directly manipulate the sort key on data points by accessing and modifying it through the non-const iterators (begin, end), it is your responsibility to bring the container back into a sorted state before any other methods are called on it. This can be achieved by calling this method immediately after finishing the sort key manipulation.

Definicja w linii 2858 pliku qcustomplot.h.

◆ squeeze()

template<class DataType >
void QCPDataContainer< DataType >::squeeze ( bool  preAllocation = true,
bool  postAllocation = true 
)

Frees all unused memory that is currently in the preallocation and postallocation pools.

Note that QCPDataContainer automatically decides whether squeezing is necessary, if setAutoSqueeze is left enabled. It should thus not be necessary to use this method for typical applications.

The parameters preAllocation and postAllocation control whether pre- and/or post allocation should be freed, respectively.

Definicja w linii 2874 pliku qcustomplot.h.

◆ valueRange()

template<class DataType >
QCPRange QCPDataContainer< DataType >::valueRange ( bool &  foundRange,
QCP::SignDomain  signDomain = QCP::sdBoth,
const QCPRange inKeyRange = QCPRange() 
)

Returns the range encompassed by the value coordinates of the data points in the specified key range (inKeyRange), using the full DataType::valueRange reported by the data points. The output parameter foundRange indicates whether a sensible range was found. If this is false, you should not use the returned QCPRange (e.g. the data container is empty or all points have the same value).

If inKeyRange has both lower and upper bound set to zero (is equal to QCPRange()), all data points are considered, without any restriction on the keys.

Use signDomain to control which sign of the value coordinates should be considered. This is relevant e.g. for logarithmic plots which can mathematically only display one sign domain at a time.

Zobacz również
keyRange

Definicja w linii 3083 pliku qcustomplot.h.

Dokumentacja przyjaciół i funkcji związanych

◆ qcpLessThanSortKey()

template<class DataType >
bool qcpLessThanSortKey ( const DataType &  a,
const DataType &  b 
)
related

Returns whether the sort key of a is less than the sort key of b.

Zobacz również
QCPDataContainer::sort

Definicja w linii 2409 pliku qcustomplot.h.

Dokumentacja atrybutów składowych

◆ mAutoSqueeze

template<class DataType >
bool QCPDataContainer< DataType >::mAutoSqueeze
protected

Definicja w linii 2456 pliku qcustomplot.h.

◆ mData

template<class DataType >
QVector<DataType> QCPDataContainer< DataType >::mData
protected

Definicja w linii 2459 pliku qcustomplot.h.

◆ mPreallocIteration

template<class DataType >
int QCPDataContainer< DataType >::mPreallocIteration
protected

Definicja w linii 2461 pliku qcustomplot.h.

◆ mPreallocSize

template<class DataType >
int QCPDataContainer< DataType >::mPreallocSize
protected

Definicja w linii 2460 pliku qcustomplot.h.


Dokumentacja dla tej klasy została wygenerowana z pliku: