feat(egui,autorouter): make it possible to set routed band width

This commit is contained in:
Mikolaj Wielgus 2024-10-21 02:07:15 +02:00
parent 81747af6df
commit dc11b5d8ff
5 changed files with 29 additions and 17 deletions

View File

@ -1,10 +1,3 @@
## Orphaned strings.
tr-menu-debug = Debug
tr-menu-properties = Properties
tr-menu-properties-set-language = Set Language
##
tr-menu-file = File
@ -35,6 +28,7 @@ tr-menu-place-place-via = Place Via
tr-menu-route = Route
tr-menu-route-autoroute = Autoroute
tr-menu-route-routed-band-width = Routed Band Width
tr-menu-help = Help
tr-menu-help-online-documentation = Online Documentation

View File

@ -61,7 +61,7 @@ impl AutorouteExecutionStepper {
let this = Self {
ratlines_iter,
options,
route: Some(router.route(source, target, 100.0)?),
route: Some(router.route(source, target, options.router_options.routed_band_width)?),
curr_ratline: Some(curr_ratline),
};
@ -120,7 +120,11 @@ impl<M: AccessMesadata> Step<Autorouter<M>, (), AutorouteContinueStatus>
Router::new(autorouter.board.layout_mut(), self.options.router_options);
self.curr_ratline = Some(new_ratline);
self.route = Some(router.route(source, target, 100.0)?);
self.route = Some(router.route(
source,
target,
self.options.router_options.routed_band_width,
)?);
} else {
self.curr_ratline = None;
//return Ok(AutorouteStatus::Finished);

View File

@ -40,6 +40,7 @@ impl MenuBar {
autorouter_options: AutorouterOptions {
presort_by_pairwise_detours: false,
router_options: RouterOptions {
routed_band_width: 100.0,
wrap_around_bands: true,
squeeze_through_under_bands: true,
},
@ -139,6 +140,18 @@ impl MenuBar {
//});
ui.separator();
ui.label(tr.text("tr-menu-route-routed-band-width"));
ui.add(
egui::widgets::Slider::new(
&mut self.autorouter_options.router_options.routed_band_width,
1.0..=1000.0,
)
.suffix(""),
);
ui.separator();
ui.menu_button(tr.text("tr-menu-options"), |ui| {
ui.checkbox(
&mut self.autorouter_options.presort_by_pairwise_detours,

View File

@ -37,7 +37,7 @@ impl Viewport {
pub fn update(
&mut self,
ctx: &egui::Context,
top: &MenuBar,
menu_bar: &MenuBar,
maybe_workspace: Option<&mut Workspace>,
) -> egui::Rect {
egui::CentralPanel::default().show(ctx, |ui| {
@ -53,21 +53,21 @@ impl Viewport {
self.transform.translation += latest_pos.to_vec2() * (old_scaling - self.transform.scaling);
self.transform.translation += ctx.input(|i| i.smooth_scroll_delta);
let mut painter = Painter::new(ui, self.transform, top.show_bboxes);
let mut painter = Painter::new(ui, self.transform, menu_bar.show_bboxes);
if let Some(workspace) = maybe_workspace {
let layers = &mut workspace.layers;
let overlay = &mut workspace.overlay;
if ctx.input(|i| i.pointer.any_click()) {
if top.is_placing_via {
if menu_bar.is_placing_via {
workspace.interactor.execute(
Command::PlaceVia(ViaWeight {
from_layer: 0,
to_layer: 0,
circle: Circle {
pos: point! {x: latest_pos.x as f64, y: -latest_pos.y as f64},
r: 100.0,
r: menu_bar.autorouter_options.router_options.routed_band_width / 2.0,
},
maybe_net: Some(1234),
}),
@ -120,7 +120,7 @@ impl Viewport {
}
}
if top.show_ratsnest {
if menu_bar.show_ratsnest {
let graph = overlay.ratsnest().graph();
for edge in graph.edge_references() {
let from = graph
@ -140,7 +140,7 @@ impl Viewport {
}
}
if top.show_navmesh {
if menu_bar.show_navmesh {
if let Some(activity) = workspace.interactor.maybe_activity() {
if let Some(navmesh) = activity.maybe_navmesh() {
for edge in navmesh.edge_references() {
@ -199,7 +199,7 @@ impl Viewport {
}
}
if top.show_bboxes {
if menu_bar.show_bboxes {
let root_bbox3d = board.layout().drawing().rtree().root().envelope();
let root_bbox = AABB::<[f64; 2]>::from_corners([root_bbox3d.lower()[0], root_bbox3d.lower()[1]].into(), [root_bbox3d.upper()[0], root_bbox3d.upper()[1]].into());
@ -212,7 +212,7 @@ impl Viewport {
}
if let Some(navmesh) = activity.maybe_navmesh() {
if top.show_origin_destination {
if menu_bar.show_origin_destination {
let (origin, destination) = (navmesh.origin(), navmesh.destination());
painter.paint_dot(
Circle {

View File

@ -32,6 +32,7 @@ use super::{
#[derive(Debug, Clone, Copy, Serialize, Deserialize)]
pub struct RouterOptions {
pub routed_band_width: f64,
pub wrap_around_bands: bool,
pub squeeze_through_under_bands: bool,
}