forked from 1b-agent/opencadstudio-upstream
refactor(entities): collocate ui_name + dxf_name into entities/names.rs
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 <[email protected]>
This commit is contained in:
1 parent
9b5073752d
commit
5da32ff202
5 files changed
+104
-87
No files matched your search
+1
-47
@@ -62,54 +62,8 @@ pub fn fallback_properties(_handle: Handle, entity: &EntityType) -> PropSection
|
||||
props: vec![Property {
|
||||
label: "Type".into(),
|
||||
field: "type",
|
||||
value: PropValue::ReadOnly(entity_type_name(entity).into()),
|
||||
value: PropValue::ReadOnly(crate::entities::names::ui_name(entity).into()),
|
||||
}],
|
||||
}
|
||||
}
|
||||
|
||||
pub fn entity_type_name(e: &EntityType) -> &'static str {
|
||||
match e {
|
||||
EntityType::Point(_) => "Point",
|
||||
EntityType::Line(_) => "Line",
|
||||
EntityType::Circle(_) => "Circle",
|
||||
EntityType::Arc(_) => "Arc",
|
||||
EntityType::Ellipse(_) => "Ellipse",
|
||||
EntityType::Spline(_) => "Spline",
|
||||
EntityType::LwPolyline(_) => "Polyline",
|
||||
EntityType::Polyline(_) => "Polyline",
|
||||
EntityType::Polyline2D(_) => "Polyline2D",
|
||||
EntityType::Polyline3D(_) => "Polyline3D",
|
||||
EntityType::PolyfaceMesh(_) => "PolyfaceMesh",
|
||||
EntityType::PolygonMesh(_) => "PolygonMesh",
|
||||
EntityType::Text(_) => "Text",
|
||||
EntityType::MText(_) => "MText",
|
||||
EntityType::Dimension(_) => "Dimension",
|
||||
EntityType::Leader(_) => "Leader",
|
||||
EntityType::MultiLeader(_) => "MultiLeader",
|
||||
EntityType::Tolerance(_) => "Tolerance",
|
||||
EntityType::Insert(_) => "Block Reference",
|
||||
EntityType::Block(_) => "Block",
|
||||
EntityType::BlockEnd(_) => "Block End",
|
||||
EntityType::Hatch(_) => "Hatch",
|
||||
EntityType::Solid(_) => "Solid",
|
||||
EntityType::Face3D(_) => "3D Face",
|
||||
EntityType::Solid3D(_) => "3D Solid",
|
||||
EntityType::Region(_) => "Region",
|
||||
EntityType::Body(_) => "Body",
|
||||
EntityType::Mesh(_) => "Mesh",
|
||||
EntityType::Ray(_) => "Ray",
|
||||
EntityType::XLine(_) => "XLine",
|
||||
EntityType::MLine(_) => "MLine",
|
||||
EntityType::Viewport(_) => "Viewport",
|
||||
EntityType::RasterImage(_) => "Raster Image",
|
||||
EntityType::Wipeout(_) => "Wipeout",
|
||||
EntityType::Underlay(_) => "Underlay",
|
||||
EntityType::Shape(_) => "Shape",
|
||||
EntityType::Table(_) => "Table",
|
||||
EntityType::AttributeDefinition(_) => "Attribute Definition",
|
||||
EntityType::AttributeEntity(_) => "Attribute",
|
||||
EntityType::Ole2Frame(_) => "OLE Frame",
|
||||
EntityType::Seqend(_) => "Seqend",
|
||||
EntityType::Unknown(_) => "Unknown",
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user