|
@@ -1,17 +1,17 @@
|
|
use std::fmt::Debug;
|
|
use std::fmt::Debug;
|
|
|
|
|
|
|
|
+use crate::{
|
|
|
|
+ array_of::ArrayOf,
|
|
|
|
+ field_of::FieldOf,
|
|
|
|
+ types::{Field, F64, U32},
|
|
|
|
+};
|
|
use binrw::{binrw, BinRead, BinWrite};
|
|
use binrw::{binrw, BinRead, BinWrite};
|
|
use diff::Diff;
|
|
use diff::Diff;
|
|
use modular_bitfield::{
|
|
use modular_bitfield::{
|
|
bitfield,
|
|
bitfield,
|
|
specifiers::{B1, B18},
|
|
specifiers::{B1, B18},
|
|
};
|
|
};
|
|
-
|
|
|
|
-use crate::{
|
|
|
|
- array_of::ArrayOf,
|
|
|
|
- field_of::FieldOf,
|
|
|
|
- types::{Field, F64, U32},
|
|
|
|
-};
|
|
|
|
|
|
+use serde::{Deserialize, Serialize};
|
|
|
|
|
|
use super::{line::Lines, Object, ObjectCore};
|
|
use super::{line::Lines, Object, ObjectCore};
|
|
|
|
|
|
@@ -25,24 +25,62 @@ use super::{line::Lines, Object, ObjectCore};
|
|
pub struct HatchFlag {
|
|
pub struct HatchFlag {
|
|
pub all_calc: B1,
|
|
pub all_calc: B1,
|
|
pub follow_edge_once: B1,
|
|
pub follow_edge_once: B1,
|
|
- pub continuous_pattern: B1, // Hatch type 4 when combined with bidirectional_pattern
|
|
|
|
- pub bidirectional_pattern: B1, // Hatch type 2
|
|
|
|
- pub ring_pattern: B1, // Hatch type 3
|
|
|
|
|
|
+ pub continuous_pattern: B1, // Hatch type 3 when combined with bidirectional_pattern
|
|
|
|
+ pub bidirectional_pattern: B1, // Hatch type 1
|
|
|
|
+ pub ring_pattern: B1, // Hatch type 2
|
|
#[skip]
|
|
#[skip]
|
|
__: B1,
|
|
__: B1,
|
|
pub auto_rotate_hatch_angle: B1,
|
|
pub auto_rotate_hatch_angle: B1,
|
|
pub average_distribute_line: B1,
|
|
pub average_distribute_line: B1,
|
|
#[skip]
|
|
#[skip]
|
|
__: B1,
|
|
__: B1,
|
|
- pub gong_pattern: B1, // Hatch type 5 when combined with bidirectional_pattern
|
|
|
|
|
|
+ pub gong_pattern: B1, // Hatch type 4 when combined with bidirectional_pattern
|
|
pub cross_hatch: B1,
|
|
pub cross_hatch: B1,
|
|
- pub background_pattern: B1, // Hatch type 6, must set all_calc as well
|
|
|
|
- pub fill_pattern: B1, // Hatch type 7 when combined with continuous_pattern and bidirectional_pattern
|
|
|
|
- pub zigzag_pattern: B1, // Hatch type 8
|
|
|
|
|
|
+ pub background_pattern: B1, // Hatch type 5, must set all_calc as well
|
|
|
|
+ pub fill_pattern: B1, // Hatch type 6 when combined with continuous_pattern and bidirectional_pattern
|
|
|
|
+ pub zigzag_pattern: B1, // Hatch type 7
|
|
#[skip]
|
|
#[skip]
|
|
__: B18,
|
|
__: B18,
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+#[derive(Copy, Clone, Debug, Serialize, Deserialize)]
|
|
|
|
+pub enum HatchPattern {
|
|
|
|
+ Directional,
|
|
|
|
+ Bidirectional,
|
|
|
|
+ Ring,
|
|
|
|
+ Continuous,
|
|
|
|
+ Gong,
|
|
|
|
+ Background,
|
|
|
|
+ Fill,
|
|
|
|
+ Zigzag,
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+impl From<HatchPattern> for HatchFlag {
|
|
|
|
+ fn from(value: HatchPattern) -> Self {
|
|
|
|
+ let mut ret = Self::new();
|
|
|
|
+ match value {
|
|
|
|
+ HatchPattern::Directional => (),
|
|
|
|
+ HatchPattern::Bidirectional => ret.set_bidirectional_pattern(1),
|
|
|
|
+ HatchPattern::Ring => ret.set_ring_pattern(1),
|
|
|
|
+ HatchPattern::Continuous => {
|
|
|
|
+ ret.set_bidirectional_pattern(1);
|
|
|
|
+ ret.set_continuous_pattern(1);
|
|
|
|
+ }
|
|
|
|
+ HatchPattern::Gong => {
|
|
|
|
+ ret.set_bidirectional_pattern(1);
|
|
|
|
+ ret.set_gong_pattern(1);
|
|
|
|
+ }
|
|
|
|
+ HatchPattern::Background => {
|
|
|
|
+ ret.set_background_pattern(1);
|
|
|
|
+ ret.set_all_calc(1);
|
|
|
|
+ }
|
|
|
|
+ HatchPattern::Fill => ret.set_fill_pattern(1),
|
|
|
|
+ HatchPattern::Zigzag => ret.set_zigzag_pattern(1),
|
|
|
|
+ }
|
|
|
|
+ ret
|
|
|
|
+ }
|
|
|
|
+}
|
|
|
|
+
|
|
#[cfg_attr(feature = "default-debug", derive(Debug))]
|
|
#[cfg_attr(feature = "default-debug", derive(Debug))]
|
|
#[derive(BinRead, BinWrite, Diff, PartialEq)]
|
|
#[derive(BinRead, BinWrite, Diff, PartialEq)]
|
|
#[diff(attr(
|
|
#[diff(attr(
|
|
@@ -147,7 +185,7 @@ impl Debug for LegacyHatchSetting {
|
|
}
|
|
}
|
|
|
|
|
|
#[cfg_attr(feature = "default-debug", derive(Debug))]
|
|
#[cfg_attr(feature = "default-debug", derive(Debug))]
|
|
-#[derive(BinRead, BinWrite, Diff, PartialEq)]
|
|
|
|
|
|
+#[derive(BinRead, BinWrite, Clone, Diff, PartialEq)]
|
|
#[diff(attr(
|
|
#[diff(attr(
|
|
#[derive(Debug, PartialEq)]
|
|
#[derive(Debug, PartialEq)]
|
|
))]
|
|
))]
|
|
@@ -199,13 +237,13 @@ impl Default for HatchSetting {
|
|
pen: 0.into(),
|
|
pen: 0.into(),
|
|
flags: HatchFlag::new().into(),
|
|
flags: HatchFlag::new().into(),
|
|
edge_offset: 0.0.into(),
|
|
edge_offset: 0.0.into(),
|
|
- line_spacing: 0.0.into(),
|
|
|
|
|
|
+ line_spacing: 1.0.into(),
|
|
start_offset: 0.0.into(),
|
|
start_offset: 0.0.into(),
|
|
end_offset: 0.0.into(),
|
|
end_offset: 0.0.into(),
|
|
angle: 0.0.into(),
|
|
angle: 0.0.into(),
|
|
- rotate_angle: 0.0.into(),
|
|
|
|
|
|
+ rotate_angle: 10.0.into(),
|
|
line_reduction: 0.0.into(),
|
|
line_reduction: 0.0.into(),
|
|
- loop_distance: 0.0.into(),
|
|
|
|
|
|
+ loop_distance: 0.5.into(),
|
|
loop_count: 0.into(),
|
|
loop_count: 0.into(),
|
|
_unknown_1: [vec![0, 0, 0, 0, 0, 0, 0, 0].into(), vec![0, 0, 0, 0].into()].into(),
|
|
_unknown_1: [vec![0, 0, 0, 0, 0, 0, 0, 0].into(), vec![0, 0, 0, 0].into()].into(),
|
|
}
|
|
}
|
|
@@ -281,7 +319,7 @@ pub struct HatchLine {
|
|
))]
|
|
))]
|
|
#[brw(magic(16_u32))] // ObjectType::HatchLine
|
|
#[brw(magic(16_u32))] // ObjectType::HatchLine
|
|
pub struct HatchLines {
|
|
pub struct HatchLines {
|
|
- pub core: ObjectCore,
|
|
|
|
|
|
+ pub core: ObjectCore, // HatchType::HatchLine
|
|
pub hatch_line: ArrayOf<HatchLine>,
|
|
pub hatch_line: ArrayOf<HatchLine>,
|
|
}
|
|
}
|
|
|
|
|
|
@@ -290,7 +328,7 @@ pub struct HatchLines {
|
|
#[derive(Debug, PartialEq)]
|
|
#[derive(Debug, PartialEq)]
|
|
))]
|
|
))]
|
|
pub struct Hatches {
|
|
pub struct Hatches {
|
|
- pub core: ObjectCore,
|
|
|
|
|
|
+ pub core: ObjectCore, // HatchType::HatchLine
|
|
pub hatch_lines: ArrayOf<HatchLines>,
|
|
pub hatch_lines: ArrayOf<HatchLines>,
|
|
}
|
|
}
|
|
|
|
|