forked from 1b-agent/opencadstudio-upstream
Use shared unit formatters across property and dynamic views
This commit is contained in:
1 parent
ca0ee37d26
commit
fca96b57de
10 files changed
+78
-65
No files matched your search
+11
-11
@@ -3,8 +3,8 @@ use crate::t;
|
||||
|
||||
use crate::command::EntityTransform;
|
||||
use crate::entities::common::{
|
||||
center_grip, edit_angle_prop as edit_angle, edit_prop as edit, parse_f64, ro_prop as ro,
|
||||
square_grip,
|
||||
center_grip, edit_angle_prop as edit_angle, edit_prop as edit, format_angle, format_area,
|
||||
format_length, parse_f64, ro_prop as ro, square_grip,
|
||||
};
|
||||
use crate::entities::traits::RenderConvertible;
|
||||
use crate::scene::convert::acad_to_render::{extrusion_wall_tris, RenderEntity, RenderObject};
|
||||
@@ -197,21 +197,21 @@ fn properties(arc: &Arc) -> Vec<PropSection> {
|
||||
vec![PropSection {
|
||||
title: t!("Geometry").into_owned(),
|
||||
props: vec![
|
||||
ro(t!("Start X").as_ref(), "start_x", format!("{sx:.4}")),
|
||||
ro(t!("Start Y").as_ref(), "start_y", format!("{sy:.4}")),
|
||||
ro(t!("Start Z").as_ref(), "start_z", format!("{sz:.4}")),
|
||||
ro(t!("Start X").as_ref(), "start_x", format_length(sx)),
|
||||
ro(t!("Start Y").as_ref(), "start_y", format_length(sy)),
|
||||
ro(t!("Start Z").as_ref(), "start_z", format_length(sz)),
|
||||
edit(t!("Center X").as_ref(), "center_x", cwx),
|
||||
edit(t!("Center Y").as_ref(), "center_y", cwy),
|
||||
edit(t!("Center Z").as_ref(), "center_z", cwz),
|
||||
ro(t!("End X").as_ref(), "end_x", format!("{ex:.4}")),
|
||||
ro(t!("End Y").as_ref(), "end_y", format!("{ey:.4}")),
|
||||
ro(t!("End Z").as_ref(), "end_z", format!("{ez:.4}")),
|
||||
ro(t!("End X").as_ref(), "end_x", format_length(ex)),
|
||||
ro(t!("End Y").as_ref(), "end_y", format_length(ey)),
|
||||
ro(t!("End Z").as_ref(), "end_z", format_length(ez)),
|
||||
edit(t!("Radius").as_ref(), "radius", arc.radius),
|
||||
edit_angle(t!("Start angle").as_ref(), "start_angle", sa.to_degrees()),
|
||||
edit_angle(t!("End angle").as_ref(), "end_angle", ea.to_degrees()),
|
||||
ro(t!("Total angle").as_ref(), "total_angle", format!("{total_angle:.2}")),
|
||||
ro(t!("Arc length").as_ref(), "arc_length", format!("{arc_length:.4}")),
|
||||
ro(t!("Area").as_ref(), "area", format!("{area:.4}")),
|
||||
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)),
|
||||
|
||||
+16
-16
@@ -9,8 +9,8 @@ use crate::t;
|
||||
|
||||
use crate::command::EntityTransform;
|
||||
use crate::entities::common::{
|
||||
center_grip, edit_prop as edit, oriented_triangle_grip, parse_f64, ro_prop as ro,
|
||||
square_grip,
|
||||
center_grip, edit_prop as edit, format_area, format_length, oriented_triangle_grip, parse_f64,
|
||||
ro_prop as ro, square_grip,
|
||||
};
|
||||
use crate::entities::traits::RenderConvertible;
|
||||
use crate::scene::convert::acad_to_render::{RenderEntity, RenderObject};
|
||||
@@ -163,30 +163,30 @@ fn properties(ell: &Ellipse) -> Vec<PropSection> {
|
||||
vec![PropSection {
|
||||
title: t!("Geometry").into_owned(),
|
||||
props: vec![
|
||||
ro(t!("Start X").as_ref(), "start_x", format!("{:.4}", start.x)),
|
||||
ro(t!("Start Y").as_ref(), "start_y", format!("{:.4}", start.y)),
|
||||
ro(t!("Start Z").as_ref(), "start_z", format!("{:.4}", start.z)),
|
||||
ro(t!("Start X").as_ref(), "start_x", format_length(start.x)),
|
||||
ro(t!("Start Y").as_ref(), "start_y", format_length(start.y)),
|
||||
ro(t!("Start Z").as_ref(), "start_z", format_length(start.z)),
|
||||
edit(t!("Center X").as_ref(), "center_x", ell.center.x),
|
||||
edit(t!("Center Y").as_ref(), "center_y", ell.center.y),
|
||||
edit(t!("Center Z").as_ref(), "center_z", ell.center.z),
|
||||
ro(t!("End X").as_ref(), "end_x", format!("{:.4}", end.x)),
|
||||
ro(t!("End Y").as_ref(), "end_y", format!("{:.4}", end.y)),
|
||||
ro(t!("End Z").as_ref(), "end_z", format!("{:.4}", end.z)),
|
||||
ro(t!("End X").as_ref(), "end_x", format_length(end.x)),
|
||||
ro(t!("End Y").as_ref(), "end_y", format_length(end.y)),
|
||||
ro(t!("End Z").as_ref(), "end_z", format_length(end.z)),
|
||||
edit(t!("Major radius").as_ref(), "major_r", r_major),
|
||||
edit(t!("Minor radius").as_ref(), "minor_r", r_minor),
|
||||
edit(t!("Radius ratio").as_ref(), "ratio", ell.minor_axis_ratio),
|
||||
edit(t!("Start angle").as_ref(), "start_angle", start_angle),
|
||||
edit(t!("End angle").as_ref(), "end_angle", end_angle),
|
||||
ro(t!("Major axis vector X").as_ref(), "major_x", format!("{:.4}", major_vec.x)),
|
||||
ro(t!("Major axis vector Y").as_ref(), "major_y", format!("{:.4}", major_vec.y)),
|
||||
ro(t!("Major axis vector Z").as_ref(), "major_z", format!("{:.4}", major_vec.z)),
|
||||
ro(t!("Minor axis vector X").as_ref(), "minor_x", format!("{:.4}", minor_vec.x)),
|
||||
ro(t!("Minor axis vector Y").as_ref(), "minor_y", format!("{:.4}", minor_vec.y)),
|
||||
ro(t!("Minor axis vector Z").as_ref(), "minor_z", format!("{:.4}", minor_vec.z)),
|
||||
ro(t!("Area").as_ref(), "area", format!("{:.4}", props.area)),
|
||||
ro(t!("Major axis vector X").as_ref(), "major_x", format_length(major_vec.x)),
|
||||
ro(t!("Major axis vector Y").as_ref(), "major_y", format_length(major_vec.y)),
|
||||
ro(t!("Major axis vector Z").as_ref(), "major_z", format_length(major_vec.z)),
|
||||
ro(t!("Minor axis vector X").as_ref(), "minor_x", format_length(minor_vec.x)),
|
||||
ro(t!("Minor axis vector Y").as_ref(), "minor_y", format_length(minor_vec.y)),
|
||||
ro(t!("Minor axis vector Z").as_ref(), "minor_z", format_length(minor_vec.z)),
|
||||
ro(t!("Area").as_ref(), "area", format_area(props.area)),
|
||||
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!("{:.4}", props.perimeter)),
|
||||
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)),
|
||||
|
||||
@@ -428,8 +428,8 @@ fn properties(h: &Hatch) -> Vec<PropSection> {
|
||||
title: t!("Geometry").into_owned(),
|
||||
props: vec![
|
||||
edit(t!("Elevation").as_ref(), "elevation", h.elevation),
|
||||
ro(t!("Area").as_ref(), "area", format!("{:.4}", area)),
|
||||
ro(t!("Cumulative area").as_ref(), "cumulative_area", format!("{:.4}", area)),
|
||||
ro(t!("Area").as_ref(), "area", crate::entities::common::format_area(area)),
|
||||
ro(t!("Cumulative area").as_ref(), "cumulative_area", crate::entities::common::format_area(area)),
|
||||
],
|
||||
},
|
||||
PropSection {
|
||||
@@ -537,8 +537,8 @@ fn properties(h: &Hatch) -> Vec<PropSection> {
|
||||
title: t!("Geometry").into_owned(),
|
||||
props: vec![
|
||||
edit(t!("Elevation").as_ref(), "elevation", h.elevation),
|
||||
ro(t!("Area").as_ref(), "area", format!("{:.4}", area)),
|
||||
ro(t!("Cumulative area").as_ref(), "cumulative_area", format!("{:.4}", area)),
|
||||
ro(t!("Area").as_ref(), "area", crate::entities::common::format_area(area)),
|
||||
ro(t!("Cumulative area").as_ref(), "cumulative_area", crate::entities::common::format_area(area)),
|
||||
],
|
||||
},
|
||||
];
|
||||
|
||||
@@ -3,8 +3,8 @@ use crate::t;
|
||||
|
||||
use crate::command::EntityTransform;
|
||||
use crate::entities::common::{
|
||||
center_grip, edit_prop as edit, oriented_triangle_grip, parse_f64, ro_prop as ro,
|
||||
square_grip,
|
||||
center_grip, edit_prop as edit, format_direction, format_length, oriented_triangle_grip,
|
||||
parse_f64, ro_prop as ro, square_grip,
|
||||
};
|
||||
use crate::entities::traits::RenderConvertible;
|
||||
use crate::scene::convert::acad_to_render::{extrusion_wall_tris, RenderEntity, RenderObject};
|
||||
@@ -187,7 +187,7 @@ fn properties(line: &Line) -> Vec<PropSection> {
|
||||
"centerline_end_extension",
|
||||
association.end_extension,
|
||||
),
|
||||
ro(t!("Length").as_ref(), "length", format!("{:.4}", line.length())),
|
||||
ro(t!("Length").as_ref(), "length", format_length(line.length())),
|
||||
ro(
|
||||
"Associative",
|
||||
"centerline_associative",
|
||||
@@ -199,7 +199,7 @@ fn properties(line: &Line) -> Vec<PropSection> {
|
||||
let dx = line.end.x - line.start.x;
|
||||
let dy = line.end.y - line.start.y;
|
||||
let dz = line.end.z - line.start.z;
|
||||
let angle = dy.atan2(dx).to_degrees().rem_euclid(360.0);
|
||||
let angle = dy.atan2(dx);
|
||||
vec![PropSection {
|
||||
title: t!("Geometry").into_owned(),
|
||||
props: vec![
|
||||
@@ -209,11 +209,11 @@ fn properties(line: &Line) -> Vec<PropSection> {
|
||||
edit(t!("End X").as_ref(), "end_x", line.end.x),
|
||||
edit(t!("End Y").as_ref(), "end_y", line.end.y),
|
||||
edit(t!("End Z").as_ref(), "end_z", line.end.z),
|
||||
ro(t!("Delta X").as_ref(), "delta_x", format!("{dx:.4}")),
|
||||
ro(t!("Delta Y").as_ref(), "delta_y", format!("{dy:.4}")),
|
||||
ro(t!("Delta Z").as_ref(), "delta_z", format!("{dz:.4}")),
|
||||
ro(t!("Length").as_ref(), "length", format!("{:.4}", line.length())),
|
||||
ro(t!("Angle").as_ref(), "angle", format!("{angle:.2}")),
|
||||
ro(t!("Delta X").as_ref(), "delta_x", format_length(dx)),
|
||||
ro(t!("Delta Y").as_ref(), "delta_y", format_length(dy)),
|
||||
ro(t!("Delta Z").as_ref(), "delta_z", format_length(dz)),
|
||||
ro(t!("Length").as_ref(), "length", format_length(line.length())),
|
||||
ro(t!("Angle").as_ref(), "angle", format_direction(angle)),
|
||||
edit(t!("Normal X").as_ref(), "normal_x", line.normal.x),
|
||||
edit(t!("Normal Y").as_ref(), "normal_y", line.normal.y),
|
||||
edit(t!("Normal Z").as_ref(), "normal_z", line.normal.z),
|
||||
|
||||
@@ -3,7 +3,7 @@ use crate::t;
|
||||
|
||||
use crate::command::EntityTransform;
|
||||
use crate::entities::common::{
|
||||
edit_prop as edit, format_length, parse_f64, ro_prop as ro, square_grip,
|
||||
edit_prop as edit, format_area, format_length, parse_f64, ro_prop as ro, square_grip,
|
||||
stepper_prop as stepper, VARIES_LABEL,
|
||||
};
|
||||
use crate::entities::traits::{Grippable, PropertyEditable, Transformable, RenderConvertible};
|
||||
@@ -705,8 +705,8 @@ impl PropertyEditable for Polyline2D {
|
||||
edit(t!("End segment width").as_ref(), "pl2_seg_end_w", seg_end_w),
|
||||
global_width_prop,
|
||||
edit(t!("Elevation").as_ref(), "pl2_elevation", self.elevation),
|
||||
ro(t!("Area").as_ref(), "pl2_area", format!("{area:.4}")),
|
||||
ro(t!("Length").as_ref(), "pl2_length", format!("{length:.4}")),
|
||||
ro(t!("Area").as_ref(), "pl2_area", format_area(area)),
|
||||
ro(t!("Length").as_ref(), "pl2_length", format_length(length)),
|
||||
],
|
||||
},
|
||||
PropSection {
|
||||
|
||||
@@ -301,9 +301,9 @@ impl PropertyEditable for RasterImage {
|
||||
edit(t!("Position X").as_ref(), "ri_ox", self.insertion_point.x),
|
||||
edit(t!("Position Y").as_ref(), "ri_oy", self.insertion_point.y),
|
||||
edit(t!("Position Z").as_ref(), "ri_oz", self.insertion_point.z),
|
||||
ro(t!("Rotation").as_ref(), "ri_rotation", format!("{:.4}", rotation_deg)),
|
||||
ro(t!("Width").as_ref(), "ri_width", format!("{:.4}", self.width())),
|
||||
ro(t!("Height").as_ref(), "ri_height", format!("{:.4}", self.height())),
|
||||
ro(t!("Rotation").as_ref(), "ri_rotation", crate::entities::common::format_angle(rotation_deg.to_radians())),
|
||||
ro(t!("Width").as_ref(), "ri_width", crate::entities::common::format_length(self.width())),
|
||||
ro(t!("Height").as_ref(), "ri_height", crate::entities::common::format_length(self.height())),
|
||||
ro(t!("Scale").as_ref(), "ri_scale", format!("{:.4}", scale)),
|
||||
],
|
||||
},
|
||||
|
||||
@@ -234,8 +234,8 @@ impl PropertyEditable for Underlay {
|
||||
edit(t!("Scale X").as_ref(), "ul_sx", self.x_scale),
|
||||
edit(t!("Scale Y").as_ref(), "ul_sy", self.y_scale),
|
||||
edit(t!("Scale Z").as_ref(), "ul_sz", self.z_scale),
|
||||
ro(t!("Width").as_ref(), "ul_width", format!("{:.4}", width)),
|
||||
ro(t!("Height").as_ref(), "ul_height", format!("{:.4}", height)),
|
||||
ro(t!("Width").as_ref(), "ul_width", crate::entities::common::format_length(width)),
|
||||
ro(t!("Height").as_ref(), "ul_height", crate::entities::common::format_length(height)),
|
||||
edit_angle(t!("Rotation").as_ref(), "ul_rot", self.rotation.to_degrees()),
|
||||
],
|
||||
},
|
||||
|
||||
Reference in new issue
Block a user