fix(autorouter): have band removal and via placement in undo/redo

This commit is contained in:
Mikolaj Wielgus 2024-12-03 23:22:05 +01:00
parent 75aa4ea443
commit 2703f662ac
3 changed files with 15 additions and 15 deletions

View File

@ -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)? {

View File

@ -32,16 +32,18 @@ impl PlaceViaExecutionStepper {
pub fn doit(
&mut self,
autorouter: &mut Autorouter<impl AccessMesadata>,
) -> Result<(), AutorouterError> {
) -> Result<Option<LayoutEdit>, 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)
}
}
}

View File

@ -31,20 +31,18 @@ impl RemoveBandsExecutionStepper {
pub fn doit(
&mut self,
autorouter: &mut Autorouter<impl AccessMesadata>,
) -> Result<(), AutorouterError> {
) -> Result<Option<LayoutEdit>, 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)
}
}
}