egui,router: add option to toggle squeezing

This commit is contained in:
Mikolaj Wielgus 2024-09-01 01:24:52 +02:00
parent 0b7e5f1b9b
commit 4b6e3e0a5c
5 changed files with 54 additions and 35 deletions

View File

@ -18,6 +18,7 @@ action-undo = Undo
action-redo = Redo
presort-by-pairwise-detours = Presort by pairwise detours
squeeze-under-bands = Squeeze under bands
wrap-around-bands = Wrap around bands
show-ratsnest = Show Ratsnest

View File

@ -31,15 +31,6 @@ pub struct AutorouterOptions {
pub router_options: RouterOptions,
}
impl AutorouterOptions {
pub fn new() -> Self {
Self {
presort_by_pairwise_detours: false,
router_options: RouterOptions::new(),
}
}
}
#[derive(Error, Debug, Clone)]
pub enum AutorouterError {
#[error("nothing to route")]

View File

@ -9,6 +9,7 @@ use topola::{
invoker::{Command, Execute, ExecuteWithStatus, Invoker, InvokerError, InvokerStatus},
AutorouterOptions,
},
router::RouterOptions,
specctra::{design::SpecctraDesign, mesadata::SpecctraMesadata},
};
@ -32,7 +33,13 @@ pub struct Top {
impl Top {
pub fn new() -> Self {
Self {
autorouter_options: AutorouterOptions::new(),
autorouter_options: AutorouterOptions {
presort_by_pairwise_detours: false,
router_options: RouterOptions {
wrap_around_bands: true,
squeeze_under_bands: true,
},
},
is_placing_via: false,
show_ratsnest: false,
show_navmesh: false,
@ -142,6 +149,10 @@ impl Top {
&mut self.autorouter_options.presort_by_pairwise_detours,
tr.text("presort-by-pairwise-detours"),
);
ui.checkbox(
&mut self.autorouter_options.router_options.squeeze_under_bands,
tr.text("squeeze-under-bands"),
);
ui.checkbox(
&mut self.autorouter_options.router_options.wrap_around_bands,
tr.text("wrap-around-bands"),

View File

@ -202,26 +202,50 @@ impl Navmesh {
map.insert(trianvertex, vec![(navvertex, navvertex)]);
} else {
map.insert(trianvertex, vec![]);
Self::add_node_to_graph_and_map_as_binavvertex(
&mut graph,
&mut map,
trianvertex,
trianvertex.into(),
);
if options.wrap_around_bands {
let mut gear =
Into::<GearIndex>::into(Into::<BinavvertexNodeIndex>::into(trianvertex));
let mut gear =
Into::<GearIndex>::into(Into::<BinavvertexNodeIndex>::into(trianvertex));
while let Some(bend) = gear.ref_(layout.drawing()).next_gear() {
Self::add_node_to_graph_and_map_as_binavvertex(
&mut graph,
&mut map,
trianvertex,
bend.into(),
);
if options.squeeze_under_bands {
Self::add_node_to_graph_and_map_as_binavvertex(
&mut graph,
&mut map,
trianvertex,
trianvertex.into(),
);
if options.wrap_around_bands {
while let Some(bend) = gear.ref_(layout.drawing()).next_gear() {
Self::add_node_to_graph_and_map_as_binavvertex(
&mut graph,
&mut map,
trianvertex,
bend.into(),
);
gear = bend.into();
}
}
} else if let Some(first_bend) = gear.ref_(layout.drawing()).next_gear() {
let mut bend = first_bend;
while let Some(next_bend) = gear.ref_(layout.drawing()).next_gear() {
bend = next_bend;
gear = bend.into();
}
Self::add_node_to_graph_and_map_as_binavvertex(
&mut graph,
&mut map,
trianvertex,
bend.into(),
);
} else {
Self::add_node_to_graph_and_map_as_binavvertex(
&mut graph,
&mut map,
trianvertex,
trianvertex.into(),
);
}
};
}

View File

@ -36,15 +36,7 @@ use super::{
#[derive(Debug, Clone, Copy, Serialize, Deserialize)]
pub struct RouterOptions {
pub wrap_around_bands: bool,
//pub squeeze_under_bands: bool,
}
impl RouterOptions {
pub fn new() -> Self {
Self {
wrap_around_bands: true,
}
}
pub squeeze_under_bands: bool,
}
#[derive(Error, Debug, Clone)]