Skip to main content

polyscope_ui/
selection_panel.rs

1//! Selection/pick results panel.
2
3use egui::{Context, SidePanel, Ui};
4use polyscope_render::{PickElementType, PickResult};
5
6/// Builds the selection panel on the right side.
7/// Only shows if there is an active selection.
8pub fn build_selection_panel(
9    ctx: &Context,
10    selection: &PickResult,
11    build_structure_pick_ui: impl FnOnce(&mut Ui),
12) {
13    SidePanel::right("selection_panel")
14        .default_width(300.0)
15        .show(ctx, |ui| {
16            ui.heading("Selection");
17            ui.separator();
18
19            ui.label(format!(
20                "Screen: ({:.0}, {:.0})",
21                selection.screen_pos.x, selection.screen_pos.y
22            ));
23            ui.label(format!("Depth: {:.4}", selection.depth));
24
25            ui.separator();
26            ui.label(format!(
27                "{}: {}",
28                selection.structure_type, selection.structure_name
29            ));
30
31            // Show element type and index
32            let element_type_str = match selection.element_type {
33                PickElementType::None => "Element",
34                PickElementType::Point => "Point",
35                PickElementType::Vertex => "Vertex",
36                PickElementType::Face => "Face",
37                PickElementType::Edge => "Edge",
38                PickElementType::Cell => "Cell",
39            };
40            ui.label(format!("{} #{}", element_type_str, selection.element_index));
41
42            ui.separator();
43            build_structure_pick_ui(ui);
44        });
45}