Skip to content

fix(peaks): zoom-scaled apex snap and Shift free placement - #74

Merged
nmrtist merged 1 commit into
nmrtist:mainfrom
Limdongcheng:up/peak-snap
Aug 29, 2026
Merged

fix(peaks): zoom-scaled apex snap and Shift free placement#74
nmrtist merged 1 commit into
nmrtist:mainfrom
Limdongcheng:up/peak-snap

Conversation

@Limdongcheng

Copy link
Copy Markdown
Contributor

Summary

Manual peak picking snapped to the tallest local maximum inside a window fixed at 1.5% of the full x span, regardless of zoom — so next to a strong line a weak line could never be picked: zooming in sharpened the click but not the window.

The apex search window is now derived from a fixed screen radius (12 px) at the current zoom, so zooming in narrows it in step with the click precision; tallest-in-window is kept (over nearest-local-maximum) so zoomed-out clicks land on real peaks instead of the nearest noise wiggle. Shift+click skips the snap and places the mark on the nearest sample — the escape hatch for shoulders the apex search refuses to land on. The hover preview resolves through the same path, modifier included.

API: Trace1d::snap becomes snap_within(x, half_width) + nearest_sample, unified under pick(x, ManualPeakSnap); add_manual_peak takes the snap explicitly. Range drag-picking keeps its 3-sigma prominence floor — it is scoped to the dragged window with MAD-based noise, and the reported failure was click-snap, not range picking.

Validation

  • cargo pr-check passes (fmt, source sizes, dependency policy, default-frontends build, clippy -D warnings, reference-backend test suite).
  • New peaks_tests.rs pins the narrow-window weak-apex pick, the wide-window tallest pick, free placement, and the no-apex fallback.
  • The peak-picking guide (English and zh-CN) documents the zoom-scaled snap and Shift placement; npm run build in docs/ passes.

Manual picking snapped to the tallest local maximum inside a window
fixed at 1.5% of the full x span, regardless of zoom — so next to a
strong line, a weak line could never be picked: zooming in sharpened
the click but not the window. The apex search window is now derived
from a fixed screen radius (12 px) at the current zoom, so zooming in
narrows it in step with the click precision; tallest-in-window is kept
(over nearest-local-maximum) so zoomed-out clicks land on real peaks
instead of the nearest noise wiggle. Shift+click skips the snap and
places the mark on the nearest sample — the escape hatch for shoulders.
The hover preview resolves through the same path, modifier included.

`Trace1d::snap` becomes `snap_within(x, half_width)` +
`nearest_sample`, unified under `pick(x, ManualPeakSnap)`;
`add_manual_peak` takes the snap explicitly. Range drag-picking
(`pick_in_range`) keeps its 3-sigma prominence floor: it is scoped to
the dragged window with MAD-based noise, which peaks inflate very
little, and the reported failure was click-snap, not range picking.

New peaks_tests.rs pins the narrow-window weak-apex pick, the
wide-window tallest pick, free placement, and the no-apex fallback.
The peak-picking guide (EN + zh-CN) documents the zoom-scaled snap and
Shift placement.
@nmrtist
nmrtist merged commit 29157a7 into nmrtist:main Aug 29, 2026
11 checks passed
@github-actions github-actions Bot locked and limited conversation to collaborators Aug 29, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants