forked from 1b-agent/opencadstudio-upstream
feat(snap): snap paper space through layout viewports
Paper-space commands could not pick model geometry displayed by a layout viewport: `hit_test_wires` deliberately excludes viewport content in PSPACE, and that has to stay true for selection. This adds the capability as a separate query rather than by changing those semantics. `OpenCADStudio::paper_viewport_snap` walks the current layout's displayed content viewports top-most first, skips those whose display is off or whose clip boundary excludes the cursor, and for each one runs the EXISTING snap engine against that viewport's model wires using the viewport's own camera and screen rectangle (`viewport_edit_frame_for`). The accepted model point is mapped back onto the sheet with `ViewportFrame::model_to_paper`, so everything downstream keeps working in paper coordinates — LINE still draws at the projected paper point. Grid snap and the paper-space rubber-band origin are suppressed for that pass; results outside the clip are rejected so no snap lands on a clip cut. Locked viewports snap like unlocked ones. No projected geometry is rebuilt per pointer event: the wire set is the renderer's resident per-viewport Arc (`model_wires_for_viewport_arc`) and the broad phase reuses the shared interaction index over it. The result is merged with the ordinary paper-sheet snap by `snap::merge_snap`, which applies the engine's own priority-then-distance rule, in both the cursor-move and the click paths. `SnapResult` gains Copy fields `viewport: Option<Handle>` and `source: Option<DimensionAssociationSource>`; the engine fills `source` from the owning wire wherever it knows it. `AcceptedSnap::from_snap` converts a result plus frame into the shared PR2/PR3 contract type. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
1 parent
53576fabdf
commit
6def465ba5
5 files changed
+525
-33
No files matched your search
@@ -95,6 +95,7 @@ mod file;
|
||||
mod style;
|
||||
mod util;
|
||||
mod viewport;
|
||||
mod viewport_snap;
|
||||
|
||||
impl OpenCADStudio {
|
||||
pub(in crate::app) fn reset_modal_geometry(&mut self) {
|
||||
|
||||
Reference in new issue
Block a user