forked from 1b-agent/opencadstudio-upstream
annotation: TEXT/MTEXT store the model height of their default scale
Annotative text in DWG/DXF holds the model height of its default (native) scale representation; other scales draw it at the ratio of the two. OCS read the stored value as paper height and multiplied it by the annotation scale again, so text from AutoCAD came out far too small (#1734), and annotative text OCS wrote came out too small in AutoCAD. - Rendering uses the active/native context ratio (1 when the object has no representation for the displayed scale). - TEXT with an annotative style asks for the paper height, stores the model height of the creation scale and gets that context; MTEXT starts from the model height; ANNOUPDATE converts a fixed style height the same way. - Properties: the Height row of annotative TEXT and MTEXT is the paper height at the displayed scale, with the model height beside it, and an edit converts back. MTEXT shows Annotative when it has contexts. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
b221ce5e33
commit
39c3e9af58
8 files changed
+183
-101
No files matched your search
+27
-12
@@ -276,22 +276,24 @@ impl super::OpenCADStudio {
|
||||
t.style = cur_style;
|
||||
}
|
||||
}
|
||||
if command_creation {
|
||||
let annotation_multiplier = if crate::scene::annotative::text_style_is_annotative(
|
||||
// TEXT asks an annotative style for the paper height; the entity
|
||||
// stores the model height of the scale it is created at.
|
||||
let annotative = command_creation
|
||||
&& crate::scene::annotative::text_style_is_annotative(
|
||||
&self.tabs[i].scene.document,
|
||||
&t.style,
|
||||
) {
|
||||
self.tabs[i].scene.creation_annotation_multiplier()
|
||||
} else {
|
||||
1.0
|
||||
};
|
||||
);
|
||||
let paper_height = t.height;
|
||||
if annotative {
|
||||
t.height *= self.tabs[i].scene.creation_annotation_multiplier();
|
||||
}
|
||||
if command_creation {
|
||||
let display_height = crate::entities::text::text_run_placement_at_scale(
|
||||
&t,
|
||||
&self.tabs[i].scene.document,
|
||||
annotation_multiplier as f32,
|
||||
1.0,
|
||||
)
|
||||
.height as f64
|
||||
* annotation_multiplier;
|
||||
.height as f64;
|
||||
if let Some(command) = self.tabs[i].suspended_cmd.as_mut() {
|
||||
command.on_editor_display_height(display_height);
|
||||
}
|
||||
@@ -311,9 +313,22 @@ impl super::OpenCADStudio {
|
||||
codec::entities::TextHorizontalAlignment::Aligned
|
||||
)
|
||||
{
|
||||
self.tabs[i].scene.document.header.text_height = t.height;
|
||||
self.tabs[i].scene.document.header.text_height = paper_height;
|
||||
}
|
||||
let handle = self.commit_entity_handle(plane.place_entity(EntityType::Text(t)));
|
||||
if annotative {
|
||||
let scale = self.tabs[i].scene.creation_annotation_scale_handle();
|
||||
if let (Some(handle), Some(scale)) = (handle, scale) {
|
||||
crate::scene::annotative::create_annotation_context(
|
||||
&mut self.tabs[i].scene.document,
|
||||
handle,
|
||||
scale,
|
||||
);
|
||||
self.tabs[i]
|
||||
.scene
|
||||
.bump_entities(&[(handle, crate::scene::ChangeKind::Modified)]);
|
||||
}
|
||||
}
|
||||
let _ = self.commit_entity_handle(plane.place_entity(EntityType::Text(t)));
|
||||
self.tabs[i].dirty = true;
|
||||
}
|
||||
self.refresh_properties();
|
||||
|
||||
Reference in new issue
Block a user