QCPColorMapData
Public Member Functions | |
QCPColorMapData (const QCPColorMapData &other) | |
QCPColorMapData (int keySize, int valueSize, const QCPRange &keyRange, const QCPRange &valueRange) | |
unsigned char | alpha (int keyIndex, int valueIndex) |
double | cell (int keyIndex, int valueIndex) |
void | cellToCoord (int keyIndex, int valueIndex, double *key, double *value) const |
void | clear () |
void | clearAlpha () |
void | coordToCell (double key, double value, int *keyIndex, int *valueIndex) const |
double | data (double key, double value) |
QCPRange | dataBounds () const |
void | fill (double z) |
void | fillAlpha (unsigned char alpha) |
bool | isEmpty () const |
QCPRange | keyRange () const |
int | keySize () const |
QCPColorMapData & | operator= (const QCPColorMapData &other) |
void | recalculateDataBounds () |
void | setAlpha (int keyIndex, int valueIndex, unsigned char alpha) |
void | setCell (int keyIndex, int valueIndex, double z) |
void | setData (double key, double value, double z) |
void | setKeyRange (const QCPRange &keyRange) |
void | setKeySize (int keySize) |
void | setRange (const QCPRange &keyRange, const QCPRange &valueRange) |
void | setSize (int keySize, int valueSize) |
void | setValueRange (const QCPRange &valueRange) |
void | setValueSize (int valueSize) |
QCPRange | valueRange () const |
int | valueSize () const |
Protected Member Functions | |
bool | createAlpha (bool initializeOpaque=true) |
Protected Attributes | |
unsigned char * | mAlpha |
double * | mData |
QCPRange | mDataBounds |
bool | mDataModified |
bool | mIsEmpty |
QCPRange | mKeyRange |
int | mKeySize |
QCPRange | mValueRange |
int | mValueSize |
Detailed Description
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.
A QCPColorMapData also holds an on-demand two-dimensional array of alpha values which (if allocated) has the same size as the data map. It can be accessed via setAlpha, fillAlpha and clearAlpha. The memory for the alpha map is only allocated if needed, i.e. on the first call of setAlpha. clearAlpha restores full opacity and frees the alpha map.
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 6022 of file qcustomplot.h.
Constructor & Destructor Documentation
◆ QCPColorMapData() [1/2]
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.
- See also
- setSize, setKeySize, setValueSize, setRange, setKeyRange, setValueRange
Definition at line 25850 of file qcustomplot.cpp.
◆ ~QCPColorMapData()
QCPColorMapData::~QCPColorMapData | ( | ) |
Definition at line 25864 of file qcustomplot.cpp.
◆ QCPColorMapData() [2/2]
QCPColorMapData::QCPColorMapData | ( | const QCPColorMapData & | other | ) |
Constructs a new QCPColorMapData instance copying the data and range of other.
Definition at line 25873 of file qcustomplot.cpp.
Member Function Documentation
◆ alpha()
unsigned char QCPColorMapData::alpha | ( | int | keyIndex, |
int | valueIndex ) |
Returns the alpha map value of the cell with the indices keyIndex and valueIndex.
If this color map data doesn't have an alpha map (because setAlpha was never called after creation or after a call to clearAlpha), returns 255, which corresponds to full opacity.
- See also
- setAlpha
Definition at line 25940 of file qcustomplot.cpp.
◆ cell()
double QCPColorMapData::cell | ( | int | keyIndex, |
int | valueIndex ) |
Definition at line 25924 of file qcustomplot.cpp.
◆ cellToCoord()
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 nullptr
as key or value.
- Note
- The QCPColorMap always displays the data at equal key/value intervals, even if the key or value axis is set to a logarithmic scaling. If you want to use QCPColorMap with logarithmic axes, you shouldn't use the QCPColorMapData::cellToCoord method as it uses a linear transformation to determine the cell index.
- See also
- coordToCell, QCPAxis::pixelToCoord
Definition at line 26272 of file qcustomplot.cpp.
◆ clear()
void QCPColorMapData::clear | ( | ) |
Frees the internal data memory.
This is equivalent to calling setSize(0, 0).
Definition at line 26184 of file qcustomplot.cpp.
◆ clearAlpha()
void QCPColorMapData::clearAlpha | ( | ) |
Frees the internal alpha map. The color map will have full opacity again.
Definition at line 26192 of file qcustomplot.cpp.
◆ coordToCell()
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 nullptr
as valueIndex or keyIndex.
- Note
- The QCPColorMap always displays the data at equal key/value intervals, even if the key or value axis is set to a logarithmic scaling. If you want to use QCPColorMap with logarithmic axes, you shouldn't use the QCPColorMapData::coordToCell method as it uses a linear transformation to determine the cell index.
- See also
- cellToCoord, QCPAxis::coordToPixel
Definition at line 26249 of file qcustomplot.cpp.
◆ createAlpha()
|
protected |
Allocates the internal alpha map with the current data map key/value size and, if initializeOpaque is true, initializes all values to 255. If initializeOpaque is false, the values are not initialized at all. In this case, the alpha map should be initialized manually, e.g. with fillAlpha.
If an alpha map exists already, it is deleted first. If this color map is empty (has either key or value size zero, see isEmpty), the alpha map is cleared.
The return value indicates the existence of the alpha map after the call. So this method returns true if the data map isn't empty and an alpha map was successfully allocated.
Definition at line 26293 of file qcustomplot.cpp.
◆ data()
double QCPColorMapData::data | ( | double | key, |
double | value ) |
Definition at line 25913 of file qcustomplot.cpp.
◆ dataBounds()
|
inline |
Definition at line 6035 of file qcustomplot.h.
◆ fill()
void QCPColorMapData::fill | ( | double | z | ) |
Sets all cells to the value z.
Definition at line 26205 of file qcustomplot.cpp.
◆ fillAlpha()
void QCPColorMapData::fillAlpha | ( | unsigned char | alpha | ) |
Sets the opacity of all color map cells to alpha. A value of 0 for alpha results in a fully transparent color map, and a value of 255 results in a fully opaque color map.
If you wish to restore opacity to 100% and free any used memory for the alpha map, rather use clearAlpha.
- See also
- setAlpha
Definition at line 26222 of file qcustomplot.cpp.
◆ isEmpty()
|
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 6057 of file qcustomplot.h.
◆ keyRange()
|
inline |
Definition at line 6033 of file qcustomplot.h.
◆ keySize()
|
inline |
Definition at line 6031 of file qcustomplot.h.
◆ operator=()
QCPColorMapData & QCPColorMapData::operator= | ( | const QCPColorMapData & | other | ) |
Overwrites this color map data instance with the data stored in other. The alpha map state is transferred, too.
Definition at line 25888 of file qcustomplot.cpp.
◆ recalculateDataBounds()
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 26160 of file qcustomplot.cpp.
◆ setAlpha()
void QCPColorMapData::setAlpha | ( | int | keyIndex, |
int | valueIndex, | ||
unsigned char | alpha ) |
Sets the alpha of the color map cell given by keyIndex and valueIndex to alpha. A value of 0 for alpha results in a fully transparent cell, and a value of 255 results in a fully opaque cell.
If an alpha map doesn't exist yet for this color map data, it will be created here. If you wish to restore full opacity and free any allocated memory of the alpha map, call clearAlpha.
Note that the cell-wise alpha which can be configured here is independent of any alpha configured in the color map's gradient (QCPColorGradient). If a cell is affected both by the cell-wise and gradient alpha, the alpha values will be blended accordingly during rendering of the color map.
- See also
- fillAlpha, clearAlpha
Definition at line 26134 of file qcustomplot.cpp.
◆ setCell()
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 26105 of file qcustomplot.cpp.
◆ setData()
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.
- Note
- The QCPColorMap always displays the data at equal key/value intervals, even if the key or value axis is set to a logarithmic scaling. If you want to use QCPColorMap with logarithmic axes, you shouldn't use the QCPColorMapData::setData method as it uses a linear transformation to determine the cell index. Rather directly access the cell index with QCPColorMapData::setCell.
Definition at line 26079 of file qcustomplot.cpp.
◆ setKeyRange()
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.
- See also
- setRange, setValueRange, setSize
Definition at line 26047 of file qcustomplot.cpp.
◆ setKeySize()
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.
- See also
- setKeyRange, setSize, setValueSize
Definition at line 26001 of file qcustomplot.cpp.
◆ setRange()
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.
- See also
- setSize
Definition at line 26031 of file qcustomplot.cpp.
◆ setSize()
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.
- See also
- setRange, setKeySize, setValueSize
Definition at line 25960 of file qcustomplot.cpp.
◆ setValueRange()
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.
- See also
- setRange, setKeyRange, setSize
Definition at line 26062 of file qcustomplot.cpp.
◆ setValueSize()
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.
- See also
- setValueRange, setSize, setKeySize
Definition at line 26016 of file qcustomplot.cpp.
◆ valueRange()
|
inline |
Definition at line 6034 of file qcustomplot.h.
◆ valueSize()
|
inline |
Definition at line 6032 of file qcustomplot.h.
Member Data Documentation
◆ mAlpha
|
protected |
Definition at line 6069 of file qcustomplot.h.
◆ mData
|
protected |
Definition at line 6068 of file qcustomplot.h.
◆ mDataBounds
|
protected |
Definition at line 6070 of file qcustomplot.h.
◆ mDataModified
|
protected |
Definition at line 6071 of file qcustomplot.h.
◆ mIsEmpty
|
protected |
Definition at line 6065 of file qcustomplot.h.
◆ mKeyRange
|
protected |
Definition at line 6064 of file qcustomplot.h.
◆ mKeySize
|
protected |
Definition at line 6063 of file qcustomplot.h.
◆ mValueRange
|
protected |
Definition at line 6064 of file qcustomplot.h.
◆ mValueSize
|
protected |
Definition at line 6063 of file qcustomplot.h.
The documentation for this class was generated from the following files:
Documentation copyright © 1996-2024 The KDE developers.
Generated on Sat Dec 21 2024 17:04:48 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006
KDE's Doxygen guidelines are available online.