From 2703f662ac527e902099ce09b76c6a3764e66f3a Mon Sep 17 00:00:00 2001 From: Mikolaj Wielgus Date: Tue, 3 Dec 2024 23:22:05 +0100 Subject: [PATCH] fix(autorouter): have band removal and via placement in undo/redo --- src/autorouter/execution.rs | 8 ++++---- src/autorouter/place_via.rs | 10 ++++++---- src/autorouter/remove_bands.rs | 12 +++++------- 3 files changed, 15 insertions(+), 15 deletions(-) diff --git a/src/autorouter/execution.rs b/src/autorouter/execution.rs index 152175a..8e500e3 100644 --- a/src/autorouter/execution.rs +++ b/src/autorouter/execution.rs @@ -53,12 +53,12 @@ impl ExecutionStepper { } }, ExecutionStepper::PlaceVia(place_via) => { - place_via.doit(autorouter)?; - ControlFlow::Break((None, "finished placing via".to_string())) + let edit = place_via.doit(autorouter)?; + ControlFlow::Break((edit, "finished placing via".to_string())) } ExecutionStepper::RemoveBands(remove_bands) => { - remove_bands.doit(autorouter)?; - ControlFlow::Break((None, "finished removing bands".to_string())) + let edit = remove_bands.doit(autorouter)?; + ControlFlow::Break((edit, "finished removing bands".to_string())) } ExecutionStepper::CompareDetours(compare_detours) => { match compare_detours.step(autorouter)? { diff --git a/src/autorouter/place_via.rs b/src/autorouter/place_via.rs index 51df12e..fad0f8d 100644 --- a/src/autorouter/place_via.rs +++ b/src/autorouter/place_via.rs @@ -32,16 +32,18 @@ impl PlaceViaExecutionStepper { pub fn doit( &mut self, autorouter: &mut Autorouter, - ) -> Result<(), AutorouterError> { + ) -> Result, AutorouterError> { if !self.done { self.done = true; + + let mut edit = LayoutEdit::new(); autorouter .board .layout_mut() - .add_via(&mut LayoutEdit::new(), self.weight)?; - Ok(()) + .add_via(&mut edit, self.weight)?; + Ok(Some(edit)) } else { - Ok(()) + Ok(None) } } } diff --git a/src/autorouter/remove_bands.rs b/src/autorouter/remove_bands.rs index 83214ef..ce51eda 100644 --- a/src/autorouter/remove_bands.rs +++ b/src/autorouter/remove_bands.rs @@ -31,20 +31,18 @@ impl RemoveBandsExecutionStepper { pub fn doit( &mut self, autorouter: &mut Autorouter, - ) -> Result<(), AutorouterError> { + ) -> Result, AutorouterError> { if !self.done { self.done = true; + let mut edit = LayoutEdit::new(); for selector in self.selection.selectors() { let band = autorouter.board.bandname_band(&selector.band).unwrap().0; - autorouter - .board - .layout_mut() - .remove_band(&mut LayoutEdit::new(), band); + autorouter.board.layout_mut().remove_band(&mut edit, band); } - Ok(()) + Ok(Some(edit)) } else { - Ok(()) + Ok(None) } } }