fix(peaks): zoom-scaled apex snap and Shift free placement - #74
Merged
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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::snapbecomessnap_within(x, half_width)+nearest_sample, unified underpick(x, ManualPeakSnap);add_manual_peaktakes 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-checkpasses (fmt, source sizes, dependency policy, default-frontends build, clippy-D warnings, reference-backend test suite).peaks_tests.rspins the narrow-window weak-apex pick, the wide-window tallest pick, free placement, and the no-apex fallback.npm run buildindocs/passes.