forked from 1b-agent/opencadstudio-upstream
style: apply cargo fmt across workspace
This commit is contained in:
1 parent
85710e5454
commit
9cf9ff2c5c
531 files changed
+57740
-33906
No files matched your search
+61
-43
@@ -1,12 +1,10 @@
|
||||
use codec::entities::{Ray, XLine};
|
||||
use crate::t;
|
||||
use codec::entities::{Ray, XLine};
|
||||
|
||||
use crate::command::EntityTransform;
|
||||
use crate::entities::common::{
|
||||
edit_prop as edit, format_length, ro_prop as ro, square_grip,
|
||||
};
|
||||
use crate::entities::common::{edit_prop as edit, format_length, ro_prop as ro, square_grip};
|
||||
use crate::entities::curve::{point_along, unit_direction};
|
||||
use crate::entities::traits::{Grippable, PropertyEditable, Transformable, RenderConvertible};
|
||||
use crate::entities::traits::{Grippable, PropertyEditable, RenderConvertible, Transformable};
|
||||
use crate::scene::convert::acad_to_render::{RenderEntity, RenderObject};
|
||||
use crate::scene::model::object::{GripApply, GripDef, PropSection};
|
||||
|
||||
@@ -103,9 +101,21 @@ impl PropertyEditable for Ray {
|
||||
edit(t!("Start X").as_ref(), "ray_bx", self.base_point.x),
|
||||
edit(t!("Start Y").as_ref(), "ray_by", self.base_point.y),
|
||||
edit(t!("Start Z").as_ref(), "ray_bz", self.base_point.z),
|
||||
edit(t!("Direction vector X").as_ref(), "ray_dx", self.direction.x),
|
||||
edit(t!("Direction vector Y").as_ref(), "ray_dy", self.direction.y),
|
||||
edit(t!("Direction vector Z").as_ref(), "ray_dz", self.direction.z),
|
||||
edit(
|
||||
t!("Direction vector X").as_ref(),
|
||||
"ray_dx",
|
||||
self.direction.x,
|
||||
),
|
||||
edit(
|
||||
t!("Direction vector Y").as_ref(),
|
||||
"ray_dy",
|
||||
self.direction.y,
|
||||
),
|
||||
edit(
|
||||
t!("Direction vector Z").as_ref(),
|
||||
"ray_dz",
|
||||
self.direction.z,
|
||||
),
|
||||
],
|
||||
}]
|
||||
}
|
||||
@@ -134,24 +144,28 @@ impl PropertyEditable for Ray {
|
||||
|
||||
impl Transformable for Ray {
|
||||
fn apply_transform(&mut self, t: &EntityTransform) {
|
||||
crate::scene::view::transform::apply_standard_entity_transform(self, t, |entity, p1, p2| {
|
||||
crate::scene::view::transform::reflect_xy_point(
|
||||
&mut entity.base_point.x,
|
||||
&mut entity.base_point.y,
|
||||
p1,
|
||||
p2,
|
||||
);
|
||||
// Mirror the direction: negate the component perpendicular to mirror axis.
|
||||
let ax = (p2.x - p1.x) as f64;
|
||||
let ay = (p2.y - p1.y) as f64;
|
||||
let len2 = ax * ax + ay * ay;
|
||||
if len2 > 1e-12 {
|
||||
let d = &mut entity.direction;
|
||||
let dot = d.x * ax + d.y * ay;
|
||||
d.x = 2.0 * dot * ax / len2 - d.x;
|
||||
d.y = 2.0 * dot * ay / len2 - d.y;
|
||||
}
|
||||
});
|
||||
crate::scene::view::transform::apply_standard_entity_transform(
|
||||
self,
|
||||
t,
|
||||
|entity, p1, p2| {
|
||||
crate::scene::view::transform::reflect_xy_point(
|
||||
&mut entity.base_point.x,
|
||||
&mut entity.base_point.y,
|
||||
p1,
|
||||
p2,
|
||||
);
|
||||
// Mirror the direction: negate the component perpendicular to mirror axis.
|
||||
let ax = (p2.x - p1.x) as f64;
|
||||
let ay = (p2.y - p1.y) as f64;
|
||||
let len2 = ax * ax + ay * ay;
|
||||
if len2 > 1e-12 {
|
||||
let d = &mut entity.direction;
|
||||
let dot = d.x * ax + d.y * ay;
|
||||
d.x = 2.0 * dot * ax / len2 - d.x;
|
||||
d.y = 2.0 * dot * ay / len2 - d.y;
|
||||
}
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -292,22 +306,26 @@ impl PropertyEditable for XLine {
|
||||
|
||||
impl Transformable for XLine {
|
||||
fn apply_transform(&mut self, t: &EntityTransform) {
|
||||
crate::scene::view::transform::apply_standard_entity_transform(self, t, |entity, p1, p2| {
|
||||
crate::scene::view::transform::reflect_xy_point(
|
||||
&mut entity.base_point.x,
|
||||
&mut entity.base_point.y,
|
||||
p1,
|
||||
p2,
|
||||
);
|
||||
let ax = (p2.x - p1.x) as f64;
|
||||
let ay = (p2.y - p1.y) as f64;
|
||||
let len2 = ax * ax + ay * ay;
|
||||
if len2 > 1e-12 {
|
||||
let d = &mut entity.direction;
|
||||
let dot = d.x * ax + d.y * ay;
|
||||
d.x = 2.0 * dot * ax / len2 - d.x;
|
||||
d.y = 2.0 * dot * ay / len2 - d.y;
|
||||
}
|
||||
});
|
||||
crate::scene::view::transform::apply_standard_entity_transform(
|
||||
self,
|
||||
t,
|
||||
|entity, p1, p2| {
|
||||
crate::scene::view::transform::reflect_xy_point(
|
||||
&mut entity.base_point.x,
|
||||
&mut entity.base_point.y,
|
||||
p1,
|
||||
p2,
|
||||
);
|
||||
let ax = (p2.x - p1.x) as f64;
|
||||
let ay = (p2.y - p1.y) as f64;
|
||||
let len2 = ax * ax + ay * ay;
|
||||
if len2 > 1e-12 {
|
||||
let d = &mut entity.direction;
|
||||
let dot = d.x * ax + d.y * ay;
|
||||
d.x = 2.0 * dot * ax / len2 - d.x;
|
||||
d.y = 2.0 * dot * ay / len2 - d.y;
|
||||
}
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user