diff --git a/locales/en-US/opencadstudio.ftl b/locales/en-US/opencadstudio.ftl index 3f61bddb1..a90b105d2 100644 --- a/locales/en-US/opencadstudio.ftl +++ b/locales/en-US/opencadstudio.ftl @@ -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 diff --git a/src/app/update/command.rs b/src/app/update/command.rs index ce1b6256d..cd1793a08 100644 --- a/src/app/update/command.rs +++ b/src/app/update/command.rs @@ -2628,7 +2628,10 @@ pub(super) fn on_tab_close(&mut self, idx: usize) -> Task { } 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 { ) => Some( crate::entities::spline::control_vertex_count(spline), ), + ( + "pm_current_vertex", + acadrust::EntityType::PolygonMesh(mesh), + ) => Some(mesh.vertices.len()), _ => None, } }) diff --git a/src/entities/mesh.rs b/src/entities/mesh.rs index 0e60322d4..772214544 100644 --- a/src/entities/mesh.rs +++ b/src/entities/mesh.rs @@ -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::() { - self.m_smooth_density = density; - } + if let Ok(density @ 0..=200) = value.trim().parse::() { + self.m_smooth_density = density; } } "pm_smooth_n" => { - if self.smooth_type != SurfaceSmoothType::NoSmooth { - if let Ok(density @ 2..=256) = value.trim().parse::() { - self.n_smooth_density = density; - } + if let Ok(density @ 0..=200) = value.trim().parse::() { + self.n_smooth_density = density; } } "pm_vx" | "pm_vy" | "pm_vz" => { diff --git a/src/entities/names.rs b/src/entities/names.rs index 3dde0f074..9a00c9ffe 100644 --- a/src/entities/names.rs +++ b/src/entities/names.rs @@ -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", diff --git a/src/locale_catalog.rs b/src/locale_catalog.rs index f86fcc48e..5de56c86a 100644 --- a/src/locale_catalog.rs +++ b/src/locale_catalog.rs @@ -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")), diff --git a/src/ui/properties.rs b/src/ui/properties.rs index 8d7262233..fadb6e918 100644 --- a/src/ui/properties.rs +++ b/src/ui/properties.rs @@ -1788,7 +1788,7 @@ fn coord_suffix(label: &str) -> Option<(&str, usize)> { /// Length of the coordinate group starting at `idx`: consecutive text rows /// labelled " X", " Y" and optionally " 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| {