forked from 1b-agent/opencadstudio-upstream
fix(style): new text/mtext/dimension use the current style (#92)
New annotation entities were created at the entity "Standard" default instead of the document's current style, so making a style current had no effect on creation. - Text / MText: seed the new entity (and the MText editor preview) from header.current_text_style_name. - Dimension: commit_entity_handle fills the new dimension's style_name from header.current_dimstyle_name, covering every dimension command centrally. Applied only when the entity is still at its default so an explicitly styled entity is preserved. MLeader and Table styles need their style tables modelled first and are left for follow-up. Co-Authored-By: Claude Opus 4.8 <[email protected]>
This commit is contained in:
1 parent
29ccfcfc46
commit
92e32243eb
3 files changed
+41
-1
No files matched your search
@@ -364,6 +364,18 @@ impl super::OpenCADStudio {
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
} else {
|
||||
// New MText inherits the document's current text style (STYLE),
|
||||
// not the "Standard" default. See #92.
|
||||
let cur_style = self.tabs[self.active_tab]
|
||||
.scene
|
||||
.document
|
||||
.header
|
||||
.current_text_style_name
|
||||
.clone();
|
||||
if !cur_style.trim().is_empty() {
|
||||
state.style = cur_style;
|
||||
}
|
||||
}
|
||||
self.mtext_editor = Some(state);
|
||||
self.rebuild_mtext_preview();
|
||||
|
||||
@@ -541,6 +541,23 @@ impl OpenCADStudio {
|
||||
entity.common_mut().linetype_scale = celtscale;
|
||||
}
|
||||
|
||||
// A new dimension inherits the document's current dimension style
|
||||
// (DIMSTYLE) instead of staying at the entity "Standard" default. Only
|
||||
// fill in when still at the default so an explicitly-styled dimension
|
||||
// is preserved. See #92.
|
||||
if let acadrust::EntityType::Dimension(ref mut d) = entity {
|
||||
let cur = self.tabs[i]
|
||||
.scene
|
||||
.document
|
||||
.header
|
||||
.current_dimstyle_name
|
||||
.clone();
|
||||
let s = d.base().style_name.clone();
|
||||
if (s.is_empty() || s.eq_ignore_ascii_case("Standard")) && !cur.is_empty() {
|
||||
d.base_mut().style_name = cur;
|
||||
}
|
||||
}
|
||||
|
||||
// Commands pick points in local space (camera coordinates with world_offset
|
||||
// already subtracted). Re-add world_offset so the entity lands at the correct
|
||||
// DXF coordinate. Skip for paper-space entities (they use sheet mm coords).
|
||||
|
||||
+12
-1
@@ -190,11 +190,22 @@ impl super::OpenCADStudio {
|
||||
self.tabs[i].scene.bump_geometry();
|
||||
self.tabs[i].dirty = true;
|
||||
} else {
|
||||
let t = Text::with_value(
|
||||
let mut t = Text::with_value(
|
||||
&ed.value,
|
||||
Vector3::new(ed.pos.x as f64, ed.pos.y as f64, ed.pos.z as f64),
|
||||
)
|
||||
.with_height(ed.height);
|
||||
// New text inherits the document's current text style (STYLE), not
|
||||
// the entity default. See #92.
|
||||
let cur_style = self.tabs[i]
|
||||
.scene
|
||||
.document
|
||||
.header
|
||||
.current_text_style_name
|
||||
.clone();
|
||||
if !cur_style.is_empty() {
|
||||
t.style = cur_style;
|
||||
}
|
||||
self.push_undo_snapshot(i, "TEXT");
|
||||
self.commit_entity(EntityType::Text(t));
|
||||
self.tabs[i].dirty = true;
|
||||
|
||||
Reference in new issue
Block a user