Browse Source

More display prints

Kevin Lee 6 months ago
parent
commit
49f8a16fa7

+ 3 - 3
src/ezcad/objects/circle.rs

@@ -28,15 +28,15 @@ impl Display for Circle {
     fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
         write!(
             f,
-            "{}, Radius: {:.2}, Origin: {}",
+            "{}, Origin: {}, Radius: {:.2}",
             self.core,
-            self.radius,
             Coordinate {
                 x: self.modifier.modifiers.correction.x
                     + self.drawn_origin.x * self.modifier.modifiers.x_scale,
                 y: self.modifier.modifiers.correction.y
                     + self.drawn_origin.y * self.modifier.modifiers.y_scale,
-            }
+            },
+            self.radius,
         )
     }
 }

+ 21 - 1
src/ezcad/objects/ellipse.rs

@@ -2,6 +2,7 @@ use std::fmt::{Debug, Display};
 
 use binrw::{BinRead, BinWrite};
 use diff::Diff;
+use num::abs;
 
 use crate::{
     field_of::FieldOf,
@@ -28,7 +29,26 @@ pub struct Ellipse {
 
 impl Display for Ellipse {
     fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
-        write!(f, "{}", self.core)
+        write!(
+            f,
+            "{}, Origin: {}, Width: {:.2}, Height: {:.2}, Start Radian: {:.2}, End Radian: {:.2}, Open Curve: {}", 
+            self.core,
+            Coordinate {
+                x: self.modifier.modifiers.correction.x
+                    + (self.drawn_corner_a.x + self.drawn_corner_b.x) / 2.0
+                        * self.modifier.modifiers.x_scale,
+                y: self.modifier.modifiers.correction.y
+                    + (self.drawn_corner_a.y + self.drawn_corner_b.y) / 2.0
+                        * self.modifier.modifiers.y_scale,
+            },
+            (abs(self.drawn_corner_a.x) + abs(self.drawn_corner_b.x)) / 2.0
+                * self.modifier.modifiers.x_scale,
+            (abs(self.drawn_corner_a.y) + abs(self.drawn_corner_b.y)) / 2.0
+                * self.modifier.modifiers.y_scale,
+                self.start_angle,
+                self.end_angle,
+                *self.open_curve != 0,
+        )
     }
 }
 

+ 49 - 0
src/ezcad/objects/hatch.rs

@@ -81,6 +81,28 @@ impl From<HatchPattern> for HatchFlag {
     }
 }
 
+impl From<HatchFlag> for HatchPattern {
+    fn from(value: HatchFlag) -> Self {
+        if value.bidirectional_pattern() != 0 {
+            HatchPattern::Bidirectional
+        } else if value.ring_pattern() != 0 {
+            HatchPattern::Ring
+        } else if value.continuous_pattern() != 0 {
+            HatchPattern::Continuous
+        } else if value.gong_pattern() != 0 {
+            HatchPattern::Gong
+        } else if value.background_pattern() != 0 {
+            HatchPattern::Background
+        } else if value.fill_pattern() != 0 {
+            HatchPattern::Fill
+        } else if value.zigzag_pattern() != 0 {
+            HatchPattern::Zigzag
+        } else {
+            HatchPattern::Directional
+        }
+    }
+}
+
 #[cfg_attr(feature = "default-debug", derive(Debug))]
 #[derive(BinRead, BinWrite, Clone, Diff, PartialEq)]
 #[diff(attr(
@@ -382,6 +404,33 @@ impl Display for Hatch {
             *self.legacy_setting.mark_contour != 0,
             *self.legacy_setting.contour_priority != 0
         )?;
+        for (index, setting) in self.hatch_settings.iter().enumerate() {
+            if setting.enabled.into() {
+                write!(
+                    f,
+                    "\nHatch #{}: Count: {}, Pen: {}, Pattern: {}, All Calc: {}, Follow Edge Once: {}, Edge Offset: {:.2}, Line Spacing: {:.2}",
+                    index,
+                    setting.count,
+                    setting.pen,
+                    HatchPattern::from(*setting.flags),
+                    setting.flags.all_calc() != 0,
+                    setting.flags.follow_edge_once() != 0,
+                    setting.edge_offset,
+                    setting.line_spacing,
+                )?;
+                write!(
+                    f,
+                    "\n          Start Offset: {:.2}, End Offset: {:.2}, Angle: {:.2}, Rotate Angle: {:.2}, Line Reduction: {:.2}, Loop Count: {}, Loop Distance: {:.2}",
+                    setting.start_offset,
+                    setting.end_offset,
+                    setting.angle,
+                    setting.rotate_angle,
+                    setting.line_reduction,
+                    setting.loop_count,
+                    setting.loop_distance,
+                )?;
+            }
+        }
         Ok(())
     }
 }

+ 24 - 1
src/ezcad/objects/polygon.rs

@@ -2,6 +2,7 @@ use std::fmt::{Debug, Display};
 
 use binrw::{BinRead, BinWrite};
 use diff::Diff;
+use num::abs;
 
 use crate::{
     field_of::FieldOf,
@@ -30,7 +31,29 @@ pub struct Polygon {
 
 impl Display for Polygon {
     fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
-        write!(f, "{}", self.core)
+        write!(
+            f,
+            "{}, Origin: {}, Width: {:.2}, Height: {:.2}, Inverted: {}, Offset CX: {:.2}, Offset CY: {:.2}, Offset DX: {:.2}, Offset: DY: {:.2}, Edges: {}",
+            self.core,
+            Coordinate {
+                x: self.modifier.modifiers.correction.x
+                    + (self.drawn_corner_a.x + self.drawn_corner_b.x) / 2.0
+                        * self.modifier.modifiers.x_scale,
+                y: self.modifier.modifiers.correction.y
+                    + (self.drawn_corner_a.y + self.drawn_corner_b.y) / 2.0
+                        * self.modifier.modifiers.y_scale,
+            },
+            (abs(self.drawn_corner_a.x) + abs(self.drawn_corner_b.x)) / 2.0
+                * self.modifier.modifiers.x_scale,
+            (abs(self.drawn_corner_a.y) + abs(self.drawn_corner_b.y)) / 2.0
+                * self.modifier.modifiers.y_scale,
+            *self.invert_shape != 0,
+            self.offset_cx,
+            self.offset_cy,
+            self.offset_dx,
+            self.offset_dy,
+            self.edges,
+        )
     }
 }
 

+ 1 - 1
src/ezcad/objects/rectangle.rs

@@ -31,7 +31,7 @@ impl Display for Rectangle {
     fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
         write!(
             f,
-            "{}, Origin: {}, Width: {}, Height: {}",
+            "{}, Origin: {}, Width: {:.2}, Height: {:.2}",
             self.core,
             Coordinate {
                 x: self.modifier.modifiers.correction.x