Forráskód Böngészése

Display print WIP

Kevin Lee 5 hónapja
szülő
commit
bc71d4778d

+ 12 - 1
src/ezcad/objects/circle.rs

@@ -26,7 +26,18 @@ pub struct Circle {
 
 impl Display for Circle {
     fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
-        write!(f, "{}, Radius: {}", self.core, self.radius)
+        write!(
+            f,
+            "{}, Radius: {:.2}, Origin: {}",
+            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,
+            }
+        )
     }
 }
 

+ 12 - 2
src/ezcad/objects/hatch.rs

@@ -43,7 +43,7 @@ pub struct HatchFlag {
     __: B18,
 }
 
-#[derive(Copy, Clone, Debug, Serialize, Deserialize)]
+#[derive(Copy, Clone, Debug, Serialize, Deserialize, strum::Display)]
 pub enum HatchPattern {
     Directional,
     Bidirectional,
@@ -372,7 +372,17 @@ pub struct Hatch {
 
 impl Display for Hatch {
     fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
-        write!(f, "{}", self.core)
+        write!(f, "{}", self.core)?;
+        for object in self.outline.iter() {
+            write!(f, "\nOutline: {}", object)?;
+        }
+        write!(
+            f,
+            "\nMark Contour: {}, Contour Priority: {}",
+            *self.legacy_setting.mark_contour != 0,
+            *self.legacy_setting.contour_priority != 0
+        )?;
+        Ok(())
     }
 }
 

+ 2 - 3
src/ezcad/objects/mod.rs

@@ -77,12 +77,11 @@ impl Display for ObjectCore {
     fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
         write!(
             f,
-            "Enabled: {}, Type: {}, Pen: {}, Count: {}, Origin: {}, Z: {}",
-            (self.flags.disabled() == 0),
+            "Type: {}, Enabled: {}, Pen: {}, Count: {}, Z: {:.2}",
             self.obj_type,
+            (self.flags.disabled() == 0),
             self.pen,
             self.count,
-            self.origin,
             self.z
         )
     }

+ 18 - 1
src/ezcad/objects/rectangle.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,23 @@ pub struct Rectangle {
 
 impl Display for Rectangle {
     fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
-        write!(f, "{}", self.core)
+        write!(
+            f,
+            "{}, Origin: {}, Width: {}, Height: {}",
+            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,
+        )
     }
 }