Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -5137,6 +5137,7 @@ version = "0.17.0-alpha.4"
dependencies = [
"anyhow",
"backtrace",
"bytemuck",
"criterion",
"document-features",
"itertools 0.13.0",
Expand Down
9 changes: 5 additions & 4 deletions crates/re_edit_ui/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ use datatype_editors::edit_enum;
use re_types::{
blueprint::components::{BackgroundKind, Corner2D, LockRangeDuringZoom, Visible},
components::{
AggregationPolicy, AxisLength, Color, Colormap, ImagePlaneDistance, MarkerSize, Name,
Radius, StrokeWidth, Text,
AggregationPolicy, AxisLength, Color, Colormap, FillRatio, ImagePlaneDistance, MarkerSize,
Name, Radius, StrokeWidth, Text,
},
};
use re_viewer_context::ViewerContext;
Expand Down Expand Up @@ -45,17 +45,18 @@ pub fn register_editors(registry: &mut re_viewer_context::ComponentUiRegistry) {
registry.add_singleline_editor_ui(marker_shape::edit_marker_shape_ui);
registry.add_singleline_editor_ui(range1d::edit_range1d);

registry.add_singleline_editor_ui::<ImagePlaneDistance>(datatype_editors::edit_f32_zero_to_inf);
registry.add_singleline_editor_ui::<AxisLength>(datatype_editors::edit_f32_zero_to_inf);
registry.add_singleline_editor_ui::<FillRatio>(datatype_editors::edit_f32_zero_to_inf);
registry.add_singleline_editor_ui::<ImagePlaneDistance>(datatype_editors::edit_f32_zero_to_inf);

registry.add_singleline_editor_ui::<Visible>(datatype_editors::edit_bool_raw);
registry.add_singleline_editor_ui::<LockRangeDuringZoom>(datatype_editors::edit_bool);

registry.add_singleline_editor_ui::<Text>(datatype_editors::edit_singleline_string);
registry.add_singleline_editor_ui::<Name>(datatype_editors::edit_singleline_string);

registry.add_singleline_editor_ui::<Radius>(datatype_editors::edit_f32_zero_to_inf_raw);
registry.add_singleline_editor_ui::<MarkerSize>(datatype_editors::edit_f32_zero_to_inf_raw);
registry.add_singleline_editor_ui::<Radius>(datatype_editors::edit_f32_zero_to_inf_raw);
registry.add_singleline_editor_ui::<StrokeWidth>(datatype_editors::edit_f32_zero_to_inf_raw);

registry.add_singleline_editor_ui(|_ctx, ui, value| {
Expand Down
28 changes: 4 additions & 24 deletions crates/re_entity_db/src/entity_properties.rs
Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@
#[cfg(feature = "serde")]
use re_log_types::EntityPath;

#[cfg(feature = "serde")]
use crate::EditableAutoValue;

// ----------------------------------------------------------------------------

/// Properties for a collection of entities.
#[cfg(feature = "serde")]
#[derive(Clone, Default, PartialEq)]
#[derive(Clone, Default, PartialEq, Eq)]
#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))]
pub struct EntityPropertyMap {
props: nohash_hasher::IntMap<EntityPath, EntityProperties>,
Expand Down Expand Up @@ -88,23 +85,19 @@ impl FromIterator<(EntityPath, EntityProperties)> for EntityPropertyMap {
// ----------------------------------------------------------------------------

#[cfg(feature = "serde")]
#[derive(Clone, Debug, PartialEq)]
#[derive(Clone, Debug, PartialEq, Eq)]
#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))]
#[cfg_attr(feature = "serde", serde(default))]
pub struct EntityProperties {
// TODO(#5067): Test property used so we don't have to continuously adjust existing tests while we're dismantling `EntityProperties`.
pub test_property: bool,

/// Used to scale the radii of the points in the resulting point cloud.
pub backproject_radius_scale: EditableAutoValue<f32>, // TODO(andreas): should be a component on the DepthImage archetype.
}

#[cfg(feature = "serde")]
impl Default for EntityProperties {
fn default() -> Self {
Self {
test_property: true,
backproject_radius_scale: EditableAutoValue::Auto(1.0),
}
}
}
Expand All @@ -115,11 +108,6 @@ impl EntityProperties {
pub fn with_child(&self, child: &Self) -> Self {
Self {
test_property: self.test_property && child.test_property,

backproject_radius_scale: self
.backproject_radius_scale
.or(&child.backproject_radius_scale)
.clone(),
}
}

Expand All @@ -130,25 +118,17 @@ impl EntityProperties {
///
/// This is important to combine the base-layer of up-to-date auto-values with values
/// loaded from the Blueprint store where the Auto values are not up-to-date.
#[allow(clippy::unused_self)] // TODO(andreas): we're on the way out anyways :)
pub fn merge_with(&self, other: &Self) -> Self {
Self {
test_property: other.test_property,

backproject_radius_scale: other
.backproject_radius_scale
.or(&self.backproject_radius_scale)
.clone(),
}
}

/// Determine whether this `EntityProperty` has user-edits relative to another `EntityProperty`
pub fn has_edits(&self, other: &Self) -> bool {
let Self {
test_property,
backproject_radius_scale,
} = self;
let Self { test_property } = self;

test_property != &other.test_property
|| backproject_radius_scale.has_edits(&other.backproject_radius_scale)
}
}
6 changes: 3 additions & 3 deletions crates/re_entity_db/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
#![doc = document_features::document_features!()]
//!

#![allow(unused_imports)] // TODO(andreas): temporary until entity_properties is removed.

pub mod entity_db;
pub mod entity_properties;
pub mod entity_tree;
Expand All @@ -20,9 +18,11 @@ pub mod blueprint;
#[cfg(feature = "serde")]
mod editable_auto_value;

#[cfg(feature = "serde")]
pub use self::entity_properties::*;

pub use self::{
entity_db::EntityDb,
entity_properties::*,
entity_tree::EntityTree,
instance_path::{InstancePath, InstancePathHash},
store_bundle::{StoreBundle, StoreLoadError},
Expand Down
75 changes: 37 additions & 38 deletions crates/re_selection_panel/src/selection_panel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,16 @@ use re_data_ui::{
item_ui::{guess_instance_path_icon, guess_query_and_db_for_selected_entity},
DataUi,
};
use re_entity_db::{EditableAutoValue, EntityPath, EntityProperties, InstancePath};
use re_entity_db::{EntityPath, InstancePath};
use re_log_types::EntityPathFilter;
use re_space_view::DataResultQuery as _;
use re_space_view::{DataResultQuery as _, HybridLatestAtResults};
use re_space_view_time_series::TimeSeriesSpaceView;
use re_types::{
archetypes::{Axes3D, DepthImage, Pinhole},
blueprint::components::Interactive,
components::{
AxisLength, Colormap, DepthMeter, ImagePlaneDistance, PinholeProjection, Transform3D,
VisualizerOverrides,
AxisLength, Colormap, DepthMeter, FillRatio, ImagePlaneDistance, PinholeProjection,
Transform3D, VisualizerOverrides,
},
tensor_data::TensorDataMeaning,
};
Expand Down Expand Up @@ -1162,22 +1162,12 @@ fn blueprint_ui_for_data_result(
.lookup_result_by_path(entity_path)
.cloned()
{
let mut accumulated_legacy_props = data_result.accumulated_properties().clone();
let accumulated_legacy_props_before = accumulated_legacy_props.clone();

entity_props_ui(
ctx,
ui,
ctx.lookup_query_result(space_view_id),
&data_result,
&mut accumulated_legacy_props,
);
if accumulated_legacy_props != accumulated_legacy_props_before {
data_result.save_individual_override_properties(
ctx.viewer_ctx,
Some(accumulated_legacy_props),
);
}
}
}
}
Expand All @@ -1187,7 +1177,6 @@ fn entity_props_ui(
ui: &mut egui::Ui,
query_result: &DataQueryResult,
data_result: &DataResult,
entity_props: &mut EntityProperties,
) {
use re_types::blueprint::components::Visible;
use re_types::Loggable as _;
Expand Down Expand Up @@ -1261,18 +1250,18 @@ fn entity_props_ui(
// TODO(wumpf): It would be nice to only show pinhole & depth properties in the context of a 3D view.
// if *view_state.state_spatial.nav_mode.get() == SpatialNavigationMode::ThreeD {
pinhole_props_ui(ctx, ui, data_result);
depth_props_ui(ctx, ui, data_result, entity_path, entity_props);
depth_props_ui(ctx, ui, data_result, entity_path);
transform3d_visualization_ui(ctx, ui, data_result);
});
}

fn colormap_props_ui(ctx: &ViewContext<'_>, ui: &mut egui::Ui, data_result: &DataResult) {
let (query, _store) =
guess_query_and_db_for_selected_entity(ctx.viewer_ctx, &data_result.entity_path);

// TODO(andreas): Queries the entire image archetype for no good reason, but all of this ui is a hack anyways.
let results = data_result.latest_at_with_overrides::<DepthImage>(ctx, &query);
let colormap = results.get_mono_with_fallback::<Colormap>();
fn colormap_props_ui(
ctx: &ViewContext<'_>,
ui: &mut egui::Ui,
data_result: &DataResult,
depth_image_results: &HybridLatestAtResults<'_>,
) {
let colormap = depth_image_results.get_mono_with_fallback::<Colormap>();
let mut new_colormap = colormap;

ui.label("Color map");
Expand Down Expand Up @@ -1401,7 +1390,6 @@ fn depth_props_ui(
ui: &mut egui::Ui,
data_result: &DataResult,
entity_path: &EntityPath,
entity_props: &mut EntityProperties,
) -> Option<()> {
re_tracing::profile_function!();

Expand All @@ -1428,20 +1416,24 @@ fn depth_props_ui(
.on_hover_text("The entity path of the pinhole transform being used to do the backprojection.");
ui.end_row();

depth_from_world_scale_ui(ctx, ui, data_result);
backproject_radius_scale_ui(ui, &mut entity_props.backproject_radius_scale);
colormap_props_ui(ctx, ui, data_result);
let (query, _store) =
guess_query_and_db_for_selected_entity(ctx.viewer_ctx, &data_result.entity_path);
let depth_image_results = data_result.latest_at_with_overrides::<DepthImage>(ctx, &query);

depth_from_world_scale_ui(ctx, ui, data_result, &depth_image_results);
backproject_radius_scale_ui(ctx, ui, data_result, &depth_image_results);
colormap_props_ui(ctx, ui, data_result, &depth_image_results);

Some(())
}

fn depth_from_world_scale_ui(ctx: &ViewContext<'_>, ui: &mut egui::Ui, data_result: &DataResult) {
let (query, _store) =
guess_query_and_db_for_selected_entity(ctx.viewer_ctx, &data_result.entity_path);

// TODO(andreas): Queries the entire image archetype for no good reason, but all of this ui is a hack anyways.
let results = data_result.latest_at_with_overrides::<DepthImage>(ctx, &query);
let depth_meter = results.get_mono_with_fallback::<DepthMeter>();
fn depth_from_world_scale_ui(
ctx: &ViewContext<'_>,
ui: &mut egui::Ui,
data_result: &DataResult,
depth_image_results: &HybridLatestAtResults<'_>,
) {
let depth_meter = depth_image_results.get_mono_with_fallback::<DepthMeter>();

ui.label("Backproject meter");
let mut value = *depth_meter;
Expand All @@ -1464,9 +1456,16 @@ fn depth_from_world_scale_ui(ctx: &ViewContext<'_>, ui: &mut egui::Ui, data_resu
ui.end_row();
}

fn backproject_radius_scale_ui(ui: &mut egui::Ui, property: &mut EditableAutoValue<f32>) {
fn backproject_radius_scale_ui(
ctx: &ViewContext<'_>,
ui: &mut egui::Ui,
data_result: &DataResult,
depth_image_results: &HybridLatestAtResults<'_>,
) {
let radius_scale = depth_image_results.get_mono_with_fallback::<FillRatio>();

ui.label("Backproject radius scale");
let mut value = *property.get();
let mut value = *radius_scale.0;
let speed = (value * 0.01).at_least(0.001);
let response = ui
.add(
Expand All @@ -1481,10 +1480,10 @@ fn backproject_radius_scale_ui(ui: &mut egui::Ui, property: &mut EditableAutoVal
Double-click to reset.",
);
if response.double_clicked() {
*property = EditableAutoValue::Auto(2.0);
data_result.clear_individual_override::<FillRatio>(ctx.viewer_ctx);
response.surrender_focus();
} else if response.changed() {
*property = EditableAutoValue::UserEdited(value);
data_result.save_individual_override(ctx.viewer_ctx, &FillRatio(value.into()));
}
ui.end_row();
}
2 changes: 1 addition & 1 deletion crates/re_space_view/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ pub use heuristics::suggest_space_view_for_each_entity;
pub use query::{
latest_at_with_blueprint_resolved_data, range_with_blueprint_resolved_data, DataResultQuery,
};
pub use results_ext::{HybridResults, RangeResultsExt};
pub use results_ext::{HybridLatestAtResults, HybridResults, RangeResultsExt};
pub use screenshot::ScreenshotMode;
pub use view_property_ui::view_property_ui;

Expand Down
50 changes: 3 additions & 47 deletions crates/re_space_view_spatial/src/heuristics.rs
Original file line number Diff line number Diff line change
@@ -1,32 +1,11 @@
use std::collections::BTreeSet;

use egui::NumExt as _;
use nohash_hasher::IntSet;

use re_data_ui::image_meaning_for_entity;
use re_entity_db::EditableAutoValue;
use re_log_types::EntityPath;
use re_types::{tensor_data::TensorDataMeaning, SpaceViewClassIdentifier};
use re_viewer_context::{IdentifiedViewSystem, PerSystemEntities, ViewerContext};

use crate::{
view_kind::SpatialSpaceViewKind,
visualizers::{ImageVisualizer, SpatialViewVisualizerData},
};

pub fn generate_auto_legacy_properties(
ctx: &ViewerContext<'_>,
per_system_entities: &PerSystemEntities,
) -> re_entity_db::EntityPropertyMap {
re_tracing::profile_function!();

let mut auto_properties = re_entity_db::EntityPropertyMap::default();
use re_types::SpaceViewClassIdentifier;
use re_viewer_context::ViewerContext;

// Do pinhole properties before, since they may be used in transform3d heuristics.
update_depth_cloud_property_heuristics(ctx, per_system_entities, &mut auto_properties);

auto_properties
}
use crate::{view_kind::SpatialSpaceViewKind, visualizers::SpatialViewVisualizerData};

pub fn auto_size_world_heuristic(
scene_bbox_accum: &macaw::BoundingBox,
Expand All @@ -53,29 +32,6 @@ pub fn auto_size_world_heuristic(
heuristic0.min(heuristic1)
}

fn update_depth_cloud_property_heuristics(
ctx: &ViewerContext<'_>,
per_system_entities: &PerSystemEntities,
auto_properties: &mut re_entity_db::EntityPropertyMap,
) {
// TODO(andreas): There should be a depth cloud system
for ent_path in per_system_entities
.get(&ImageVisualizer::identifier())
.unwrap_or(&BTreeSet::new())
{
let meaning =
image_meaning_for_entity(ent_path, &ctx.current_query(), ctx.recording().store());

let mut properties = auto_properties.get(ent_path);

if meaning == TensorDataMeaning::Depth {
properties.backproject_radius_scale = EditableAutoValue::Auto(1.0);

auto_properties.overwrite_properties(ent_path.clone(), properties);
}
}
}

/// Returns all entities for which a visualizer of the given kind would be picked.
///
/// I.e. all entities for which at least one visualizer of the specified kind is applicable
Expand Down
Loading