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
+40
-4
@@ -167,15 +167,51 @@ void generate_ticks(Range range, f32 px, f32 min_px, std::vector<Tick>& out, boo
|
||||
const f64 minor_step = step / minor_ratio;
|
||||
if (!std::isfinite(minor_step) || !(minor_step > 0.0)) return;
|
||||
|
||||
const f64 stride = include_minors ? minor_step : step;
|
||||
// Minors subdivide the major step an exact integer number of times, so the
|
||||
// major/minor split is an *integer-index* test: a tick is a major when its
|
||||
// minor index, counted from `first_major`, is a multiple of the ratio. Both
|
||||
// operands of the index are exact for the windows axes actually show --
|
||||
// `v - first_major` is the difference of two near doubles (Sterbenz-exact), and
|
||||
// rounding the small quotient lands on the index the grid defines -- so no float
|
||||
// tolerance is needed and none is applied. The old `|v - round(v/step)*step| <=
|
||||
// step*1e-9` test fought a ULP-sized residue that an epoch origin produces
|
||||
// whenever the step is not a power of two (v/step carries a rounding error of a
|
||||
// few ULP of 1.75e9, i.e. far more than step*1e-9) and misclassified its majors;
|
||||
// the index here has no residue to fight.
|
||||
const auto minor_index_is_major = [&](f64 v) {
|
||||
const f64 index = std::round((v - first_major) / minor_step);
|
||||
return std::fmod(index, minor_ratio) == 0.0;
|
||||
};
|
||||
|
||||
// Mutable: once the minors are capped the walk steps the major stride (see the
|
||||
// cap branch below).
|
||||
f64 stride = include_minors ? minor_step : step;
|
||||
const f64 first = include_minors ? std::ceil(lo / minor_step) * minor_step : first_major;
|
||||
if (!std::isfinite(first)) return;
|
||||
|
||||
char label[kLabelBuf];
|
||||
usize minors = 0;
|
||||
for (f64 v = first; v <= hi + stride * 1e-9;) {
|
||||
if (out.size() >= kMaxTicks) break;
|
||||
const bool major = !include_minors ||
|
||||
std::fabs(v - std::round(v / step) * step) <= step * 1e-9;
|
||||
const bool major = !include_minors || minor_index_is_major(v);
|
||||
if (!major && minors >= kMaxTicks) {
|
||||
// The cap counts minors only, and the majors are never truncated: an axis
|
||||
// dense enough to want more subdivisions than fit loses its *subdivisions*,
|
||||
// not its labels, so the far end of the axis keeps its numbers. From here on
|
||||
// the walk steps the major stride; the next major at or after `v` is
|
||||
// re-seated onto the major grid explicitly, because continuing from an
|
||||
// off-grid minor with the new stride would visit only off-grid points and
|
||||
// silently drop every remaining label. `minors >= kMaxTicks` is also the
|
||||
// guard that keeps a hostile request (px towering over min_px) from stepping
|
||||
// a minor stride across the whole range after the cap; the majors-only walk
|
||||
// is as long as the caller's own pixel count asked it to be.
|
||||
stride = step;
|
||||
const f64 major_index = std::ceil((v - first_major) / step - 1e-9);
|
||||
f64 reseat = first_major + major_index * step;
|
||||
if (reseat < v) reseat = first_major + (major_index + 1.0) * step;
|
||||
v = reseat;
|
||||
continue;
|
||||
}
|
||||
if (!major) ++minors;
|
||||
Tick tick;
|
||||
tick.value = v;
|
||||
tick.major = major;
|
||||
|
||||
Reference in new issue
Block a user