Compare commits
2 Commits
78461161b1
...
f7f0ff88e0
| Author | SHA1 | Date |
|---|---|---|
|
|
f7f0ff88e0 | |
|
|
58dff12fd0 |
|
|
@ -658,6 +658,7 @@ dependencies = [
|
||||||
"clap",
|
"clap",
|
||||||
"eframe",
|
"eframe",
|
||||||
"egui",
|
"egui",
|
||||||
|
"egui-file-dialog",
|
||||||
"egui_plot",
|
"egui_plot",
|
||||||
"rand",
|
"rand",
|
||||||
]
|
]
|
||||||
|
|
@ -877,6 +878,27 @@ dependencies = [
|
||||||
"crypto-common",
|
"crypto-common",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "directories"
|
||||||
|
version = "5.0.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "9a49173b84e034382284f27f1af4dcbbd231ffa358c0fe316541a7337f376a35"
|
||||||
|
dependencies = [
|
||||||
|
"dirs-sys",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "dirs-sys"
|
||||||
|
version = "0.4.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "520f05a5cbd335fae5a99ff7a6ab8627577660ee5cfd6a94a6a929b52ff0321c"
|
||||||
|
dependencies = [
|
||||||
|
"libc",
|
||||||
|
"option-ext",
|
||||||
|
"redox_users",
|
||||||
|
"windows-sys 0.48.0",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "dispatch"
|
name = "dispatch"
|
||||||
version = "0.2.0"
|
version = "0.2.0"
|
||||||
|
|
@ -972,6 +994,18 @@ dependencies = [
|
||||||
"nohash-hasher",
|
"nohash-hasher",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "egui-file-dialog"
|
||||||
|
version = "0.7.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "09999eebe148a045df9e0d38f32b4ac03ac51bbf136d96fc4ff5e05f73a19ec5"
|
||||||
|
dependencies = [
|
||||||
|
"directories",
|
||||||
|
"egui",
|
||||||
|
"serde",
|
||||||
|
"sysinfo",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "egui-wgpu"
|
name = "egui-wgpu"
|
||||||
version = "0.29.1"
|
version = "0.29.1"
|
||||||
|
|
@ -2057,6 +2091,12 @@ version = "1.20.2"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "1261fe7e33c73b354eab43b1273a57c8f967d0391e80353e51f764ac02cf6775"
|
checksum = "1261fe7e33c73b354eab43b1273a57c8f967d0391e80353e51f764ac02cf6775"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "option-ext"
|
||||||
|
version = "0.2.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "04744f49eae99ab78e0d5c0b603ab218f515ea8cfe5a456d7629ad883a3b6e7d"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "orbclient"
|
name = "orbclient"
|
||||||
version = "0.3.48"
|
version = "0.3.48"
|
||||||
|
|
@ -2324,6 +2364,17 @@ dependencies = [
|
||||||
"bitflags 2.6.0",
|
"bitflags 2.6.0",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "redox_users"
|
||||||
|
version = "0.4.6"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "ba009ff324d1fc1b900bd1fdb31564febe58a8ccc8a6fdbb93b543d33b13ca43"
|
||||||
|
dependencies = [
|
||||||
|
"getrandom",
|
||||||
|
"libredox",
|
||||||
|
"thiserror",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "renderdoc-sys"
|
name = "renderdoc-sys"
|
||||||
version = "1.1.0"
|
version = "1.1.0"
|
||||||
|
|
@ -2564,6 +2615,17 @@ dependencies = [
|
||||||
"unicode-ident",
|
"unicode-ident",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "sysinfo"
|
||||||
|
version = "0.31.4"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "355dbe4f8799b304b05e1b0f05fc59b2a18d36645cf169607da45bde2f69a1be"
|
||||||
|
dependencies = [
|
||||||
|
"core-foundation-sys",
|
||||||
|
"libc",
|
||||||
|
"windows 0.57.0",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "tempfile"
|
name = "tempfile"
|
||||||
version = "3.13.0"
|
version = "3.13.0"
|
||||||
|
|
@ -3166,6 +3228,16 @@ dependencies = [
|
||||||
"windows-targets 0.52.6",
|
"windows-targets 0.52.6",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "windows"
|
||||||
|
version = "0.57.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "12342cb4d8e3b046f3d80effd474a7a02447231330ef77d71daa6fbc40681143"
|
||||||
|
dependencies = [
|
||||||
|
"windows-core 0.57.0",
|
||||||
|
"windows-targets 0.52.6",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "windows"
|
name = "windows"
|
||||||
version = "0.58.0"
|
version = "0.58.0"
|
||||||
|
|
@ -3185,19 +3257,42 @@ dependencies = [
|
||||||
"windows-targets 0.52.6",
|
"windows-targets 0.52.6",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "windows-core"
|
||||||
|
version = "0.57.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "d2ed2439a290666cd67ecce2b0ffaad89c2a56b976b736e6ece670297897832d"
|
||||||
|
dependencies = [
|
||||||
|
"windows-implement 0.57.0",
|
||||||
|
"windows-interface 0.57.0",
|
||||||
|
"windows-result 0.1.2",
|
||||||
|
"windows-targets 0.52.6",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "windows-core"
|
name = "windows-core"
|
||||||
version = "0.58.0"
|
version = "0.58.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "6ba6d44ec8c2591c134257ce647b7ea6b20335bf6379a27dac5f1641fcf59f99"
|
checksum = "6ba6d44ec8c2591c134257ce647b7ea6b20335bf6379a27dac5f1641fcf59f99"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"windows-implement",
|
"windows-implement 0.58.0",
|
||||||
"windows-interface",
|
"windows-interface 0.58.0",
|
||||||
"windows-result",
|
"windows-result 0.2.0",
|
||||||
"windows-strings",
|
"windows-strings",
|
||||||
"windows-targets 0.52.6",
|
"windows-targets 0.52.6",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "windows-implement"
|
||||||
|
version = "0.57.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "9107ddc059d5b6fbfbffdfa7a7fe3e22a226def0b2608f72e9d552763d3e1ad7"
|
||||||
|
dependencies = [
|
||||||
|
"proc-macro2",
|
||||||
|
"quote",
|
||||||
|
"syn 2.0.87",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "windows-implement"
|
name = "windows-implement"
|
||||||
version = "0.58.0"
|
version = "0.58.0"
|
||||||
|
|
@ -3209,6 +3304,17 @@ dependencies = [
|
||||||
"syn 2.0.87",
|
"syn 2.0.87",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "windows-interface"
|
||||||
|
version = "0.57.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "29bee4b38ea3cde66011baa44dba677c432a78593e202392d1e9070cf2a7fca7"
|
||||||
|
dependencies = [
|
||||||
|
"proc-macro2",
|
||||||
|
"quote",
|
||||||
|
"syn 2.0.87",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "windows-interface"
|
name = "windows-interface"
|
||||||
version = "0.58.0"
|
version = "0.58.0"
|
||||||
|
|
@ -3220,6 +3326,15 @@ dependencies = [
|
||||||
"syn 2.0.87",
|
"syn 2.0.87",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "windows-result"
|
||||||
|
version = "0.1.2"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "5e383302e8ec8515204254685643de10811af0ed97ea37210dc26fb0032647f8"
|
||||||
|
dependencies = [
|
||||||
|
"windows-targets 0.52.6",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "windows-result"
|
name = "windows-result"
|
||||||
version = "0.2.0"
|
version = "0.2.0"
|
||||||
|
|
@ -3235,7 +3350,7 @@ version = "0.1.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "4cd9b125c486025df0eabcb585e62173c6c9eddcec5d117d3b6e8c30e2ee4d10"
|
checksum = "4cd9b125c486025df0eabcb585e62173c6c9eddcec5d117d3b6e8c30e2ee4d10"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"windows-result",
|
"windows-result 0.2.0",
|
||||||
"windows-targets 0.52.6",
|
"windows-targets 0.52.6",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
@ -3248,6 +3363,15 @@ dependencies = [
|
||||||
"windows-targets 0.42.2",
|
"windows-targets 0.42.2",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "windows-sys"
|
||||||
|
version = "0.48.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "677d2418bec65e3338edb076e806bc1ec15693c5d0104683f2efe857f61056a9"
|
||||||
|
dependencies = [
|
||||||
|
"windows-targets 0.48.5",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "windows-sys"
|
name = "windows-sys"
|
||||||
version = "0.52.0"
|
version = "0.52.0"
|
||||||
|
|
|
||||||
|
|
@ -8,5 +8,6 @@ anyhow = "1.0.92"
|
||||||
clap = { version = "4.5.20", features = ["derive"] }
|
clap = { version = "4.5.20", features = ["derive"] }
|
||||||
eframe = "0.29.1"
|
eframe = "0.29.1"
|
||||||
egui = "0.29.1"
|
egui = "0.29.1"
|
||||||
|
egui-file-dialog = "0.7.0"
|
||||||
egui_plot = "0.29.0"
|
egui_plot = "0.29.0"
|
||||||
rand = "0.8.5"
|
rand = "0.8.5"
|
||||||
|
|
|
||||||
|
|
@ -32,9 +32,20 @@ impl PlotDisplay {
|
||||||
|
|
||||||
impl eframe::App for PlotDisplay {
|
impl eframe::App for PlotDisplay {
|
||||||
fn update(&mut self, ctx: &egui::Context, _frame: &mut eframe::Frame) {
|
fn update(&mut self, ctx: &egui::Context, _frame: &mut eframe::Frame) {
|
||||||
egui::CentralPanel::default().show(ctx, |ui| {
|
egui::CentralPanel::default().show(ctx, |ui| {
|
||||||
|
ui.with_layout(egui::Layout::bottom_up(egui::Align::Center), |ui| {
|
||||||
|
save_button(ui);
|
||||||
crate::plot(ui, &mut self.circles, &self.circle_length, &self.line_colors);
|
crate::plot(ui, &mut self.circles, &self.circle_length, &self.line_colors);
|
||||||
});
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn save_button(ui: &mut egui::Ui) {
|
||||||
|
if ui.button("Save").clicked() {
|
||||||
|
//TODO: Open file dialog
|
||||||
|
// Get destination path
|
||||||
|
// save screenshot of plot to path
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
14
src/gui.rs
14
src/gui.rs
|
|
@ -1,8 +1,15 @@
|
||||||
pub fn gui() -> Result<(), eframe::Error> {
|
pub struct Error(eframe::Error);
|
||||||
|
|
||||||
|
pub fn gui() -> anyhow::Result<()> {
|
||||||
let options = eframe::NativeOptions::default();
|
let options = eframe::NativeOptions::default();
|
||||||
eframe::run_native("Encoded Message", options, Box::new(|_cc| Ok(Box::<Gui>::new(
|
eframe::run_native(
|
||||||
|
"Encoded Message",
|
||||||
|
options,
|
||||||
|
Box::new(|_cc| Ok(Box::<Gui>::new(
|
||||||
Default::default()
|
Default::default()
|
||||||
))))
|
)))
|
||||||
|
).map_err(crate::Error::from)?;
|
||||||
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
struct Gui {
|
struct Gui {
|
||||||
|
|
@ -31,7 +38,6 @@ impl eframe::App for Gui {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct Error(eframe::Error);
|
|
||||||
|
|
||||||
impl From<eframe::Error> for Error {
|
impl From<eframe::Error> for Error {
|
||||||
fn from(err: eframe::Error) -> Self {
|
fn from(err: eframe::Error) -> Self {
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,9 @@
|
||||||
use egui_plot::{Plot, PlotPoints};
|
|
||||||
use std::f64::{self, consts::PI};
|
use std::f64::{self, consts::PI};
|
||||||
|
|
||||||
pub fn plot(ui: &mut egui::Ui, circles: &mut Vec<crate::Circle>, num_points: &usize, line_colors: &Vec<egui::Color32>) {
|
pub fn plot(ui: &mut egui::Ui, circles: &mut Vec<crate::Circle>, num_points: &usize, line_colors: &Vec<egui::Color32>) {
|
||||||
Plot::new("Encoded Message")
|
egui_plot::Plot::new("Encoded Message")
|
||||||
.min_size(ui.available_size())
|
.height(ui.available_height())
|
||||||
|
.width(ui.available_width())
|
||||||
.show_axes(false)
|
.show_axes(false)
|
||||||
.show_grid(false)
|
.show_grid(false)
|
||||||
.show_x(false)
|
.show_x(false)
|
||||||
|
|
@ -23,10 +23,10 @@ pub fn plot(ui: &mut egui::Ui, circles: &mut Vec<crate::Circle>, num_points: &us
|
||||||
gaussian_distribution(num_points, &points, &(count as f64))
|
gaussian_distribution(num_points, &points, &(count as f64))
|
||||||
).color(line_colors[count]));
|
).color(line_colors[count]));
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
fn gaussian_distribution(num_points: &usize, peak_values: &Vec<f64>, offset: &f64) -> PlotPoints {
|
fn gaussian_distribution(num_points: &usize, peak_values: &Vec<f64>, offset: &f64) -> egui_plot::PlotPoints {
|
||||||
let mut radii: Vec<f64> = vec![1.0; *num_points];
|
let mut radii: Vec<f64> = vec![1.0; *num_points];
|
||||||
let num_peaks = peak_values.len();
|
let num_peaks = peak_values.len();
|
||||||
let peak_angles = generate_peak_angles(&num_peaks);
|
let peak_angles = generate_peak_angles(&num_peaks);
|
||||||
|
|
@ -53,7 +53,7 @@ fn normalize(radii: &mut Vec<f64>, offset: &f64) -> Vec<f64> {
|
||||||
}).collect()
|
}).collect()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn cartesian_to_polar(radii: &Vec<f64>, theta: &Vec<f64>) -> PlotPoints {
|
fn cartesian_to_polar(radii: &Vec<f64>, theta: &Vec<f64>) -> egui_plot::PlotPoints {
|
||||||
theta.iter()
|
theta.iter()
|
||||||
.zip(radii.iter())
|
.zip(radii.iter())
|
||||||
.map(|(&theta, &radius)| {
|
.map(|(&theta, &radius)| {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue