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
|
action-redo = Redo
|
||||||
|
|
||||||
presort-by-pairwise-detours = Presort by pairwise detours
|
presort-by-pairwise-detours = Presort by pairwise detours
|
||||||
|
squeeze-under-bands = Squeeze under bands
|
||||||
wrap-around-bands = Wrap around bands
|
wrap-around-bands = Wrap around bands
|
||||||
|
|
||||||
show-ratsnest = Show Ratsnest
|
show-ratsnest = Show Ratsnest
|
||||||
|
|
|
||||||
|
|
@ -31,15 +31,6 @@ pub struct AutorouterOptions {
|
||||||
pub router_options: RouterOptions,
|
pub router_options: RouterOptions,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl AutorouterOptions {
|
|
||||||
pub fn new() -> Self {
|
|
||||||
Self {
|
|
||||||
presort_by_pairwise_detours: false,
|
|
||||||
router_options: RouterOptions::new(),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Error, Debug, Clone)]
|
#[derive(Error, Debug, Clone)]
|
||||||
pub enum AutorouterError {
|
pub enum AutorouterError {
|
||||||
#[error("nothing to route")]
|
#[error("nothing to route")]
|
||||||
|
|
|
||||||
|
|
@ -9,6 +9,7 @@ use topola::{
|
||||||
invoker::{Command, Execute, ExecuteWithStatus, Invoker, InvokerError, InvokerStatus},
|
invoker::{Command, Execute, ExecuteWithStatus, Invoker, InvokerError, InvokerStatus},
|
||||||
AutorouterOptions,
|
AutorouterOptions,
|
||||||
},
|
},
|
||||||
|
router::RouterOptions,
|
||||||
specctra::{design::SpecctraDesign, mesadata::SpecctraMesadata},
|
specctra::{design::SpecctraDesign, mesadata::SpecctraMesadata},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -32,7 +33,13 @@ pub struct Top {
|
||||||
impl Top {
|
impl Top {
|
||||||
pub fn new() -> Self {
|
pub fn new() -> Self {
|
||||||
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,
|
is_placing_via: false,
|
||||||
show_ratsnest: false,
|
show_ratsnest: false,
|
||||||
show_navmesh: false,
|
show_navmesh: false,
|
||||||
|
|
@ -142,6 +149,10 @@ impl Top {
|
||||||
&mut self.autorouter_options.presort_by_pairwise_detours,
|
&mut self.autorouter_options.presort_by_pairwise_detours,
|
||||||
tr.text("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(
|
ui.checkbox(
|
||||||
&mut self.autorouter_options.router_options.wrap_around_bands,
|
&mut self.autorouter_options.router_options.wrap_around_bands,
|
||||||
tr.text("wrap-around-bands"),
|
tr.text("wrap-around-bands"),
|
||||||
|
|
|
||||||
|
|
@ -202,26 +202,50 @@ impl Navmesh {
|
||||||
map.insert(trianvertex, vec![(navvertex, navvertex)]);
|
map.insert(trianvertex, vec![(navvertex, navvertex)]);
|
||||||
} else {
|
} else {
|
||||||
map.insert(trianvertex, vec![]);
|
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 =
|
||||||
let mut gear =
|
Into::<GearIndex>::into(Into::<BinavvertexNodeIndex>::into(trianvertex));
|
||||||
Into::<GearIndex>::into(Into::<BinavvertexNodeIndex>::into(trianvertex));
|
|
||||||
|
|
||||||
while let Some(bend) = gear.ref_(layout.drawing()).next_gear() {
|
if options.squeeze_under_bands {
|
||||||
Self::add_node_to_graph_and_map_as_binavvertex(
|
Self::add_node_to_graph_and_map_as_binavvertex(
|
||||||
&mut graph,
|
&mut graph,
|
||||||
&mut map,
|
&mut map,
|
||||||
trianvertex,
|
trianvertex,
|
||||||
bend.into(),
|
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();
|
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)]
|
#[derive(Debug, Clone, Copy, Serialize, Deserialize)]
|
||||||
pub struct RouterOptions {
|
pub struct RouterOptions {
|
||||||
pub wrap_around_bands: bool,
|
pub wrap_around_bands: bool,
|
||||||
//pub squeeze_under_bands: bool,
|
pub squeeze_under_bands: bool,
|
||||||
}
|
|
||||||
|
|
||||||
impl RouterOptions {
|
|
||||||
pub fn new() -> Self {
|
|
||||||
Self {
|
|
||||||
wrap_around_bands: true,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Error, Debug, Clone)]
|
#[derive(Error, Debug, Clone)]
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue