diff --git a/packages/cadmium/src/main.rs b/packages/cadmium/src/main.rs index 84503d6b..5a4aed1a 100644 --- a/packages/cadmium/src/main.rs +++ b/packages/cadmium/src/main.rs @@ -37,6 +37,7 @@ fn main() { }); let extrude_sha = el.append(Operation::NewExtrusion { name: "Extrude1".to_string(), + unique_id: "abc123".to_string(), sketch_name: "Sketch1".to_string(), click_x: 50.0, click_y: 50.0, @@ -53,8 +54,12 @@ fn main() { }); el.cherry_pick(extrude_sha); - el.pretty_print(); + el.append(Operation::ModifyExtrusionDepth { + unique_id: "abc123".to_string(), + depth: 200.0, + }); + el.pretty_print(); } fn main_old() { diff --git a/packages/cadmium/src/oplog/mod.rs b/packages/cadmium/src/oplog/mod.rs index 44a59d03..6d53a453 100644 --- a/packages/cadmium/src/oplog/mod.rs +++ b/packages/cadmium/src/oplog/mod.rs @@ -156,18 +156,23 @@ pub enum Operation { width: f64, height: f64, }, + NewCircle { + sketch_name: String, + x: f64, + y: f64, + radius: f64, + }, NewExtrusion { name: String, + unique_id: String, sketch_name: String, click_x: f64, click_y: f64, depth: f64, }, - NewCircle { - sketch_name: String, - x: f64, - y: f64, - radius: f64, + ModifyExtrusionDepth { + unique_id: String, + depth: f64, }, } @@ -195,20 +200,25 @@ impl Operation { width, height, } => hasher.update(format!("{sketch_name}-{x}-{y}-{width}-{height}").as_bytes()), - Operation::NewExtrusion { - name, - sketch_name, - click_x, - click_y, - depth, - } => hasher - .update(format!("{name}-{sketch_name}-{click_x}-{click_y}-{depth}").as_bytes()), Operation::NewCircle { sketch_name, x, y, radius, } => hasher.update(format!("{sketch_name}-{x}-{y}-{radius}").as_bytes()), + Operation::NewExtrusion { + name, + unique_id, + sketch_name, + click_x, + click_y, + depth, + } => hasher.update( + format!("{name}-{unique_id}-{sketch_name}-{click_x}-{click_y}-{depth}").as_bytes(), + ), + Operation::ModifyExtrusionDepth { unique_id, depth } => { + hasher.update(format!("{unique_id}-{depth}").as_bytes()) + } } format!("{:x}", hasher.finalize()) @@ -235,8 +245,18 @@ impl Operation { "NewRectangle: {} {} {} {} on '{}'", x, y, width, height, sketch_name ), + Operation::NewCircle { + sketch_name, + x, + y, + radius, + } => format!( + "NewCircle: ({},{}) radius: {} on '{}'", + x, y, radius, sketch_name + ), Operation::NewExtrusion { name, + unique_id, sketch_name, click_x, click_y, @@ -245,15 +265,9 @@ impl Operation { "NewExtrusion: '{}' on '{}' ({},{}) depth: {}", name, sketch_name, click_x, click_y, depth ), - Operation::NewCircle { - sketch_name, - x, - y, - radius, - } => format!( - "NewCircle: ({},{}) radius: {} on '{}'", - x, y, radius, sketch_name - ), + Operation::ModifyExtrusionDepth { unique_id, depth } => { + format!("ModifyExtrusionDepth: {} to {}", unique_id, depth) + } } } }