iCub-main
|
A plottable representing a two-dimensional color map in a plot. More...
#include <qcustomplot.h>
Signals | |
void | dataRangeChanged (QCPRange newRange) |
This signal is emitted when the data range changes. More... | |
void | dataScaleTypeChanged (QCPAxis::ScaleType scaleType) |
This signal is emitted when the data scale type changes. More... | |
void | gradientChanged (QCPColorGradient newGradient) |
This signal is emitted when the gradient changes. More... | |
Signals inherited from QCPAbstractPlottable | |
void | selectionChanged (bool selected) |
This signal is emitted when the selection state of this plottable has changed, either by user interaction or by a direct call to setSelected. More... | |
void | selectableChanged (bool selectable) |
This signal is emitted when the selectability of this plottable has changed. More... | |
Signals inherited from QCPLayerable | |
void | layerChanged (QCPLayer *newLayer) |
This signal is emitted when the layer of this layerable changes, i.e. More... | |
Public Member Functions | |
QCPColorMap (QCPAxis *keyAxis, QCPAxis *valueAxis) | |
Constructs a color map with the specified keyAxis and valueAxis. More... | |
virtual | ~QCPColorMap () |
QCPColorMapData * | data () const |
Returns a pointer to the internal data storage of type QCPColorMapData. More... | |
QCPRange | dataRange () const |
QCPAxis::ScaleType | dataScaleType () const |
bool | interpolate () const |
bool | tightBoundary () const |
QCPColorGradient | gradient () const |
QCPColorScale * | colorScale () const |
void | setData (QCPColorMapData *data, bool copy=false) |
Replaces the current data with the provided data. More... | |
Q_SLOT void | setDataRange (const QCPRange &dataRange) |
Sets the data range of this color map to dataRange. More... | |
Q_SLOT void | setDataScaleType (QCPAxis::ScaleType scaleType) |
Sets whether the data is correlated with the color gradient linearly or logarithmically. More... | |
Q_SLOT void | setGradient (const QCPColorGradient &gradient) |
Sets the color gradient that is used to represent the data. More... | |
void | setInterpolate (bool enabled) |
Sets whether the color map image shall use bicubic interpolation when displaying the color map shrinked or expanded, and not at a 1:1 pixel-to-data scale. More... | |
void | setTightBoundary (bool enabled) |
Sets whether the outer most data rows and columns are clipped to the specified key and value range (see QCPColorMapData::setKeyRange, QCPColorMapData::setValueRange). More... | |
void | setColorScale (QCPColorScale *colorScale) |
Associates the color scale colorScale with this color map. More... | |
void | rescaleDataRange (bool recalculateDataBounds=false) |
Sets the data range (setDataRange) to span the minimum and maximum values that occur in the current data set. More... | |
Q_SLOT void | updateLegendIcon (Qt::TransformationMode transformMode=Qt::SmoothTransformation, const QSize &thumbSize=QSize(32, 18)) |
Takes the current appearance of the color map and updates the legend icon, which is used to represent this color map in the legend (see QCPLegend). More... | |
virtual void | clearData () |
Clears the colormap data by calling QCPColorMapData::clear() on the internal data. More... | |
virtual double | selectTest (const QPointF &pos, bool onlySelectable, QVariant *details=0) const |
This function is used to decide whether a click hits a layerable object or not. More... | |
Public Member Functions inherited from QCPAbstractPlottable | |
QCPAbstractPlottable (QCPAxis *keyAxis, QCPAxis *valueAxis) | |
Constructs an abstract plottable which uses keyAxis as its key axis ("x") and valueAxis as its value axis ("y"). More... | |
QString | name () const |
bool | antialiasedFill () const |
bool | antialiasedScatters () const |
bool | antialiasedErrorBars () const |
QPen | pen () const |
QPen | selectedPen () const |
QBrush | brush () const |
QBrush | selectedBrush () const |
QCPAxis * | keyAxis () const |
QCPAxis * | valueAxis () const |
bool | selectable () const |
bool | selected () const |
void | setName (const QString &name) |
The name is the textual representation of this plottable as it is displayed in the legend (QCPLegend). More... | |
void | setAntialiasedFill (bool enabled) |
Sets whether fills of this plottable is drawn antialiased or not. More... | |
void | setAntialiasedScatters (bool enabled) |
Sets whether the scatter symbols of this plottable are drawn antialiased or not. More... | |
void | setAntialiasedErrorBars (bool enabled) |
Sets whether the error bars of this plottable are drawn antialiased or not. More... | |
void | setPen (const QPen &pen) |
The pen is used to draw basic lines that make up the plottable representation in the plot. More... | |
void | setSelectedPen (const QPen &pen) |
When the plottable is selected, this pen is used to draw basic lines instead of the normal pen set via setPen. More... | |
void | setBrush (const QBrush &brush) |
The brush is used to draw basic fills of the plottable representation in the plot. More... | |
void | setSelectedBrush (const QBrush &brush) |
When the plottable is selected, this brush is used to draw fills instead of the normal brush set via setBrush. More... | |
void | setKeyAxis (QCPAxis *axis) |
The key axis of a plottable can be set to any axis of a QCustomPlot, as long as it is orthogonal to the plottable's value axis. More... | |
void | setValueAxis (QCPAxis *axis) |
The value axis of a plottable can be set to any axis of a QCustomPlot, as long as it is orthogonal to the plottable's key axis. More... | |
Q_SLOT void | setSelectable (bool selectable) |
Sets whether the user can (de-)select this plottable by clicking on the QCustomPlot surface. More... | |
Q_SLOT void | setSelected (bool selected) |
Sets whether this plottable is selected or not. More... | |
virtual bool | addToLegend () |
Adds this plottable to the legend of the parent QCustomPlot (QCustomPlot::legend). More... | |
virtual bool | removeFromLegend () const |
Removes the plottable from the legend of the parent QCustomPlot. More... | |
void | rescaleAxes (bool onlyEnlarge=false) const |
Rescales the key and value axes associated with this plottable to contain all displayed data, so the whole plottable is visible. More... | |
void | rescaleKeyAxis (bool onlyEnlarge=false) const |
Rescales the key axis of the plottable so the whole plottable is visible. More... | |
void | rescaleValueAxis (bool onlyEnlarge=false) const |
Rescales the value axis of the plottable so the whole plottable is visible. More... | |
Public Member Functions inherited from QCPLayerable | |
QCPLayerable (QCustomPlot *plot, QString targetLayer="", QCPLayerable *parentLayerable=0) | |
Creates a new QCPLayerable instance. More... | |
~QCPLayerable () | |
bool | visible () const |
QCustomPlot * | parentPlot () const |
QCPLayerable * | parentLayerable () const |
Returns the parent layerable of this layerable. More... | |
QCPLayer * | layer () const |
bool | antialiased () const |
void | setVisible (bool on) |
Sets the visibility of this layerable object. More... | |
Q_SLOT bool | setLayer (QCPLayer *layer) |
Sets the layer of this layerable object. More... | |
bool | setLayer (const QString &layerName) |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. Sets the layer of this layerable object by name. More... | |
void | setAntialiased (bool enabled) |
Sets whether this object will be drawn antialiased or not. More... | |
bool | realVisibility () const |
Returns whether this layerable is visible, taking the visibility of the layerable parent and the visibility of the layer this layerable is on into account. More... | |
Protected Member Functions | |
virtual void | updateMapImage () |
virtual void | draw (QCPPainter *painter) |
virtual void | drawLegendIcon (QCPPainter *painter, const QRectF &rect) const |
virtual QCPRange | getKeyRange (bool &foundRange, SignDomain inSignDomain=sdBoth) const |
virtual QCPRange | getValueRange (bool &foundRange, SignDomain inSignDomain=sdBoth) const |
Protected Member Functions inherited from QCPAbstractPlottable | |
virtual QRect | clipRect () const |
virtual QCP::Interaction | selectionCategory () const |
void | applyDefaultAntialiasingHint (QCPPainter *painter) const |
virtual void | selectEvent (QMouseEvent *event, bool additive, const QVariant &details, bool *selectionStateChanged) |
virtual void | deselectEvent (bool *selectionStateChanged) |
void | coordsToPixels (double key, double value, double &x, double &y) const |
const QPointF | coordsToPixels (double key, double value) const |
void | pixelsToCoords (double x, double y, double &key, double &value) const |
void | pixelsToCoords (const QPointF &pixelPos, double &key, double &value) const |
QPen | mainPen () const |
QBrush | mainBrush () const |
void | applyFillAntialiasingHint (QCPPainter *painter) const |
void | applyScattersAntialiasingHint (QCPPainter *painter) const |
void | applyErrorBarsAntialiasingHint (QCPPainter *painter) const |
double | distSqrToLine (const QPointF &start, const QPointF &end, const QPointF &point) const |
Protected Member Functions inherited from QCPLayerable | |
virtual void | parentPlotInitialized (QCustomPlot *parentPlot) |
void | initializeParentPlot (QCustomPlot *parentPlot) |
void | setParentLayerable (QCPLayerable *parentLayerable) |
bool | moveToLayer (QCPLayer *layer, bool prepend) |
void | applyAntialiasingHint (QCPPainter *painter, bool localAntialiased, QCP::AntialiasedElement overrideElement) const |
Protected Attributes | |
QCPRange | mDataRange |
QCPAxis::ScaleType | mDataScaleType |
QCPColorMapData * | mMapData |
QCPColorGradient | mGradient |
bool | mInterpolate |
bool | mTightBoundary |
QPointer< QCPColorScale > | mColorScale |
QImage | mMapImage |
QPixmap | mLegendIcon |
bool | mMapImageInvalidated |
Protected Attributes inherited from QCPAbstractPlottable | |
QString | mName |
bool | mAntialiasedFill |
bool | mAntialiasedScatters |
bool | mAntialiasedErrorBars |
QPen | mPen |
QPen | mSelectedPen |
QBrush | mBrush |
QBrush | mSelectedBrush |
QPointer< QCPAxis > | mKeyAxis |
QPointer< QCPAxis > | mValueAxis |
bool | mSelectable |
bool | mSelected |
Protected Attributes inherited from QCPLayerable | |
bool | mVisible |
QCustomPlot * | mParentPlot |
QPointer< QCPLayerable > | mParentLayerable |
QCPLayer * | mLayer |
bool | mAntialiased |
Friends | |
class | QCustomPlot |
class | QCPLegend |
Additional Inherited Members | |
Protected Types inherited from QCPAbstractPlottable | |
enum | SignDomain { sdNegative , sdBoth , sdPositive } |
Represents negative and positive sign domain for passing to getKeyRange and getValueRange. More... | |
A plottable representing a two-dimensional color map in a plot.
The data is stored in the class QCPColorMapData, which can be accessed via the data() method.
A color map has three dimensions to represent a data point: The key dimension, the value dimension and the data dimension. As with other plottables such as graphs, key and value correspond to two orthogonal axes on the QCustomPlot surface that you specify in the QColorMap constructor. The data dimension however is encoded as the color of the point at (key, value).
Set the number of points (or cells) in the key/value dimension via QCPColorMapData::setSize. The plot coordinate range over which these points will be displayed is specified via QCPColorMapData::setRange. The first cell will be centered on the lower range boundary and the last cell will be centered on the upper range boundary. The data can be set by either accessing the cells directly with QCPColorMapData::setCell or by addressing the cells via their plot coordinates with QCPColorMapData::setData. If possible, you should prefer setCell, since it doesn't need to do any coordinate transformation and thus performs a bit better.
The cell with index (0, 0) is at the bottom left, if the color map uses normal (i.e. not reversed) key and value axes.
To show the user which colors correspond to which data values, a QCPColorScale is typically placed to the right of the axis rect. See the documentation there for details on how to add and use a color scale.
The central part of the appearance is the color gradient, which can be specified via setGradient. See the documentation of QCPColorGradient for details on configuring a color gradient.
The data range that is mapped to the colors of the gradient can be specified with setDataRange. To make the data range encompass the whole data set minimum to maximum, call rescaleDataRange.
Like all data representing objects in QCustomPlot, the QCPColorMap is a plottable (QCPAbstractPlottable). So the plottable-interface of QCustomPlot applies (QCustomPlot::plottable, QCustomPlot::addPlottable, QCustomPlot::removePlottable, etc.)
Usually, you first create an instance:
add it to the customPlot with QCustomPlot::addPlottable:
and then modify the properties of the newly created color map, e.g.:
Definition at line 2928 of file qcustomplot.h.
Constructs a color map with the specified keyAxis and valueAxis.
The constructed QCPColorMap can be added to the plot with QCustomPlot::addPlottable, QCustomPlot then takes ownership of the color map.
Definition at line 18905 of file qcustomplot.cpp.
|
virtual |
Definition at line 18915 of file qcustomplot.cpp.
|
virtual |
Clears the colormap data by calling QCPColorMapData::clear() on the internal data.
This also resizes the map to 0x0 cells.
Implements QCPAbstractPlottable.
Definition at line 19125 of file qcustomplot.cpp.
|
inline |
Definition at line 2950 of file qcustomplot.h.
|
inline |
Returns a pointer to the internal data storage of type QCPColorMapData.
Access this to modify data points (cells) and the color map key/value range.
Definition at line 2944 of file qcustomplot.h.
|
inline |
Definition at line 2945 of file qcustomplot.h.
|
signal |
This signal is emitted when the data range changes.
|
inline |
Definition at line 2946 of file qcustomplot.h.
|
signal |
This signal is emitted when the data scale type changes.
|
protectedvirtual |
Implements QCPAbstractPlottable.
Definition at line 19197 of file qcustomplot.cpp.
|
protectedvirtual |
Implements QCPAbstractPlottable.
Definition at line 19233 of file qcustomplot.cpp.
|
protectedvirtual |
Implements QCPAbstractPlottable.
Definition at line 19253 of file qcustomplot.cpp.
|
protectedvirtual |
Implements QCPAbstractPlottable.
Definition at line 19275 of file qcustomplot.cpp.
|
inline |
Definition at line 2949 of file qcustomplot.h.
|
signal |
This signal is emitted when the gradient changes.
|
inline |
Definition at line 2947 of file qcustomplot.h.
void QCPColorMap::rescaleDataRange | ( | bool | recalculateDataBounds = false | ) |
Sets the data range (setDataRange) to span the minimum and maximum values that occur in the current data set.
This corresponds to the rescaleKeyAxis or rescaleValueAxis methods, only for the third data dimension of the color map.
The minimum and maximum values of the data set are buffered in the internal QCPColorMapData instance (data). As data is updated via its QCPColorMapData::setCell or QCPColorMapData::setData, the buffered minimum and maximum values are updated, too. For performance reasons, however, they are only updated in an expanding fashion. So the buffered maximum can only increase and the buffered minimum can only decrease. In consequence, changes to the data that actually lower the maximum of the data set (by overwriting the cell holding the current maximum with a smaller value), aren't recognized and the buffered maximum overestimates the true maximum of the data set. The same happens for the buffered minimum. To recalculate the true minimum and maximum by explicitly looking at each cell, the method QCPColorMapData::recalculateDataBounds can be used. For convenience, setting the parameter recalculateDataBounds calls this method before setting the data range to the buffered minimum and maximum.
Definition at line 19087 of file qcustomplot.cpp.
|
virtual |
This function is used to decide whether a click hits a layerable object or not.
pos is a point in pixel coordinates on the QCustomPlot surface. This function returns the shortest pixel distance of this point to the object. If the object is either invisible or the distance couldn't be determined, -1.0 is returned. Further, if onlySelectable is true and the object is not selectable, -1.0 is returned, too.
If the item is represented not by single lines but by an area like QCPItemRect or QCPItemText, a click inside the area returns a constant value greater zero (typically the selectionTolerance of the parent QCustomPlot multiplied by 0.99). If the click lies outside the area, this function returns -1.0.
Providing a constant value for area objects allows selecting line objects even when they are obscured by such area objects, by clicking close to the lines (i.e. closer than 0.99*selectionTolerance).
The actual setting of the selection state is not done by this function. This is handled by the parent QCustomPlot when the mouseReleaseEvent occurs, and the finally selected object is notified via the selectEvent/deselectEvent methods.
details is an optional output parameter. Every layerable subclass may place any information in details. This information will be passed to selectEvent when the parent QCustomPlot decides on the basis of this selectTest call, that the object was successfully selected. The subsequent call to selectEvent will carry the details. This is useful for multi-part objects (like QCPAxis). This way, a possibly complex calculation to decide which part was clicked is only done once in selectTest. The result (i.e. the actually clicked part) can then be placed in details. So in the subsequent selectEvent, the decision which part was selected doesn't have to be done a second time for a single selection operation.
You may pass 0 as details to indicate that you are not interested in those selection details.
Implements QCPAbstractPlottable.
Definition at line 19131 of file qcustomplot.cpp.
void QCPColorMap::setColorScale | ( | QCPColorScale * | colorScale | ) |
Associates the color scale colorScale with this color map.
This means that both the color scale and the color map synchronize their gradient, data range and data scale type (setGradient, setDataRange, setDataScaleType). Multiple color maps can be associated with one single color scale. This causes the color maps to also synchronize those properties, via the mutual color scale.
This function causes the color map to adopt the current color gradient, data range and data scale type of colorScale. After this call, you may change these properties at either the color map or the color scale, and the setting will be applied to both.
Pass 0 as colorScale to disconnect the color scale from this color map again.
Definition at line 19041 of file qcustomplot.cpp.
void QCPColorMap::setData | ( | QCPColorMapData * | data, |
bool | copy = false |
||
) |
Replaces the current data with the provided data.
If copy is set to true, the data object will only be copied. if false, the color map takes ownership of the passed data and replaces the internal data pointer with it. This is significantly faster than copying for large datasets.
Definition at line 18927 of file qcustomplot.cpp.
void QCPColorMap::setDataRange | ( | const QCPRange & | dataRange | ) |
Sets the data range of this color map to dataRange.
The data range defines which data values are mapped to the color gradient.
To make the data range span the full range of the data set, use rescaleDataRange.
Definition at line 18948 of file qcustomplot.cpp.
void QCPColorMap::setDataScaleType | ( | QCPAxis::ScaleType | scaleType | ) |
Sets whether the data is correlated with the color gradient linearly or logarithmically.
Definition at line 18967 of file qcustomplot.cpp.
void QCPColorMap::setGradient | ( | const QCPColorGradient & | gradient | ) |
Sets the color gradient that is used to represent the data.
For more details on how to create an own gradient or use one of the preset gradients, see QCPColorGradient.
The colors defined by the gradient will be used to represent data values in the currently set data range, see setDataRange. Data points that are outside this data range will either be colored uniformly with the respective gradient boundary color, or the gradient will repeat, depending on QCPColorGradient::setPeriodic.
Definition at line 18990 of file qcustomplot.cpp.
void QCPColorMap::setInterpolate | ( | bool | enabled | ) |
Sets whether the color map image shall use bicubic interpolation when displaying the color map shrinked or expanded, and not at a 1:1 pixel-to-data scale.
Definition at line 19006 of file qcustomplot.cpp.
void QCPColorMap::setTightBoundary | ( | bool | enabled | ) |
Sets whether the outer most data rows and columns are clipped to the specified key and value range (see QCPColorMapData::setKeyRange, QCPColorMapData::setValueRange).
if enabled is set to false, the data points at the border of the color map are drawn with the same width and height as all other data points. Since the data points are represented by rectangles of one color centered on the data coordinate, this means that the shown color map extends by half a data point over the specified key/value range in each direction.
Definition at line 19022 of file qcustomplot.cpp.
|
inline |
Definition at line 2948 of file qcustomplot.h.
void QCPColorMap::updateLegendIcon | ( | Qt::TransformationMode | transformMode = Qt::SmoothTransformation , |
const QSize & | thumbSize = QSize(32, 18) |
||
) |
Takes the current appearance of the color map and updates the legend icon, which is used to represent this color map in the legend (see QCPLegend).
The transformMode specifies whether the rescaling is done by a faster, low quality image scaling algorithm (Qt::FastTransformation) or by a slower, higher quality algorithm (Qt::SmoothTransformation).
The current color map appearance is scaled down to thumbSize. Ideally, this should be equal to the size of the legend icon (see QCPLegend::setIconSize). If it isn't exactly the configured legend icon size, the thumb will be rescaled during drawing of the legend item.
Definition at line 19108 of file qcustomplot.cpp.
|
protectedvirtual |
Definition at line 19157 of file qcustomplot.cpp.
|
friend |
Definition at line 2998 of file qcustomplot.h.
|
friend |
Definition at line 2997 of file qcustomplot.h.
|
protected |
Definition at line 2982 of file qcustomplot.h.
|
protected |
Definition at line 2976 of file qcustomplot.h.
|
protected |
Definition at line 2977 of file qcustomplot.h.
|
protected |
Definition at line 2979 of file qcustomplot.h.
|
protected |
Definition at line 2980 of file qcustomplot.h.
|
protected |
Definition at line 2985 of file qcustomplot.h.
|
protected |
Definition at line 2978 of file qcustomplot.h.
|
protected |
Definition at line 2984 of file qcustomplot.h.
|
protected |
Definition at line 2986 of file qcustomplot.h.
|
protected |
Definition at line 2981 of file qcustomplot.h.