Skip to content

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.

qreal QAccelPlot::ColorBar::barThickness;


property border

Outline inside the strip's edges, e.g. border.width: 2 . Default:Colors.dark.axisLine , width 1.

Border* QAccelPlot::ColorBar::border;


property hovered

Read-only: true while the mouse cursor is over the bar. Reported only whileinteractive is set.

bool QAccelPlot::ColorBar::hovered;


property interactive

Whether dragging, the mouse wheel, and double-clicking change the colormap's value range. Default: false .

bool QAccelPlot::ColorBar::interactive;

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.

QString QAccelPlot::ColorBar::label;


property labelColor

Color of the title. Default: Colors.dark.axisLine .

QColor QAccelPlot::ColorBar::labelColor;


property labelFont

Font of the title. Default: application default font.

QFont QAccelPlot::ColorBar::labelFont;


property labelPadding

Gap in pixels between the tick labels and the title. Default: 6.

qreal QAccelPlot::ColorBar::labelPadding;


property orientation

Direction of the ramp: Qt.Vertical orQt.Horizontal . Default:Qt.Vertical .

Qt::Orientation QAccelPlot::ColorBar::orientation;


property series

Series whose colormap and resolved value range are shown. Default: null.

ColormappedSeries* QAccelPlot::ColorBar::series;


property tickLabelWidth

Width in pixels reserved for the tick labels of a vertical bar. Default: 16.

qreal QAccelPlot::ColorBar::tickLabelWidth;

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.

AxisTicker* QAccelPlot::ColorBar::ticker;

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.

qreal QAccelPlot::ColorBar::zoomScaleFactor;

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.

void QAccelPlot::ColorBar::barThicknessChanged;


signal hoveredChanged

Emitted when the hovered property changes.

void QAccelPlot::ColorBar::hoveredChanged;


signal interactiveChanged

Emitted when the interactive property changes.

void QAccelPlot::ColorBar::interactiveChanged;


signal labelChanged

Emitted when the label property changes.

void QAccelPlot::ColorBar::labelChanged;


signal labelColorChanged

Emitted when the labelColor property changes.

void QAccelPlot::ColorBar::labelColorChanged;


signal labelFontChanged

Emitted when the labelFont property changes.

void QAccelPlot::ColorBar::labelFontChanged;


signal labelPaddingChanged

Emitted when the labelPadding property changes.

void QAccelPlot::ColorBar::labelPaddingChanged;


signal orientationChanged

Emitted when the orientation property changes.

void QAccelPlot::ColorBar::orientationChanged;


signal seriesChanged

Emitted when the series property changes.

void QAccelPlot::ColorBar::seriesChanged;


signal tickLabelWidthChanged

Emitted when the tickLabelWidth property changes.

void QAccelPlot::ColorBar::tickLabelWidthChanged;


signal zoomScaleFactorChanged

Emitted when the zoomScaleFactor property changes.

void QAccelPlot::ColorBar::zoomScaleFactorChanged;


Public Functions Documentation

function ColorBar

Constructs a ColorBar with the given__parent .

explicit QAccelPlot::ColorBar::ColorBar (
    QQuickItem * parent=nullptr
) 


function barThickness

Returns the strip thickness in pixels.

qreal QAccelPlot::ColorBar::barThickness () const


function border

Returns the strip outline settings. The object is owned by the bar.

Border * QAccelPlot::ColorBar::border () const


function hovered

Returns true while the mouse cursor is over an interactive bar.

bool QAccelPlot::ColorBar::hovered () const


function interactive

Returns whether the gestures that change the colormap's value range are enabled.

bool QAccelPlot::ColorBar::interactive () const


function label

Returns the title.

QString QAccelPlot::ColorBar::label () const


function labelColor

Returns the title color.

QColor QAccelPlot::ColorBar::labelColor () const


function labelFont

Returns the title font.

QFont QAccelPlot::ColorBar::labelFont () const


function labelPadding

Returns the gap between the tick labels and the title in pixels.

qreal QAccelPlot::ColorBar::labelPadding () const


function orientation

Returns the ramp direction.

Qt::Orientation QAccelPlot::ColorBar::orientation () const


function paint

Paints the strip, ticks, tick labels, and title computed in updatePolish() .

