forked from 1b-agent/opencadstudio-upstream
feat(properties): add 3D Visualization group + General Plot style/Hyperlink
Per the COMMON section of PROPERTIES.md. Insert a "3D Visualization" group (Material, Shadow display) after General for every graphical object, and add Plot style + Hyperlink rows to General. Material / plot style / shadow are sourced from the entity's flags (ByLayer / ByBlock / custom); resolving a custom material or plot-style handle to its name, and reading the hyperlink from XDATA, are follow-ups that need document access. Co-Authored-By: Claude Opus 4.8 <[email protected]>
This commit is contained in:
1 parent
b9cebab951
commit
f4c60a39a9
2 files changed
+62
No files matched your search
Vendored
+59
@@ -39,6 +39,18 @@ pub fn general_section(entity: &EntityType) -> PropSection {
|
||||
field: "linetype_scale",
|
||||
value: PropValue::EditText(format!("{:.4}", common.linetype_scale)),
|
||||
},
|
||||
Property {
|
||||
label: "Plot style".into(),
|
||||
field: "plot_style",
|
||||
value: PropValue::ReadOnly(
|
||||
match common.plotstyle_flags {
|
||||
0 => "ByLayer",
|
||||
1 => "ByBlock",
|
||||
_ => "ByColor",
|
||||
}
|
||||
.into(),
|
||||
),
|
||||
},
|
||||
Property {
|
||||
label: "Lineweight".into(),
|
||||
field: "lineweight",
|
||||
@@ -49,6 +61,11 @@ pub fn general_section(entity: &EntityType) -> PropSection {
|
||||
field: "transparency",
|
||||
value: PropValue::EditText(format!("{transp_pct}")),
|
||||
},
|
||||
Property {
|
||||
label: "Hyperlink".into(),
|
||||
field: "hyperlink",
|
||||
value: PropValue::ReadOnly(String::new()),
|
||||
},
|
||||
Property {
|
||||
label: "Invisible".into(),
|
||||
field: "invisible",
|
||||
@@ -61,6 +78,48 @@ pub fn general_section(entity: &EntityType) -> PropSection {
|
||||
}
|
||||
}
|
||||
|
||||
/// The "3D Visualization" group (Material + Shadow display), common to every
|
||||
/// graphical object. Material / plot-style / shadow source is flag-based; a
|
||||
/// custom material handle is shown as "Custom" (name resolution needs the doc).
|
||||
pub fn visualization_section(entity: &EntityType) -> Option<PropSection> {
|
||||
if matches!(
|
||||
entity,
|
||||
EntityType::Block(_)
|
||||
| EntityType::BlockEnd(_)
|
||||
| EntityType::Seqend(_)
|
||||
| EntityType::Unknown(_)
|
||||
) {
|
||||
return None;
|
||||
}
|
||||
let common = entity.common();
|
||||
let material = match common.material_flags {
|
||||
0 => "ByLayer",
|
||||
1 => "ByBlock",
|
||||
_ => "Custom",
|
||||
};
|
||||
let shadow = match common.shadow_flags {
|
||||
0 => "Casts and Receives Shadows",
|
||||
1 => "Casts Shadows",
|
||||
2 => "Receives Shadows",
|
||||
_ => "Ignores Shadows",
|
||||
};
|
||||
Some(PropSection {
|
||||
title: "3D Visualization".into(),
|
||||
props: vec![
|
||||
Property {
|
||||
label: "Material".into(),
|
||||
field: "material",
|
||||
value: PropValue::ReadOnly(material.into()),
|
||||
},
|
||||
Property {
|
||||
label: "Shadow display".into(),
|
||||
field: "shadow_display",
|
||||
value: PropValue::ReadOnly(shadow.into()),
|
||||
},
|
||||
],
|
||||
})
|
||||
}
|
||||
|
||||
pub fn fallback_properties(_handle: Handle, entity: &EntityType) -> PropSection {
|
||||
PropSection {
|
||||
title: "Geometry".into(),
|
||||
|
||||
@@ -18,6 +18,9 @@ pub fn properties_sectioned(
|
||||
text_style_names: &[String],
|
||||
) -> Vec<PropSection> {
|
||||
let mut sections = vec![properties::general_section(entity)];
|
||||
if let Some(viz) = properties::visualization_section(entity) {
|
||||
sections.push(viz);
|
||||
}
|
||||
let groups = entity.geometry_properties(text_style_names);
|
||||
if groups.is_empty() {
|
||||
sections.push(properties::fallback_properties(handle, entity));
|
||||
|
||||
Reference in new issue
Block a user