forked from 1b-agent/opencadstudio-upstream
Merge pull request #1332 from ramox81/codex/concentric-constraint-parity
# Conflicts: # src/entities/arc.rs # src/entities/ellipse.rs # src/modules/parametric/mod.rs # src/scene/parametric_solve.rs # src/ui/overlay.rs
This commit is contained in:
commit
16c417f81d
17 files changed
+692
-52
No files matched your search
+21
-3
@@ -212,9 +212,9 @@ fn properties(arc: &Arc) -> Vec<PropSection> {
|
||||
ro(t!("Total angle").as_ref(), "total_angle", format_angle(total_angle.to_radians())),
|
||||
ro(t!("Arc length").as_ref(), "arc_length", format_length(arc_length)),
|
||||
ro(t!("Area").as_ref(), "area", format_area(area)),
|
||||
ro(t!("Normal X").as_ref(), "normal_x", format!("{:.4}", arc.normal.x)),
|
||||
ro(t!("Normal Y").as_ref(), "normal_y", format!("{:.4}", arc.normal.y)),
|
||||
ro(t!("Normal Z").as_ref(), "normal_z", format!("{:.4}", arc.normal.z)),
|
||||
edit(t!("Normal X").as_ref(), "normal_x", arc.normal.x),
|
||||
edit(t!("Normal Y").as_ref(), "normal_y", arc.normal.y),
|
||||
edit(t!("Normal Z").as_ref(), "normal_z", arc.normal.z),
|
||||
],
|
||||
}]
|
||||
}
|
||||
@@ -244,6 +244,24 @@ 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" | "normal_y" | "normal_z" => {
|
||||
let center = arc.center_wcs();
|
||||
let mut normal = glam::DVec3::new(arc.normal.x, arc.normal.y, arc.normal.z);
|
||||
match field {
|
||||
"normal_x" => normal.x = v,
|
||||
"normal_y" => normal.y = v,
|
||||
"normal_z" => normal.z = v,
|
||||
_ => {}
|
||||
}
|
||||
if let Some(normal) = normal.try_normalize() {
|
||||
arc.normal = acadrust::types::Vector3::new(normal.x, normal.y, normal.z);
|
||||
let (x, y, z) = crate::scene::view::transform::wcs_point_to_ocs(
|
||||
(center.x, center.y, center.z),
|
||||
(normal.x, normal.y, normal.z),
|
||||
);
|
||||
arc.center = acadrust::types::Vector3::new(x, y, z);
|
||||
}
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
|
||||
+22
-4
@@ -3,7 +3,7 @@ use crate::t;
|
||||
|
||||
use crate::command::EntityTransform;
|
||||
use crate::entities::common::{
|
||||
center_grip, edit_prop as edit, parse_f64, ro_prop as ro, square_grip,
|
||||
center_grip, edit_prop as edit, parse_f64, square_grip,
|
||||
};
|
||||
use crate::entities::traits::RenderConvertible;
|
||||
use crate::scene::convert::acad_to_render::{extrusion_wall_tris, RenderEntity, RenderObject};
|
||||
@@ -169,9 +169,9 @@ fn properties(circle: &Circle) -> Vec<PropSection> {
|
||||
edit(t!("Diameter").as_ref(), "diameter", r * 2.0),
|
||||
edit(t!("Circumference").as_ref(), "circumference", 2.0 * PI * r),
|
||||
edit(t!("Area").as_ref(), "area", PI * r * r),
|
||||
ro(t!("Normal X").as_ref(), "normal_x", format!("{:.4}", circle.normal.x)),
|
||||
ro(t!("Normal Y").as_ref(), "normal_y", format!("{:.4}", circle.normal.y)),
|
||||
ro(t!("Normal Z").as_ref(), "normal_z", format!("{:.4}", circle.normal.z)),
|
||||
edit(t!("Normal X").as_ref(), "normal_x", circle.normal.x),
|
||||
edit(t!("Normal Y").as_ref(), "normal_y", circle.normal.y),
|
||||
edit(t!("Normal Z").as_ref(), "normal_z", circle.normal.z),
|
||||
],
|
||||
}]
|
||||
}
|
||||
@@ -202,6 +202,24 @@ fn apply_geom_prop(circle: &mut Circle, field: &str, value: &str) {
|
||||
"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(),
|
||||
"normal_x" | "normal_y" | "normal_z" => {
|
||||
let center = circle.center_wcs();
|
||||
let mut normal = glam::DVec3::new(circle.normal.x, circle.normal.y, circle.normal.z);
|
||||
match field {
|
||||
"normal_x" => normal.x = v,
|
||||
"normal_y" => normal.y = v,
|
||||
"normal_z" => normal.z = v,
|
||||
_ => {}
|
||||
}
|
||||
if let Some(normal) = normal.try_normalize() {
|
||||
circle.normal = acadrust::types::Vector3::new(normal.x, normal.y, normal.z);
|
||||
let (x, y, z) = crate::scene::view::transform::wcs_point_to_ocs(
|
||||
(center.x, center.y, center.z),
|
||||
(normal.x, normal.y, normal.z),
|
||||
);
|
||||
circle.center = acadrust::types::Vector3::new(x, y, z);
|
||||
}
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
|
||||
+35
-3
@@ -187,9 +187,9 @@ fn properties(ell: &Ellipse) -> Vec<PropSection> {
|
||||
ro(t!("Start parameter").as_ref(), "start_param", format!("{:.4}", ell.start_parameter)),
|
||||
ro(t!("End parameter").as_ref(), "end_param", format!("{:.4}", ell.end_parameter)),
|
||||
ro(t!("Length").as_ref(), "length", format_length(props.perimeter)),
|
||||
ro(t!("Normal X").as_ref(), "normal_x", format!("{:.4}", ell.normal.x)),
|
||||
ro(t!("Normal Y").as_ref(), "normal_y", format!("{:.4}", ell.normal.y)),
|
||||
ro(t!("Normal Z").as_ref(), "normal_z", format!("{:.4}", ell.normal.z)),
|
||||
edit(t!("Normal X").as_ref(), "normal_x", ell.normal.x),
|
||||
edit(t!("Normal Y").as_ref(), "normal_y", ell.normal.y),
|
||||
edit(t!("Normal Z").as_ref(), "normal_z", ell.normal.z),
|
||||
],
|
||||
}]
|
||||
}
|
||||
@@ -220,6 +220,38 @@ fn apply_geom_prop(ell: &mut Ellipse, field: &str, value: &str) {
|
||||
"ratio" if v > 0.0 => ell.minor_axis_ratio = v,
|
||||
"start_angle" => ell.start_parameter = v.to_radians(),
|
||||
"end_angle" => ell.end_parameter = v.to_radians(),
|
||||
"normal_x" | "normal_y" | "normal_z" => {
|
||||
let mut normal = glam::DVec3::new(ell.normal.x, ell.normal.y, ell.normal.z);
|
||||
match field {
|
||||
"normal_x" => normal.x = v,
|
||||
"normal_y" => normal.y = v,
|
||||
"normal_z" => normal.z = v,
|
||||
_ => {}
|
||||
}
|
||||
if let Some(normal) = normal.try_normalize() {
|
||||
let current = glam::DVec3::new(
|
||||
ell.major_axis.x,
|
||||
ell.major_axis.y,
|
||||
ell.major_axis.z,
|
||||
);
|
||||
let length = current.length();
|
||||
let projected = current - normal * current.dot(normal);
|
||||
let major = projected.try_normalize().or_else(|| {
|
||||
let helper = if normal.x.abs() < 0.8 {
|
||||
glam::DVec3::X
|
||||
} else {
|
||||
glam::DVec3::Y
|
||||
};
|
||||
normal.cross(helper).try_normalize()
|
||||
});
|
||||
if let Some(major) = major {
|
||||
ell.normal = acadrust::types::Vector3::new(normal.x, normal.y, normal.z);
|
||||
let major = major * length;
|
||||
ell.major_axis =
|
||||
acadrust::types::Vector3::new(major.x, major.y, major.z);
|
||||
}
|
||||
}
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user