feat(properties): show XDATA records in Properties panel

This commit is contained in:
Sebastian committed 2026-08-23 21:27:30 +02:00
1 parent a67affcb93
commit 86a29b4b97
3 files changed
+49

No files matched your search

+1
View File
@@ -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
+47
View File
@@ -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::<Vec<_>>()
.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
+1
View File
@@ -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")),