Breaking: Series::gather emits x relative to x0() and takes a GatherMode; consumers reconstruct absolute x in f64 before mapping (series.hpp documents the contract). Bugs, each pinned by a fail-before regression test: - render: f32 staging quantised epoch-time x into 128 px columns; every data-space draw now stages to_space(x) - to_space(origin) with the origin folded into the offset uniform in f64 (epoch/zero-origin twins rasterise identically) - ticks: major test was ULP-fragile and blanked epoch axes; majors are an integer-index test and are never truncated by the minor cap - gather: LOD envelope emitted buckets straddling [begin,end); ceil/floor bucket edges + raw lead/trail spans - live follow: log x axes held a linear span and zoomed every frame; span and offset now live in axis space (plot + both figure link-group paths) - input: a zero-notch wheel disarmed auto_scale on every axis; dy==0 pans x, factor == 1 / inf refused in wheel and drag zoom - render: the single text flush painted legend names over the crosshair readout panel; two batches, under flushed before the panel - data: NaN dropped from min/max unless it seeded the fold; non-finite samples are now excluded from every aggregate and from cached bounds Robustness: viewport normalisation (no clamp UB), non-finite range refusal, pyramid level cap at 57 (no shift/div UB through public gather), rounded ring capacity documented + pre-sized, GL blend func and UNPACK_ALIGNMENT save/restore, Renderer::release_gl() teardown, u64 buffer epochs, annotation captions clamped, button-aware GLFW row capture, cached figure row rects (no per-event layout), ruler-pair measurement refused, span-nonfinite guards in axis_ends. Features: XY series (sorted x, binary-search neighbours/snap, LOD over sample index); StreamSeries::freeze(); ArraySeries::push(); per-trace dash and markers (scatter at width 0) with auto or literal stride; GatherMode Envelope/Nearest/Mean via bucket_sum/sumsq; Style::line_aa_px; per-glyph text colour (readout values in trace colour); wheel-dx x pan; arrow-key pan; Escape cancels a drag and restores captured ranges; modifier-masked box zoom (Shift both, Ctrl x, Alt y); double-click reset via PointerEvent::time_s; ImGui key repeat unified; pinch gestures on Qt and GTK; pixelDelta wheel path and DevicePixelRatioChange handling; GNUInstallDirs, SOVERSION, SameMinorVersion, generated plot/version.hpp, relocatable plot.pc, licence install, FILES_MATCHING, GitHub Actions CI (debug/coverage/asan). Suite 283 -> 350 cases, 0 failed; coverage 93.9% (3730/3971) over 24 files, floor 80/90 held; ASAN preset suite green; all four demos run headless (the GTK scripted-resize check needs a window manager and fails identically on the parent commit); readme_main.cpp committed and compiles with the README command; pkg-config and find_package consumption verified from a relocated install prefix.
84 lines
3.5 KiB
C++
84 lines
3.5 KiB
C++
// SPDX-License-Identifier: MIT
|
|
// SPDX-FileCopyrightText: 2026 Martino Ferrari
|
|
|
|
#pragma once
|
|
#include <plot/core/color.hpp>
|
|
#include <plot/core/types.hpp>
|
|
#include <plot/data/series.hpp>
|
|
#include <string>
|
|
|
|
namespace plot {
|
|
|
|
/// How a trace's geometry is gathered from its LOD pyramid. The level choice
|
|
/// is unchanged; this picks what a bucket contributes (see
|
|
/// `data::GatherMode`).
|
|
using TraceMode = data::GatherMode;
|
|
|
|
/// A marker shape for per-sample points. Drawn with the trace's own colour
|
|
/// through the shared line pipeline; `marker_every == 0` strides
|
|
/// automatically (one marker per pixel column at most).
|
|
enum class Marker { None, Cross, Circle, Square };
|
|
|
|
/// How a caller asks for a trace. The series pointer is borrowed and must outlive
|
|
/// the plot's use of it; `axis_x`/`axis_y` index the plot's x and y axis lists.
|
|
struct TraceDesc {
|
|
const data::Series* series = nullptr;
|
|
Color color = Color::hex(0x4FA3FF);
|
|
/// The stroke's width in **logical** pixels, like every stroke in `Style` (see
|
|
/// that struct's unit rule): the renderer converts it once, so a trace has the
|
|
/// same weight against the axis lines whatever the display's DPI. `0` draws
|
|
/// the markers only -- a scatter trace.
|
|
f32 width = 1.5f;
|
|
u32 axis_x = 0, axis_y = 0;
|
|
/// What the trace is called, for the legend. Empty means "do not list it", which
|
|
/// is the whole cost of a legend for a caller that never names one: the trailing
|
|
/// default is what keeps the five-field aggregate initialisation every existing
|
|
/// caller writes -- `{&series, colour, width, axis_x, axis_y}` -- working
|
|
/// unchanged, exactly as `AxisDesc`'s trailing format does (and, in a build with
|
|
/// `-Wextra`, warning-clean).
|
|
std::string name{};
|
|
/// Downsample policy for the LOD buckets (Envelope by default).
|
|
TraceMode mode = TraceMode::Envelope;
|
|
/// Dash pattern in logical pixels: ink, then gap. `dash_off <= 0` (and the
|
|
/// default) is a solid line -- no geometry is added, the dash is a
|
|
/// fragment-shader discard.
|
|
f32 dash_on = 0.0f;
|
|
f32 dash_off = 0.0f;
|
|
/// Per-sample markers (see `Marker`). `marker_every == 0` strides
|
|
/// automatically -- at most about one marker per pixel column -- so a dense
|
|
/// trace never stages more markers than it has columns; a positive value
|
|
/// draws every n-th gathered sample literally.
|
|
Marker marker = Marker::None;
|
|
f32 marker_size_px = 3.0f;
|
|
u32 marker_every = 0;
|
|
};
|
|
|
|
/// A series bound to a colour, width and axis pair. The series pointer may be
|
|
/// null (a trace whose data has not arrived yet): every consumer skips such a
|
|
/// trace rather than dereferencing it.
|
|
struct Trace {
|
|
const data::Series* series = nullptr;
|
|
Color color = Color::hex(0x4FA3FF);
|
|
/// Logical pixels, as in `TraceDesc::width`: converted to device pixels by the
|
|
/// renderer's one `Style::device()` call per stroke. `0` = scatter (markers
|
|
/// only, if any).
|
|
f32 width = 1.5f;
|
|
u32 axis_x = 0, axis_y = 0;
|
|
/// The legend's entry for this trace, empty when it has none. A name does not
|
|
/// make a trace drawable: the legend lists a trace only when it is visible, so a
|
|
/// null series is skipped there exactly as it is by every other consumer.
|
|
std::string name{};
|
|
/// Same fields as `TraceDesc`, applied by the renderer.
|
|
TraceMode mode = TraceMode::Envelope;
|
|
f32 dash_on = 0.0f;
|
|
f32 dash_off = 0.0f;
|
|
Marker marker = Marker::None;
|
|
f32 marker_size_px = 3.0f;
|
|
u32 marker_every = 0;
|
|
|
|
/// True when the trace has a series with at least one sample to draw.
|
|
bool visible() const noexcept { return series != nullptr && series->size() > 0; }
|
|
};
|
|
|
|
} // namespace plot
|