Skip to content

Commit

Permalink
reimplement PanelView using new blueprint types (re_viewer is now arr…
Browse files Browse the repository at this point in the history
…ow2-convert free)
  • Loading branch information
teh-cmc committed Oct 13, 2023
1 parent 136a2e5 commit 5172b1a
Show file tree
Hide file tree
Showing 12 changed files with 46 additions and 65 deletions.
1 change: 0 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions crates/re_types/src/blueprint/mod.rs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion crates/re_types/src/blueprint/panel_view.rs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions crates/re_types/src/blueprint/panel_view_ext.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
use super::PanelView;

impl PanelView {
// TODO(jleibs): Would be nice if this could be a const EntityPath but making
// the hash const is a bit of a pain.
pub const BLUEPRINT_VIEW_PATH: &str = "blueprint_view";
pub const SELECTION_VIEW_PATH: &str = "selection_view";
pub const TIMELINE_VIEW_PATH: &str = "timeline_view";
}
7 changes: 7 additions & 0 deletions crates/re_types/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,13 @@ pub mod components;
/// They all implement the [`Datatype`] trait.
pub mod datatypes;

/// Blueprint-related types.
///
/// They all implement the [`Component`] trait.
///
/// Unstable. Used for the ongoing blueprint experimentations.
pub mod blueprint;

