Skip to main content

eulumdat_ui/widgets/
info.rs

1//! Information panel widget for displaying luminaire details
2
3use egui::Ui;
4use eulumdat::Eulumdat;
5
6/// Information panel showing luminaire details
7pub struct InfoPanel;
8
9impl InfoPanel {
10    /// Show the info panel (read-only view)
11    pub fn show(ui: &mut Ui, ldt: &Eulumdat) {
12        egui::ScrollArea::vertical().show(ui, |ui| {
13            ui.heading("Luminaire Information");
14            ui.separator();
15
16            egui::Grid::new("info_grid")
17                .num_columns(2)
18                .spacing([40.0, 6.0])
19                .striped(true)
20                .show(ui, |ui| {
21                    Self::row(ui, "Name", &ldt.luminaire_name);
22                    Self::row(ui, "Manufacturer", &ldt.identification);
23                    Self::row(ui, "Number", &ldt.luminaire_number);
24                    Self::row(ui, "File Name", &ldt.file_name);
25                    Self::row(ui, "Date/User", &ldt.date_user);
26                    Self::row(ui, "Type", &format!("{:?}", ldt.type_indicator));
27                    Self::row(ui, "Symmetry", &format!("{:?}", ldt.symmetry));
28                });
29
30            ui.add_space(20.0);
31            ui.heading("Dimensions");
32            ui.separator();
33
34            egui::Grid::new("dimensions_grid")
35                .num_columns(2)
36                .spacing([40.0, 6.0])
37                .striped(true)
38                .show(ui, |ui| {
39                    Self::row(ui, "Length", &format!("{:.1} mm", ldt.length));
40                    Self::row(ui, "Width", &format!("{:.1} mm", ldt.width));
41                    Self::row(ui, "Height", &format!("{:.1} mm", ldt.height));
42                    Self::row(
43                        ui,
44                        "Luminous Area",
45                        &format!(
46                            "{:.1} × {:.1} mm",
47                            ldt.luminous_area_length, ldt.luminous_area_width
48                        ),
49                    );
50                });
51
52            ui.add_space(20.0);
53            ui.heading("Photometric Data");
54            ui.separator();
55
56            egui::Grid::new("photometric_grid")
57                .num_columns(2)
58                .spacing([40.0, 6.0])
59                .striped(true)
60                .show(ui, |ui| {
61                    Self::row(ui, "C-planes", &format!("{}", ldt.c_angles.len()));
62                    Self::row(
63                        ui,
64                        "C-plane Range",
65                        &format!(
66                            "{:.0}° - {:.0}°",
67                            ldt.c_angles.first().unwrap_or(&0.0),
68                            ldt.c_angles.last().unwrap_or(&0.0)
69                        ),
70                    );
71                    Self::row(ui, "Gamma Angles", &format!("{}", ldt.g_angles.len()));
72                    Self::row(
73                        ui,
74                        "Gamma Range",
75                        &format!(
76                            "{:.0}° - {:.0}°",
77                            ldt.g_angles.first().unwrap_or(&0.0),
78                            ldt.g_angles.last().unwrap_or(&0.0)
79                        ),
80                    );
81                    Self::row(
82                        ui,
83                        "Max Intensity",
84                        &format!("{:.1} cd/klm", ldt.max_intensity()),
85                    );
86                    Self::row(
87                        ui,
88                        "Total Flux",
89                        &format!("{:.0} lm", ldt.total_luminous_flux()),
90                    );
91                });
92
93            // Lamp sets
94            if !ldt.lamp_sets.is_empty() {
95                ui.add_space(20.0);
96                ui.heading("Lamp Sets");
97                ui.separator();
98
99                for (i, lamp) in ldt.lamp_sets.iter().enumerate() {
100                    ui.collapsing(format!("Lamp Set {}", i + 1), |ui| {
101                        egui::Grid::new(format!("lamp_grid_{}", i))
102                            .num_columns(2)
103                            .spacing([40.0, 4.0])
104                            .show(ui, |ui| {
105                                Self::row(ui, "Number of Lamps", &format!("{}", lamp.num_lamps));
106                                Self::row(ui, "Type", &lamp.lamp_type);
107                                Self::row(
108                                    ui,
109                                    "Luminous Flux",
110                                    &format!("{:.0} lm", lamp.total_luminous_flux),
111                                );
112                                Self::row(ui, "Color", &lamp.color_appearance);
113                                Self::row(ui, "CRI/Group", &lamp.color_rendering_group);
114                                Self::row(
115                                    ui,
116                                    "Wattage",
117                                    &format!("{:.1} W", lamp.wattage_with_ballast),
118                                );
119                            });
120                    });
121                }
122            }
123
124            // Direct ratios
125            if ldt.direct_ratios.iter().any(|&r| r > 0.0) {
126                ui.add_space(20.0);
127                ui.heading("Direct Ratios (DFF)");
128                ui.separator();
129
130                ui.horizontal_wrapped(|ui| {
131                    for (i, &ratio) in ldt.direct_ratios.iter().enumerate() {
132                        if ratio > 0.0 {
133                            ui.label(format!("DFF{}: {:.1}%", i + 1, ratio * 100.0));
134                        }
135                    }
136                });
137            }
138        });
139    }
140
141    fn row(ui: &mut Ui, label: &str, value: &str) {
142        ui.label(label);
143        ui.label(value);
144        ui.end_row();
145    }
146}