Align polygon mesh properties

This commit is contained in:
ramox81 committed 2026-08-31 10:13:12 +03:00
1 parent 3e45cff72f
commit 9d947d75c5
6 files changed
+42 -39

No files matched your search

+1 -1
View File
@@ -2829,7 +2829,7 @@ properties =
.point-y = Point Y
.point-z = Point Z
.polyfacemesh = PolyfaceMesh
.polygonmesh = PolygonMesh
.polygonmesh = Polygon Mesh
.polyline2d = Polyline2D
.polyline3d = 3D Polyline
.predefined = Predefined
+8 -1
View File
@@ -2628,7 +2628,10 @@ pub(super) fn on_tab_close(&mut self, idx: usize) -> Task<Message> {
} else {
raw_val
};
if matches!(field, "current_fit_point" | "current_control_point") {
if matches!(
field,
"current_fit_point" | "current_control_point" | "pm_current_vertex"
) {
let count = handles
.iter()
.filter_map(|handle| {
@@ -2644,6 +2647,10 @@ pub(super) fn on_tab_close(&mut self, idx: usize) -> Task<Message> {
) => Some(
crate::entities::spline::control_vertex_count(spline),
),
(
"pm_current_vertex",
acadrust::EntityType::PolygonMesh(mesh),
) => Some(mesh.vertices.len()),
_ => None,
}
})
+30 -34
View File
@@ -449,24 +449,16 @@ impl PropertyEditable for PolygonMesh {
let current = crate::scene::view::dispatch::prop_current_vertex()
.min(vertex_count.saturating_sub(1));
let vertex = self.vertices.get(current);
let display = if vertex_count == 0 {
"—".to_string()
} else {
format!("{} / {}", current + 1, vertex_count)
};
let smoothed = self.smooth_type != SurfaceSmoothType::NoSmooth;
let density_prop = |label: &str, field: &'static str, value: i16| {
if smoothed {
edit_scalar(label, field, value as f64)
} else {
ro(label, field, value.to_string())
}
};
let current_vertex = if vertex_count == 0 { 0 } else { current + 1 };
vec![
PropSection {
title: t!("Geometry").into_owned(),
props: vec![
stepper(t!("Current Vertex").as_ref(), "pm_current_vertex", display),
edit_scalar(
t!("Current Vertex").as_ref(),
"pm_current_vertex",
current_vertex as f64,
),
edit(t!("Vertex X").as_ref(),
"pm_vx",
vertex.map_or(0.0, |vertex| vertex.location.x),
@@ -479,26 +471,34 @@ impl PropertyEditable for PolygonMesh {
"pm_vz",
vertex.map_or(0.0, |vertex| vertex.location.z),
),
ro(t!("M vertex count").as_ref(), "pm_m", self.m_vertex_count.to_string()),
ro(t!("N vertex count").as_ref(), "pm_n", self.n_vertex_count.to_string()),
Property {
label: t!("M closed").into_owned(),
field: "pm_closed_m",
value: PropValue::BoolToggle {
field: "pm_closed_m",
value: self.is_closed_m(),
value: PropValue::Choice {
selected: if self.is_closed_m() { "Yes" } else { "No" }.to_string(),
options: vec!["No".to_string(), "Yes".to_string()],
},
},
Property {
label: t!("N closed").into_owned(),
field: "pm_closed_n",
value: PropValue::BoolToggle {
field: "pm_closed_n",
value: self.is_closed_n(),
value: PropValue::Choice {
selected: if self.is_closed_n() { "Yes" } else { "No" }.to_string(),
options: vec!["No".to_string(), "Yes".to_string()],
},
},
density_prop(t!("M density").as_ref(), "pm_smooth_m", self.m_smooth_density),
density_prop(t!("N density").as_ref(), "pm_smooth_n", self.n_smooth_density),
edit_scalar(
t!("M density").as_ref(),
"pm_smooth_m",
self.m_smooth_density as f64,
),
edit_scalar(
t!("N density").as_ref(),
"pm_smooth_n",
self.n_smooth_density as f64,
),
ro(t!("M vertex count").as_ref(), "pm_m", self.m_vertex_count.to_string()),
ro(t!("N vertex count").as_ref(), "pm_n", self.n_vertex_count.to_string()),
],
},
PropSection {
@@ -559,26 +559,22 @@ impl PropertyEditable for PolygonMesh {
};
self.smooth_type = smooth;
if self.smooth_type != SurfaceSmoothType::NoSmooth {
if !(2..=256).contains(&self.m_smooth_density) {
if !(2..=200).contains(&self.m_smooth_density) {
self.m_smooth_density = 6;
}
if !(2..=256).contains(&self.n_smooth_density) {
if !(2..=200).contains(&self.n_smooth_density) {
self.n_smooth_density = 6;
}
}
}
"pm_smooth_m" => {
if self.smooth_type != SurfaceSmoothType::NoSmooth {
if let Ok(density @ 2..=256) = value.trim().parse::<i16>() {
self.m_smooth_density = density;
}
if let Ok(density @ 0..=200) = value.trim().parse::<i16>() {
self.m_smooth_density = density;
}
}
"pm_smooth_n" => {
if self.smooth_type != SurfaceSmoothType::NoSmooth {
if let Ok(density @ 2..=256) = value.trim().parse::<i16>() {
self.n_smooth_density = density;
}
if let Ok(density @ 0..=200) = value.trim().parse::<i16>() {
self.n_smooth_density = density;
}
}
"pm_vx" | "pm_vy" | "pm_vz" => {
+1 -1
View File
@@ -33,7 +33,7 @@ pub fn ui_name(e: &EntityType) -> &'static str {
EntityType::Polyline2D(_) => "Polyline2D",
EntityType::Polyline3D(_) => "Polyline3D",
EntityType::PolyfaceMesh(_) => "PolyfaceMesh",
EntityType::PolygonMesh(_) => "PolygonMesh",
EntityType::PolygonMesh(_) => "Polygon Mesh",
EntityType::Text(_) => "Text",
EntityType::MText(_) => "MText",
EntityType::Dimension(_) => "Dimension",
+1 -1
View File
@@ -2067,7 +2067,7 @@ pub(super) fn message_attribute(source: &str) -> Option<(&'static str, &'static
"Polygon - Circumscribed" => Some(("draw", "polygon-circumscribed")),
"Polygon - Edge" => Some(("draw", "polygon-edge")),
"Polygon - Inscribed" => Some(("draw", "polygon-inscribed")),
"PolygonMesh" => Some(("properties", "polygonmesh")),
"Polygon Mesh" => Some(("properties", "polygonmesh")),
"Polygonal" => Some(("layout", "polygonal")),
"Polyline" => Some(("common", "polyline")),
"Polyline broken at vertex." => Some(("command", "polyline-broken-at-vertex")),
+1 -1
View File
@@ -1788,7 +1788,7 @@ fn coord_suffix(label: &str) -> Option<(&str, usize)> {
/// Length of the coordinate group starting at `idx`: consecutive text rows
/// labelled "<Base> X", "<Base> Y" and optionally "<Base> Z". 0/1 = no group.
fn coord_group_len(props: &[crate::scene::model::object::Property], idx: usize) -> usize {
if props[idx].field == "pl3_vertex_x" {
if matches!(props[idx].field, "pl3_vertex_x" | "pm_vx") {
return 0;
}
let groupable = |p: &crate::scene::model::object::Property| {