diff --git a/packages/cadmium/src/main.rs b/packages/cadmium/src/main.rs index 5a4aed1a..7ee55d21 100644 --- a/packages/cadmium/src/main.rs +++ b/packages/cadmium/src/main.rs @@ -26,10 +26,11 @@ fn main() { }); let new_sketch_hash = el.append(Operation::NewSketch { name: "Sketch1".to_string(), + unique_id: "qwerty".to_string(), plane_name: "Front".to_string(), }); el.append(Operation::NewRectangle { - sketch_name: "Sketch1".to_string(), + sketch_id: "qwerty".to_string(), x: 0.0, y: 0.0, width: 100.0, @@ -38,7 +39,7 @@ fn main() { let extrude_sha = el.append(Operation::NewExtrusion { name: "Extrude1".to_string(), unique_id: "abc123".to_string(), - sketch_name: "Sketch1".to_string(), + sketch_id: "qwerty".to_string(), click_x: 50.0, click_y: 50.0, depth: 100.0, @@ -47,7 +48,7 @@ fn main() { // Actually, let's try something different el.checkout(new_sketch_hash); el.append(Operation::NewCircle { - sketch_name: "Sketch1".to_string(), + sketch_id: "qwerty".to_string(), x: 50.0, y: 50.0, radius: 50.0, diff --git a/packages/cadmium/src/oplog/mod.rs b/packages/cadmium/src/oplog/mod.rs index 6d53a453..f9be398c 100644 --- a/packages/cadmium/src/oplog/mod.rs +++ b/packages/cadmium/src/oplog/mod.rs @@ -148,16 +148,17 @@ pub enum Operation { NewSketch { name: String, plane_name: String, + unique_id: String, }, NewRectangle { - sketch_name: String, + sketch_id: String, x: f64, y: f64, width: f64, height: f64, }, NewCircle { - sketch_name: String, + sketch_id: String, x: f64, y: f64, radius: f64, @@ -165,7 +166,7 @@ pub enum Operation { NewExtrusion { name: String, unique_id: String, - sketch_name: String, + sketch_id: String, click_x: f64, click_y: f64, depth: f64, @@ -190,31 +191,33 @@ impl Operation { Operation::NewPlane { name, plane } => { hasher.update(format!("{name}-{plane:?}").as_bytes()) } - Operation::NewSketch { name, plane_name } => { - hasher.update(format!("{name}-{plane_name:?}").as_bytes()) - } + Operation::NewSketch { + name, + plane_name, + unique_id, + } => hasher.update(format!("{name}-{plane_name:?}-{unique_id}").as_bytes()), Operation::NewRectangle { - sketch_name, + sketch_id, x, y, width, height, - } => hasher.update(format!("{sketch_name}-{x}-{y}-{width}-{height}").as_bytes()), + } => hasher.update(format!("{sketch_id}-{x}-{y}-{width}-{height}").as_bytes()), Operation::NewCircle { - sketch_name, + sketch_id, x, y, radius, - } => hasher.update(format!("{sketch_name}-{x}-{y}-{radius}").as_bytes()), + } => hasher.update(format!("{sketch_id}-{x}-{y}-{radius}").as_bytes()), Operation::NewExtrusion { name, unique_id, - sketch_name, + sketch_id, click_x, click_y, depth, } => hasher.update( - format!("{name}-{unique_id}-{sketch_name}-{click_x}-{click_y}-{depth}").as_bytes(), + format!("{name}-{unique_id}-{sketch_id}-{click_x}-{click_y}-{depth}").as_bytes(), ), Operation::ModifyExtrusionDepth { unique_id, depth } => { hasher.update(format!("{unique_id}-{depth}").as_bytes()) @@ -232,38 +235,42 @@ impl Operation { commit, } => format!("Describe: {} '{}'", commit, description), Operation::NewPlane { name, plane } => format!("NewPlane: '{}'", name), - Operation::NewSketch { name, plane_name } => { + Operation::NewSketch { + name, + plane_name, + unique_id, + } => { format!("NewSketch: '{}' on plane '{}'", name, plane_name) } Operation::NewRectangle { - sketch_name, + sketch_id, x, y, width, height, } => format!( "NewRectangle: {} {} {} {} on '{}'", - x, y, width, height, sketch_name + x, y, width, height, sketch_id ), Operation::NewCircle { - sketch_name, + sketch_id, x, y, radius, } => format!( "NewCircle: ({},{}) radius: {} on '{}'", - x, y, radius, sketch_name + x, y, radius, sketch_id ), Operation::NewExtrusion { name, unique_id, - sketch_name, + sketch_id, click_x, click_y, depth, } => format!( "NewExtrusion: '{}' on '{}' ({},{}) depth: {}", - name, sketch_name, click_x, click_y, depth + name, sketch_id, click_x, click_y, depth ), Operation::ModifyExtrusionDepth { unique_id, depth } => { format!("ModifyExtrusionDepth: {} to {}", unique_id, depth)