forked from 1b-agent/opencadstudio-upstream
feat(app): seed ribbon defaults from CECOLOR/CELTYPE/CELWEIGHT/CLAYER + apply CELTSCALE
The Home ribbon's creation-default chips were hard-coded to ByLayer
whenever the selection went empty. New entities therefore ignored the
file's saved CECOLOR / CELTYPE / CELWEIGHT and started fresh at ByLayer.
Pick those defaults up from header instead:
- sync_ribbon_from_selection() reads current_layer_name, current_entity_color,
current_linetype_{name|handle} and current_line_weight when nothing is
selected, mapping the i16 weight code through LineWeight::from_value.
- commit_entity() stamps header.current_entity_linetype_scale onto the
fresh entity's linetype_scale when it differs from 1.0.
ELEVATION / PAPER_ELEVATION / CMLSCALE / CMLJUST will follow with the
commands that consume them; PLINEGEN already routes through the per-
polyline bit at render time.
Co-Authored-By: Claude Opus 4.7 <[email protected]>
This commit is contained in:
1 parent
65920959d4
commit
0db21568c1
1 file changed
+36
-4
+36
-4
@@ -286,11 +286,36 @@ impl H7CAD {
|
||||
let i = self.active_tab;
|
||||
let selected = self.tabs[i].scene.selected_entities();
|
||||
if selected.is_empty() {
|
||||
let layer = self.tabs[i].active_layer.clone();
|
||||
// Creation defaults: prefer the file's saved CECOLOR / CELTYPE /
|
||||
// CELWEIGHT (and current_layer_name); fall back to ByLayer when
|
||||
// those slots are still at their factory default.
|
||||
let header = &self.tabs[i].scene.document.header;
|
||||
let layer = if header.current_layer_name.is_empty() {
|
||||
self.tabs[i].active_layer.clone()
|
||||
} else {
|
||||
header.current_layer_name.clone()
|
||||
};
|
||||
self.ribbon.active_layer = layer;
|
||||
self.ribbon.active_color = acadrust::types::Color::ByLayer;
|
||||
self.ribbon.active_linetype = "ByLayer".to_string();
|
||||
self.ribbon.active_lineweight = acadrust::types::LineWeight::ByLayer;
|
||||
self.ribbon.active_color = header.current_entity_color;
|
||||
// current_linetype_name may be empty when only the handle was
|
||||
// written; resolve via line_types table in that case.
|
||||
let lt = if !header.current_linetype_name.is_empty() {
|
||||
header.current_linetype_name.clone()
|
||||
} else if !header.current_linetype_handle.is_null() {
|
||||
self.tabs[i]
|
||||
.scene
|
||||
.document
|
||||
.line_types
|
||||
.iter()
|
||||
.find(|lt| lt.handle == header.current_linetype_handle)
|
||||
.map(|lt| lt.name.clone())
|
||||
.unwrap_or_else(|| "ByLayer".to_string())
|
||||
} else {
|
||||
"ByLayer".to_string()
|
||||
};
|
||||
self.ribbon.active_linetype = lt;
|
||||
self.ribbon.active_lineweight =
|
||||
acadrust::types::LineWeight::from_value(header.current_line_weight);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -410,6 +435,13 @@ impl H7CAD {
|
||||
&self.ribbon.active_linetype.clone(),
|
||||
);
|
||||
crate::scene::dispatch::apply_line_weight(&mut entity, self.ribbon.active_lineweight);
|
||||
// CELTSCALE (header.current_entity_linetype_scale): new entities
|
||||
// pick up the document's saved per-entity linetype scale. The user
|
||||
// can override per entity later via the properties panel.
|
||||
let celtscale = self.tabs[i].scene.document.header.current_entity_linetype_scale;
|
||||
if (celtscale - 1.0).abs() > 1e-9 && celtscale.abs() > 1e-9 {
|
||||
entity.common_mut().linetype_scale = celtscale;
|
||||
}
|
||||
|
||||
// Commands pick points in local space (camera coordinates with world_offset
|
||||
// already subtracted). Re-add world_offset so the entity lands at the correct
|
||||
|
||||
Reference in new issue
Block a user