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

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.
This commit is contained in:
sLuCHa committed 2026-07-06 13:38:56 +02:00
1 parent b50921923f
commit 6cd422e5b9
4 files changed
+121 -2

No files matched your search

+7
View File
@@ -530,6 +530,13 @@ pub trait CadCommand: Send {
false
}
/// True if this command should have Endpoint/Intersection object-snap
/// forced on while it is active, regardless of the global OSNAP toggle.
/// Used by PLOTWINDOW so the plot-area corners always snap to geometry.
fn forces_endpoint_snap(&self) -> bool {
false
}
/// Called when the text editor closes, either because the user committed or cancelled the edit.
fn on_editor_closed(&mut self, _committed: bool) -> CmdResult {
CmdResult::Cancel