Class QAccelPlot::ColorBar¶
ClassList > QAccelPlot > ColorBar
A continuous key that shows how a series' Colormap maps values to colors.More...
#include <ColorBar.hpp>
Inherits the following classes: QQuickPaintedItem
Inheritance diagram¶
flowchart TB
classQAccelPlot_1_1ColorBar["QAccelPlot::ColorBar"]
external_base_classQAccelPlot_1_1ColorBar_1["QQuickPaintedItem"]
external_base_classQAccelPlot_1_1ColorBar_1 --> classQAccelPlot_1_1ColorBar
Public Properties¶
| Type | Name |
|---|---|
| property qreal | barThickness Thickness in pixels of the color strip across the ramp direction. Default: 12. |
| property Border * | border Outline inside the strip's edges, e.g. border.width: 2 . Default:Colors.dark.axisLine , width 1. |
| property bool | hovered Read-only: true while the mouse cursor is over the bar. Reported only whileinteractive is set. |
| property bool | interactive Whether dragging, the mouse wheel, and double-clicking change the colormap's value range. Default: false . |
| property QString | label Optional title drawn beside the tick labels. Default: empty. |
| property QColor | labelColor Color of the title. Default: Colors.dark.axisLine . |
| property QFont | labelFont Font of the title. Default: application default font. |
| property qreal | labelPadding Gap in pixels between the tick labels and the title. Default: 6. |
| property Qt::Orientation | orientation Direction of the ramp: Qt.Vertical orQt.Horizontal . Default:Qt.Vertical . |
| property ColormappedSeries * | series Series whose colormap and resolved value range are shown. Default: null. |
| property qreal | tickLabelWidth Width in pixels reserved for the tick labels of a vertical bar. Default: 16. |
| property AxisTicker * | ticker Read-only constant: tick appearance, count, and label formatter. |
| property qreal | zoomScaleFactor Fraction by which the value range is multiplied on each inward mouse-wheel step. Must be in (0, 1). Default: 0.9. |
Public Signals¶
| Type | Name |
|---|---|
| signal void | barThicknessChanged Emitted when the barThickness property changes. |
| signal void | hoveredChanged Emitted when the hovered property changes. |
| signal void | interactiveChanged Emitted when the interactive property changes. |
| signal void | labelChanged Emitted when the label property changes. |
| signal void | labelColorChanged Emitted when the labelColor property changes. |
| signal void | labelFontChanged Emitted when the labelFont property changes. |
| signal void | labelPaddingChanged Emitted when the labelPadding property changes. |
| signal void | orientationChanged Emitted when the orientation property changes. |
| signal void | seriesChanged Emitted when the series property changes. |
| signal void | tickLabelWidthChanged Emitted when the tickLabelWidth property changes. |
| signal void | zoomScaleFactorChanged Emitted when the zoomScaleFactor property changes. |
Public Functions¶
| Type | Name |
|---|---|
| ColorBar (QQuickItem * parent=nullptr) Constructs a ColorBar with the given__parent . |
|
| qreal | barThickness () const Returns the strip thickness in pixels. |
| Border * | border () const Returns the strip outline settings. The object is owned by the bar. |
| bool | hovered () const Returns true while the mouse cursor is over an interactive bar. |
| bool | interactive () const Returns whether the gestures that change the colormap's value range are enabled. |
| QString | label () const Returns the title. |
| QColor | labelColor () const Returns the title color. |
| QFont | labelFont () const Returns the title font. |
| qreal | labelPadding () const Returns the gap between the tick labels and the title in pixels. |
| Qt::Orientation | orientation () const Returns the ramp direction. |
| void | paint (QPainter * painter) override Paints the strip, ticks, tick labels, and title computed in updatePolish() . |
| qreal | pixelToValue (qreal pixel, qreal length) const Maps a pixel position along a strip of__length pixels back to a value. |
| Q_INVOKABLE void | rescaleToData () Unsets the colormap's min andmax , so the range is resolved from the data again. |
| ColormappedSeries * | series () const Returns the series whose colormap is shown, or nullptr . |
| void | setBarThickness (qreal thickness) Sets the strip thickness to thickness pixels. Negative values are clamped to 0. |
| void | setInteractive (bool interactive) Sets whether the gestures that change the colormap's value range are enabled to interactive . |
| void | setLabel (const QString & label) Sets the title to label . |
| void | setLabelColor (const QColor & color) Sets the title color to color . |
| void | setLabelFont (const QFont & font) Sets the title font to font . |
| void | setLabelPadding (qreal padding) Sets the gap between the tick labels and the title to padding pixels. Negative values are clamped to 0. |
| void | setOrientation (Qt::Orientation orientation) Sets the ramp direction to orientation . |
| void | setSeries (ColormappedSeries * series) Sets the series whose colormap is shown to series . |
| void | setTickLabelWidth (qreal width) Sets the width reserved for tick labels to width pixels. Negative values are clamped to 0. |
| void | setZoomScaleFactor (qreal factor) Sets the zoom scale factor to factor (clamped to the range (0, 1)). |
| qreal | tickLabelWidth () const Returns the width reserved for tick labels in pixels. |
| AxisTicker * | ticker () const Returns the tick configuration object. The object is owned by the color bar. |
| qreal | valueToPixel (qreal value, qreal length) const Maps value to a pixel position along a strip of__length pixels. |
| qreal | zoomScaleFactor () const Returns the zoom scale factor. |
Protected Functions¶
| Type | Name |
|---|---|
| void | geometryChange (const QRectF & newGeometry, const QRectF & oldGeometry) override Schedules a new layout when the item is resized. |
| void | hoverEnterEvent (QHoverEvent * event) override Marks the bar as hovered. |
| void | hoverLeaveEvent (QHoverEvent * event) override Clears the hovered state. |
| void | mouseDoubleClickEvent (QMouseEvent * event) override Calls rescaleToData() on a left-button double-click whileinteractive is set. |
| void | mouseMoveEvent (QMouseEvent * event) override Pans the value range by the distance dragged along the ramp. |
| void | mousePressEvent (QMouseEvent * event) override Starts panning the value range on a left-button press while interactive is set. |
| void | mouseReleaseEvent (QMouseEvent * event) override Ends panning on a left-button release. |
| void | mouseUngrabEvent () override Ends panning when the mouse grab is lost. |
| void | updatePolish () override Captures the colormap, formats tick labels, and lays out the bar on the GUI thread, ahead of paint() . |
| void | wheelEvent (QWheelEvent * event) override Zooms the value range around the value under the cursor while interactive is set. |
Detailed Description¶
Draws the color ramp of a PointCloud, HeatmapSeries, or BarSeries as a strip, with ticks and labels for the value range the series resolved (ColormappedSeries::dataValueMin and ColormappedSeries::dataValueMax). Ticks follow the colormap's logScale, so a log-scale colormap gets decade ticks. The bar redraws when the colormap, the resolved range, or the assigned colormap changes. Nothing is drawn while the series has no colormap.
A vertical bar has its minimum at the bottom, with ticks on the right and label beside them, reading top to bottom. A horizontal bar has its minimum on the left, with ticks and label below. Position the bar like any item, for example inside the plot area:
QAccelPlot.ColorBar {
series: cloud
label: "Intensity"
x: plot.plotRect.right - width - 8
y: plot.plotRect.y + 8
}
The implicit size fits the strip, ticks, tick labels, and label, with a length of 160 pixels along the ramp. A vertical bar gives its tick labels the fixed tickLabelWidth and clips wider ones. Tick labels at the ends are kept inside the item.
With interactive set, a left drag along the ramp pans the colormap's value range, the mouse wheel zooms it around the value under the cursor, and a double-click calls rescaleToData(). The gestures write Colormap::min and Colormap::max, so every series sharing the colormap follows. A QML binding on either bound overrides them when it is next evaluated.
See also: ColormappedSeries, PointCloud, HeatmapSeries, BarSeries, Colormap, AxisTicker
Public Properties Documentation¶
property barThickness¶
Thickness in pixels of the color strip across the ramp direction. Default: 12.
property border¶
Outline inside the strip's edges, e.g. border.width: 2 . Default:Colors.dark.axisLine , width 1.
property hovered¶
Read-only: true while the mouse cursor is over the bar. Reported only whileinteractive is set.
property interactive¶
Whether dragging, the mouse wheel, and double-clicking change the colormap's value range. Default: false .
While false, the bar leaves mouse and wheel events to the items below it.
property label¶
Optional title drawn beside the tick labels. Default: empty.
property labelColor¶
Color of the title. Default: Colors.dark.axisLine .
property labelFont¶
Font of the title. Default: application default font.
property labelPadding¶
Gap in pixels between the tick labels and the title. Default: 6.
property orientation¶
Direction of the ramp: Qt.Vertical orQt.Horizontal . Default:Qt.Vertical .
property series¶
Series whose colormap and resolved value range are shown. Default: null.
property tickLabelWidth¶
Width in pixels reserved for the tick labels of a vertical bar. Default: 16.
The width is fixed, so the implicit width and the title stay in place while the labels change. Labels wider than it are clipped. Ignored by horizontal bars.
property ticker¶
Read-only constant: tick appearance, count, and label formatter.
Defaults differ from Axis : tickLengthIn 0, tickLengthOut 4, subtickLengthIn 0, subtickLengthOut 2, subtickCount 0, and tickWidth 1.
property zoomScaleFactor¶
Fraction by which the value range is multiplied on each inward mouse-wheel step. Must be in (0, 1). Default: 0.9.
On a zoom-out step the range is multiplied by the reciprocal. Used only while interactive is set.
Public Signals Documentation¶
signal barThicknessChanged¶
Emitted when the barThickness property changes.
signal hoveredChanged¶
Emitted when the hovered property changes.
signal interactiveChanged¶
Emitted when the interactive property changes.
signal labelChanged¶
Emitted when the label property changes.
signal labelColorChanged¶
Emitted when the labelColor property changes.
signal labelFontChanged¶
Emitted when the labelFont property changes.
signal labelPaddingChanged¶
Emitted when the labelPadding property changes.
signal orientationChanged¶
Emitted when the orientation property changes.
signal seriesChanged¶
Emitted when the series property changes.
signal tickLabelWidthChanged¶
Emitted when the tickLabelWidth property changes.
signal zoomScaleFactorChanged¶
Emitted when the zoomScaleFactor property changes.
Public Functions Documentation¶
function ColorBar¶
Constructs a ColorBar with the given__parent .
function barThickness¶
Returns the strip thickness in pixels.
function border¶
Returns the strip outline settings. The object is owned by the bar.
function hovered¶
Returns true while the mouse cursor is over an interactive bar.
function interactive¶
Returns whether the gestures that change the colormap's value range are enabled.
function label¶
Returns the title.
function labelColor¶
Returns the title color.
function labelFont¶
Returns the title font.
function labelPadding¶
Returns the gap between the tick labels and the title in pixels.
function orientation¶
Returns the ramp direction.
function paint¶
Paints the strip, ticks, tick labels, and title computed in updatePolish() .
function pixelToValue¶
Maps a pixel position along a strip of__length pixels back to a value.
The inverse of valueToPixel(). Returns the range minimum when length is 0.
function rescaleToData¶
Unsets the colormap's min andmax , so the range is resolved from the data again.
function series¶
Returns the series whose colormap is shown, or nullptr .
function setBarThickness¶
Sets the strip thickness to thickness pixels. Negative values are clamped to 0.
function setInteractive¶
Sets whether the gestures that change the colormap's value range are enabled to interactive .
function setLabel¶
Sets the title to label .
function setLabelColor¶
Sets the title color to color .
function setLabelFont¶
Sets the title font to font .
function setLabelPadding¶
Sets the gap between the tick labels and the title to padding pixels. Negative values are clamped to 0.
function setOrientation¶
Sets the ramp direction to orientation .
function setSeries¶
Sets the series whose colormap is shown to series .
function setTickLabelWidth¶
Sets the width reserved for tick labels to width pixels. Negative values are clamped to 0.
function setZoomScaleFactor¶
Sets the zoom scale factor to factor (clamped to the range (0, 1)).
function tickLabelWidth¶
Returns the width reserved for tick labels in pixels.
function ticker¶
Returns the tick configuration object. The object is owned by the color bar.
function valueToPixel¶
Maps value to a pixel position along a strip of__length pixels.
Horizontal bars measure from the left edge, vertical bars from the top edge. Uses the range and normalization captured at the last polish, so it matches what paint() draws.
function zoomScaleFactor¶
Returns the zoom scale factor.
Protected Functions Documentation¶
function geometryChange¶
Schedules a new layout when the item is resized.
void QAccelPlot::ColorBar::geometryChange (
const QRectF & newGeometry,
const QRectF & oldGeometry
) override
function hoverEnterEvent¶
Marks the bar as hovered.
function hoverLeaveEvent¶
Clears the hovered state.
function mouseDoubleClickEvent¶
Calls rescaleToData() on a left-button double-click whileinteractive is set.
function mouseMoveEvent¶
Pans the value range by the distance dragged along the ramp.
function mousePressEvent¶
Starts panning the value range on a left-button press while interactive is set.
function mouseReleaseEvent¶
Ends panning on a left-button release.
function mouseUngrabEvent¶
Ends panning when the mouse grab is lost.
function updatePolish¶
Captures the colormap, formats tick labels, and lays out the bar on the GUI thread, ahead of paint() .
function wheelEvent¶
Zooms the value range around the value under the cursor while interactive is set.
The documentation for this class was generated from the following file QAccelPlot/src/QAccelPlot/axis/ColorBar.hpp