Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add the basic structure of launch view #13

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1,218 changes: 1,218 additions & 0 deletions assets/frodo_J.obj

Large diffs are not rendered by default.

24 changes: 15 additions & 9 deletions src/gui.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,13 @@ use egui::{Align, Color32, FontFamily, FontId, Key, Layout, Modifiers, Vec2};

use mithril::telemetry::*;

mod panels;
mod fc_settings;
mod map;
mod maxi_grid;
mod misc;
mod panels;
mod plot;
mod plots;
mod simulation_settings;
mod tabs;
mod theme;
Expand All @@ -34,6 +35,7 @@ pub struct Sam {
data_source: Box<dyn DataSource>,
tab: GuiTab,
plot_tab: PlotTab,
launch_tab: LaunchTab,
configure_tab: ConfigureTab,
archive_window: ArchiveWindow,
}
Expand All @@ -56,6 +58,7 @@ impl Sam {

let plot_tab = PlotTab::init(&settings);
let configure_tab = ConfigureTab::init();
let launch_tab = LaunchTab::init(&settings);

egui_extras::install_image_loaders(ctx);

Expand All @@ -66,6 +69,7 @@ impl Sam {
tab: GuiTab::Plot,
plot_tab,
configure_tab,
launch_tab,

archive_window: ArchiveWindow::default(),
}
Expand Down Expand Up @@ -151,7 +155,9 @@ impl Sam {
}

// Header containing text indicators and flight mode buttons
HeaderPanel::show(ctx, self.data_source.as_mut(), !self.archive_window.open);
if self.tab != GuiTab::Launch {
HeaderPanel::show(ctx, self.data_source.as_mut(), !self.archive_window.open);
}

// Bottom status bar
egui::TopBottomPanel::bottom("bottombar").min_height(30.0).show(ctx, |ui| {
Expand All @@ -167,12 +173,12 @@ impl Sam {
});

// ... and the current tab some space on the right.
ui.allocate_ui_with_layout(ui.available_size(), Layout::right_to_left(Align::Center), |ui| {
match self.tab {
GuiTab::Launch => {}
GuiTab::Plot => self.plot_tab.bottom_bar_ui(ui, self.data_source.as_mut()),
GuiTab::Configure => {}
}
ui.allocate_ui_with_layout(ui.available_size(), Layout::right_to_left(Align::Center), |ui| match self
.tab
{
GuiTab::Launch => {}
GuiTab::Plot => self.plot_tab.bottom_bar_ui(ui, self.data_source.as_mut()),
GuiTab::Configure => {}
});
});
});
Expand All @@ -181,7 +187,7 @@ impl Sam {
egui::CentralPanel::default().show(ctx, |ui| {
ui.set_enabled(!self.archive_window.open);
match self.tab {
GuiTab::Launch => {}
GuiTab::Launch => self.launch_tab.main_ui(ui, self.data_source.as_mut()),
GuiTab::Plot => self.plot_tab.main_ui(ui, self.data_source.as_mut()),
GuiTab::Configure => {
let changed = self.configure_tab.main_ui(ui, self.data_source.as_mut(), &mut self.settings);
Expand Down
16 changes: 16 additions & 0 deletions src/gui/plots/accelerometer_plot.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
use std::{cell::RefCell, rc::Rc};

use crate::gui::plot::{PlotState, SharedPlotState};

use super::color_constants::*;

pub fn accelerometer_plot(shared_plot: &Rc<RefCell<SharedPlotState>>) -> PlotState {
let accelerometer_plot = PlotState::new("Accelerometers", (Some(-10.0), Some(10.0)), shared_plot.clone())
.line("Accel 2 (X) [m/s²]", R1, |vs| vs.accelerometer2.map(|a| a.x))
.line("Accel 2 (Y) [m/s²]", G1, |vs| vs.accelerometer2.map(|a| a.y))
.line("Accel 2 (Z) [m/s²]", B1, |vs| vs.accelerometer2.map(|a| a.z))
.line("Accel 1 (X) [m/s²]", R, |vs| vs.accelerometer1.map(|a| a.x))
.line("Accel 1 (Y) [m/s²]", G, |vs| vs.accelerometer1.map(|a| a.y))
.line("Accel 1 (Z) [m/s²]", B, |vs| vs.accelerometer1.map(|a| a.z));
accelerometer_plot
}
14 changes: 14 additions & 0 deletions src/gui/plots/altitude_plot.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
use std::{cell::RefCell, rc::Rc};

use crate::gui::plot::{PlotState, SharedPlotState};

use super::color_constants::*;

pub fn altitude_plot(shared_plot: &Rc<RefCell<SharedPlotState>>) -> PlotState {
let altitude_plot = PlotState::new("Altitude (ASL)", (None, None), shared_plot.clone())
.line("Altitude (Ground) [m]", BR, |vs| vs.altitude_ground_asl)
.line("Altitude (Baro) [m]", B1, |vs| vs.altitude_baro)
.line("Altitude [m]", B, |vs| vs.altitude_asl)
.line("Altitude (GPS) [m]", G, |vs| vs.altitude_gps_asl);
altitude_plot
}
12 changes: 12 additions & 0 deletions src/gui/plots/barometer_plot.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
use std::{cell::RefCell, rc::Rc};

use crate::gui::plot::{PlotState, SharedPlotState};

use super::color_constants::*;

pub fn barometer_plot(shared_plot: &Rc<RefCell<SharedPlotState>>) -> PlotState {
let barometer_plot =
PlotState::new("Pressures", (None, None), shared_plot.clone())
.line("Barometer [bar]", C, |vs| vs.pressure_baro.map(|p| p / 1000.0));
barometer_plot
}
13 changes: 13 additions & 0 deletions src/gui/plots/color_constants.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
use egui::Color32;

pub const R: Color32 = Color32::from_rgb(0xfb, 0x49, 0x34);
pub const G: Color32 = Color32::from_rgb(0xb8, 0xbb, 0x26);
pub const B: Color32 = Color32::from_rgb(0x83, 0xa5, 0x98);
pub const R1: Color32 = Color32::from_rgb(0xcc, 0x24, 0x1d);
pub const G1: Color32 = Color32::from_rgb(0x98, 0x97, 0x1a);
pub const B1: Color32 = Color32::from_rgb(0x45, 0x85, 0x88);
pub const O: Color32 = Color32::from_rgb(0xfa, 0xbd, 0x2f);
pub const O1: Color32 = Color32::from_rgb(0xd6, 0x5d, 0x0e);
pub const BR: Color32 = Color32::from_rgb(0x61, 0x48, 0x1c);
// pub const P: Color32 = Color32::from_rgb(0xb1, 0x62, 0x86);
pub const C: Color32 = Color32::from_rgb(0x68, 0x9d, 0x6a);
12 changes: 12 additions & 0 deletions src/gui/plots/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
pub mod accelerometer_plot;
pub mod altitude_plot;
pub mod barometer_plot;
pub mod color_constants;
pub mod orientation_plot;
pub mod vertical_speed_plot;

pub use accelerometer_plot::*;
pub use altitude_plot::*;
pub use barometer_plot::*;
pub use orientation_plot::*;
pub use vertical_speed_plot::*;
18 changes: 18 additions & 0 deletions src/gui/plots/orientation_plot.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
use std::{cell::RefCell, rc::Rc};

use crate::gui::plot::{PlotState, SharedPlotState};

use super::color_constants::*;

pub fn orientation_plot(shared_plot: &Rc<RefCell<SharedPlotState>>) -> PlotState {
let orientation_plot = PlotState::new("Orientation", (Some(-180.0), Some(540.0)), shared_plot.clone())
.line("Roll (Z) [°]", B, |vs| vs.euler_angles.map(|a| a.z))
.line("Pitch (X) [°]", R, |vs| vs.euler_angles.map(|a| a.x))
.line("Yaw (Y) [°]", G, |vs| vs.euler_angles.map(|a| a.y))
.line("Angle of Attack [°]", O, |vs| vs.angle_of_attack)
.line("Roll (True) (Z) [°]", B1, |vs| vs.true_euler_angles.map(|a| a.z))
.line("Pitch (True) (X) [°]", R1, |vs| vs.true_euler_angles.map(|a| a.x))
.line("Yaw (True) (Y) [°]", G1, |vs| vs.true_euler_angles.map(|a| a.y))
.line("Angle of Attack (True) [°]", O1, |vs| vs.true_angle_of_attack);
orientation_plot
}
15 changes: 15 additions & 0 deletions src/gui/plots/vertical_speed_plot.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
use std::{cell::RefCell, rc::Rc};

use crate::gui::plot::{PlotState, SharedPlotState};

use super::color_constants::*;

pub fn vertical_speed_plot(shared_plot: &Rc<RefCell<SharedPlotState>>) -> PlotState {
let vertical_speed_plot = PlotState::new("Vert. Speed & Accel.", (None, None), shared_plot.clone())
.line("Vertical Accel [m/s²]", O1, |vs| vs.vertical_accel)
.line("Vertical Accel (Filt.) [m/s²]", O, |vs| vs.vertical_accel_filtered)
.line("Vario [m/s]", B, |vs| vs.vertical_speed)
.line("True Vertical Accel [m/s²]", G, |vs| vs.true_vertical_accel)
.line("True Vario [m/s]", B1, |vs| vs.true_vertical_speed);
vertical_speed_plot
}
Loading
Loading