mirror of https://codeberg.org/topola/topola.git
autorouter: show whole detour compare animation
This commit is contained in:
parent
c9d99c2c1f
commit
deb2fffbf1
|
|
@ -62,12 +62,12 @@ impl Autoroute {
|
|||
|
||||
impl<M: AccessMesadata> Step<Autorouter<M>, AutorouteStatus, AutorouterError, ()> for Autoroute {
|
||||
fn step(&mut self, autorouter: &mut Autorouter<M>) -> Result<AutorouteStatus, AutorouterError> {
|
||||
let Some(ref mut route) = self.route else {
|
||||
// Shouldn't happen.
|
||||
let Some(curr_ratline) = self.curr_ratline else {
|
||||
return Ok(AutorouteStatus::Finished);
|
||||
};
|
||||
|
||||
let Some(curr_ratline) = self.curr_ratline else {
|
||||
let Some(ref mut route) = self.route else {
|
||||
// Shouldn't happen.
|
||||
return Ok(AutorouteStatus::Finished);
|
||||
};
|
||||
|
||||
|
|
@ -97,16 +97,16 @@ impl<M: AccessMesadata> Step<Autorouter<M>, AutorouteStatus, AutorouterError, ()
|
|||
.board
|
||||
.try_set_band_between_nodes(source, target, band);
|
||||
|
||||
let Some(new_ratline) = self.ratlines_iter.next() else {
|
||||
self.curr_ratline = None;
|
||||
return Ok(AutorouteStatus::Finished);
|
||||
};
|
||||
|
||||
if let Some(new_ratline) = self.ratlines_iter.next() {
|
||||
let (source, target) = autorouter.ratline_endpoints(new_ratline);
|
||||
let mut router = Router::new(autorouter.board.layout_mut());
|
||||
|
||||
self.curr_ratline = Some(new_ratline);
|
||||
self.route = Some(router.route(source, target, 100.0)?);
|
||||
} else {
|
||||
self.curr_ratline = None;
|
||||
//return Ok(AutorouteStatus::Finished);
|
||||
}
|
||||
|
||||
Ok(AutorouteStatus::Routed(band_termseg))
|
||||
}
|
||||
|
|
|
|||
|
|
@ -37,8 +37,8 @@ pub struct CompareDetours {
|
|||
next_autoroute: Option<Autoroute>,
|
||||
ratline1: EdgeIndex<usize>,
|
||||
ratline2: EdgeIndex<usize>,
|
||||
total_length1: Option<f64>,
|
||||
total_length2: Option<f64>,
|
||||
total_length1: f64,
|
||||
total_length2: f64,
|
||||
done: bool,
|
||||
}
|
||||
|
||||
|
|
@ -53,8 +53,8 @@ impl CompareDetours {
|
|||
next_autoroute: Some(autorouter.autoroute_ratlines(vec![ratline2, ratline1])?),
|
||||
ratline1,
|
||||
ratline2,
|
||||
total_length1: None,
|
||||
total_length2: None,
|
||||
total_length1: 0.0,
|
||||
total_length2: 0.0,
|
||||
done: false,
|
||||
})
|
||||
}
|
||||
|
|
@ -71,8 +71,8 @@ impl<M: AccessMesadata> Step<Autorouter<M>, CompareDetoursStatus, AutorouterErro
|
|||
) -> Result<CompareDetoursStatus, AutorouterError> {
|
||||
if self.done {
|
||||
return Ok(CompareDetoursStatus::Finished(
|
||||
self.total_length1.unwrap(),
|
||||
self.total_length2.unwrap(),
|
||||
self.total_length1,
|
||||
self.total_length2,
|
||||
));
|
||||
}
|
||||
|
||||
|
|
@ -83,12 +83,10 @@ impl<M: AccessMesadata> Step<Autorouter<M>, CompareDetoursStatus, AutorouterErro
|
|||
.ref_(autorouter.board.layout().drawing())
|
||||
.length();
|
||||
|
||||
if self.total_length1.is_none() {
|
||||
self.total_length1 = Some(length);
|
||||
} else if self.total_length2.is_none() {
|
||||
self.total_length2 = Some(length);
|
||||
if self.next_autoroute.is_some() {
|
||||
self.total_length1 += length;
|
||||
} else {
|
||||
panic!();
|
||||
self.total_length2 += length;
|
||||
}
|
||||
|
||||
Ok(CompareDetoursStatus::Running)
|
||||
|
|
@ -104,8 +102,8 @@ impl<M: AccessMesadata> Step<Autorouter<M>, CompareDetoursStatus, AutorouterErro
|
|||
autorouter.undo_autoroute_ratlines(vec![self.ratline2, self.ratline1]);
|
||||
|
||||
Ok(CompareDetoursStatus::Finished(
|
||||
self.total_length1.unwrap(),
|
||||
self.total_length2.unwrap(),
|
||||
self.total_length1,
|
||||
self.total_length2,
|
||||
))
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue