Skip to content

Commit

Permalink
Merge pull request #334 from nyx-space/gh-327-gui-update
Browse files Browse the repository at this point in the history
Move logger to within window
  • Loading branch information
ChristopherRabotin authored Oct 13, 2024
2 parents d33f6e2 + 232b0b1 commit 8345fe5
Show file tree
Hide file tree
Showing 7 changed files with 322 additions and 332 deletions.
25 changes: 18 additions & 7 deletions anise-gui/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,33 @@ homepage = { workspace = true }
license = { workspace = true }
repository = { workspace = true }
description = "A graphical user interface for ANISE"
build = "build.rs"

[dependencies]
anise = { workspace = true }
hifitime = { workspace = true }
log = { workspace = true }
bytes = { workspace = true }
pretty_env_logger = { workspace = true }
egui-toast = "0.14"
eframe = { version = "0.28" }
egui = { version = "0.28" }
egui_extras = { version = "0.28", features = ["datepicker", "http", "image"] }
catppuccin-egui = { version = "5.1", default-features = false, features = [
"egui28",
] }
eframe = { version = "0.29" }
egui = { version = "0.29" }
egui_extras = { version = "0.29", features = ["datepicker", "http", "image"] }
rfd = { version = "0.15.0" }
egui_logger = "0.6.1"

[target.'cfg(target_arch = "wasm32")'.dependencies]
wasm-bindgen-futures = "0.4"
poll-promise = { version = "0.3.0", features = ["web"] }


[target.'cfg(windows)'.build-dependencies]
tauri-winres = "0.1"

[package.metadata.tauri-winres]
FileDescription = "Inspect SPICE SPK and PCK binary files"
FileVersion = "0.4"
InternalName = "ANISE-GUI.EXE"
OriginalFilename = "ANISE-GUI.EXE"
ProductName = "ANISE"
ProductVersion = "0.4"
LegalCopyright = "Copyright (C) 2021-onward Christopher Rabotin"
9 changes: 9 additions & 0 deletions anise-gui/build.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#[cfg(windows)]
fn main() {
let mut res = tauri_winres::WindowsResource::new();
res.set_icon("icon.ico");
res.compile().unwrap();
}

#[cfg(not(windows))]
fn main() {}
Binary file added anise-gui/icon.ico
Binary file not shown.
116 changes: 116 additions & 0 deletions anise-gui/src/bpc.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
use anise::{
constants::orientations::orientation_name_from_id,
prelude::{Almanac, NAIFSummaryRecord},
};
use egui_extras::{Column, TableBuilder};
use hifitime::{TimeScale, Unit};

pub fn bpc_ui(
ui: &mut egui::Ui,
almanac: &Almanac,
show_unix: bool,
selected_time_scale: TimeScale,
) {
// We can use the summary
TableBuilder::new(ui)
.column(Column::auto().at_least(125.0).resizable(true))
.column(Column::auto().at_least(125.0).resizable(true))
.column(Column::auto().at_least(250.0).resizable(true))
.column(Column::auto().at_least(250.0).resizable(true))
.column(Column::auto().at_least(200.0).resizable(true))
.column(Column::auto().at_least(150.0).resizable(true))
.column(Column::remainder())
.header(20.0, |mut header| {
header.col(|ui| {
ui.heading("Frame");
});
header.col(|ui| {
ui.heading("Segment name");
});
header.col(|ui| {
ui.heading("Start");
});
header.col(|ui| {
ui.heading("End");
});
header.col(|ui| {
ui.heading("Inertial frame");
});
header.col(|ui| {
ui.heading("Domain");
});
header.col(|ui| {
ui.heading("Type");
});
})
.body(|mut body| {
let pck = almanac.bpc_data[0].as_ref().unwrap();

for (sno, summary) in pck.data_summaries().unwrap().iter().enumerate() {
let name_rcrd = pck.name_record().unwrap();
let name = name_rcrd.nth_name(sno, pck.file_record().unwrap().summary_size());
if summary.is_empty() {
continue;
}

body.row(30.0, |mut row| {
row.col(|ui| {
ui.label(name);
});

row.col(|ui| {
if show_unix {
ui.text_edit_singleline(&mut format!(
"{}",
summary.start_epoch().to_unix_seconds()
));
} else {
ui.label(summary.start_epoch().to_gregorian_str(selected_time_scale));
};
});

row.col(|ui| {
if show_unix {
ui.text_edit_singleline(&mut format!(
"{}",
summary.end_epoch().to_unix_seconds()
));
} else {
ui.label(summary.end_epoch().to_gregorian_str(selected_time_scale));
};
});

row.col(|ui| match orientation_name_from_id(summary.frame_id) {
Some(name) => {
ui.label(format!("{name} ({})", summary.frame_id));
}
None => {
ui.label(format!("{}", summary.frame_id));
}
});

row.col(
|ui| match orientation_name_from_id(summary.inertial_frame_id) {
Some(name) => {
ui.label(format!("{name} ({})", summary.inertial_frame_id));
}
None => {
ui.label(format!("{}", summary.inertial_frame_id));
}
},
);

row.col(|ui| {
ui.label(format!(
"{}",
(summary.end_epoch() - summary.start_epoch()).round(Unit::Second * 1)
));
});

row.col(|ui| {
ui.label(format!("{}", summary.data_type().unwrap()));
});
});
}
});
}
16 changes: 14 additions & 2 deletions anise-gui/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
#![windows_subsystem = "windows"]
#[allow(dead_code)]
const LOG_VAR: &str = "ANISE_LOG";

