refactor(properties): editable circle metrics, RO normals
Circle: Diameter/Circumference/Area now editable (each derives radius); Normal X/Y/Z read-only. Arc: reorder to Start/Center/End first; Normal X/Y/Z read-only. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
parent
b2db939034
commit
b808fc2f86
2 changed files with 19 additions and 25 deletions
|
|
@ -152,24 +152,24 @@ fn properties(arc: &Arc) -> Vec<PropSection> {
|
||||||
vec![PropSection {
|
vec![PropSection {
|
||||||
title: "Geometry".into(),
|
title: "Geometry".into(),
|
||||||
props: vec![
|
props: vec![
|
||||||
|
ro("Start X", "start_x", format!("{sx:.4}")),
|
||||||
|
ro("Start Y", "start_y", format!("{sy:.4}")),
|
||||||
|
ro("Start Z", "start_z", format!("{sz:.4}")),
|
||||||
edit("Center X", "center_x", arc.center.x),
|
edit("Center X", "center_x", arc.center.x),
|
||||||
edit("Center Y", "center_y", arc.center.y),
|
edit("Center Y", "center_y", arc.center.y),
|
||||||
edit("Center Z", "center_z", arc.center.z),
|
edit("Center Z", "center_z", arc.center.z),
|
||||||
|
ro("End X", "end_x", format!("{ex:.4}")),
|
||||||
|
ro("End Y", "end_y", format!("{ey:.4}")),
|
||||||
|
ro("End Z", "end_z", format!("{ez:.4}")),
|
||||||
edit("Radius", "radius", arc.radius),
|
edit("Radius", "radius", arc.radius),
|
||||||
edit("Start angle", "start_angle", sa.to_degrees()),
|
edit("Start angle", "start_angle", sa.to_degrees()),
|
||||||
edit("End angle", "end_angle", ea.to_degrees()),
|
edit("End angle", "end_angle", ea.to_degrees()),
|
||||||
ro("Total angle", "total_angle", format!("{total_angle:.2}")),
|
ro("Total angle", "total_angle", format!("{total_angle:.2}")),
|
||||||
ro("Arc length", "arc_length", format!("{arc_length:.4}")),
|
ro("Arc length", "arc_length", format!("{arc_length:.4}")),
|
||||||
ro("Area", "area", format!("{area:.4}")),
|
ro("Area", "area", format!("{area:.4}")),
|
||||||
ro("Start X", "start_x", format!("{sx:.4}")),
|
ro("Normal X", "normal_x", format!("{:.4}", arc.normal.x)),
|
||||||
ro("Start Y", "start_y", format!("{sy:.4}")),
|
ro("Normal Y", "normal_y", format!("{:.4}", arc.normal.y)),
|
||||||
ro("Start Z", "start_z", format!("{sz:.4}")),
|
ro("Normal Z", "normal_z", format!("{:.4}", arc.normal.z)),
|
||||||
ro("End X", "end_x", format!("{ex:.4}")),
|
|
||||||
ro("End Y", "end_y", format!("{ey:.4}")),
|
|
||||||
ro("End Z", "end_z", format!("{ez:.4}")),
|
|
||||||
edit("Normal X", "normal_x", arc.normal.x),
|
|
||||||
edit("Normal Y", "normal_y", arc.normal.y),
|
|
||||||
edit("Normal Z", "normal_z", arc.normal.z),
|
|
||||||
],
|
],
|
||||||
}]
|
}]
|
||||||
}
|
}
|
||||||
|
|
@ -185,9 +185,6 @@ fn apply_geom_prop(arc: &mut Arc, field: &str, value: &str) {
|
||||||
"radius" if v > 0.0 => arc.radius = v,
|
"radius" if v > 0.0 => arc.radius = v,
|
||||||
"start_angle" => arc.start_angle = v.to_radians(),
|
"start_angle" => arc.start_angle = v.to_radians(),
|
||||||
"end_angle" => arc.end_angle = v.to_radians(),
|
"end_angle" => arc.end_angle = v.to_radians(),
|
||||||
"normal_x" => arc.normal.x = v,
|
|
||||||
"normal_y" => arc.normal.y = v,
|
|
||||||
"normal_z" => arc.normal.z = v,
|
|
||||||
_ => {}
|
_ => {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -128,21 +128,18 @@ fn properties(circle: &Circle) -> Vec<PropSection> {
|
||||||
edit("Center Y", "center_y", circle.center.y),
|
edit("Center Y", "center_y", circle.center.y),
|
||||||
edit("Center Z", "center_z", circle.center.z),
|
edit("Center Z", "center_z", circle.center.z),
|
||||||
edit("Radius", "radius", r),
|
edit("Radius", "radius", r),
|
||||||
ro("Diameter", "diameter", format!("{:.4}", r * 2.0)),
|
edit("Diameter", "diameter", r * 2.0),
|
||||||
ro(
|
edit("Circumference", "circumference", 2.0 * PI * r),
|
||||||
"Circumference",
|
edit("Area", "area", PI * r * r),
|
||||||
"circumference",
|
ro("Normal X", "normal_x", format!("{:.4}", circle.normal.x)),
|
||||||
format!("{:.4}", 2.0 * PI * r),
|
ro("Normal Y", "normal_y", format!("{:.4}", circle.normal.y)),
|
||||||
),
|
ro("Normal Z", "normal_z", format!("{:.4}", circle.normal.z)),
|
||||||
ro("Area", "area", format!("{:.4}", PI * r * r)),
|
|
||||||
edit("Normal X", "normal_x", circle.normal.x),
|
|
||||||
edit("Normal Y", "normal_y", circle.normal.y),
|
|
||||||
edit("Normal Z", "normal_z", circle.normal.z),
|
|
||||||
],
|
],
|
||||||
}]
|
}]
|
||||||
}
|
}
|
||||||
|
|
||||||
fn apply_geom_prop(circle: &mut Circle, field: &str, value: &str) {
|
fn apply_geom_prop(circle: &mut Circle, field: &str, value: &str) {
|
||||||
|
use std::f64::consts::PI;
|
||||||
let Some(v) = parse_f64(value) else {
|
let Some(v) = parse_f64(value) else {
|
||||||
return;
|
return;
|
||||||
};
|
};
|
||||||
|
|
@ -151,9 +148,9 @@ fn apply_geom_prop(circle: &mut Circle, field: &str, value: &str) {
|
||||||
"center_y" => circle.center.y = v,
|
"center_y" => circle.center.y = v,
|
||||||
"center_z" => circle.center.z = v,
|
"center_z" => circle.center.z = v,
|
||||||
"radius" if v > 0.0 => circle.radius = v,
|
"radius" if v > 0.0 => circle.radius = v,
|
||||||
"normal_x" => circle.normal.x = v,
|
"diameter" if v > 0.0 => circle.radius = v / 2.0,
|
||||||
"normal_y" => circle.normal.y = v,
|
"circumference" if v > 0.0 => circle.radius = v / (2.0 * PI),
|
||||||
"normal_z" => circle.normal.z = v,
|
"area" if v > 0.0 => circle.radius = (v / PI).sqrt(),
|
||||||
_ => {}
|
_ => {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue