|
@@ -5,13 +5,12 @@ use diff::Diff;
|
|
|
|
|
|
use crate::{
|
|
|
field_of::FieldOf,
|
|
|
- types::{ObjectType, Coordinate, F64, U32},
|
|
|
+ types::{Coordinate, ObjectType, F64, U32},
|
|
|
};
|
|
|
|
|
|
-use super::{ObjectCore, Translate, ObjectModified};
|
|
|
+use super::{ObjectCore, ObjectModifier, Translate};
|
|
|
|
|
|
-#[cfg_attr(feature = "default-debug", derive(Debug))]
|
|
|
-#[derive(BinRead, BinWrite, Clone, Diff, PartialEq)]
|
|
|
+#[derive(BinRead, BinWrite, Clone, Debug, Diff, PartialEq)]
|
|
|
#[diff(attr(
|
|
|
#[derive(Debug, PartialEq)]
|
|
|
))]
|
|
@@ -23,26 +22,10 @@ pub struct Ellipse {
|
|
|
pub drawn_corner_b: FieldOf<Coordinate>,
|
|
|
pub start_angle: F64, // Radians
|
|
|
pub end_angle: F64, // Radians
|
|
|
- pub modified: ObjectModified,
|
|
|
+ pub modifier: ObjectModifier,
|
|
|
pub open_curve: U32,
|
|
|
}
|
|
|
|
|
|
-// Custom Debug implementation to only print known fields
|
|
|
-#[cfg(not(feature = "default-debug"))]
|
|
|
-impl Debug for Ellipse {
|
|
|
- fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
|
|
- f.debug_struct("Ellipse")
|
|
|
- .field("core", &self.core)
|
|
|
- .field("clockwise", &self.clockwise)
|
|
|
- .field("corner_a", &self.drawn_corner_a)
|
|
|
- .field("corner_b", &self.drawn_corner_b)
|
|
|
- .field("start_angle", &self.start_angle)
|
|
|
- .field("end_angle", &self.end_angle)
|
|
|
- .field("open_curve", &self.open_curve)
|
|
|
- .finish()
|
|
|
- }
|
|
|
-}
|
|
|
-
|
|
|
impl Default for Ellipse {
|
|
|
fn default() -> Self {
|
|
|
Self {
|
|
@@ -52,7 +35,7 @@ impl Default for Ellipse {
|
|
|
drawn_corner_b: Coordinate { x: 0.0, y: 0.0 }.into(),
|
|
|
start_angle: 0.0.into(),
|
|
|
end_angle: 0.0.into(),
|
|
|
- modified: ObjectModified::default(),
|
|
|
+ modifier: ObjectModifier::default(),
|
|
|
open_curve: 0.into(),
|
|
|
}
|
|
|
}
|
|
@@ -61,17 +44,15 @@ impl Default for Ellipse {
|
|
|
impl Translate for Ellipse {
|
|
|
fn move_absolute(&mut self, origin: Option<Coordinate>, z: Option<f64>) {
|
|
|
origin.map(|origin| {
|
|
|
- let delta: Coordinate = *self.core.origin - origin;
|
|
|
- *self.drawn_corner_a += delta;
|
|
|
- *self.drawn_corner_b += delta;
|
|
|
+ let delta: Coordinate = origin - *self.core.origin;
|
|
|
+ self.modifier.move_relative(delta);
|
|
|
});
|
|
|
self.core.move_absolute(origin, z);
|
|
|
}
|
|
|
|
|
|
fn move_relative(&mut self, delta: Option<Coordinate>, z: Option<f64>) {
|
|
|
delta.map(|delta| {
|
|
|
- *self.drawn_corner_a += delta;
|
|
|
- *self.drawn_corner_b += delta;
|
|
|
+ self.modifier.move_relative(delta);
|
|
|
});
|
|
|
self.core.move_relative(delta, z);
|
|
|
}
|