1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
use re_log_types::ComponentPath;
use re_ui::UiExt;
use re_viewer_context::{UiLayout, ViewerContext};

use super::DataUi;

impl DataUi for ComponentPath {
    fn data_ui(
        &self,
        ctx: &ViewerContext<'_>,
        ui: &mut egui::Ui,
        ui_layout: UiLayout,
        query: &re_chunk_store::LatestAtQuery,
        db: &re_entity_db::EntityDb,
    ) {
        let Self {
            entity_path,
            component_name,
        } = self;

        let engine = db.storage_engine();

        if let Some(archetype_name) = component_name.indicator_component_archetype() {
            ui.label(format!(
                "Indicator component for the {archetype_name} archetype"
            ));
        } else {
            let results = engine
                .cache()
                .latest_at(query, entity_path, [*component_name]);
            if let Some(unit) = results.components.get(component_name) {
                crate::ComponentPathLatestAtResults {
                    component_path: self.clone(),
                    unit,
                }
                .data_ui(ctx, ui, ui_layout, query, db);
            } else if ctx.recording().tree().subtree(entity_path).is_some() {
                if engine.store().entity_has_component_on_timeline(
                    &query.timeline(),
                    entity_path,
                    component_name,
                ) {
                    ui.label("<unset>");
                } else {
                    ui.label(format!(
                        "Entity {entity_path:?} has no component {component_name:?}"
                    ));
                }
            } else {
                ui.error_label(&format!("Unknown component path: {self}"));
            }
        }
    }
}