mod ui;
use ui::UiApp;

mod bpc;
mod spk;

#[cfg(not(target_arch = "wasm32"))]
fn main() {
use std::env::{set_var, var};
Expand All @@ -12,11 +16,19 @@ fn main() {
set_var(LOG_VAR, "INFO");
}

let _ = pretty_env_logger::try_init_custom_env(LOG_VAR).is_err();
// Initialize the logger
egui_logger::builder()
.init()
.expect("Error initializing logger");

let opts = eframe::NativeOptions {
viewport: egui::ViewportBuilder::default().with_inner_size([1024.0, 640.0]),
..Default::default()
};

let _ = eframe::run_native(
"ANISE by Nyx Space",
eframe::NativeOptions::default(),
opts,
Box::new(|cc| Ok(Box::new(UiApp::new(cc)))),
);
}
Expand Down
107 changes: 107 additions & 0 deletions anise-gui/src/spk.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
use anise::prelude::{Almanac, NAIFSummaryRecord};
use egui_extras::{Column, TableBuilder};
use hifitime::{TimeScale, Unit};

pub fn spk_ui(
ui: &mut egui::Ui,
almanac: &Almanac,
show_unix: bool,
selected_time_scale: TimeScale,
) {
TableBuilder::new(ui)
.column(Column::auto().at_least(150.0).resizable(true))
.column(Column::auto().at_least(150.0).resizable(true))
.column(Column::auto().at_least(250.0).resizable(true))
.column(Column::auto().at_least(250.0).resizable(true))
.column(Column::auto().at_least(200.0).resizable(true))
.column(Column::auto().at_least(150.0).resizable(true))
.column(Column::remainder())
.header(20.0, |mut header| {
header.col(|ui| {
ui.heading("Target");
});
header.col(|ui| {
ui.heading("Name");
});
header.col(|ui| {
ui.heading("Start");
});
header.col(|ui| {
ui.heading("End");
});
header.col(|ui| {
ui.heading("Center");
});
header.col(|ui| {
ui.heading("Domain");
});
header.col(|ui| {
ui.heading("Type");
});
})
.body(|mut body| {
let spk = almanac.spk_data[0].as_ref().unwrap();

for (sno, summary) in spk.data_summaries().unwrap().iter().enumerate() {
let name_rcrd = spk.name_record().unwrap();
let name = name_rcrd.nth_name(sno, spk.file_record().unwrap().summary_size());
if summary.is_empty() {
continue;
}

body.row(30.0, |mut row| {
row.col(|ui| {
ui.label(format!(
"{} ({})",
summary.target_frame(),
summary.target_id
));
});
row.col(|ui| {
ui.label(name);
});

row.col(|ui| {
if show_unix {
ui.text_edit_singleline(&mut format!(
"{}",
summary.start_epoch().to_unix_seconds()
));
} else {
ui.label(summary.start_epoch().to_gregorian_str(selected_time_scale));
};
});

row.col(|ui| {
if show_unix {
ui.text_edit_singleline(&mut format!(
"{}",
summary.end_epoch().to_unix_seconds()
));
} else {
ui.label(summary.end_epoch().to_gregorian_str(selected_time_scale));
};
});

row.col(|ui| {
ui.label(format!(
"{} ({})",
summary.center_frame(),
summary.center_id
));
});

row.col(|ui| {
ui.label(format!(
"{}",
(summary.end_epoch() - summary.start_epoch()).round(Unit::Second * 1)
));
});

row.col(|ui| {
ui.label(format!("{}", summary.data_type().unwrap()));
});
});
}
});
}
Loading

0 comments on commit 8345fe5

Please sign in to comment.