From 726984e3a5a9cd024c6c5aa5ec53fbabb2321e97 Mon Sep 17 00:00:00 2001 From: Hakan Seven Date: Fri, 3 Jul 2026 16:51:05 +0300 Subject: [PATCH] feat(properties): show Thickness in the General group Thickness (DXF 39) is a General-group property in the palette, but it is stored per-entity, so it was previously shown (inconsistently) only in the Geometry section of a few entities. Surface it in General for every entity type that carries an extrusion thickness (arc, circle, line, lwpolyline, point, polyface mesh, 2D polyline, shape, 2D solid, text) via entity_thickness / set_entity_thickness, routed through apply_common_prop. Removes the now-duplicate Thickness rows (and dead apply arms) from the arc/circle/shape/solid Geometry sections so it is never shown twice. Co-Authored-By: Claude Opus 4.8 --- src/entities/arc.rs | 2 -- src/entities/circle.rs | 2 -- src/entities/shape.rs | 2 -- src/entities/solid.rs | 2 -- src/scene/cache/properties.rs | 30 ++++++++++++++++-------- src/scene/view/dispatch.rs | 43 +++++++++++++++++++++++++++++++++++ 6 files changed, 64 insertions(+), 17 deletions(-) diff --git a/src/entities/arc.rs b/src/entities/arc.rs index a1aa18c88..96b6c9e6b 100644 --- a/src/entities/arc.rs +++ b/src/entities/arc.rs @@ -170,7 +170,6 @@ fn properties(arc: &Arc) -> Vec { edit("Normal X", "normal_x", arc.normal.x), edit("Normal Y", "normal_y", arc.normal.y), edit("Normal Z", "normal_z", arc.normal.z), - edit("Thickness", "thickness", arc.thickness), ], }] } @@ -189,7 +188,6 @@ fn apply_geom_prop(arc: &mut Arc, field: &str, value: &str) { "normal_x" => arc.normal.x = v, "normal_y" => arc.normal.y = v, "normal_z" => arc.normal.z = v, - "thickness" => arc.thickness = v, _ => {} } } diff --git a/src/entities/circle.rs b/src/entities/circle.rs index 6eafc05d7..4f04c041e 100644 --- a/src/entities/circle.rs +++ b/src/entities/circle.rs @@ -138,7 +138,6 @@ fn properties(circle: &Circle) -> Vec { edit("Normal X", "normal_x", circle.normal.x), edit("Normal Y", "normal_y", circle.normal.y), edit("Normal Z", "normal_z", circle.normal.z), - edit("Thickness", "thickness", circle.thickness), ], }] } @@ -155,7 +154,6 @@ fn apply_geom_prop(circle: &mut Circle, field: &str, value: &str) { "normal_x" => circle.normal.x = v, "normal_y" => circle.normal.y = v, "normal_z" => circle.normal.z = v, - "thickness" => circle.thickness = v, _ => {} } } diff --git a/src/entities/shape.rs b/src/entities/shape.rs index 12e419418..cd60f7205 100644 --- a/src/entities/shape.rs +++ b/src/entities/shape.rs @@ -144,7 +144,6 @@ impl PropertyEditable for Shape { edit("Rotation", "shp_rot", self.rotation.to_degrees()), edit("Width Factor", "shp_xs", self.relative_x_scale), edit("Oblique Angle", "shp_ob", self.oblique_angle.to_degrees()), - edit("Thickness", "shp_th", self.thickness), edit("Normal X", "shp_nx", self.normal.x), edit("Normal Y", "shp_ny", self.normal.y), edit("Normal Z", "shp_nz", self.normal.z), @@ -168,7 +167,6 @@ impl PropertyEditable for Shape { "shp_rot" => self.rotation = v.to_radians(), "shp_xs" if v.abs() > 1e-9 => self.relative_x_scale = v, "shp_ob" => self.oblique_angle = v.to_radians(), - "shp_th" => self.thickness = v, "shp_nx" => self.normal.x = v, "shp_ny" => self.normal.y = v, "shp_nz" => self.normal.z = v, diff --git a/src/entities/solid.rs b/src/entities/solid.rs index 74c33af7c..88365210c 100644 --- a/src/entities/solid.rs +++ b/src/entities/solid.rs @@ -117,7 +117,6 @@ impl PropertyEditable for Solid { edit("Point 4 Y", "sl_p4y", self.fourth_corner.y), edit("Point 4 Z", "sl_p4z", self.fourth_corner.z), ro("Elevation", "sl_elev", format!("{:.4}", elevation)), - edit("Thickness", "sl_thick", self.thickness), ], }] } @@ -139,7 +138,6 @@ impl PropertyEditable for Solid { "sl_p4x" => self.fourth_corner.x = v, "sl_p4y" => self.fourth_corner.y = v, "sl_p4z" => self.fourth_corner.z = v, - "sl_thick" => self.thickness = v, _ => {} } } diff --git a/src/scene/cache/properties.rs b/src/scene/cache/properties.rs index ebafc0a67..5e7293819 100644 --- a/src/scene/cache/properties.rs +++ b/src/scene/cache/properties.rs @@ -23,7 +23,7 @@ pub fn general_section(entity: &EntityType) -> PropSection { }) .unwrap_or_default(); - PropSection { + let mut section = PropSection { title: "General".into(), props: vec![ Property { @@ -78,16 +78,28 @@ pub fn general_section(entity: &EntityType) -> PropSection { field: "hyperlink", value: PropValue::ReadOnly(hyperlink), }, - Property { - label: "Invisible".into(), - field: "invisible", - value: PropValue::BoolToggle { - field: "invisible", - value: common.invisible, - }, - }, ], + }; + + // Thickness (DXF 39) is a General-group property, but only the entity + // types that carry an extrusion thickness expose it (line, circle, arc, + // polyline, text, 2D solid, …). Show it right after Hyperlink for those. + if let Some(t) = crate::scene::view::dispatch::entity_thickness(entity) { + section + .props + .push(crate::entities::common::edit_prop("Thickness", "thickness", t)); } + + section.props.push(Property { + label: "Invisible".into(), + field: "invisible", + value: PropValue::BoolToggle { + field: "invisible", + value: common.invisible, + }, + }); + + section } /// The "3D Visualization" group (Material + Shadow display), common to every diff --git a/src/scene/view/dispatch.rs b/src/scene/view/dispatch.rs index 6ab1e8ed7..98503a3e7 100644 --- a/src/scene/view/dispatch.rs +++ b/src/scene/view/dispatch.rs @@ -56,6 +56,49 @@ pub fn apply_common_prop(entity: &mut EntityType, field: &str, value: &str) { .set_transparency(Transparency::new(alpha)); } } + "thickness" => { + if let Ok(v) = value.trim().parse::() { + set_entity_thickness(entity, v); + } + } + _ => {} + } +} + +/// The extrusion thickness (DXF 39) of the entities that carry one, or `None` +/// for entity types that have none. Thickness is a per-entity field but is +/// surfaced in the General group (as in a standard properties palette), so +/// this bridges the two. +pub fn entity_thickness(entity: &EntityType) -> Option { + Some(match entity { + EntityType::Arc(e) => e.thickness, + EntityType::Circle(e) => e.thickness, + EntityType::Line(e) => e.thickness, + EntityType::LwPolyline(e) => e.thickness, + EntityType::Point(e) => e.thickness, + EntityType::PolyfaceMesh(e) => e.thickness, + EntityType::Polyline2D(e) => e.thickness, + EntityType::Shape(e) => e.thickness, + EntityType::Solid(e) => e.thickness, + EntityType::Text(e) => e.thickness, + _ => return None, + }) +} + +/// Set the extrusion thickness on the entity types that carry one; no-op for +/// the rest. +pub fn set_entity_thickness(entity: &mut EntityType, v: f64) { + match entity { + EntityType::Arc(e) => e.thickness = v, + EntityType::Circle(e) => e.thickness = v, + EntityType::Line(e) => e.thickness = v, + EntityType::LwPolyline(e) => e.thickness = v, + EntityType::Point(e) => e.thickness = v, + EntityType::PolyfaceMesh(e) => e.thickness = v, + EntityType::Polyline2D(e) => e.thickness = v, + EntityType::Shape(e) => e.thickness = v, + EntityType::Solid(e) => e.thickness = v, + EntityType::Text(e) => e.thickness = v, _ => {} } }