Skip to content

Commit

Permalink
port extend_viewer_ui example
Browse files Browse the repository at this point in the history
  • Loading branch information
teh-cmc committed Mar 21, 2024
1 parent 0027fe1 commit 779edc7
Showing 1 changed file with 14 additions and 9 deletions.
23 changes: 14 additions & 9 deletions examples/rust/extend_viewer_ui/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
//! This example shows how to wrap the Rerun Viewer in your own GUI.
use re_viewer::external::{
arrow2, eframe, egui, re_data_store, re_entity_db, re_log, re_log_types, re_memory, re_query,
re_types,
arrow2, eframe, egui, re_data_store, re_entity_db, re_log, re_log_types, re_memory, re_types,
};

// By using `re_memory::AccountingAllocator` Rerun can keep track of exactly how much memory it is using,
Expand Down Expand Up @@ -153,20 +152,26 @@ fn component_ui(
// just show the last value logged for each component:
let query = re_data_store::LatestAtQuery::latest(timeline);

if let Some((_, _, component)) = re_query::get_component_with_instances(
let results = entity_db.query_caches2().latest_at(
entity_db.store(),
&query,
entity_path,
component_name,
) {
[component_name],
);
let component = results
.components
.get(&component_name)
.and_then(|result| result.raw(entity_db.resolver(), component_name));

if let Some(data) = component {
egui::ScrollArea::vertical()
.auto_shrink([false, true])
.show(ui, |ui| {
// Iterate over all the instances (e.g. all the points in the point cloud):
for instance_key in component.instance_keys() {
if let Some(value) = component.lookup_arrow(&instance_key) {
ui.label(format_arrow(&*value));
}

let num_instances = data.len();
for i in 0..num_instances {
ui.label(format_arrow(&*data.sliced(i, 1)));
}
});
};
Expand Down

0 comments on commit 779edc7

Please sign in to comment.