|
@@ -85,7 +85,7 @@ impl From<HatchConfig> for HatchSetting {
|
|
|
flags.set_average_distribute_line(1);
|
|
|
}
|
|
|
|
|
|
- let mut ret = Self::default();
|
|
|
+ let mut ret: HatchSetting = Self::default();
|
|
|
|
|
|
*ret.line_spacing = value.line_spacing;
|
|
|
value.pen.map(|x| *ret.pen = x.into());
|
|
@@ -172,24 +172,14 @@ impl InputObject {
|
|
|
|
|
|
#[derive(Debug, Serialize, Deserialize)]
|
|
|
#[serde(rename_all = "PascalCase")]
|
|
|
-pub struct ObjectOperation {
|
|
|
- input: InputObject,
|
|
|
+pub struct ObjectModify {
|
|
|
z: Option<f64>,
|
|
|
origin: Option<Point>,
|
|
|
pen: Option<u32>,
|
|
|
- layer: Option<usize>,
|
|
|
- array: Option<ArrayConfig>,
|
|
|
- hatch: Option<HatchConfig>,
|
|
|
- export: Option<PathBuf>,
|
|
|
- replace_object: Option<usize>,
|
|
|
}
|
|
|
|
|
|
-impl ObjectOperation {
|
|
|
- pub fn process(&self, pens: &mut Vec<Pen>, layers: &mut ArrayOf<Layer>) {
|
|
|
- debug!("Begin processing of object {:?}", self.input);
|
|
|
-
|
|
|
- let mut object: Object = self.input.new(layers);
|
|
|
-
|
|
|
+impl ObjectModify {
|
|
|
+ pub fn process(&self, object: &mut Object, pens: &mut Vec<Pen>) {
|
|
|
// Process basic transformation
|
|
|
if self.origin.is_some() || self.z.is_some() {
|
|
|
debug!(
|
|
@@ -200,14 +190,34 @@ impl ObjectOperation {
|
|
|
}
|
|
|
|
|
|
self.pen.map(|pen| {
|
|
|
- if self.array.is_some() {
|
|
|
- warn!("Ignoring pen setting as values will be overridden by array setting");
|
|
|
- } else {
|
|
|
assert!(pen < pens.len().try_into().unwrap(), "Invalid pen index");
|
|
|
debug!("Setting object pen to #{}", pen);
|
|
|
object.set_pen(pen);
|
|
|
- }
|
|
|
+
|
|
|
});
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+#[derive(Debug, Serialize, Deserialize)]
|
|
|
+#[serde(rename_all = "PascalCase")]
|
|
|
+pub struct ObjectOperation {
|
|
|
+ input: InputObject,
|
|
|
+ modify: Option<ObjectModify>,
|
|
|
+ layer: Option<usize>,
|
|
|
+ array: Option<ArrayConfig>,
|
|
|
+ hatch: Option<HatchConfig>,
|
|
|
+ export: Option<PathBuf>,
|
|
|
+ replace_object: Option<usize>,
|
|
|
+}
|
|
|
+
|
|
|
+impl ObjectOperation {
|
|
|
+ pub fn process(&self, pens: &mut Vec<Pen>, layers: &mut ArrayOf<Layer>) {
|
|
|
+ debug!("Begin processing of object {:?}", self.input);
|
|
|
+
|
|
|
+ let mut object: Object = self.input.new(layers);
|
|
|
+
|
|
|
+ // Modify object properties
|
|
|
+ self.modify.as_ref().map(|modify| modify.process(&mut object, pens));
|
|
|
|
|
|
// Process conversion to hatch object
|
|
|
let object = self.hatch.as_ref().map_or(object.clone(), |hatch| {
|