forked from 1b-agent/opencadstudio-upstream
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 <[email protected]>
This commit is contained in:
1 parent
b2db939034
commit
b808fc2f86
2 files changed
+19
-25
No files matched your search
+9
-12
@@ -152,24 +152,24 @@ fn properties(arc: &Arc) -> Vec<PropSection> {
|
||||
vec![PropSection {
|
||||
title: "Geometry".into(),
|
||||
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 Y", "center_y", arc.center.y),
|
||||
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("Start angle", "start_angle", sa.to_degrees()),
|
||||
edit("End angle", "end_angle", ea.to_degrees()),
|
||||
ro("Total angle", "total_angle", format!("{total_angle:.2}")),
|
||||
ro("Arc length", "arc_length", format!("{arc_length:.4}")),
|
||||
ro("Area", "area", format!("{area:.4}")),
|
||||
ro("Start X", "start_x", format!("{sx:.4}")),
|
||||
ro("Start Y", "start_y", format!("{sy:.4}")),
|
||||
ro("Start Z", "start_z", format!("{sz:.4}")),
|
||||
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),
|
||||
ro("Normal X", "normal_x", format!("{:.4}", arc.normal.x)),
|
||||
ro("Normal Y", "normal_y", format!("{:.4}", arc.normal.y)),
|
||||
ro("Normal Z", "normal_z", format!("{:.4}", 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,
|
||||
"start_angle" => arc.start_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,
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
|
||||
+10
-13
@@ -128,21 +128,18 @@ fn properties(circle: &Circle) -> Vec<PropSection> {
|
||||
edit("Center Y", "center_y", circle.center.y),
|
||||
edit("Center Z", "center_z", circle.center.z),
|
||||
edit("Radius", "radius", r),
|
||||
ro("Diameter", "diameter", format!("{:.4}", r * 2.0)),
|
||||
ro(
|
||||
"Circumference",
|
||||
"circumference",
|
||||
format!("{:.4}", 2.0 * PI * r),
|
||||
),
|
||||
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),
|
||||
edit("Diameter", "diameter", r * 2.0),
|
||||
edit("Circumference", "circumference", 2.0 * PI * r),
|
||||
edit("Area", "area", PI * r * r),
|
||||
ro("Normal X", "normal_x", format!("{:.4}", circle.normal.x)),
|
||||
ro("Normal Y", "normal_y", format!("{:.4}", circle.normal.y)),
|
||||
ro("Normal Z", "normal_z", format!("{:.4}", circle.normal.z)),
|
||||
],
|
||||
}]
|
||||
}
|
||||
|
||||
fn apply_geom_prop(circle: &mut Circle, field: &str, value: &str) {
|
||||
use std::f64::consts::PI;
|
||||
let Some(v) = parse_f64(value) else {
|
||||
return;
|
||||
};
|
||||
@@ -151,9 +148,9 @@ fn apply_geom_prop(circle: &mut Circle, field: &str, value: &str) {
|
||||
"center_y" => circle.center.y = v,
|
||||
"center_z" => circle.center.z = v,
|
||||
"radius" if v > 0.0 => circle.radius = v,
|
||||
"normal_x" => circle.normal.x = v,
|
||||
"normal_y" => circle.normal.y = v,
|
||||
"normal_z" => circle.normal.z = v,
|
||||
"diameter" if v > 0.0 => circle.radius = v / 2.0,
|
||||
"circumference" if v > 0.0 => circle.radius = v / (2.0 * PI),
|
||||
"area" if v > 0.0 => circle.radius = (v / PI).sqrt(),
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user