Skip to content

Commit

Permalink
UI tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
emilk committed Nov 7, 2022
1 parent 39b1b1c commit 98b4190
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 11 deletions.
4 changes: 2 additions & 2 deletions crates/re_viewer/src/ui/selection_panel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -202,12 +202,12 @@ fn ui_space_view(ctx: &mut ViewerContext<'_>, ui: &mut egui::Ui, space_view: &mu

match space_view.selected_category {
super::space_view::ViewCategory::ThreeD => {
ui.label("3D:");
ui.label("3D view.");
super::view3d::show_settings_ui(ctx, ui, &mut space_view.view_state.state_3d);
}
super::space_view::ViewCategory::Tensor => {
if let Some(state_tensor) = &mut space_view.view_state.state_tensor {
ui.label("Tensor:");
ui.label("Tensor view.");
state_tensor.ui(ui);
}
}
Expand Down
4 changes: 3 additions & 1 deletion crates/re_viewer/src/ui/space_view.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,9 @@ impl SpaceView {

match categories.len() {
0 => {
ui.label("(empty)");
ui.centered_and_justified(|ui| {
ui.label("(empty)");
});
}
1 => {
self.selected_category = categories[0];
Expand Down
24 changes: 16 additions & 8 deletions crates/re_viewer/src/ui/view3d/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,9 @@ pub(crate) struct State3D {

/// Filled in at the start of each frame
#[serde(skip)]
pub space_specs: SpaceSpecs,
pub(crate) space_specs: SpaceSpecs,
#[serde(skip)]
space_camera: Vec<SpaceCamera>,
}

impl Default for State3D {
Expand All @@ -66,6 +68,7 @@ impl Default for State3D {
show_axes: false,
last_eye_interact_time: f64::NEG_INFINITY,
space_specs: Default::default(),
space_camera: Default::default(),
}
}
}
Expand All @@ -78,7 +81,7 @@ impl State3D {
response: &egui::Response,
) -> &mut OrbitEye {
if response.double_clicked() {
// Reset camera
// Reset eye
if tracking_camera.is_some() {
ctx.rec_cfg.selection = Selection::None;
}
Expand Down Expand Up @@ -225,7 +228,7 @@ pub(crate) fn show_settings_ui(
}

if ui
.button("Reset camera")
.button("Reset virtual camera")
.on_hover_text("You can also double-click the 3D view")
.clicked()
{
Expand All @@ -234,13 +237,17 @@ pub(crate) fn show_settings_ui(
// TODO(emilk): reset tracking camera too
}

// TODO(emilk): only show if there is a camera om scene.
ui.toggle_value(&mut ctx.options.show_camera_mesh_in_3d, "Show camera mesh");

ui.toggle_value(&mut state.spin, "Spin Camera")
ui.checkbox(&mut state.spin, "Spin virtual camera")
.on_hover_text("Spin view");
ui.toggle_value(&mut state.show_axes, "Show Axes")
ui.checkbox(&mut state.show_axes, "show origin axes")
.on_hover_text("Show X-Y-Z axes");

if !state.space_camera.is_empty() {
ui.checkbox(
&mut ctx.options.show_camera_mesh_in_3d,
"Show camera meshes",
);
}
}

#[derive(Clone, Default)]
Expand Down Expand Up @@ -330,6 +337,7 @@ pub(crate) fn view_3d(
crate::profile_function!();

state.scene_bbox = state.scene_bbox.union(scene.calc_bbox());
state.space_camera = space_cameras.to_vec();

let (rect, response) = ui.allocate_at_least(ui.available_size(), egui::Sense::click_and_drag());

Expand Down
1 change: 1 addition & 0 deletions crates/re_viewer/src/ui/view3d/space_camera.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ use re_data_store::ObjPath;
use re_log_types::{IndexHash, ViewCoordinates};

/// A logged camera that connects spaces.
#[derive(Clone)]
pub struct SpaceCamera {
/// Path to the object which has the rigid [Self::world_from_camera`] transforms.
pub camera_obj_path: ObjPath,
Expand Down

0 comments on commit 98b4190

Please sign in to comment.