mirror of https://codeberg.org/topola/topola.git
egui,router: add option to toggle squeezing
This commit is contained in:
parent
0b7e5f1b9b
commit
4b6e3e0a5c
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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")]
|
||||
|
|
|
|||
|
|
@ -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"),
|
||||
|
|
|
|||
|
|
@ -202,6 +202,11 @@ impl Navmesh {
|
|||
map.insert(trianvertex, vec![(navvertex, navvertex)]);
|
||||
} else {
|
||||
map.insert(trianvertex, vec![]);
|
||||
|
||||
let mut gear =
|
||||
Into::<GearIndex>::into(Into::<BinavvertexNodeIndex>::into(trianvertex));
|
||||
|
||||
if options.squeeze_under_bands {
|
||||
Self::add_node_to_graph_and_map_as_binavvertex(
|
||||
&mut graph,
|
||||
&mut map,
|
||||
|
|
@ -210,9 +215,6 @@ impl Navmesh {
|
|||
);
|
||||
|
||||
if options.wrap_around_bands {
|
||||
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,
|
||||
|
|
@ -223,6 +225,28 @@ impl Navmesh {
|
|||
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(),
|
||||
);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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)]
|
||||
|
|
|
|||
Loading…
Reference in New Issue