Skip to content

GUI: canvas fixes, per-capture scales, zoom and pan - #4

Open
rssdev10 wants to merge 3 commits into
mainfrom
fix/scope-canvas-bugs
Open

rssdev10 wants to merge 3 commits into
mainfrom
fix/scope-canvas-bugs

Conversation

@rssdev10

@rssdev10 rssdev10 commented Nov 26, 2026 •

Copy link
Copy Markdown
Owner

Summary

Fixes several problems in the scope canvas, gives each capture its own scale, adds zoom and pan with the mouse, and bumps the version to 0.3.0. Three commits:

1. Canvas fixes and per-capture scales

  • Cursor dragging: the canvas now tells the app which lines were grabbed. A press within 12 px of where the nearest X and Y lines cross drags both; elsewhere only the single nearest line moves, measured in pixels. A drag keeps following the pointer outside the canvas and ends on release anywhere, so it can no longer get stuck. The pointer changes shape over lines and crossings.
  • No dropped samples: a new plot.rs is shared by the canvas and the PNG export. Each pixel column draws the min/max of its samples, so single-sample spikes stay visible in Line and Dot modes. Smooth mode still averages. PNG Dot mode now draws every sample instead of every N-th one.
  • Clipping: traces are clipped to the grid on the geometry itself. Frame::with_clip isn't used because in iced 0.14 the clipped sub-frame is drawn before the parent's shapes, so the background hid the traces.
  • Speed: the trace layer is cached and Dot mode uses iced's rectangle fast path, so cursor drags and Dot mode on 60 000 samples are responsive again.
  • Per-capture scales (scale.rs): a capture with metadata uses its own V/div, V/off and t/div, shown read-only. A capture without metadata (debug dump) uses the manual scale from settings. Receiving or selecting a capture no longer overwrites the manual scale, and PNG export uses the exported capture's scale.
  • Lints: fixes three clippy lints that are new in Rust 1.100.

2. Zoom and pan

  • Time zoom: the wheel zooms around the pointer. Horizontal scroll or Shift+wheel pans time.
  • Voltage zoom: Option/Alt+wheel, or the wheel over the voltage labels. Zoom-out may go past the device screen to the full ADC range (0–255), with the screen edges marked.
  • Pan both axes: right- or middle-drag.
  • Reset: a double-click resets the zoom. The cursor move made by the first click is undone.
  • Per capture: the zoom is remembered for each capture. Cursors and labels follow the zoom. PNG export is unchanged and always shows the whole capture.

The user manual, GUI design doc, README module table and all five locales are updated.

3. Version 0.3.0, edition 2024, dependency updates

  • Version: workspace version 0.3.0, inherited by dso-parser and the GUI. The CLI flasher keeps its own version (0.1.2), edition and dependencies.
  • Edition 2024: the workspace moves to edition 2024 with resolver 3. Nested ifs flagged by clippy are merged into let-chains; only those blocks are reformatted. The unused workspace.package.description field is removed.
  • Dependencies: rust-i18n 3→4, png 0.17→0.18, rfd 0.15→0.18 and dirs 6→7, plus a refreshed Cargo.lock. dirs 7 returns the same config folder on all platforms, so existing settings stay where they are.
  • Test: a new test checks that translations load for every supported language.

Testing

  • cargo test --workspace passes (73 GUI tests, including new ones for hit-testing, double-click, zoom/pan, clipping, the min/max reduction and per-capture scales).
  • cargo clippy --workspace --all-targets -- -D warnings passes.
  • Tried by hand in the GUI with saved captures: traces, Dot mode, cursor dragging, zoom, pan and double-click reset.

🤖 Developed with Claude Code

Cursor dragging on the graph:
- The canvas now sends which lines it picked. A press within 12 px of the
  crossing of the nearest X and Y lines drags both; elsewhere only the
  single nearest line moves (distance in pixels, not fractions).
- A drag keeps following the pointer outside the canvas and ends on
  release anywhere, so it can no longer get stuck.
- Resize/move pointer over lines and crossings.

Traces:
- New plot.rs shared by the canvas and the PNG export: per-column min/max,
  so Line and Dot modes never drop samples (single-sample spikes stay
  visible). Smooth mode still averages.
- Canvas traces are clipped to the grid on the geometry itself.
  Frame::with_clip is not used: in iced 0.14 the clipped sub-frame is
  drawn before the parent's shapes, so the background hid the traces.
- PNG Dot mode draws every sample instead of every N-th one.
- The canvas draws in layers; the trace layer is cached and rebuilt only
  when samples, trace options or size change, so cursor drags no longer
  re-tessellate 60 000 samples. Dots use iced's rectangle fast path
  (one path of thousands of overlapping circles was very slow).

Per-capture scales (scale.rs):
- A capture with metadata uses its own V/div, V/off and t/div (shown
  read-only); a capture without metadata (debug dump) uses the manual
  scale from settings. Receiving, loading or selecting a capture no
  longer overwrites the manual scale, and PNG export uses the scale of
  the exported capture.

Also fixes three clippy lints new in Rust 1.100 so the lint check passes.
- Wheel zooms the time axis around the pointer (1.25x per notch,
  smooth on trackpads); horizontal scroll or Shift+wheel pans time.
- Option/Alt+wheel, or wheel over the voltage labels, zooms the voltage
  axis. Zoom-out may go past the device screen to the full ADC range
  0..=255; the screen's edges are then marked with orange lines.
- Right/middle-drag pans both axes.
- Double-click resets the zoom; the cursor move made by the first click
  is undone, so cursors stay where they were.
- Zooming through the unzoomed view stops there exactly (detent). Time
  zoom stops at 10 visible samples, voltage zoom at 8 ADC levels.
- The zoom is stored with the identity of its capture, so other captures
  are shown unzoomed without explicit resets.
- Measurement and device cursors stay on the signal; lines outside the
  view are neither drawn nor grabbable. Time and voltage labels follow
  the visible window with enough decimals; an "X xN  Y xM" indicator
  shows the zoomed axes. Only visible samples are drawn, clipped on both
  axes. PNG export is unchanged (whole capture, unzoomed).
- Remove the unused n_samples field of Scope.
- Workspace version 0.3.0 (dso-parser and the GUI inherit it; the CLI
  flasher keeps its own version, edition and dependencies).
- Edition 2021 -> 2024 and resolver 3 for the workspace. The edition
  migration adds `use<>` to plot::distinct_values (its iterator does not
  borrow the input). Nested ifs flagged by clippy's collapsible_if are
  merged into let-chains; only those blocks are reformatted.
- Remove workspace.package.description, which no member used (cargo
  warned about it).
- Dependencies: rust-i18n 3 -> 4, png 0.17 -> 0.18 (Compression::Best is
  now Compression::High), rfd 0.15 -> 0.18, dirs 6 -> 7 (config_dir is
  unchanged on all platforms, so settings stay where they are), and
  Cargo.lock refreshed to the latest compatible versions.
- Add a test that translations load for every supported language.
- README: Rust 1.85 or later is required for the 2024 edition.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant