mirror of https://codeberg.org/topola/topola.git
feat(topola-egui): Add checkboxes to toggle displaying obstacles and ghosts
Disabled showing them by default.
This commit is contained in:
parent
c23b56516b
commit
7b66db1672
|
|
@ -364,6 +364,8 @@ impl InspectActions {
|
|||
}
|
||||
|
||||
pub struct DebugActions {
|
||||
pub highlight_obstacles: Switch,
|
||||
pub show_ghosts: Switch,
|
||||
pub show_navmesh: Switch,
|
||||
pub show_guide_circles: Switch,
|
||||
pub show_guide_bitangents: Switch,
|
||||
|
|
@ -379,6 +381,9 @@ pub struct DebugActions {
|
|||
impl DebugActions {
|
||||
pub fn new(tr: &Translator) -> Self {
|
||||
Self {
|
||||
highlight_obstacles: Action::new_keyless(tr.text("tr-menu-debug-highlight-obstacles"))
|
||||
.into_switch(),
|
||||
show_ghosts: Action::new_keyless(tr.text("tr-menu-debug-show-ghosts")).into_switch(),
|
||||
show_navmesh: Action::new_keyless(tr.text("tr-menu-debug-show-navmesh")).into_switch(),
|
||||
show_guide_circles: Action::new_keyless(tr.text("tr-menu-debug-show-guide-circles"))
|
||||
.into_switch(),
|
||||
|
|
@ -409,6 +414,9 @@ impl DebugActions {
|
|||
}
|
||||
|
||||
pub fn render_menu(&mut self, _ctx: &Context, ui: &mut Ui, menu_bar: &mut MenuBar) {
|
||||
self.highlight_obstacles
|
||||
.checkbox(ui, &mut menu_bar.highlight_obstacles);
|
||||
self.show_ghosts.checkbox(ui, &mut menu_bar.show_ghosts);
|
||||
self.show_navmesh.checkbox(ui, &mut menu_bar.show_navmesh);
|
||||
self.show_guide_circles
|
||||
.checkbox(ui, &mut menu_bar.show_guide_circles);
|
||||
|
|
|
|||
|
|
@ -49,7 +49,7 @@ impl<'a> Displayer<'a> {
|
|||
}
|
||||
|
||||
pub fn update(&mut self, ctx: &egui::Context, menu_bar: &MenuBar) {
|
||||
self.display_layout(ctx);
|
||||
self.display_layout(ctx, menu_bar);
|
||||
|
||||
if menu_bar.show_ratsnest {
|
||||
self.display_ratsnest(menu_bar);
|
||||
|
|
@ -82,7 +82,7 @@ impl<'a> Displayer<'a> {
|
|||
}
|
||||
}
|
||||
|
||||
fn display_layout(&mut self, ctx: &egui::Context) {
|
||||
fn display_layout(&mut self, ctx: &egui::Context, menu_bar: &MenuBar) {
|
||||
let board = self.workspace.interactor.invoker().autorouter().board();
|
||||
let active_polygons = self
|
||||
.workspace
|
||||
|
|
@ -109,7 +109,8 @@ impl<'a> Displayer<'a> {
|
|||
.color(board.layout().rules().layer_layername(i))
|
||||
.highlighted
|
||||
} else if let Some(activity) = &mut self.workspace.interactor.maybe_activity() {
|
||||
if activity.obstacles().contains(&primitive) {
|
||||
if menu_bar.highlight_obstacles && activity.obstacles().contains(&primitive)
|
||||
{
|
||||
self.config
|
||||
.colors(ctx)
|
||||
.layers
|
||||
|
|
@ -527,9 +528,11 @@ impl<'a> Displayer<'a> {
|
|||
let board = self.workspace.interactor.invoker().autorouter().board();
|
||||
|
||||
if let Some(activity) = self.workspace.interactor.maybe_activity() {
|
||||
for ghost in activity.ghosts() {
|
||||
self.painter
|
||||
.paint_primitive(ghost, egui::Color32::from_rgb(75, 75, 150));
|
||||
if menu_bar.show_ghosts {
|
||||
for ghost in activity.ghosts() {
|
||||
self.painter
|
||||
.paint_primitive(ghost, egui::Color32::from_rgb(75, 75, 150));
|
||||
}
|
||||
}
|
||||
|
||||
if let ActivityStepper::Interaction(InteractionStepper::RoutePlan(rp)) =
|
||||
|
|
@ -585,7 +588,7 @@ impl<'a> Displayer<'a> {
|
|||
.center();
|
||||
|
||||
let color = if let Some(activity) = &mut self.workspace.interactor.maybe_activity() {
|
||||
if activity.obstacles().contains(&primitive) {
|
||||
if menu_bar.highlight_obstacles && activity.obstacles().contains(&primitive) {
|
||||
egui::Color32::from_rgb(255, 255, 255)
|
||||
} else {
|
||||
egui::Color32::from_rgb(150, 150, 150)
|
||||
|
|
|
|||
|
|
@ -28,6 +28,8 @@ use crate::{
|
|||
pub struct MenuBar {
|
||||
pub multilayer_autoroute_options: MultilayerAutorouteOptions,
|
||||
pub is_placing_via: bool,
|
||||
pub highlight_obstacles: bool,
|
||||
pub show_ghosts: bool,
|
||||
pub show_ratsnest: bool,
|
||||
pub show_navmesh: bool,
|
||||
pub show_guide_circles: bool,
|
||||
|
|
@ -63,6 +65,8 @@ impl MenuBar {
|
|||
},
|
||||
},
|
||||
is_placing_via: false,
|
||||
highlight_obstacles: false,
|
||||
show_ghosts: false,
|
||||
show_ratsnest: true,
|
||||
show_navmesh: false,
|
||||
show_guide_circles: false,
|
||||
|
|
|
|||
|
|
@ -37,6 +37,8 @@ tr-menu-route-routed-band-width = Routed Band Width
|
|||
tr-menu-route-fanout-clearance = Fanout Clearance
|
||||
|
||||
tr-menu-debug = Debug
|
||||
tr-menu-debug-highlight-obstacles = Highlight Obstacles
|
||||
tr-menu-debug-show-ghosts = Show Ghosts
|
||||
tr-menu-debug-show-navmesh = Show Navmesh
|
||||
tr-menu-debug-show-guide-circles = Show Guide-Circles
|
||||
tr-menu-debug-show-guide-bitangents = Show Guide-Bitangents
|
||||
|
|
|
|||
Loading…
Reference in New Issue