iCub-main
|
Holds the two-dimensional data of a QCPColorMap plottable. More...
#include <qcustomplot.h>
Public Member Functions | |
QCPColorMapData (int keySize, int valueSize, const QCPRange &keyRange, const QCPRange &valueRange) | |
Constructs a new QCPColorMapData instance. | |
~QCPColorMapData () | |
QCPColorMapData (const QCPColorMapData &other) | |
Constructs a new QCPColorMapData instance copying the data and range of other. | |
QCPColorMapData & | operator= (const QCPColorMapData &other) |
Overwrites this color map data instance with the data stored in other. | |
int | keySize () const |
int | valueSize () const |
QCPRange | keyRange () const |
QCPRange | valueRange () const |
QCPRange | dataBounds () const |
double | data (double key, double value) |
double | cell (int keyIndex, int valueIndex) |
void | setSize (int keySize, int valueSize) |
Resizes the data array to have keySize cells in the key dimension and valueSize cells in the value dimension. | |
void | setKeySize (int keySize) |
Resizes the data array to have keySize cells in the key dimension. | |
void | setValueSize (int valueSize) |
Resizes the data array to have valueSize cells in the value dimension. | |
void | setRange (const QCPRange &keyRange, const QCPRange &valueRange) |
Sets the coordinate ranges the data shall be distributed over. | |
void | setKeyRange (const QCPRange &keyRange) |
Sets the coordinate range the data shall be distributed over in the key dimension. | |
void | setValueRange (const QCPRange &valueRange) |
Sets the coordinate range the data shall be distributed over in the value dimension. | |
void | setData (double key, double value, double z) |
Sets the data of the cell, which lies at the plot coordinates given by key and value, to z. | |
void | setCell (int keyIndex, int valueIndex, double z) |
Sets the data of the cell with indices keyIndex and valueIndex to z. | |
void | recalculateDataBounds () |
Goes through the data and updates the buffered minimum and maximum data values. | |
void | clear () |
Frees the internal data memory. | |
void | fill (double z) |
Sets all cells to the value z. | |
bool | isEmpty () const |
Returns whether this instance carries no data. | |
void | coordToCell (double key, double value, int *keyIndex, int *valueIndex) const |
Transforms plot coordinates given by key and value to cell indices of this QCPColorMapData instance. | |
void | cellToCoord (int keyIndex, int valueIndex, double *key, double *value) const |
Transforms cell indices given by keyIndex and valueIndex to cell indices of this QCPColorMapData instance. | |
Protected Attributes | |
int | mKeySize |
int | mValueSize |
QCPRange | mKeyRange |
QCPRange | mValueRange |
bool | mIsEmpty |
double * | mData |
QCPRange | mDataBounds |
bool | mDataModified |
Friends | |
class | QCPColorMap |
Holds the two-dimensional data of a QCPColorMap plottable.
This class is a data storage for QCPColorMap. It holds a two-dimensional array, which QCPColorMap then displays as a 2D image in the plot, where the array values are represented by a color, depending on the value.
The size of the array can be controlled via setSize (or setKeySize, setValueSize). Which plot coordinates these cells correspond to can be configured with setRange (or setKeyRange, setValueRange).
The data cells can be accessed in two ways: They can be directly addressed by an integer index with setCell. This is the fastest method. Alternatively, they can be addressed by their plot coordinate with setData. plot coordinate to cell index transformations and vice versa are provided by the functions coordToCell and cellToCoord.
This class also buffers the minimum and maximum values that are in the data set, to provide QCPColorMap::rescaleDataRange with the necessary information quickly. Setting a cell to a value that is greater than the current maximum increases this maximum to the new value. However, setting the cell that currently holds the maximum value to a smaller value doesn't decrease the maximum again, because finding the true new maximum would require going through the entire data array, which might be time consuming. The same holds for the data minimum. This functionality is given by recalculateDataBounds, such that you can decide when it is sensible to find the true current minimum and maximum. The method QCPColorMap::rescaleDataRange offers a convenience parameter recalculateDataBounds which may be set to true to automatically call recalculateDataBounds internally.
Definition at line 2879 of file qcustomplot.h.
QCPColorMapData::QCPColorMapData | ( | int | keySize, |
int | valueSize, | ||
const QCPRange & | keyRange, | ||
const QCPRange & | valueRange | ||
) |
Constructs a new QCPColorMapData instance.
The instance has keySize cells in the key direction and valueSize cells in the value direction. These cells will be displayed by the QCPColorMap at the coordinates keyRange and valueRange.
Definition at line 18462 of file qcustomplot.cpp.
QCPColorMapData::~QCPColorMapData | ( | ) |
Definition at line 18475 of file qcustomplot.cpp.
QCPColorMapData::QCPColorMapData | ( | const QCPColorMapData & | other | ) |
Constructs a new QCPColorMapData instance copying the data and range of other.
Definition at line 18484 of file qcustomplot.cpp.
double QCPColorMapData::cell | ( | int | keyIndex, |
int | valueIndex | ||
) |
Definition at line 18525 of file qcustomplot.cpp.
void QCPColorMapData::cellToCoord | ( | int | keyIndex, |
int | valueIndex, | ||
double * | key, | ||
double * | value | ||
) | const |
Transforms cell indices given by keyIndex and valueIndex to cell indices of this QCPColorMapData instance.
The resulting coordinates are returned via the output parameters key and value.
If you are only interested in a key or value coordinate, you may pass 0 as key or value.
Definition at line 18777 of file qcustomplot.cpp.
void QCPColorMapData::clear | ( | ) |
Frees the internal data memory.
This is equivalent to calling setSize(0, 0).
Definition at line 18731 of file qcustomplot.cpp.
void QCPColorMapData::coordToCell | ( | double | key, |
double | value, | ||
int * | keyIndex, | ||
int * | valueIndex | ||
) | const |
Transforms plot coordinates given by key and value to cell indices of this QCPColorMapData instance.
The resulting cell indices are returned via the output parameters keyIndex and valueIndex.
The retrieved key/value cell indices can then be used for example with setCell.
If you are only interested in a key or value index, you may pass 0 as valueIndex or keyIndex.
Definition at line 18759 of file qcustomplot.cpp.
double QCPColorMapData::data | ( | double | key, |
double | value | ||
) |
Definition at line 18514 of file qcustomplot.cpp.
|
inline |
Definition at line 2892 of file qcustomplot.h.
void QCPColorMapData::fill | ( | double | z | ) |
Sets all cells to the value z.
Definition at line 18739 of file qcustomplot.cpp.
|
inline |
Returns whether this instance carries no data.
This is equivalent to having a size where at least one of the dimensions is 0 (see setSize).
Definition at line 2910 of file qcustomplot.h.
|
inline |
Definition at line 2890 of file qcustomplot.h.
|
inline |
Definition at line 2888 of file qcustomplot.h.
QCPColorMapData & QCPColorMapData::operator= | ( | const QCPColorMapData & | other | ) |
Overwrites this color map data instance with the data stored in other.
Definition at line 18497 of file qcustomplot.cpp.
void QCPColorMapData::recalculateDataBounds | ( | ) |
Goes through the data and updates the buffered minimum and maximum data values.
Calling this method is only advised if you are about to call QCPColorMap::rescaleDataRange and can not guarantee that the cells holding the maximum or minimum data haven't been overwritten with a smaller or larger value respectively, since the buffered maximum/minimum values have been updated the last time. Why this is the case is explained in the class description (QCPColorMapData).
Note that the method QCPColorMap::rescaleDataRange provides a parameter recalculateDataBounds for convenience. Setting this to true will call this method for you, before doing the rescale.
Definition at line 18707 of file qcustomplot.cpp.
void QCPColorMapData::setCell | ( | int | keyIndex, |
int | valueIndex, | ||
double | z | ||
) |
Sets the data of the cell with indices keyIndex and valueIndex to z.
The indices enumerate the cells starting from zero, up to the map's size-1 in the respective dimension (see setSize).
In the standard plot configuration (horizontal key axis and vertical value axis, both not range-reversed), the cell with indices (0, 0) is in the bottom left corner and the cell with indices (keySize-1, valueSize-1) is in the top right corner of the color map.
Definition at line 18681 of file qcustomplot.cpp.
void QCPColorMapData::setData | ( | double | key, |
double | value, | ||
double | z | ||
) |
Sets the data of the cell, which lies at the plot coordinates given by key and value, to z.
Definition at line 18655 of file qcustomplot.cpp.
void QCPColorMapData::setKeyRange | ( | const QCPRange & | keyRange | ) |
Sets the coordinate range the data shall be distributed over in the key dimension.
Together with the value range, This defines the rectangular area covered by the color map in plot coordinates.
The outer cells will be centered on the range boundaries given to this function. For example, if the key size (setKeySize) is 3 and keyRange is set to QCPRange(2, 3)
there will be cells centered on the key coordinates 2, 2.5 and 3.
Definition at line 18629 of file qcustomplot.cpp.
void QCPColorMapData::setKeySize | ( | int | keySize | ) |
Resizes the data array to have keySize cells in the key dimension.
The current data is discarded and the map cells are set to 0, unless the map had already the requested size.
Setting keySize to zero frees the internal data array and isEmpty returns true.
Definition at line 18583 of file qcustomplot.cpp.
Sets the coordinate ranges the data shall be distributed over.
This defines the rectangular area covered by the color map in plot coordinates.
The outer cells will be centered on the range boundaries given to this function. For example, if the key size (setKeySize) is 3 and keyRange is set to QCPRange(2, 3)
there will be cells centered on the key coordinates 2, 2.5 and 3.
Definition at line 18613 of file qcustomplot.cpp.
void QCPColorMapData::setSize | ( | int | keySize, |
int | valueSize | ||
) |
Resizes the data array to have keySize cells in the key dimension and valueSize cells in the value dimension.
The current data is discarded and the map cells are set to 0, unless the map had already the requested size.
Setting at least one of keySize or valueSize to zero frees the internal data array and isEmpty returns true.
Definition at line 18545 of file qcustomplot.cpp.
void QCPColorMapData::setValueRange | ( | const QCPRange & | valueRange | ) |
Sets the coordinate range the data shall be distributed over in the value dimension.
Together with the key range, This defines the rectangular area covered by the color map in plot coordinates.
The outer cells will be centered on the range boundaries given to this function. For example, if the value size (setValueSize) is 3 and valueRange is set to QCPRange(2, 3)
there will be cells centered on the value coordinates 2, 2.5 and 3.
Definition at line 18644 of file qcustomplot.cpp.
void QCPColorMapData::setValueSize | ( | int | valueSize | ) |
Resizes the data array to have valueSize cells in the value dimension.
The current data is discarded and the map cells are set to 0, unless the map had already the requested size.
Setting valueSize to zero frees the internal data array and isEmpty returns true.
Definition at line 18598 of file qcustomplot.cpp.
|
inline |
Definition at line 2891 of file qcustomplot.h.
|
inline |
Definition at line 2889 of file qcustomplot.h.
|
friend |
Definition at line 2924 of file qcustomplot.h.
|
protected |
Definition at line 2920 of file qcustomplot.h.
|
protected |
Definition at line 2921 of file qcustomplot.h.
|
protected |
Definition at line 2922 of file qcustomplot.h.
|
protected |
Definition at line 2918 of file qcustomplot.h.
|
protected |
Definition at line 2917 of file qcustomplot.h.
|
protected |
Definition at line 2916 of file qcustomplot.h.
|
protected |
Definition at line 2917 of file qcustomplot.h.
|
protected |
Definition at line 2916 of file qcustomplot.h.