From 779edc76de6ea9802eeff59df6a996ffa5771264 Mon Sep 17 00:00:00 2001 From: Clement Rey Date: Thu, 21 Mar 2024 18:34:06 +0100 Subject: [PATCH] port extend_viewer_ui example --- examples/rust/extend_viewer_ui/src/main.rs | 23 +++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/examples/rust/extend_viewer_ui/src/main.rs b/examples/rust/extend_viewer_ui/src/main.rs index d0ac54af050e..fbc37dee872b 100644 --- a/examples/rust/extend_viewer_ui/src/main.rs +++ b/examples/rust/extend_viewer_ui/src/main.rs @@ -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, @@ -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))); } }); };