fix(annotative): start new drawings at the unit-aware annotation scale

A new drawing is metric with metre insertion units, but its annotation
multiplier stayed at Scene::new()'s unitless 1 while opened files and
CANNOSCALE convert paper millimetres into drawing units (0.001 at 1:1).
Annotative text and dimensions were drawn 1000x too large until the
first scale change, then shrank to their real size and looked gone,
also after switching back to 1:1.

One helper now derives the multiplier from the header; new drawings,
file open and every INSUNITS change (UNITS, the units popup, DWGUNITS,
SETVAR) go through it.

Fixes #1674

Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
Hakan SevenandClaude Opus 5.5 committed 2026-10-13 10:41:00 +03:00
1 parent 85627ebc8a
commit 5d0390bcdf
6 files changed
+31 -31

No files matched your search

+1
View File
@@ -893,6 +893,7 @@ impl OpenCADStudio {
self.push_undo_snapshot(i, "DWGUNITS");
self.tabs[i].scene.document.header.insertion_units = to;
self.tabs[i].scene.sync_annotation_scale_from_header();
let factor = units::conversion_factor(from, to).filter(|f| (f - 1.0).abs() > 1e-12);
let (from_label, to_label) = (units::label(from), units::label(to));
+4
View File
@@ -3088,6 +3088,10 @@ impl OpenCADStudio {
self.delete_objects = value;
}
if changed {
if name == "INSUNITS" {
self.tabs[i].scene.sync_annotation_scale_from_header();
self.tabs[i].scene.invalidate_annotation_dependencies();
}
if matches!(
name.as_str(),
"ZOOMWHEEL"
+1 -16
View File
@@ -2115,22 +2115,7 @@ impl OpenCADStudio {
) {
crate::scene::text::ttf_glyph::clear_fallback_cache();
}
// Current model-space annotation scale comes from the drawing's
// CANNOSCALEVALUE (paper/drawing factor). Convert its inverse into
// drawing units as well: metric annotation sizes are paper millimetres
// and imperial annotation sizes are paper inches.
// Current model-space annotation scale comes from the drawing's
// CANNOSCALEVALUE (paper/drawing factor). Convert its paper unit into
// the drawing's INSUNITS as well, so e.g. a metre drawing uses
// 0.001 model units for 1 mm of paper at 1:1.
let cannoscale_value = self.tabs[i].scene.document.header.annotation_scale_value;
let unit_factor = self.tabs[i].scene.annotation_scale_unit_factor();
self.tabs[i].scene.annotation_scale = if cannoscale_value > 1e-9 {
((1.0 / cannoscale_value) / unit_factor) as f32
} else {
(1.0 / unit_factor) as f32
};
self.tabs[i].scene.sync_annotation_scale_from_header();
// Open-time breakdown so regressions are visible immediately.
// `total` is wall time from the Open click to here (post-xref,
+4
View File
@@ -5442,6 +5442,8 @@ impl OpenCADStudio {
header.angle_base = degrees.to_radians();
}
header.insertion_units = state.insertion_units;
self.tabs[i].scene.sync_annotation_scale_from_header();
self.tabs[i].scene.invalidate_annotation_dependencies();
self.tabs[i].dirty = true;
self.tabs[i].scene.bump_geometry();
self.refresh_properties();
@@ -6020,6 +6022,8 @@ impl OpenCADStudio {
// menu having done nothing. (#668)
self.push_undo_snapshot(i, "UNITS");
self.tabs[i].scene.document.header.insertion_units = code;
self.tabs[i].scene.sync_annotation_scale_from_header();
self.tabs[i].scene.invalidate_annotation_dependencies();
self.tabs[i].dirty = true;
let label = crate::modules::draw::units::label(code);
self.command_line.push_output(