From 64ad9798a40bbfb5d163ce64d02fd01674dfe223 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jochen=20G=C3=B6rtler?= Date: Mon, 16 Dec 2024 11:52:16 +0100 Subject: [PATCH 1/2] Build `debug` information only in debug builds --- crates/viewer/re_view_graph/src/ui/draw.rs | 1 + crates/viewer/re_view_graph/src/view.rs | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/crates/viewer/re_view_graph/src/ui/draw.rs b/crates/viewer/re_view_graph/src/ui/draw.rs index 0916e1026372..80274e59f4df 100644 --- a/crates/viewer/re_view_graph/src/ui/draw.rs +++ b/crates/viewer/re_view_graph/src/ui/draw.rs @@ -158,6 +158,7 @@ fn draw_node( node_ui.response() } +#[cfg(debug_assertions)] /// Draws a bounding box, as well as a basic coordinate system. pub fn draw_debug(ui: &Ui, world_bounding_rect: Rect) { let painter = ui.painter(); diff --git a/crates/viewer/re_view_graph/src/view.rs b/crates/viewer/re_view_graph/src/view.rs index edb59eceb27d..50b3c6fc82d4 100644 --- a/crates/viewer/re_view_graph/src/view.rs +++ b/crates/viewer/re_view_graph/src/view.rs @@ -131,6 +131,9 @@ Display a graph of nodes and edges. ui.selection_grid("graph_view_settings_ui").show(ui, |ui| { state.layout_ui(ui); state.simulation_ui(ui); + + // Limit debug UI to debug builds. + #[cfg(debug_assertions)] state.debug_ui(ui); }); @@ -199,6 +202,7 @@ Display a graph of nodes and edges. } // We need to draw the debug information after the rest to ensure that we have the correct bounding box. + #[cfg(debug_assertions)] if state.show_debug { draw_debug(ui, world_bounding_rect); } From 7177c4307e1a3cf24537078a3d68fc7df2c883aa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jochen=20G=C3=B6rtler?= Date: Tue, 17 Dec 2024 10:19:29 +0100 Subject: [PATCH 2/2] Remove all debug code --- crates/viewer/re_view_graph/src/ui/draw.rs | 23 --------------------- crates/viewer/re_view_graph/src/ui/mod.rs | 2 +- crates/viewer/re_view_graph/src/ui/state.rs | 9 -------- crates/viewer/re_view_graph/src/view.rs | 12 +---------- 4 files changed, 2 insertions(+), 44 deletions(-) diff --git a/crates/viewer/re_view_graph/src/ui/draw.rs b/crates/viewer/re_view_graph/src/ui/draw.rs index 80274e59f4df..b8e26133cd05 100644 --- a/crates/viewer/re_view_graph/src/ui/draw.rs +++ b/crates/viewer/re_view_graph/src/ui/draw.rs @@ -158,29 +158,6 @@ fn draw_node( node_ui.response() } -#[cfg(debug_assertions)] -/// Draws a bounding box, as well as a basic coordinate system. -pub fn draw_debug(ui: &Ui, world_bounding_rect: Rect) { - let painter = ui.painter(); - - // Paint coordinate system at the world origin - let origin = Pos2::new(0.0, 0.0); - let x_axis = Pos2::new(100.0, 0.0); - let y_axis = Pos2::new(0.0, 100.0); - - painter.line_segment([origin, x_axis], Stroke::new(1.0, Color32::RED)); - painter.line_segment([origin, y_axis], Stroke::new(1.0, Color32::GREEN)); - - if world_bounding_rect.is_positive() { - painter.rect( - world_bounding_rect, - 0.0, - Color32::from_rgba_unmultiplied(255, 0, 255, 8), - Stroke::new(1.0, Color32::from_rgb(255, 0, 255)), - ); - } -} - /// Helper function to draw an arrow at the end of the edge fn draw_arrow(painter: &Painter, tip: Pos2, direction: Vec2, color: Color32) { let arrow_size = 10.0; // Adjust size as needed diff --git a/crates/viewer/re_view_graph/src/ui/mod.rs b/crates/viewer/re_view_graph/src/ui/mod.rs index 4e00cdfe7388..304e793452ff 100644 --- a/crates/viewer/re_view_graph/src/ui/mod.rs +++ b/crates/viewer/re_view_graph/src/ui/mod.rs @@ -2,6 +2,6 @@ mod draw; mod selection; mod state; -pub use draw::{draw_debug, draw_graph, DrawableLabel}; +pub use draw::{draw_graph, DrawableLabel}; pub use selection::view_property_force_ui; pub use state::GraphViewState; diff --git a/crates/viewer/re_view_graph/src/ui/state.rs b/crates/viewer/re_view_graph/src/ui/state.rs index d8dce815d1df..e15ec96afb3c 100644 --- a/crates/viewer/re_view_graph/src/ui/state.rs +++ b/crates/viewer/re_view_graph/src/ui/state.rs @@ -12,9 +12,6 @@ use crate::layout::{ForceLayoutParams, ForceLayoutProvider, Layout, LayoutReques #[derive(Default)] pub struct GraphViewState { pub layout_state: LayoutState, - - pub show_debug: bool, - pub visual_bounds: Option, pub rect_in_ui: Option, } @@ -35,12 +32,6 @@ impl GraphViewState { ui.end_row(); } - pub fn debug_ui(&mut self, ui: &mut egui::Ui) { - ui.re_checkbox(&mut self.show_debug, "Show debug information") - .on_hover_text("Shows debug information for the current graph"); - ui.end_row(); - } - pub fn simulation_ui(&mut self, ui: &mut egui::Ui) { if ui.button("Reset simulation").clicked() { self.layout_state.reset(); diff --git a/crates/viewer/re_view_graph/src/view.rs b/crates/viewer/re_view_graph/src/view.rs index 50b3c6fc82d4..f83e8a898941 100644 --- a/crates/viewer/re_view_graph/src/view.rs +++ b/crates/viewer/re_view_graph/src/view.rs @@ -28,7 +28,7 @@ use re_viewport_blueprint::ViewProperty; use crate::{ graph::Graph, layout::{ForceLayoutParams, LayoutRequest}, - ui::{draw_debug, draw_graph, view_property_force_ui, GraphViewState}, + ui::{draw_graph, view_property_force_ui, GraphViewState}, visualizers::{merge, EdgesVisualizer, NodeVisualizer}, }; @@ -131,10 +131,6 @@ Display a graph of nodes and edges. ui.selection_grid("graph_view_settings_ui").show(ui, |ui| { state.layout_ui(ui); state.simulation_ui(ui); - - // Limit debug UI to debug builds. - #[cfg(debug_assertions)] - state.debug_ui(ui); }); re_ui::list_item::list_item_scope(ui, "graph_selection_ui", |ui| { @@ -200,12 +196,6 @@ Display a graph of nodes and edges. let graph_rect = draw_graph(ui, ctx, graph, layout, query); world_bounding_rect = world_bounding_rect.union(graph_rect); } - - // We need to draw the debug information after the rest to ensure that we have the correct bounding box. - #[cfg(debug_assertions)] - if state.show_debug { - draw_debug(ui, world_bounding_rect); - } }); // Update blueprint if changed