Skip to content

feat(plot): snap plot-window corners to geometry endpoints#293

Open
sLuCHaa wants to merge 1 commit into
HakanSeven12:mainfrom
sLuCHaa:feat/plotwindow-corner-snap-pr
Open

feat(plot): snap plot-window corners to geometry endpoints#293
sLuCHaa wants to merge 1 commit into
HakanSeven12:mainfrom
sLuCHaa:feat/plotwindow-corner-snap-pr

Conversation

@sLuCHaa

@sLuCHaa sLuCHaa commented Jul 6, 2026

Copy link
Copy Markdown
Contributor

Summary

PLOTWINDOW / PW now snaps to geometry while you pick the two corners of the plot window, so the plotted area lands exactly on a frame's corners.

Previously the plot-window corners followed the raw cursor (the global object-snap master toggle is off by default, so nothing snapped), and it was hard to hit the frame corners precisely.

Behavior

While PLOTWINDOW is picking either corner (model or paper space), Endpoint object-snap is forced on — independent of the global OSNAP toggle — with the normal snap marker, so the pick lands on frame corners. The snapper's master toggle and configured modes are saved before the pick and restored after, so the user's global OSNAP settings are unchanged. No other command is affected.

Implementation

  • CadCommand::forces_endpoint_snap(&self) -> bool — new opt-in trait method (default false); only PlotWindowCommand returns true.
  • Snapper::snap_forced_corners(...) — same signature as snap(); replaces the active mode set with Endpoint only, runs the existing snap(), then restores snap_enabled and the mode set.
    • Endpoint only, deliberately: frame corners are line endpoints, so a single O(n) Endpoint pass catches them. Intersection snap is O(n²) over every segment pair in the hit-test wire set and froze the UI on large drawings viewed zoomed-out (exactly when a plot window is picked), so it is excluded.
  • The cursor-move handler routes the plot-window pick through snap_forced_corners when the active command opts in, leaving every other command on the existing snap() path.

The rest of the snap pipeline (marker rendering, effective-point selection, on_point) is unchanged.

Tests

  • PlotWindowCommand::forces_endpoint_snap() returns true (opt-in).
  • forced_corner_modes() is exactly {Endpoint} (no Intersection/Midpoint/Center).
  • snap_forced_corners restores snap_enabled and the mode set after the call.

The live corner-snap-during-pick was verified manually (it depends on the camera projection, already covered by existing snap tests).

Scope

PLOTWINDOW / PW only. No changes to global OSNAP defaults or any other snap caller.

PLOTWINDOW / PW now forces Endpoint object-snap while picking its two
corners, independent of the global OSNAP toggle, so the plot area lands
exactly on frame corners. The snapper's master toggle and configured
modes are saved and restored around the pick, so the user's OSNAP
settings are unchanged afterward.

- CadCommand::forces_endpoint_snap() opt-in (default false; PlotWindowCommand true).
- Snapper::snap_forced_corners() forces Endpoint only, then restores state.
  Intersection is deliberately excluded: it is O(n^2) over the hit-test wire
  set and froze the UI on large drawings when a plot window is picked
  zoomed-out. Frame corners are endpoints, so Endpoint alone suffices.
- the cursor-move handler routes the plot-window pick through the forced path.

Works in model and paper space (shared pick path). Tests: opt-in flag;
forced mode set is endpoint-only; snapper state is restored after the call.
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