Skip to content

Commit

Permalink
Address TODO for systemparam limit workaround
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 Sep 8, 2023
1 parent 26c4a36 commit 2060bdf
Show file tree
Hide file tree
Showing 8 changed files with 23 additions and 37 deletions.
14 changes: 4 additions & 10 deletions rmf_site_editor/src/keyboard.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,6 @@ impl Plugin for KeyboardInputPlugin {
}
}

// TODO(luca) get rid of this once 16 parameters limit is lifted in bevy 0.10
#[derive(SystemParam)]
struct KeyboardParams<'w> {
align_site: EventWriter<'w, AlignSiteDrawings>,
current_workspace: Res<'w, CurrentWorkspace>,
}

fn handle_keyboard_input(
keyboard_input: Res<Input<KeyCode>>,
selection: Res<Selection>,
Expand All @@ -64,7 +57,8 @@ fn handle_keyboard_input(
mut change_camera_mode: EventWriter<ChangeProjectionMode>,
current_level: Res<CurrentLevel>,
mut debug_mode: ResMut<DebugMode>,
mut params: KeyboardParams,
mut align_site: EventWriter<AlignSiteDrawings>,
current_workspace: Res<CurrentWorkspace>,
) {
let egui_context = egui_context.ctx_mut();
let ui_has_focus = egui_context.wants_pointer_input()
Expand Down Expand Up @@ -113,8 +107,8 @@ fn handle_keyboard_input(
}

if keyboard_input.just_pressed(KeyCode::T) {
if let Some(site) = params.current_workspace.root {
params.align_site.send(AlignSiteDrawings(site));
if let Some(site) = current_workspace.root {
align_site.send(AlignSiteDrawings(site));
}
}

Expand Down
6 changes: 3 additions & 3 deletions rmf_site_editor/src/widgets/diagnostic_window.rs
Original file line number Diff line number Diff line change
Expand Up @@ -176,21 +176,21 @@ impl<'a, 'w1, 's1, 'w2, 's2> DiagnosticWindow<'a, 'w1, 's1, 'w2, 's2> {
}

if ui.add(Button::new("Validate")).clicked() {
self.events.validate_workspace.send(ValidateWorkspace(root));
self.events.request.validate_workspace.send(ValidateWorkspace(root));
}
if ui.add(Button::new("Close")).clicked() {
state.show = false;
}
});
if new_filtered_issues != *filtered_issues {
self.events
.change_more
.change
.filtered_issues
.send(Change::new(new_filtered_issues, root));
}
if new_filtered_issue_kinds != *filtered_issue_kinds {
self.events
.change_more
.change
.filtered_issue_kinds
.send(Change::new(new_filtered_issue_kinds, root));
}
Expand Down
10 changes: 5 additions & 5 deletions rmf_site_editor/src/widgets/inspector/inspect_fiducial.rs
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ impl<'a, 'w1, 'w2, 's1, 's2> InspectFiducialWidget<'a, 'w1, 'w2, 's1, 's2> {
get_group_name(*affiliation).unwrap_or_else(|| "<broken reference>".to_owned());

ui.horizontal(|ui| {
let search = &mut self.events.change_more.search_for_fiducial.0;
let search = &mut self.events.change.search_for_fiducial.0;
let mut result = SearchResult::NoMatch;
let mut any_partial_matches = false;

Expand Down Expand Up @@ -194,7 +194,7 @@ impl<'a, 'w1, 'w2, 's1, 's2> InspectFiducialWidget<'a, 'w1, 'w2, 's1, 's2> {
.set_parent(tracker.site())
.id();
self.events
.change_more
.change
.affiliation
.send(Change::new(Affiliation(Some(new_group)), self.entity));
}
Expand All @@ -209,7 +209,7 @@ impl<'a, 'w1, 'w2, 's1, 's2> InspectFiducialWidget<'a, 'w1, 'w2, 's1, 's2> {
.clicked()
{
self.events
.change_more
.change
.affiliation
.send(Change::new(Affiliation(Some(group)), self.entity));
}
Expand Down Expand Up @@ -249,7 +249,7 @@ impl<'a, 'w1, 'w2, 's1, 's2> InspectFiducialWidget<'a, 'w1, 'w2, 's1, 's2> {
}

for (group, name) in tracker.unused() {
if name.contains(&self.events.change_more.search_for_fiducial.0) {
if name.contains(&self.events.change.search_for_fiducial.0) {
let select_affiliation = Affiliation(Some(*group));
ui.selectable_value(&mut new_affiliation, select_affiliation, name);
}
Expand All @@ -259,7 +259,7 @@ impl<'a, 'w1, 'w2, 's1, 's2> InspectFiducialWidget<'a, 'w1, 'w2, 's1, 's2> {

if new_affiliation != *affiliation {
self.events
.change_more
.change
.affiliation
.send(Change::new(new_affiliation, self.entity));
}
Expand Down
2 changes: 1 addition & 1 deletion rmf_site_editor/src/widgets/inspector/inspect_group.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ impl<'a, 'w1, 'w2, 's1, 's2> InspectGroup<'a, 'w1, 'w2, 's1, 's2> {
ui.label(RichText::new("Texture Properties").size(18.0));
if let Some(new_texture) = InspectTexture::new(texture, self.default_file).show(ui) {
self.events
.change_more
.change
.texture
.send(Change::new(new_texture, self.group));
}
Expand Down
8 changes: 4 additions & 4 deletions rmf_site_editor/src/widgets/inspector/inspect_texture.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ impl<'a, 'w1, 'w2, 's1, 's2> InspectTextureAffiliation<'a, 'w1, 'w2, 's1, 's2> {
};
let site = site;

let search = &mut self.events.change_more.search_for_texture.0;
let search = &mut self.events.change.search_for_texture.0;

let mut any_partial_matches = false;
let mut result = SearchResult::NoMatch;
Expand Down Expand Up @@ -187,7 +187,7 @@ impl<'a, 'w1, 'w2, 's1, 's2> InspectTextureAffiliation<'a, 'w1, 'w2, 's1, 's2> {
})
.set_parent(site)
.id();
self.events.change_more.affiliation.send(Change::new(
self.events.change.affiliation.send(Change::new(
Affiliation(Some(new_texture_group)),
self.entity,
));
Expand All @@ -203,7 +203,7 @@ impl<'a, 'w1, 'w2, 's1, 's2> InspectTextureAffiliation<'a, 'w1, 'w2, 's1, 's2> {
.clicked()
{
self.events
.change_more
.change
.affiliation
.send(Change::new(Affiliation(Some(group)), self.entity));
}
Expand Down Expand Up @@ -267,7 +267,7 @@ impl<'a, 'w1, 'w2, 's1, 's2> InspectTextureAffiliation<'a, 'w1, 'w2, 's1, 's2> {

if new_affiliation != *affiliation {
self.events
.change_more
.change
.affiliation
.send(Change::new(new_affiliation, self.entity));
}
Expand Down
4 changes: 2 additions & 2 deletions rmf_site_editor/src/widgets/inspector/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,7 @@ impl<'a, 'w1, 'w2, 's1, 's2> InspectorWidget<'a, 'w1, 'w2, 's1, 's2> {
.clicked()
{
if let Some(site) = self.events.request.current_workspace.root {
self.events.align_site.send(AlignSiteDrawings(site));
self.events.request.align_site.send(AlignSiteDrawings(site));
}
}
ui.add_space(10.0);
Expand Down Expand Up @@ -525,7 +525,7 @@ impl<'a, 'w1, 'w2, 's1, 's2> InspectorWidget<'a, 'w1, 'w2, 's1, 's2> {
.show(ui)
{
self.events
.change_more
.change
.distance
.send(Change::new(Distance(new_distance), selection));
}
Expand Down
14 changes: 3 additions & 11 deletions rmf_site_editor/src/widgets/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -158,12 +158,6 @@ pub struct ChangeEvents<'w> {
pub visibility: EventWriter<'w, Change<Visibility>>,
pub associated_graphs: EventWriter<'w, Change<AssociatedGraphs<Entity>>>,
pub location_tags: EventWriter<'w, Change<LocationTags>>,
}

// We split out this new struct to deal with the 16 field limitation on
// SystemParams.
#[derive(SystemParam)]
pub struct MoreChangeEvents<'w> {
pub affiliation: EventWriter<'w, Change<Affiliation<Entity>>>,
pub search_for_fiducial: ResMut<'w, SearchForFiducial>,
pub search_for_texture: ResMut<'w, SearchForTexture>,
Expand Down Expand Up @@ -219,6 +213,8 @@ pub struct Requests<'w> {
pub calculate_grid: EventWriter<'w, CalculateGrid>,
pub consider_tag: EventWriter<'w, ConsiderLocationTag>,
pub consider_graph: EventWriter<'w, ConsiderAssociatedGraph>,
pub align_site: EventWriter<'w, AlignSiteDrawings>,
pub validate_workspace: EventWriter<'w, ValidateWorkspace>,
}

#[derive(SystemParam)]
Expand Down Expand Up @@ -289,7 +285,6 @@ pub struct MenuParams<'w, 's> {
pub struct AppEvents<'w, 's> {
pub commands: Commands<'w, 's>,
pub change: ChangeEvents<'w>,
pub change_more: MoreChangeEvents<'w>,
pub workcell_change: WorkcellChangeEvents<'w>,
pub display: PanelResources<'w>,
pub request: Requests<'w>,
Expand All @@ -299,9 +294,6 @@ pub struct AppEvents<'w, 's> {
pub app_state: Res<'w, State<AppState>>,
pub next_app_state: ResMut<'w, NextState<AppState>>,
pub visibility_parameters: VisibilityParameters<'w>,
// TODO(luca) move these to Requests once 16 limit is lifted
pub align_site: EventWriter<'w, AlignSiteDrawings>,
pub validate_workspace: EventWriter<'w, ValidateWorkspace>,
}

fn site_ui_layout(
Expand Down Expand Up @@ -558,7 +550,7 @@ fn site_visualizer_ui_layout(
.clicked()
{
if let Some(site) = events.request.current_workspace.root {
events.align_site.send(AlignSiteDrawings(site));
events.request.align_site.send(AlignSiteDrawings(site));
}
}
if ui.add(Button::image_and_text(
Expand Down
2 changes: 1 addition & 1 deletion rmf_site_editor/src/widgets/view_groups.rs
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ impl<'a, 'w1, 's1, 'w2, 's2> ViewGroups<'a, 'w1, 's1, 'w2, 's2> {
.on_hover_text("Merge into this group")
.clicked()
{
events.change_more.merge_groups.send(MergeGroups {
events.change.merge_groups.send(MergeGroups {
from_group: merge_from,
into_group: *child,
});
Expand Down

0 comments on commit 2060bdf

Please sign in to comment.