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 tr-menu-file = File
@ -35,6 +28,7 @@ tr-menu-place-place-via = Place Via
tr-menu-route = Route tr-menu-route = Route
tr-menu-route-autoroute = Autoroute tr-menu-route-autoroute = Autoroute
tr-menu-route-routed-band-width = Routed Band Width
tr-menu-help = Help tr-menu-help = Help
tr-menu-help-online-documentation = Online Documentation tr-menu-help-online-documentation = Online Documentation

View File

@ -61,7 +61,7 @@ impl AutorouteExecutionStepper {
let this = Self { let this = Self {
ratlines_iter, ratlines_iter,
options, 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), 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); Router::new(autorouter.board.layout_mut(), self.options.router_options);
self.curr_ratline = Some(new_ratline); 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 { } else {
self.curr_ratline = None; self.curr_ratline = None;
//return Ok(AutorouteStatus::Finished); //return Ok(AutorouteStatus::Finished);

View File

@ -40,6 +40,7 @@ impl MenuBar {
autorouter_options: AutorouterOptions { autorouter_options: AutorouterOptions {
presort_by_pairwise_detours: false, presort_by_pairwise_detours: false,
router_options: RouterOptions { router_options: RouterOptions {
routed_band_width: 100.0,
wrap_around_bands: true, wrap_around_bands: true,
squeeze_through_under_bands: true, squeeze_through_under_bands: true,
}, },
@ -139,6 +140,18 @@ impl MenuBar {
//}); //});
ui.separator(); 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.menu_button(tr.text("tr-menu-options"), |ui| {
ui.checkbox( ui.checkbox(
&mut self.autorouter_options.presort_by_pairwise_detours, &mut self.autorouter_options.presort_by_pairwise_detours,

View File

@ -37,7 +37,7 @@ impl Viewport {
pub fn update( pub fn update(
&mut self, &mut self,
ctx: &egui::Context, ctx: &egui::Context,
top: &MenuBar, menu_bar: &MenuBar,
maybe_workspace: Option<&mut Workspace>, maybe_workspace: Option<&mut Workspace>,
) -> egui::Rect { ) -> egui::Rect {
egui::CentralPanel::default().show(ctx, |ui| { 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 += latest_pos.to_vec2() * (old_scaling - self.transform.scaling);
self.transform.translation += ctx.input(|i| i.smooth_scroll_delta); 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 { if let Some(workspace) = maybe_workspace {
let layers = &mut workspace.layers; let layers = &mut workspace.layers;
let overlay = &mut workspace.overlay; let overlay = &mut workspace.overlay;
if ctx.input(|i| i.pointer.any_click()) { if ctx.input(|i| i.pointer.any_click()) {
if top.is_placing_via { if menu_bar.is_placing_via {
workspace.interactor.execute( workspace.interactor.execute(
Command::PlaceVia(ViaWeight { Command::PlaceVia(ViaWeight {
from_layer: 0, from_layer: 0,
to_layer: 0, to_layer: 0,
circle: Circle { circle: Circle {
pos: point! {x: latest_pos.x as f64, y: -latest_pos.y as f64}, 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), maybe_net: Some(1234),
}), }),
@ -120,7 +120,7 @@ impl Viewport {
} }
} }
if top.show_ratsnest { if menu_bar.show_ratsnest {
let graph = overlay.ratsnest().graph(); let graph = overlay.ratsnest().graph();
for edge in graph.edge_references() { for edge in graph.edge_references() {
let from = graph 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(activity) = workspace.interactor.maybe_activity() {
if let Some(navmesh) = activity.maybe_navmesh() { if let Some(navmesh) = activity.maybe_navmesh() {
for edge in navmesh.edge_references() { 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_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()); 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 let Some(navmesh) = activity.maybe_navmesh() {
if top.show_origin_destination { if menu_bar.show_origin_destination {
let (origin, destination) = (navmesh.origin(), navmesh.destination()); let (origin, destination) = (navmesh.origin(), navmesh.destination());
painter.paint_dot( painter.paint_dot(
Circle { Circle {

View File

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