mod archetype;
mod loggable;
mod loggable_batch;
Expand Down
2 changes: 1 addition & 1 deletion crates/re_types_builder/src/codegen/rust/api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -714,7 +714,7 @@ fn quote_trait_impls_from_obj(

match kind {
ObjectKind::Datatype | ObjectKind::Component | ObjectKind::Blueprint => {
let quoted_kind = if *kind == ObjectKind::Datatype || *kind == ObjectKind::Blueprint {
let quoted_kind = if *kind == ObjectKind::Datatype {
quote!(Datatype)
} else {
quote!(Component)
Expand Down
1 change: 0 additions & 1 deletion crates/re_viewer/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,6 @@ re_analytics = { workspace = true, optional = true }
ahash.workspace = true
anyhow.workspace = true
arrow2.workspace = true
arrow2_convert.workspace = true
bytemuck.workspace = true
cfg-if.workspace = true
eframe = { workspace = true, default-features = false, features = [
Expand Down
37 changes: 18 additions & 19 deletions crates/re_viewer/src/app_blueprint.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
use re_data_store::StoreDb;
use re_log_types::{DataRow, EntityPath, RowId, TimePoint};
use re_types::blueprint::PanelView;
use re_viewer_context::{CommandSender, StoreContext, SystemCommand, SystemCommandSender};

use crate::blueprint_components::panel::PanelState;

/// Blueprint for top-level application
pub struct AppBlueprint<'a> {
blueprint_db: Option<&'a StoreDb>,
Expand All @@ -27,17 +26,17 @@ impl<'a> AppBlueprint<'a> {

if let Some(blueprint_db) = blueprint_db {
if let Some(expanded) =
load_panel_state(&PanelState::BLUEPRINT_VIEW_PATH.into(), blueprint_db)
load_panel_state(&PanelView::BLUEPRINT_VIEW_PATH.into(), blueprint_db)
{
ret.blueprint_panel_expanded = expanded;
}
if let Some(expanded) =
load_panel_state(&PanelState::SELECTION_VIEW_PATH.into(), blueprint_db)
load_panel_state(&PanelView::SELECTION_VIEW_PATH.into(), blueprint_db)
{
ret.selection_panel_expanded = expanded;
}
if let Some(expanded) =
load_panel_state(&PanelState::TIMELINE_VIEW_PATH.into(), blueprint_db)
load_panel_state(&PanelView::TIMELINE_VIEW_PATH.into(), blueprint_db)
{
ret.time_panel_expanded = expanded;
}
Expand All @@ -49,47 +48,47 @@ impl<'a> AppBlueprint<'a> {
pub fn toggle_blueprint_panel(&self, command_sender: &CommandSender) {
let blueprint_panel_expanded = !self.blueprint_panel_expanded;
self.send_panel_expanded(
PanelState::BLUEPRINT_VIEW_PATH,
PanelView::BLUEPRINT_VIEW_PATH,
blueprint_panel_expanded,
command_sender,
);
if self.is_narrow_screen && self.blueprint_panel_expanded {
self.send_panel_expanded(PanelState::SELECTION_VIEW_PATH, false, command_sender);
self.send_panel_expanded(PanelView::SELECTION_VIEW_PATH, false, command_sender);
}
}

pub fn toggle_selection_panel(&self, command_sender: &CommandSender) {
let selection_panel_expanded = !self.selection_panel_expanded;
self.send_panel_expanded(
PanelState::SELECTION_VIEW_PATH,
PanelView::SELECTION_VIEW_PATH,
selection_panel_expanded,
command_sender,
);
if self.is_narrow_screen && self.blueprint_panel_expanded {
self.send_panel_expanded(PanelState::BLUEPRINT_VIEW_PATH, false, command_sender);
self.send_panel_expanded(PanelView::BLUEPRINT_VIEW_PATH, false, command_sender);
}
}

pub fn toggle_time_panel(&self, command_sender: &CommandSender) {
self.send_panel_expanded(
PanelState::TIMELINE_VIEW_PATH,
PanelView::TIMELINE_VIEW_PATH,
!self.time_panel_expanded,
command_sender,
);
}
}

pub fn setup_welcome_screen_blueprint(welcome_screen_blueprint: &mut StoreDb) {
for (panel_name, expanded) in [
(PanelState::BLUEPRINT_VIEW_PATH, true),
(PanelState::SELECTION_VIEW_PATH, false),
(PanelState::TIMELINE_VIEW_PATH, false),
for (panel_name, is_expanded) in [
(PanelView::BLUEPRINT_VIEW_PATH, true),
(PanelView::SELECTION_VIEW_PATH, false),
(PanelView::TIMELINE_VIEW_PATH, false),
] {
let entity_path = EntityPath::from(panel_name);
// TODO(jleibs): Seq instead of timeless?
let timepoint = TimePoint::timeless();

let component = PanelState { expanded };
let component = PanelView { is_expanded };

let row =
DataRow::from_cells1_sized(RowId::random(), entity_path, timepoint, 1, [component])
Expand All @@ -105,15 +104,15 @@ impl<'a> AppBlueprint<'a> {
fn send_panel_expanded(
&self,
panel_name: &str,
expanded: bool,
is_expanded: bool,
command_sender: &CommandSender,
) {
if let Some(blueprint_db) = self.blueprint_db {
let entity_path = EntityPath::from(panel_name);
// TODO(jleibs): Seq instead of timeless?
let timepoint = TimePoint::timeless();

let component = PanelState { expanded };
let component = PanelView { is_expanded };

let row =
DataRow::from_cells1_sized(RowId::random(), entity_path, timepoint, 1, [component])
Expand All @@ -131,6 +130,6 @@ fn load_panel_state(path: &EntityPath, blueprint_db: &re_data_store::StoreDb) ->
re_tracing::profile_function!();
blueprint_db
.store()
.query_timeless_component::<PanelState>(path)
.map(|p| p.expanded)
.query_timeless_component::<PanelView>(path)
.map(|p| p.is_expanded)
}
3 changes: 0 additions & 3 deletions crates/re_viewer/src/blueprint_components/mod.rs

This file was deleted.

32 changes: 0 additions & 32 deletions crates/re_viewer/src/blueprint_components/panel.rs

This file was deleted.

1 change: 0 additions & 1 deletion crates/re_viewer/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ mod app;
mod app_blueprint;
mod app_state;
mod background_tasks;
pub mod blueprint_components;
pub mod env_vars;
#[cfg(not(target_arch = "wasm32"))]
mod loading;
Expand Down
15 changes: 9 additions & 6 deletions rerun_py/src/python_bridge.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ use pyo3::{
types::{PyBytes, PyDict},
};

use re_viewer::blueprint_components::panel::PanelState;
use re_viewer_context::SpaceViewId;
use re_viewport::{
blueprint_components::{AutoSpaceViews, SpaceViewComponent, VIEWPORT_PATH},
Expand Down Expand Up @@ -694,26 +693,30 @@ fn set_panels(
timeline_view_expanded: Option<bool>,
blueprint: Option<&PyRecordingStream>,
) {
use rerun::external::re_types::blueprint::PanelView;

if let Some(expanded) = blueprint_view_expanded {
set_panel(PanelState::BLUEPRINT_VIEW_PATH, expanded, blueprint);
set_panel(PanelView::BLUEPRINT_VIEW_PATH, expanded, blueprint);
}
if let Some(expanded) = selection_view_expanded {
set_panel(PanelState::SELECTION_VIEW_PATH, expanded, blueprint);
set_panel(PanelView::SELECTION_VIEW_PATH, expanded, blueprint);
}
if let Some(expanded) = timeline_view_expanded {
set_panel(PanelState::TIMELINE_VIEW_PATH, expanded, blueprint);
set_panel(PanelView::TIMELINE_VIEW_PATH, expanded, blueprint);
}
}

fn set_panel(entity_path: &str, expanded: bool, blueprint: Option<&PyRecordingStream>) {
fn set_panel(entity_path: &str, is_expanded: bool, blueprint: Option<&PyRecordingStream>) {
let Some(blueprint) = get_blueprint_recording(blueprint) else {
return;
};

use rerun::external::re_types::blueprint::PanelView;

// TODO(jleibs): Validation this is a valid blueprint path?
let entity_path = parse_entity_path(entity_path);

let panel_state = PanelState { expanded };
let panel_state = PanelView { is_expanded };

let row = DataRow::from_cells1(
RowId::random(),
Expand Down

0 comments on commit 5172b1a

Please sign in to comment.