feat(plot)!: harden pipeline, XY series, dash/markers, touch, packaging
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.
This commit is contained in:
1 parent
f132a5ec92
commit
38ef459897
77 files changed
+5905
-688
No files matched your search
@@ -2,6 +2,7 @@
|
||||
// SPDX-FileCopyrightText: 2026 Martino Ferrari
|
||||
|
||||
#pragma once
|
||||
#include <plot/core/color.hpp>
|
||||
#include <plot/core/types.hpp>
|
||||
#include <plot/math/vec2.hpp>
|
||||
#include <plot/render/text.hpp>
|
||||
@@ -60,7 +61,7 @@ class LineBatch {
|
||||
/// Like `LineBatch` it keeps its capacity across frames. Each staged glyph is
|
||||
/// one instance: the glyph cell's top-left corner in pixels, the glyph rect's
|
||||
/// normalised top-left in the atlas and the cell's rotation basis, interleaved as
|
||||
/// `x,y,u,v,ax,ay` — the layout the text shader declares (see `TextInstance` in
|
||||
/// `x,y,u,v,ax,ay,r,g,b,a` — the layout the text shader declares (see `TextInstance` in
|
||||
/// buffer.hpp).
|
||||
///
|
||||
/// Every glyph a batch stages is read through one atlas rect of one size — its
|
||||
@@ -92,8 +93,9 @@ class TextBatch {
|
||||
/// rasterised them. `axis` is the direction the run advances in, in pixel
|
||||
/// space; it rotates the cell (see `TextInstance`), and is normalised here, so
|
||||
/// any non-zero direction works and a zero or non-finite one means "unrotated".
|
||||
void add_glyph(Vec2 pen_px, const Glyph& glyph, f32 px = 1.0f,
|
||||
Vec2 axis = {1.0f, 0.0f});
|
||||
/// `color` tints this run's glyphs (per-vertex `a_colour`, see `TextInstance`).
|
||||
void add_glyph(Vec2 pen_px, const Glyph& glyph, f32 px = 1.0f, Vec2 axis = {1.0f, 0.0f},
|
||||
Color color = {1.0f, 1.0f, 1.0f, 1.0f});
|
||||
|
||||
/// Stages every codepoint of `utf8` from `pen_px` and returns the pen past the
|
||||
/// last glyph, so the run is exactly `font.measure(utf8) * px` long measured
|
||||
@@ -104,14 +106,14 @@ class TextBatch {
|
||||
/// `next_codepoint()` and `glyph()`, so a run stages exactly what `measure()`
|
||||
/// summed. A codepoint the backend has no glyph for stages nothing and moves
|
||||
/// the pen nowhere — a run is never wider than the glyphs it can draw. A null
|
||||
/// or empty string stages nothing and returns `pen_px`.
|
||||
/// or empty string stages nothing and returns `pen_px`. `color` tints the run.
|
||||
Vec2 add_text(const char* utf8, Vec2 pen_px, f32 px, const TextBackend& font,
|
||||
Vec2 axis = {1.0f, 0.0f});
|
||||
Vec2 axis = {1.0f, 0.0f}, Color color = {1.0f, 1.0f, 1.0f, 1.0f});
|
||||
|
||||
/// Glyphs staged so far, one instance each.
|
||||
u32 glyph_count() const noexcept { return static_cast<u32>(v_.size() / 6u); }
|
||||
u32 glyph_count() const noexcept { return static_cast<u32>(v_.size() / 10u); }
|
||||
|
||||
/// Interleaved `x,y,u,v,ax,ay`, six floats per staged glyph.
|
||||
/// Interleaved `x,y,u,v,ax,ay,r,g,b,a`, ten floats per staged glyph.
|
||||
const std::vector<f32>& data() const noexcept { return v_; }
|
||||
|
||||
/// The cell the staged glyphs are drawn in: what `set_cell()` declared, or --
|
||||
@@ -124,7 +126,7 @@ class TextBatch {
|
||||
private:
|
||||
/// Stages one cell whose basis the caller has already normalised, so a run and
|
||||
/// the pen it advances share one rounding of the axis.
|
||||
void add_cell(Vec2 pen_px, const Glyph& glyph, f32 px, Vec2 unit_ux);
|
||||
void add_cell(Vec2 pen_px, const Glyph& glyph, f32 px, Vec2 unit_ux, Color color);
|
||||
|
||||
std::vector<f32> v_;
|
||||
Vec2 cell_uv_{};
|
||||
|
||||
Reference in new issue
Block a user