diff --git a/crates/topola-egui/src/actions.rs b/crates/topola-egui/src/actions.rs index 2b46686..68dd0eb 100644 --- a/crates/topola-egui/src/actions.rs +++ b/crates/topola-egui/src/actions.rs @@ -174,6 +174,7 @@ pub struct ViewActions { pub show_topo_navmesh: Switch, pub show_bboxes: Switch, pub show_origin_destination: Switch, + pub show_primitive_indices: Switch, pub show_appearance_panel: Switch, } @@ -206,6 +207,10 @@ impl ViewActions { tr.text("tr-menu-view-show-origin-destination"), ) .into_switch(), + show_primitive_indices: Action::new_keyless( + tr.text("tr-menu-view-show-primitive-indices"), + ) + .into_switch(), show_appearance_panel: Action::new_keyless(tr.text("tr-menu-view-show-layer-manager")) .into_switch(), } @@ -242,6 +247,8 @@ impl ViewActions { self.show_bboxes.checkbox(ui, &mut menu_bar.show_bboxes); self.show_origin_destination .checkbox(ui, &mut menu_bar.show_origin_destination); + self.show_primitive_indices + .checkbox(ui, &mut menu_bar.show_primitive_indices); }); ui.separator(); diff --git a/crates/topola-egui/src/displayer.rs b/crates/topola-egui/src/displayer.rs index d104df9..87cd9cc 100644 --- a/crates/topola-egui/src/displayer.rs +++ b/crates/topola-egui/src/displayer.rs @@ -19,7 +19,7 @@ use topola::{ primitive::MakePrimitiveShape, }, geometry::{shape::AccessShape, GenericNode}, - graph::MakeRef, + graph::{GetIndex, MakeRef}, interactor::{activity::ActivityStepper, interaction::InteractionStepper}, layout::poly::MakePolygon, math::{self, Circle, RotationSense}, @@ -76,6 +76,10 @@ impl<'a> Displayer<'a> { } self.display_activity(menu_bar); + + if menu_bar.show_primitive_indices { + self.display_primitive_indices(); + } } fn display_layout(&mut self, ctx: &egui::Context) { @@ -555,4 +559,24 @@ impl<'a> Displayer<'a> { } } } + + fn display_primitive_indices(&mut self) { + let board = self.workspace.interactor.invoker().autorouter().board(); + + if let Some(active_layer) = self.workspace.appearance_panel.active_layer { + for primitive in board.layout().drawing().layer_primitive_nodes(active_layer) { + let pos = primitive + .primitive_ref(board.layout().drawing()) + .shape() + .center(); + + self.painter.paint_text( + pos, + egui::Align2::CENTER_CENTER, + &format!("{}", primitive.index()), + egui::Color32::from_rgb(200, 200, 200), + ); + } + } + } } diff --git a/crates/topola-egui/src/menu_bar.rs b/crates/topola-egui/src/menu_bar.rs index b0727b0..f19d99e 100644 --- a/crates/topola-egui/src/menu_bar.rs +++ b/crates/topola-egui/src/menu_bar.rs @@ -37,6 +37,7 @@ pub struct MenuBar { pub show_topo_navmesh: bool, pub show_bboxes: bool, pub show_origin_destination: bool, + pub show_primitive_indices: bool, pub show_appearance_panel: bool, pub frame_timestep: f32, } @@ -64,6 +65,7 @@ impl MenuBar { show_topo_navmesh: false, show_bboxes: false, show_origin_destination: false, + show_primitive_indices: false, show_appearance_panel: true, frame_timestep: 0.1, } diff --git a/locales/en-US/main.ftl b/locales/en-US/main.ftl index 321de37..2dc2c62 100644 --- a/locales/en-US/main.ftl +++ b/locales/en-US/main.ftl @@ -30,6 +30,7 @@ tr-menu-view-show-pathfinding-scores = Show Pathfinding Scores tr-menu-view-show-topo-navmesh = Show Topological Navmesh tr-menu-view-show-bboxes = Show BBoxes tr-menu-view-show-origin-destination = Show Origin–Destination +tr-menu-view-show-primitive-indices = Show Primitive Indices tr-menu-view-show-layer-manager = Show Layer Manager tr-menu-view-kdb-scroll-delta-factor = Keyboard scroll delta factor tr-menu-view-frame-timestep = Frame Timestep