Two near-identical match-on-EntityType tables lived far apart: scene/properties.rs::entity_type_name returned mixed-case UI labels; app/commands.rs::entity_type_name returned uppercase DXF record names. Both enumerated ~30 variants; adding a new entity meant remembering to touch two files in two crates' worth of source layout. Move both into a single entities/names.rs as `ui_name()` and `dxf_name()`. Adjacent so a new variant gets both labels added at once; function names make the intended audience explicit at the callsite. scene/properties.rs and app/commands.rs each lose their local match plus one re-export, gaining a `crate::entities::names::*` call. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
69 lines
2.2 KiB
Rust
69 lines
2.2 KiB
Rust
use acadrust::{EntityType, Handle};
|
|
|
|
use crate::scene::object::{PropSection, PropValue, Property};
|
|
|
|
pub fn general_section(entity: &EntityType) -> PropSection {
|
|
let common = entity.common();
|
|
let linetype_display = if common.linetype.is_empty() {
|
|
"ByLayer".to_string()
|
|
} else {
|
|
common.linetype.clone()
|
|
};
|
|
let transp_pct = (common.transparency.alpha() as f64 / 255.0 * 100.0).round() as u32;
|
|
|
|
PropSection {
|
|
title: "General".into(),
|
|
props: vec![
|
|
Property {
|
|
label: "Layer".into(),
|
|
field: "layer",
|
|
value: PropValue::LayerChoice(common.layer.clone()),
|
|
},
|
|
Property {
|
|
label: "Color".into(),
|
|
field: "color",
|
|
value: PropValue::ColorChoice(common.color),
|
|
},
|
|
Property {
|
|
label: "Linetype".into(),
|
|
field: "linetype",
|
|
value: PropValue::LinetypeChoice(linetype_display),
|
|
},
|
|
Property {
|
|
label: "LT Scale".into(),
|
|
field: "linetype_scale",
|
|
value: PropValue::EditText(format!("{:.4}", common.linetype_scale)),
|
|
},
|
|
Property {
|
|
label: "Lineweight".into(),
|
|
field: "lineweight",
|
|
value: PropValue::LwChoice(common.line_weight),
|
|
},
|
|
Property {
|
|
label: "Transparency".into(),
|
|
field: "transparency",
|
|
value: PropValue::EditText(format!("{transp_pct}")),
|
|
},
|
|
Property {
|
|
label: "Invisible".into(),
|
|
field: "invisible",
|
|
value: PropValue::BoolToggle {
|
|
field: "invisible",
|
|
value: common.invisible,
|
|
},
|
|
},
|
|
],
|
|
}
|
|
}
|
|
|
|
pub fn fallback_properties(_handle: Handle, entity: &EntityType) -> PropSection {
|
|
PropSection {
|
|
title: "Geometry".into(),
|
|
props: vec![Property {
|
|
label: "Type".into(),
|
|
field: "type",
|
|
value: PropValue::ReadOnly(crate::entities::names::ui_name(entity).into()),
|
|
}],
|
|
}
|
|
}
|
|
|