ColorRampLegend
A vertical color ramp with ticks, out-of-range swatches, markers and a caption.
| Inherits | QWidget |
| Group | widgets |
Declared in src/libs/libwidgets/components/visualization/ColorRampLegend.hpp.
Detailed description
The scale of a false-color view: the ramp from the low end at the bottom to the high end at the top, and the ticks beside it. Each color is one strip of the bar, scaled to its height, and no gradient blends two: a colormap's 256 table entries show as the exact texels the GPU samples (field-presentation §FVC-6). A banded map shows its bands as flat steps with a hairline between two.
Data outside the range shows one of two ways. The clamp rule paints it as the end color, and a "≥" beside the top or a "≤" beside the bottom says so. The distinct rule paints it in its own color, and a swatch over or under the bar shows that color with its text, as commercial post-processors show it (§FVC-4). A NaN has its own swatch at the bottom. A marker is a small triangle and a text at a value: the true maximum of a robust range sits in a line over the bar. The hover tick crosses the bar at the value under the cursor. Muted lines under the bar name the map and the range.
It knows colors and text only. The caller turns its own data into colors, places and labels: Construct's field legend (construct-fea-solve §FEC-5) reads a colormap's table and formats the range.
paint() draws a LegendData into any painter, so a capture draws the same legend with no widget (§FVL-6). The widget paints with it straight into itself, with no cached pixmap, so it is sharp at any device pixel ratio.
It takes no input until setEditable() makes it editable (field-presentation §FVU-5). Then it takes the mouse, and the HUD around it keeps passing clicks to the viewport. Each input is a place along the bar, 0 the low end and 1 the high end, and the caller turns a place into a value and back:
- Drag the top or the bottom end. endDragged() gives the place under the cursor for each move, not clamped, so a drag can extend the range. endDragFinished() gives the place at the release.
- Double-click an end. A QLineEdit opens over that end's label with the text of the end, and takes the focus (§FVU-10). Enter gives endTyped() when the place parser reads the text, else the editor stays open with a warning border. Esc closes it with no signal.
- Right click. contextMenuRequested() gives the place on the screen, and the owner builds the menu.
- Hover over the bar. The tooltip is the place formatter's text at the height of the cursor, then the widget's own tooltip.
paint() does not paint the editor: it is a child widget.
The charts derive from AbstractChartWidget.
See also HeatStrip.