Skip to content

Commit

Permalink
no InstanceKey, no NumInstances, no splats
Browse files Browse the repository at this point in the history
  • Loading branch information
teh-cmc committed Apr 25, 2024
1 parent 5198c80 commit dced19b
Show file tree
Hide file tree
Showing 169 changed files with 669 additions and 1,705 deletions.
11 changes: 6 additions & 5 deletions crates/re_data_ui/src/component.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ use std::sync::Arc;
use egui::NumExt;

use re_entity_db::{external::re_query::LatestAtComponentResults, EntityPath, InstancePath};
use re_log_types::Instance;
use re_types::ComponentName;
use re_ui::SyntaxHighlighting as _;
use re_viewer_context::{UiVerbosity, ViewerContext};
Expand Down Expand Up @@ -131,7 +132,7 @@ impl DataUi for EntityLatestAtResults {
db,
&self.entity_path,
&self.results,
&re_types::components::InstanceKey(0),
&Instance::from(0),
);
} else if one_line {
ui.label(format!("{} values", re_format::format_uint(num_instances)));
Expand All @@ -154,18 +155,18 @@ impl DataUi for EntityLatestAtResults {
re_ui::ReUi::setup_table_body(&mut body);
let row_height = re_ui::ReUi::table_line_height();
body.rows(row_height, num_displayed_rows, |mut row| {
let instance_key = re_types::components::InstanceKey(row.index() as _);
let instance = Instance::from(row.index() as u64);
row.col(|ui| {
let instance_path =
InstancePath::instance(self.entity_path.clone(), instance_key);
InstancePath::instance(self.entity_path.clone(), instance);
item_ui::instance_path_button_to(
ctx,
query,
db,
ui,
None,
&instance_path,
instance_key.syntax_highlighted(ui.style()),
instance.syntax_highlighted(ui.style()),
);
});
row.col(|ui| {
Expand All @@ -177,7 +178,7 @@ impl DataUi for EntityLatestAtResults {
db,
&self.entity_path,
&self.results,
&instance_key,
&instance,
);
});
});
Expand Down
9 changes: 5 additions & 4 deletions crates/re_data_ui/src/component_ui_registry.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use re_data_store::LatestAtQuery;
use re_entity_db::{external::re_query::LatestAtComponentResults, EntityDb};
use re_log_types::{external::arrow2, EntityPath};
use re_log_types::{external::arrow2, EntityPath, Instance};
use re_types::external::arrow2::array::Utf8Array;
use re_viewer_context::{ComponentUiRegistry, UiVerbosity, ViewerContext};

Expand Down Expand Up @@ -44,7 +44,8 @@ pub fn add_to_registry<C: EntityDataUi + re_types::Component>(registry: &mut Com
Box::new(
|ctx, ui, verbosity, query, db, entity_path, component, instance| {
// TODO(#5607): what should happen if the promise is still pending?
if let Some(component) = component.instance::<C>(db.resolver(), instance.0 as _) {
if let Some(component) = component.instance::<C>(db.resolver(), instance.get() as _)
{
component.entity_data_ui(ctx, ui, verbosity, entity_path, query, db);
} else {
ui.weak("(not found)");
Expand All @@ -63,13 +64,13 @@ fn fallback_component_ui(
db: &EntityDb,
_entity_path: &EntityPath,
component: &LatestAtComponentResults,
instance_key: &re_types::components::InstanceKey,
instance: &Instance,
) {
// TODO(#5607): what should happen if the promise is still pending?
let value = component
.component_name(db.resolver())
.and_then(|component_name| {
component.instance_raw(db.resolver(), component_name, instance_key.0 as _)
component.instance_raw(db.resolver(), component_name, instance.get() as _)
});

// No special ui implementation - use a generic one:
Expand Down
36 changes: 18 additions & 18 deletions crates/re_data_ui/src/editors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
use egui::NumExt as _;
use re_data_store::LatestAtQuery;
use re_entity_db::{external::re_query::LatestAtComponentResults, EntityDb};
use re_log_types::EntityPath;
use re_log_types::{EntityPath, Instance};
use re_types::{
components::{
Color, MarkerShape, MarkerSize, Name, Radius, ScalarScattering, StrokeWidth, Text,
Expand All @@ -24,11 +24,11 @@ fn edit_color_ui(
entity_path: &EntityPath,
override_path: &EntityPath,
component: &LatestAtComponentResults,
instance_key: &re_types::components::InstanceKey,
instance: &Instance,
) {
let current_color = component
// TODO(#5607): what should happen if the promise is still pending?
.instance::<Color>(db.resolver(), instance_key.0 as _)
.instance::<Color>(db.resolver(), instance.get() as _)
.unwrap_or_else(|| default_color(ctx, query, db, entity_path));

let current_color = current_color.into();
Expand Down Expand Up @@ -67,11 +67,11 @@ fn edit_text_ui(
entity_path: &EntityPath,
override_path: &EntityPath,
component: &LatestAtComponentResults,
instance_key: &re_types::components::InstanceKey,
instance: &Instance,
) {
let current_text = component
// TODO(#5607): what should happen if the promise is still pending?
.instance::<Text>(db.resolver(), instance_key.0 as _)
.instance::<Text>(db.resolver(), instance.get() as _)
.unwrap_or_else(|| default_text(ctx, query, db, entity_path));

let current_text = current_text.to_string();
Expand Down Expand Up @@ -107,11 +107,11 @@ fn edit_name_ui(
entity_path: &EntityPath,
override_path: &EntityPath,
component: &LatestAtComponentResults,
instance_key: &re_types::components::InstanceKey,
instance: &Instance,
) {
let current_text = component
// TODO(#5607): what should happen if the promise is still pending?
.instance::<Name>(db.resolver(), instance_key.0 as _)
.instance::<Name>(db.resolver(), instance.get() as _)
.unwrap_or_else(|| default_name(ctx, query, db, entity_path));

let current_text = current_text.to_string();
Expand Down Expand Up @@ -148,11 +148,11 @@ fn edit_scatter_ui(
entity_path: &EntityPath,
override_path: &EntityPath,
component: &LatestAtComponentResults,
instance_key: &re_types::components::InstanceKey,
instance: &Instance,
) {
let current_scatter = component
// TODO(#5607): what should happen if the promise is still pending?
.instance::<ScalarScattering>(db.resolver(), instance_key.0 as _)
.instance::<ScalarScattering>(db.resolver(), instance.get() as _)
.unwrap_or_else(|| default_scatter(ctx, query, db, entity_path));

let current_scatter = current_scatter.0;
Expand Down Expand Up @@ -197,11 +197,11 @@ fn edit_radius_ui(
entity_path: &EntityPath,
override_path: &EntityPath,
component: &LatestAtComponentResults,
instance_key: &re_types::components::InstanceKey,
instance: &Instance,
) {
let current_radius = component
// TODO(#5607): what should happen if the promise is still pending?
.instance::<Radius>(db.resolver(), instance_key.0 as _)
.instance::<Radius>(db.resolver(), instance.get() as _)
.unwrap_or_else(|| default_radius(ctx, query, db, entity_path));

let current_radius = current_radius.0;
Expand Down Expand Up @@ -244,11 +244,11 @@ fn edit_marker_shape_ui(
entity_path: &EntityPath,
override_path: &EntityPath,
component: &LatestAtComponentResults,
instance_key: &re_types::components::InstanceKey,
instance: &Instance,
) {
let current_marker = component
// TODO(#5607): what should happen if the promise is still pending?
.instance::<MarkerShape>(db.resolver(), instance_key.0 as _)
.instance::<MarkerShape>(db.resolver(), instance.get() as _)
.unwrap_or_else(|| default_marker_shape(ctx, query, db, entity_path));

let mut edit_marker = current_marker;
Expand Down Expand Up @@ -330,11 +330,11 @@ fn edit_stroke_width_ui(
entity_path: &EntityPath,
override_path: &EntityPath,
component: &LatestAtComponentResults,
instance_key: &re_types::components::InstanceKey,
instance: &Instance,
) {
let current_stroke_width = component
// TODO(#5607): what should happen if the promise is still pending?
.instance::<StrokeWidth>(db.resolver(), instance_key.0 as _)
.instance::<StrokeWidth>(db.resolver(), instance.get() as _)
.unwrap_or_else(|| default_stroke_width(ctx, query, db, entity_path));

let current_stroke_width = current_stroke_width.0;
Expand Down Expand Up @@ -377,11 +377,11 @@ fn edit_marker_size_ui(
entity_path: &EntityPath,
override_path: &EntityPath,
component: &LatestAtComponentResults,
instance_key: &re_types::components::InstanceKey,
instance: &Instance,
) {
let current_marker_size = component
// TODO(#5607): what should happen if the promise is still pending?
.instance::<MarkerSize>(db.resolver(), instance_key.0 as _)
.instance::<MarkerSize>(db.resolver(), instance.get() as _)
.unwrap_or_else(|| default_marker_size(ctx, query, db, entity_path));

let current_marker_size = current_marker_size.0;
Expand Down Expand Up @@ -426,7 +426,7 @@ fn register_editor<'a, C: Component + Loggable + 'static>(
&EntityPath,
&EntityPath,
&LatestAtComponentResults,
&re_types::components::InstanceKey,
&Instance,
),
) where
C: Into<::std::borrow::Cow<'a, C>>,
Expand Down
2 changes: 1 addition & 1 deletion crates/re_data_ui/src/entity_path.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@ impl DataUi for re_entity_db::EntityPath {
query: &re_data_store::LatestAtQuery,
db: &re_entity_db::EntityDb,
) {
InstancePath::entity_splat(self.clone()).data_ui(ctx, ui, verbosity, query, db);
InstancePath::entity_all(self.clone()).data_ui(ctx, ui, verbosity, query, db);
}
}
6 changes: 3 additions & 3 deletions crates/re_data_ui/src/instance_path.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ impl DataUi for InstancePath {
) {
let Self {
entity_path,
instance_key,
instance,
} = self;

let Some(components) = ctx
Expand Down Expand Up @@ -93,7 +93,7 @@ impl DataUi for InstancePath {
db,
);

if instance_key.is_splat() {
if instance.is_all() {
crate::EntityLatestAtResults {
entity_path: entity_path.clone(),
component_name,
Expand All @@ -109,7 +109,7 @@ impl DataUi for InstancePath {
db,
entity_path,
results,
instance_key,
instance,
);
}

Expand Down
30 changes: 14 additions & 16 deletions crates/re_data_ui/src/item_ui.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ pub fn entity_path_button(
db,
ui,
space_view_id,
&InstancePath::entity_splat(entity_path.clone()),
&InstancePath::entity_all(entity_path.clone()),
entity_path.syntax_highlighted(ui.style()),
)
}
Expand All @@ -67,7 +67,7 @@ pub fn entity_path_parts_buttons(
ui.spacing_mut().item_spacing.x = 2.0;

// Show one single icon up-front instead:
let instance_path = InstancePath::entity_splat(entity_path.clone());
let instance_path = InstancePath::entity_all(entity_path.clone());
ui.add(instance_path_icon(&query.timeline(), db, &instance_path).as_image());

let mut accumulated = Vec::new();
Expand All @@ -81,7 +81,7 @@ pub fn entity_path_parts_buttons(
db,
ui,
space_view_id,
&InstancePath::entity_splat(accumulated.clone().into()),
&InstancePath::entity_all(accumulated.clone().into()),
part.syntax_highlighted(ui.style()),
with_icon,
);
Expand All @@ -106,7 +106,7 @@ pub fn entity_path_button_to(
db,
ui,
space_view_id,
&InstancePath::entity_splat(entity_path.clone()),
&InstancePath::entity_all(entity_path.clone()),
text,
)
}
Expand Down Expand Up @@ -140,7 +140,7 @@ pub fn instance_path_icon(
db: &re_entity_db::EntityDb,
instance_path: &InstancePath,
) -> &'static icons::Icon {
if instance_path.is_splat() {
if instance_path.is_all() {
// It is an entity path
if db
.store()
Expand Down Expand Up @@ -268,13 +268,13 @@ pub fn instance_path_parts_buttons(
db,
ui,
space_view_id,
&InstancePath::entity_splat(accumulated.clone().into()),
&InstancePath::entity_all(accumulated.clone().into()),
part.syntax_highlighted(ui.style()),
with_icon,
);
}

if !instance_path.instance_key.is_splat() {
if !instance_path.instance.is_all() {
ui.weak("[");
instance_path_button_to_ex(
ctx,
Expand All @@ -283,7 +283,7 @@ pub fn instance_path_parts_buttons(
ui,
space_view_id,
instance_path,
instance_path.instance_key.syntax_highlighted(ui.style()),
instance_path.instance.syntax_highlighted(ui.style()),
with_icon,
);
ui.weak("]");
Expand Down Expand Up @@ -419,10 +419,7 @@ pub fn data_blueprint_button_to(
space_view_id: SpaceViewId,
entity_path: &EntityPath,
) -> egui::Response {
let item = Item::DataResult(
space_view_id,
InstancePath::entity_splat(entity_path.clone()),
);
let item = Item::DataResult(space_view_id, InstancePath::entity_all(entity_path.clone()));
let response = ui
.selectable_label(ctx.selection().contains_item(&item), text)
.on_hover_ui(|ui| {
Expand Down Expand Up @@ -505,7 +502,8 @@ pub fn cursor_interact_with_selectable(

/// Displays the "hover card" (i.e. big tooltip) for an instance or an entity.
///
/// The entity hover card is displayed the provided instance path is a splat.
/// The entity hover card is displayed if the provided instance path doesn't refer to a specific
/// instance.
pub fn instance_hover_card_ui(
ui: &mut egui::Ui,
ctx: &ViewerContext<'_>,
Expand All @@ -518,7 +516,7 @@ pub fn instance_hover_card_ui(
return;
}

let subtype_string = if instance_path.instance_key.is_splat() {
let subtype_string = if instance_path.instance.is_all() {
"Entity"
} else {
"Entity instance"
Expand All @@ -529,7 +527,7 @@ pub fn instance_hover_card_ui(
// TODO(emilk): give data_ui an alternate "everything on this timeline" query?
// Then we can move the size view into `data_ui`.

if instance_path.instance_key.is_splat() {
if instance_path.instance.is_all() {
if let Some(subtree) = ctx.recording().tree().subtree(&instance_path.entity_path) {
entity_tree_stats_ui(ui, &query.timeline(), subtree);
}
Expand All @@ -548,7 +546,7 @@ pub fn entity_hover_card_ui(
db: &re_entity_db::EntityDb,
entity_path: &EntityPath,
) {
let instance_path = InstancePath::entity_splat(entity_path.clone());
let instance_path = InstancePath::entity_all(entity_path.clone());
instance_hover_card_ui(ui, ctx, query, db, &instance_path);
}

Expand Down
2 changes: 1 addition & 1 deletion crates/re_data_ui/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ pub fn ui_visible_components<'a>(

/// Show this component in the UI.
pub fn is_component_visible_in_ui(component_name: &ComponentName) -> bool {
const HIDDEN_COMPONENTS: &[&str] = &["rerun.components.InstanceKey"];
const HIDDEN_COMPONENTS: &[&str] = &[];
!HIDDEN_COMPONENTS.contains(&component_name.as_ref())
}

Expand Down
2 changes: 0 additions & 2 deletions crates/re_entity_db/examples/memory_usage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,6 @@ fn log_messages() {
RowId::new(),
entity_path!("points"),
[build_frame_nr(TimeInt::ZERO)],
1,
build_some_positions2d(1),
)
.unwrap()
Expand All @@ -139,7 +138,6 @@ fn log_messages() {
RowId::new(),
entity_path!("points"),
[build_frame_nr(TimeInt::ZERO)],
NUM_POINTS as _,
build_some_positions2d(NUM_POINTS),
)
.unwrap()
Expand Down
Loading

0 comments on commit dced19b

Please sign in to comment.