Skip to content

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

Closed
Limdongcheng wants to merge 1 commit into
feat/plot-fit-shortcutsfrom
fix/peak-snap
Closed

fix(peaks): zoom-scaled apex snap and Shift free placement#5
Limdongcheng wants to merge 1 commit into
feat/plot-fit-shortcutsfrom
fix/peak-snap

Conversation

@Limdongcheng

Copy link
Copy Markdown
Owner

Root cause

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.

Fix

  • 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 the zoom affords.
  • 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 (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.

Docs & tests

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. cargo pr-check passes.


Part 4 of the stack, based on feat/plot-fit-shortcuts (#4).

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.
@github-actions

Copy link
Copy Markdown


Thank you for your submission, we really appreciate it. Like many open-source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution. You can sign the CLA by just posting a Pull Request Comment same as the below format.


I have read the CLA Document and I hereby sign the CLA


You can retrigger this bot by commenting recheck in this Pull Request. Posted by the CLA Assistant Lite bot.

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.

1 participant