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

Move logger to within window #334

Merged
merged 5 commits into from
Oct 13, 2024
Merged
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
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
Loading