Skip to content

Commit

Permalink
Merge pull request #358 from nyx-space/feat/gh-356-gui-epa
Browse files Browse the repository at this point in the history
GUI and description of EPA files
  • Loading branch information
ChristopherRabotin authored Dec 10, 2024
2 parents faf8226 + 8b171cb commit 0fa2507
Show file tree
Hide file tree
Showing 10 changed files with 368 additions and 182 deletions.
Binary file removed anise-gui/icon-128.png
Binary file not shown.
Binary file added anise-gui/icon-256.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
100 changes: 100 additions & 0 deletions anise-gui/src/epa.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
use anise::prelude::Almanac;
use egui_extras::{Column, TableBuilder};

pub fn epa_ui(ui: &mut egui::Ui, almanac: &Almanac) {
TableBuilder::new(ui)
.column(Column::auto().at_least(100.0).resizable(true))
.column(Column::auto().at_least(75.0).resizable(true))
.column(Column::auto().at_least(75.0).resizable(true))
.column(Column::auto().at_least(75.0).resizable(true))
.column(Column::auto().at_least(75.0).resizable(true))
.column(Column::auto().at_least(75.0).resizable(true))
.column(Column::auto().at_least(75.0).resizable(true))
.column(Column::remainder())
.header(20.0, |mut header| {
header.col(|ui| {
ui.heading("Name");
});
header.col(|ui| {
ui.heading("ID");
});
header.col(|ui| {
ui.heading("Quat w");
});

header.col(|ui| {
ui.heading("Quat x");
});
header.col(|ui| {
ui.heading("Quat y");
});
header.col(|ui| {
ui.heading("Quat z");
});

header.col(|ui| {
ui.heading("From ID");
});
header.col(|ui| {
ui.heading("To ID");
});
})
.body(|mut body| {
let epa = &almanac.euler_param_data;

let binding = epa.lut.entries();
let mut values = binding.values().collect::<Vec<_>>().to_vec();
values.sort_by_key(|(opt_id, _)| match opt_id {
Some(id) => *id,
None => 0,
});

for (opt_id, opt_name) in values {
let data = if let Some(id) = opt_id {
epa.get_by_id(*id).unwrap()
} else {
epa.get_by_name(&opt_name.clone().unwrap()).unwrap()
};

body.row(30.0, |mut row| {
row.col(|ui| {
ui.label(match opt_name {
Some(name) => format!("{name}"),
None => "Unset".to_string(),
});
});

row.col(|ui| {
ui.label(match opt_id {
Some(id) => format!("{id}"),
None => "Unset".to_string(),
});
});

row.col(|ui| {
ui.text_edit_singleline(&mut format!("{}", data.w));
});

row.col(|ui| {
ui.text_edit_singleline(&mut format!("{}", data.x));
});

row.col(|ui| {
ui.text_edit_singleline(&mut format!("{}", data.y));
});

row.col(|ui| {
ui.text_edit_singleline(&mut format!("{}", data.z));
});

row.col(|ui| {
ui.text_edit_singleline(&mut format!("{}", data.from));
});

row.col(|ui| {
ui.text_edit_singleline(&mut format!("{}", data.to));
});
})
}
});
}
4 changes: 3 additions & 1 deletion anise-gui/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ mod ui;
use ui::UiApp;

mod bpc;
mod epa;
mod pca;
mod spk;

#[cfg(not(target_arch = "wasm32"))]
Expand All @@ -25,7 +27,7 @@ fn main() {
viewport: egui::ViewportBuilder::default()
.with_inner_size([1024.0, 640.0])
.with_icon(
eframe::icon_data::from_png_bytes(&include_bytes!("../icon-128.png")[..]).unwrap(),
eframe::icon_data::from_png_bytes(&include_bytes!("../icon-256.png")[..]).unwrap(),
),
..Default::default()
};
Expand Down
143 changes: 143 additions & 0 deletions anise-gui/src/pca.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,143 @@
use anise::prelude::Almanac;
use egui_extras::{Column, TableBuilder};

pub fn pca_ui(ui: &mut egui::Ui, almanac: &Almanac) {
TableBuilder::new(ui)
.column(Column::auto().at_least(100.0).resizable(true))
.column(Column::auto().at_least(50.0).resizable(true))
.column(Column::auto().at_least(75.0).resizable(true))
.column(Column::auto().at_least(75.0).resizable(true))
.column(Column::auto().at_least(75.0).resizable(true))
.column(Column::auto().at_least(125.0).resizable(true))
.column(Column::auto().at_least(125.0).resizable(true))
.column(Column::auto().at_least(125.0).resizable(true))
.column(Column::remainder())
.header(20.0, |mut header| {
header.col(|ui| {
ui.heading("Name");
});
header.col(|ui| {
ui.heading("ID");
});
header.col(|ui| {
ui.heading("Gravity param (km^3/s^2)");
});

header.col(|ui| {
ui.heading("Major axis (km)");
});
header.col(|ui| {
ui.heading("Minor axis (km)");
});
header.col(|ui| {
ui.heading("Polar axis (km)");
});

header.col(|ui| {
ui.heading("Pole right asc.");
});
header.col(|ui| {
ui.heading("Pole declination");
});
header.col(|ui| {
ui.heading("Prime meridian");
});
})
.body(|mut body| {
let pck = &almanac.planetary_data;

let binding = pck.lut.entries();
let mut values = binding.values().collect::<Vec<_>>().to_vec();
values.sort_by_key(|(opt_id, _)| match opt_id {
Some(id) => *id,
None => 0,
});

for (opt_id, opt_name) in values {
let data = if let Some(id) = opt_id {
pck.get_by_id(*id).unwrap()
} else {
pck.get_by_name(&opt_name.clone().unwrap()).unwrap()
};

body.row(30.0, |mut row| {
row.col(|ui| {
ui.label(match opt_name {
Some(name) => format!("{name}"),
None => "Unset".to_string(),
});
});

row.col(|ui| {
ui.label(match opt_id {
Some(id) => format!("{id}"),
None => "Unset".to_string(),
});
});

row.col(|ui| {
ui.text_edit_singleline(&mut format!("{}", data.mu_km3_s2));
});

match data.shape {
None => {
// Three empty columns
row.col(|ui| {
ui.label("Unset");
});
row.col(|ui| {
ui.label("Unset");
});
row.col(|ui| {
ui.label("Unset");
});
}
Some(shape) => {
row.col(|ui| {
ui.text_edit_singleline(&mut format!(
"{}",
shape.semi_major_equatorial_radius_km
));
});
row.col(|ui| {
ui.text_edit_singleline(&mut format!(
"{}",
shape.semi_minor_equatorial_radius_km
));
});
row.col(|ui| {
ui.text_edit_singleline(&mut format!("{}", shape.polar_radius_km));
});
}
}

match data.pole_right_ascension {
None => row.col(|ui| {
ui.label("Unset");
}),
Some(pole_ra) => row.col(|ui| {
ui.label(format!("{pole_ra}"));
}),
};

match data.pole_declination {
None => row.col(|ui| {
ui.label("Unset");
}),
Some(pole_dec) => row.col(|ui| {
ui.label(format!("{pole_dec}"));
}),
};

match data.prime_meridian {
None => row.col(|ui| {
ui.label("Unset");
}),
Some(pm) => row.col(|ui| {
ui.label(format!("{pm}"));
}),
};
});
}
});
}
Loading

0 comments on commit 0fa2507

Please sign in to comment.