|
@@ -1,47 +1,49 @@
|
|
-use ezcad::{array_of::ArrayOf, layer::Layer, pen::Pen};
|
|
|
|
-use serde::{Deserialize, Serialize};
|
|
|
|
-
|
|
|
|
-use self::{
|
|
|
|
- object::{DeleteObjects, ObjectOperation},
|
|
|
|
- pen::{ClonePen, ImportExportPen, PatchPen, PatternPen},
|
|
|
|
-};
|
|
|
|
-
|
|
|
|
-pub mod object;
|
|
|
|
-pub mod pen;
|
|
|
|
-
|
|
|
|
-#[derive(Debug, Serialize, Deserialize)]
|
|
|
|
-pub enum Operation {
|
|
|
|
- PatchPen(PatchPen),
|
|
|
|
- ClonePen(ClonePen),
|
|
|
|
- PatternPen(PatternPen),
|
|
|
|
- ExportPen(ImportExportPen),
|
|
|
|
- ImportPen(ImportExportPen),
|
|
|
|
- DeleteObjects(DeleteObjects),
|
|
|
|
- Object(ObjectOperation),
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-pub trait Operations {
|
|
|
|
- fn apply(&self, pens: &mut Vec<Pen>, layers: &mut ArrayOf<Layer>);
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-impl Operations for Vec<Operation> {
|
|
|
|
- fn apply(&self, pens: &mut Vec<Pen>, layers: &mut ArrayOf<Layer>) {
|
|
|
|
- for op in self {
|
|
|
|
- match op {
|
|
|
|
- Operation::PatchPen(x) => x.patch(pens),
|
|
|
|
- Operation::ClonePen(x) => x.clone(pens),
|
|
|
|
- Operation::PatternPen(x) => x.pattern(pens),
|
|
|
|
- Operation::ImportPen(x) => x.import(pens),
|
|
|
|
- Operation::ExportPen(x) => x.export(pens),
|
|
|
|
- Operation::DeleteObjects(x) => x.delete(layers),
|
|
|
|
- Operation::Object(x) => x.process(pens, layers),
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-#[derive(Debug, Serialize, Deserialize)]
|
|
|
|
-#[serde(rename_all = "PascalCase")]
|
|
|
|
-pub struct Config {
|
|
|
|
- pub ops: Vec<Operation>,
|
|
|
|
-}
|
|
|
|
|
|
+use ezcad::{array_of::ArrayOf, layer::Layer, pen::Pen};
|
|
|
|
+use serde::{Deserialize, Serialize};
|
|
|
|
+
|
|
|
|
+use self::{
|
|
|
|
+ object::{DeleteObjects, ObjectOperation},
|
|
|
|
+ pen::{ClonePen, ImportExportPen, PatchPen, PatternPen, RandomizePen},
|
|
|
|
+};
|
|
|
|
+
|
|
|
|
+pub mod object;
|
|
|
|
+pub mod pen;
|
|
|
|
+
|
|
|
|
+#[derive(Debug, Serialize, Deserialize)]
|
|
|
|
+pub enum Operation {
|
|
|
|
+ PatchPen(PatchPen),
|
|
|
|
+ ClonePen(ClonePen),
|
|
|
|
+ PatternPen(PatternPen),
|
|
|
|
+ RandomizePen(RandomizePen),
|
|
|
|
+ ExportPen(ImportExportPen),
|
|
|
|
+ ImportPen(ImportExportPen),
|
|
|
|
+ DeleteObjects(DeleteObjects),
|
|
|
|
+ Object(ObjectOperation),
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+pub trait Operations {
|
|
|
|
+ fn apply(&self, pens: &mut Vec<Pen>, layers: &mut ArrayOf<Layer>);
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+impl Operations for Vec<Operation> {
|
|
|
|
+ fn apply(&self, pens: &mut Vec<Pen>, layers: &mut ArrayOf<Layer>) {
|
|
|
|
+ for op in self {
|
|
|
|
+ match op {
|
|
|
|
+ Operation::PatchPen(x) => x.patch(pens),
|
|
|
|
+ Operation::ClonePen(x) => x.clone(pens),
|
|
|
|
+ Operation::PatternPen(x) => x.pattern(pens),
|
|
|
|
+ Operation::RandomizePen(x) => x.random(pens),
|
|
|
|
+ Operation::ImportPen(x) => x.import(pens),
|
|
|
|
+ Operation::ExportPen(x) => x.export(pens),
|
|
|
|
+ Operation::DeleteObjects(x) => x.delete(layers),
|
|
|
|
+ Operation::Object(x) => x.process(pens, layers),
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+#[derive(Debug, Serialize, Deserialize)]
|
|
|
|
+#[serde(rename_all = "PascalCase")]
|
|
|
|
+pub struct Config {
|
|
|
|
+ pub ops: Vec<Operation>,
|
|
|
|
+}
|