Use viewport snap frame and accepted snaps for dimension measurement

Removes PR2's two seams now that PR1 (viewport snapping) is underneath.

* `Scene::viewport_frame` is PR1's camera-derived implementation. The
  viewport-record version is gone; PR1's returns `None` for oblique /
  perspective viewports, which is what we want — every entry point in
  `viewport_dim_seam` then declines rather than guessing a planar
  mapping. `viewport_dim_seam` is now just the dimension object-pick
  path, and its module doc says so.

* There is one accepted-snap store: PR1's `OpenCADStudio::accepted_snaps`.
  PR2's parallel `dim_accepted_snaps` (and its command-name ownership
  tracking, which PR1's clear-on-command-start/end already does) is
  deleted, along with the `record_dimension_accepted_snap` seam.
  `accepted_snap_for_point` reads PR1's list.

  Two things layer on top:
  - the explicit object pick is not a point step, so it still records its
    own snaps, now through `push_accepted_snap` into PR1's list, and now
    carrying the picked entity handle + block path as a `SnapSourceRef`
    so PR3 can associate it;
  - a typed coordinate carries no snap, so `measure_snap` re-attaches the
    content viewport under a snap that is free *and* source-less. That
    keeps `DIMLINEAR` with typed coordinates inside a 1:10 viewport
    measuring the model, without ever reinterpreting a real paper-sheet
    snap that happens to sit over a viewport.

* One association gate, not two. `dimension_association_allowed` is the
  single predicate, derived from the same `dimension_measure_space`
  classification that decides whether to compensate the measurement, so
  the two can never disagree. `infer_dimension_sources_guarded` delegates
  to it, and the commit path's "commit unassociated when measured through
  a viewport" condition is now that predicate rather than a second,
  independently-computed bool. It also covers the explicit-pick and
  explicit-source-list branches, which the old inference-only guard did
  not. Because the classification ignores the trailing dimension-line
  placement click, an ordinary paper dimension whose placement click lands
  inside a viewport rectangle keeps its association.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
This commit is contained in:
Christopher OverbeckandClaude Fable 5.1 committed 2026-09-15 12:45:59 -05:00
1 parent 848f789018
commit 43dea41498
5 files changed
+170 -177

No files matched your search

+12 -23
View File
@@ -454,17 +454,6 @@ impl OpenCADStudio {
}
}
if matches!(&input, StepInput::Point(_)) { self.refresh_command_point_pick_context(i); }
// PR2: remember which viewport (if any) each dimension point was
// picked through, before the command turns it into geometry.
if let StepInput::Point(p) = &input {
if self.tabs[i]
.active_cmd
.as_ref()
.is_some_and(|command| command.measures_through_viewports())
{
self.record_dimension_accepted_snap(i, *p);
}
}
let ctrl = self.ctrl_down;
let shift = self.shift_down;
let result: Option<CmdResult> = {
@@ -2117,15 +2106,17 @@ impl OpenCADStudio {
acadrust::entities::Dimension::Ordinate(_)
)
);
// PR2: a dimension placed on the sheet but measuring model
// geometry through a viewport carries the compensation as a
// negative DIMLFAC override. It is deliberately *not*
// associated: its definition points are projected paper
// coordinates, so inferring a paper-space association would
// bind it to geometry that is not there. PR3 records the real
// dimension -> viewport -> entity chain.
let measured_through_viewport =
self.apply_viewport_dimension_measurement(i, &mut entity);
// A dimension placed on the sheet but measuring model geometry
// through a viewport carries the compensation as a negative
// DIMLFAC override.
self.apply_viewport_dimension_measurement(i, &mut entity);
// ...and is deliberately *not* associated in paper space: its
// definition points are projected paper coordinates, so a
// paper-space association would bind it to geometry that is
// not there. PR3 records the real dimension -> viewport ->
// entity chain instead. One gate, shared with
// `infer_dimension_sources_guarded`.
let association_allowed = self.dimension_association_allowed(i);
let inherited_dimension = if preserve_base_style {
match &entity {
acadrust::EntityType::Dimension(dimension) => Some((
@@ -2192,7 +2183,7 @@ impl OpenCADStudio {
entity,
preserve_base_style,
) {
if association_mode == 2 && !measured_through_viewport {
if association_mode == 2 && association_allowed {
let mut changes = vec![
(handle, crate::scene::ChangeKind::Modified),
];
@@ -2236,7 +2227,6 @@ impl OpenCADStudio {
self.tabs[i].dirty = true;
self.tabs[i].scene.clear_preview_wire();
self.tabs[i].snap_result = None;
self.clear_dimension_accepted_snaps();
if let Some(pd) = pending {
self.commit_undo_delta(i, pd);
}
@@ -2254,7 +2244,6 @@ impl OpenCADStudio {
}
}
CmdResult::CommitDimensionsAndExit(dimensions) => {
self.clear_dimension_accepted_snaps();
let association_mode = self.tabs[i]
.scene
.document