void QAccelPlot::ColorBar::paint (
    QPainter * painter
) override


function pixelToValue

Maps a pixel position along a strip of__length pixels back to a value.

qreal QAccelPlot::ColorBar::pixelToValue (
    qreal pixel,
    qreal length
) const

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.

Q_INVOKABLE void QAccelPlot::ColorBar::rescaleToData () 


function series

Returns the series whose colormap is shown, or nullptr .

ColormappedSeries * QAccelPlot::ColorBar::series () const


function setBarThickness

Sets the strip thickness to thickness pixels. Negative values are clamped to 0.

void QAccelPlot::ColorBar::setBarThickness (
    qreal thickness
) 


function setInteractive

Sets whether the gestures that change the colormap's value range are enabled to interactive .

void QAccelPlot::ColorBar::setInteractive (
    bool interactive
) 


function setLabel

Sets the title to label .

void QAccelPlot::ColorBar::setLabel (
    const QString & label
) 


function setLabelColor

Sets the title color to color .

void QAccelPlot::ColorBar::setLabelColor (
    const QColor & color
) 


function setLabelFont

Sets the title font to font .

void QAccelPlot::ColorBar::setLabelFont (
    const QFont & font
) 


function setLabelPadding

Sets the gap between the tick labels and the title to padding pixels. Negative values are clamped to 0.

void QAccelPlot::ColorBar::setLabelPadding (
    qreal padding
) 


function setOrientation

Sets the ramp direction to orientation .

void QAccelPlot::ColorBar::setOrientation (
    Qt::Orientation orientation
) 


function setSeries

Sets the series whose colormap is shown to series .

void QAccelPlot::ColorBar::setSeries (
    ColormappedSeries * series
) 


function setTickLabelWidth

Sets the width reserved for tick labels to width pixels. Negative values are clamped to 0.

void QAccelPlot::ColorBar::setTickLabelWidth (
    qreal width
) 


function setZoomScaleFactor

Sets the zoom scale factor to factor (clamped to the range (0, 1)).

void QAccelPlot::ColorBar::setZoomScaleFactor (
    qreal factor
) 


function tickLabelWidth

Returns the width reserved for tick labels in pixels.

qreal QAccelPlot::ColorBar::tickLabelWidth () const


function ticker

Returns the tick configuration object. The object is owned by the color bar.

AxisTicker * QAccelPlot::ColorBar::ticker () const


function valueToPixel

Maps value to a pixel position along a strip of__length pixels.

qreal QAccelPlot::ColorBar::valueToPixel (
    qreal value,
    qreal length
) const

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.

qreal QAccelPlot::ColorBar::zoomScaleFactor () const


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.

void QAccelPlot::ColorBar::hoverEnterEvent (
    QHoverEvent * event
) override


function hoverLeaveEvent

Clears the hovered state.

void QAccelPlot::ColorBar::hoverLeaveEvent (
    QHoverEvent * event
) override


function mouseDoubleClickEvent

Calls rescaleToData() on a left-button double-click whileinteractive is set.

void QAccelPlot::ColorBar::mouseDoubleClickEvent (
    QMouseEvent * event
) override


function mouseMoveEvent

Pans the value range by the distance dragged along the ramp.

void QAccelPlot::ColorBar::mouseMoveEvent (
    QMouseEvent * event
) override


function mousePressEvent

Starts panning the value range on a left-button press while interactive is set.

void QAccelPlot::ColorBar::mousePressEvent (
    QMouseEvent * event
) override


function mouseReleaseEvent

Ends panning on a left-button release.

void QAccelPlot::ColorBar::mouseReleaseEvent (
    QMouseEvent * event
) override


function mouseUngrabEvent

Ends panning when the mouse grab is lost.

void QAccelPlot::ColorBar::mouseUngrabEvent () override


function updatePolish

Captures the colormap, formats tick labels, and lays out the bar on the GUI thread, ahead of paint() .

void QAccelPlot::ColorBar::updatePolish () override


function wheelEvent

Zooms the value range around the value under the cursor while interactive is set.

void QAccelPlot::ColorBar::wheelEvent (
    QWheelEvent * event
) override



The documentation for this class was generated from the following file QAccelPlot/src/QAccelPlot/axis/ColorBar.hpp