From 86a29b4b976277151c77eaaa3270f1180032d2cc Mon Sep 17 00:00:00 2001 From: Sebastian <106036+schoeller@users.noreply.github.com> Date: Sun, 23 Aug 2026 21:27:30 +0200 Subject: [PATCH] feat(properties): show XDATA records in Properties panel --- locales/en-US/opencadstudio.ftl | 1 + src/app/properties.rs | 47 +++++++++++++++++++++++++++++++++ src/locale_catalog.rs | 1 + 3 files changed, 49 insertions(+) diff --git a/locales/en-US/opencadstudio.ftl b/locales/en-US/opencadstudio.ftl index 671366f4d..99040facd 100644 --- a/locales/en-US/opencadstudio.ftl +++ b/locales/en-US/opencadstudio.ftl @@ -2563,6 +2563,7 @@ properties = .ext-line-lineweight = Ext line lineweight .ext-line-offset = Ext line offset .extended-entity = Extended Entity + .extended-data = Extended Data .extended-lighting = Extended Lighting .extents-max = Extents Max .extents-min = Extents Min diff --git a/src/app/properties.rs b/src/app/properties.rs index abb9b0bc7..a51ed03a2 100644 --- a/src/app/properties.rs +++ b/src/app/properties.rs @@ -27,6 +27,27 @@ fn visual_style_properties_text(style: &acadrust::objects::VisualStyle) -> Strin .join("\n") } +/// Format an XDATA value for display in the Properties panel. +fn format_xdata_value(value: &acadrust::xdata::XDataValue) -> String { + use acadrust::xdata::XDataValue; + match value { + XDataValue::String(s) => s.clone(), + XDataValue::ControlString(s) => format!("ControlString: {s}"), + XDataValue::LayerName(s) => format!("Layer: {s}"), + XDataValue::BinaryData(b) => format!("Binary: {} bytes", b.len()), + XDataValue::Handle(h) => format!("Handle: {:X}", h.value()), + XDataValue::Point3D(v) + | XDataValue::Position3D(v) + | XDataValue::Displacement3D(v) + | XDataValue::Direction3D(v) => format!("{:.6}, {:.6}, {:.6}", v.x, v.y, v.z), + XDataValue::Real(r) | XDataValue::Distance(r) | XDataValue::ScaleFactor(r) => { + format!("{r}") + } + XDataValue::Integer16(i) => format!("{i}"), + XDataValue::Integer32(i) => format!("{i}"), + } +} + impl OpenCADStudio { /// Rebuild the PropertiesPanel from the current entity selection. /// Preserves UI state (open pickers, edit buffer) across refreshes. @@ -613,6 +634,32 @@ impl OpenCADStudio { entity, )); + // Extended Data (XDATA) section: show attached app records. + { + use crate::entities::common::ro_prop; + let xd = &source_entity.common().extended_data; + if !xd.is_empty() { + let mut xd_props = Vec::new(); + for rec in xd.records() { + let value_text = rec + .values + .iter() + .map(format_xdata_value) + .collect::>() + .join(", "); + xd_props.push(ro_prop( + &rec.application_name, + "xdata_value", + value_text, + )); + } + sections.push(crate::scene::model::object::PropSection { + title: t!("Extended Data").into_owned(), + props: xd_props, + }); + } + } + // Uniform-scale checkbox for block references (#427): // while the three scale factors are equal (and the user // hasn't opted into per-axis editing) the panel shows one diff --git a/src/locale_catalog.rs b/src/locale_catalog.rs index c9d6a8944..eeb33ea4c 100644 --- a/src/locale_catalog.rs +++ b/src/locale_catalog.rs @@ -1006,6 +1006,7 @@ pub(super) fn message_attribute(source: &str) -> Option<(&'static str, &'static "Ext line offset" => Some(("properties", "ext-line-offset")), "Ext line weight (DIMLWE)" => Some(("draw", "ext-line-weight-dimlwe")), "Extend" => Some(("modify", "extend")), + "Extended Data" => Some(("properties", "extended-data")), "Extended Entity" => Some(("properties", "extended-entity")), "Extended Lighting" => Some(("properties", "extended-lighting")), "Extension" => Some(("common", "extension")),