mirror of https://codeberg.org/topola/topola.git
feat(topola-egui): Add option to display primitive indices on debug overlay
This commit is contained in:
parent
5ec5b2f809
commit
d75c73b540
|
|
@ -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();
|
||||
|
|
|
|||
|
|
@ -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),
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Reference in New Issue