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
+10
-12
@@ -346,26 +346,24 @@ pub(super) fn dyn_component_value(
|
||||
) && relative
|
||||
&& !comma_cartesian;
|
||||
match f.component {
|
||||
DynComponent::X if relative => format!("{:.4}", if wh { dx.abs() } else { dx }),
|
||||
DynComponent::Y if relative => format!("{:.4}", if wh { dy.abs() } else { dy }),
|
||||
DynComponent::Z if relative => "0.0000".to_string(),
|
||||
DynComponent::X => format!("{:.4}", p.x),
|
||||
DynComponent::Y => format!("{:.4}", p.y),
|
||||
DynComponent::Z => format!("{:.4}", p.z),
|
||||
DynComponent::X if relative => crate::entities::common::format_length(if wh { dx.abs() } else { dx }),
|
||||
DynComponent::Y if relative => crate::entities::common::format_length(if wh { dy.abs() } else { dy }),
|
||||
DynComponent::Z if relative => crate::entities::common::format_length(0.0),
|
||||
DynComponent::X => crate::entities::common::format_length(p.x),
|
||||
DynComponent::Y => crate::entities::common::format_length(p.y),
|
||||
DynComponent::Z => crate::entities::common::format_length(p.z),
|
||||
// Scaled by the role so a diameter box reads twice the radius.
|
||||
DynComponent::Distance => {
|
||||
format!(
|
||||
"{:.4}",
|
||||
(dx * dx + dy * dy).sqrt() * f.role.value_scale() as f64
|
||||
crate::entities::common::format_length(
|
||||
(dx * dx + dy * dy).sqrt() * f.role.value_scale() as f64,
|
||||
)
|
||||
}
|
||||
// Shared rule: unsigned magnitude of the short angle, so CW (below the
|
||||
// reference axis) reads positive (e.g. 30°, not -30°/330°). The
|
||||
// committed value stays signed (see dyn_resolve_point).
|
||||
DynComponent::Angle => {
|
||||
format!(
|
||||
"{:.1}",
|
||||
crate::command::dyn_display_angle_deg(dy.atan2(dx) as f32)
|
||||
crate::entities::common::format_angle(
|
||||
(crate::command::dyn_display_angle_deg(dy.atan2(dx) as f32) as f64).to_radians(),
|
||||
)
|
||||
}
|
||||
// Typed-only scalar — no geometric value to track when empty.
|
||||
|
||||
Reference in new issue
Block a user