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