fix(view): keep named views of earlier versions at their place, in f64

A VIEW record's centre is an offset from its target in view coordinates.
Views saved by earlier versions stored the target itself as the centre;
treating that as an offset put them (and VIEW plots) at about twice the
coordinates. One shared `named_view_center` now resolves the centre in
f64 (DVec3/DQuat), taking a centre equal to a non-zero target as the old
convention; VIEW RESTORE, the view plot window and Place on Sheet use it.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
Hakan SevenandClaude Opus 5.5 committed 2026-10-06 09:29:22 +03:00
1 parent 76f4bb97dc
commit 8b9049c604
4 files changed
+24 -9

No files matched your search

+2 -3
View File
@@ -247,14 +247,13 @@ struct ModelView {
}
/// Named view `view` of a model drawing, or its extents.
// ponytail: plan views only (centre = target + view centre); a twisted or 3D
// view would need the full DCS transform.
fn model_view(doc: &codec::CadDocument, view: Option<&str>) -> Option<ModelView> {
use codec::types::Vector3;
if let Some(name) = view {
let v = doc.views.iter().find(|v| !v.paper_space && v.name.eq_ignore_ascii_case(name))?;
let c = crate::scene::named_view_center(v);
return Some(ModelView {
center: Vector3::new(v.target.x + v.center.x, v.target.y + v.center.y, v.target.z),
center: Vector3::new(c.x, c.y, c.z),
width: v.width.abs().max(1e-6),
height: v.height.abs().max(1e-6),
target: v.target.clone(),
+2 -2
View File
@@ -5519,8 +5519,8 @@ impl OpenCADStudio {
let half_w = view.width.abs() * 0.5;
let half_h = view.height.abs() * 0.5;
(half_w > 1e-9 && half_h > 1e-9).then_some(())?;
// The view centre is relative to its target (plan views).
let (cx, cy) = (view.target.x + view.center.x, view.target.y + view.center.y);
let center = crate::scene::named_view_center(view);
let (cx, cy) = (center.x, center.y);
self.area_plot_job((cx - half_w, cy - half_h, cx + half_w, cy + half_h))
}