Skip to content

Commit

Permalink
Move workspace loading to workflows (#233)
Browse files Browse the repository at this point in the history
Signed-off-by: Luca Della Vedova <lucadv@intrinsic.ai>
  • Loading branch information
luca-della-vedova committed Aug 5, 2024
1 parent 9c44fe0 commit 47552ea
Show file tree
Hide file tree
Showing 8 changed files with 412 additions and 250 deletions.
153 changes: 137 additions & 16 deletions Cargo.lock

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

2 changes: 2 additions & 0 deletions rmf_site_editor/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ nalgebra = "0.32.5"

[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
clap = { version = "4.0.10", features = ["color", "derive", "help", "usage", "suggestions"] }
bevy_impulse = { git = "https://github.com/open-rmf/bevy_impulse", branch = "main" }

[target.'cfg(target_arch = "wasm32")'.dependencies]
console_error_panic_hook = "0.1.7"
bevy_impulse = { git = "https://github.com/open-rmf/bevy_impulse", branch = "main", features = ["single_threaded_async"]}
6 changes: 3 additions & 3 deletions rmf_site_editor/src/keyboard.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
use crate::{
interaction::{ChangeMode, ChangeProjectionMode, InteractionMode, Selection},
site::{AlignSiteDrawings, Delete},
CreateNewWorkspace, CurrentWorkspace, LoadWorkspace, SaveWorkspace,
CreateNewWorkspace, CurrentWorkspace, SaveWorkspace, WorkspaceLoader,
};
use bevy::{prelude::*, window::PrimaryWindow};
use bevy_egui::EguiContexts;
Expand Down Expand Up @@ -50,12 +50,12 @@ fn handle_keyboard_input(
mut delete: EventWriter<Delete>,
mut save_workspace: EventWriter<SaveWorkspace>,
mut new_workspace: EventWriter<CreateNewWorkspace>,
mut load_workspace: EventWriter<LoadWorkspace>,
mut change_camera_mode: EventWriter<ChangeProjectionMode>,
mut debug_mode: ResMut<DebugMode>,
mut align_site: EventWriter<AlignSiteDrawings>,
current_workspace: Res<CurrentWorkspace>,
primary_windows: Query<Entity, With<PrimaryWindow>>,
mut workspace_loader: WorkspaceLoader,
) {
let Some(egui_context) = primary_windows
.get_single()
Expand Down Expand Up @@ -122,7 +122,7 @@ fn handle_keyboard_input(
}

if keyboard_input.just_pressed(KeyCode::O) {
load_workspace.send(LoadWorkspace::Dialog);
workspace_loader.load_from_dialog();
}
}
}
1 change: 1 addition & 0 deletions rmf_site_editor/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,7 @@ impl Plugin for SiteEditor {
OccupancyPlugin,
WorkspacePlugin,
IssuePlugin,
bevy_impulse::ImpulsePlugin::default(),
));

if self.headless_export.is_none() {
Expand Down
16 changes: 7 additions & 9 deletions rmf_site_editor/src/main_menu.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@
*/

use super::demo_world::*;
use crate::{AppState, Autoload, LoadWorkspace, WorkspaceData};
use crate::{AppState, Autoload, WorkspaceData, WorkspaceLoader};
use bevy::{app::AppExit, prelude::*, window::PrimaryWindow};
use bevy_egui::{egui, EguiContexts};

fn egui_ui(
mut egui_context: EguiContexts,
mut _exit: EventWriter<AppExit>,
mut _load_workspace: EventWriter<LoadWorkspace>,
mut workspace_loader: WorkspaceLoader,
mut _app_state: ResMut<State<AppState>>,
autoload: Option<ResMut<Autoload>>,
primary_windows: Query<Entity, With<PrimaryWindow>>,
Expand All @@ -32,7 +32,7 @@ fn egui_ui(
#[cfg(not(target_arch = "wasm32"))]
{
if let Some(filename) = autoload.filename.take() {
_load_workspace.send(LoadWorkspace::Path(filename));
workspace_loader.load_from_path(filename);
}
}
return;
Expand All @@ -57,23 +57,21 @@ fn egui_ui(

ui.horizontal(|ui| {
if ui.button("View demo map").clicked() {
_load_workspace.send(LoadWorkspace::Data(WorkspaceData::LegacyBuilding(
demo_office(),
)));
workspace_loader.load_from_data(WorkspaceData::LegacyBuilding(demo_office()));
}

if ui.button("Open a file").clicked() {
_load_workspace.send(LoadWorkspace::Dialog);
workspace_loader.load_from_dialog();
}

if ui.button("Create new file").clicked() {
_load_workspace.send(LoadWorkspace::BlankFromDialog);
workspace_loader.create_empty_from_dialog();
}

// TODO(@mxgrey): Bring this back when we have finished developing
// the key features for workcell editing.
// if ui.button("Workcell Editor").clicked() {
// _load_workspace.send(LoadWorkspace::Data(WorkspaceData::Workcell(
// workspace_loader.send(LoadWorkspace::Data(WorkspaceData::Workcell(
// demo_workcell(),
// )));
// }
Expand Down
6 changes: 3 additions & 3 deletions rmf_site_editor/src/site/sdf_exporter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use crate::{
ChildLiftCabinGroup, CollisionMeshMarker, DoorSegments, DrawingMarker, FloorSegments,
LiftDoormat, ModelSceneRoot, TentativeModelFormat, VisualMeshMarker,
},
Autoload, LoadWorkspace,
Autoload, WorkspaceLoader,
};
use rmf_site_format::{
IsStatic, LevelElevation, LiftCabin, ModelMarker, NameInSite, NameOfSite, SiteID, WallMarker,
Expand Down Expand Up @@ -51,11 +51,11 @@ pub fn headless_sdf_export(
sites: Query<(Entity, &NameOfSite)>,
drawings: Query<Entity, With<DrawingMarker>>,
autoload: Option<ResMut<Autoload>>,
mut load_workspace: EventWriter<LoadWorkspace>,
mut workspace_loader: WorkspaceLoader,
) {
if let Some(mut autoload) = autoload {
if let Some(filename) = autoload.filename.take() {
load_workspace.send(LoadWorkspace::Path(filename));
workspace_loader.load_from_path(filename);
}
} else {
error!("Cannot perform a headless export since no site file was specified for loading");
Expand Down
Loading

0 comments on commit 47552ea

Please sign in to comment.