add plot function
This commit is contained in:
parent
12e1d4d4c2
commit
13d6f003d4
|
@ -686,6 +686,7 @@ version = "0.1.0"
|
|||
dependencies = [
|
||||
"eframe",
|
||||
"egui_extras",
|
||||
"egui_plot",
|
||||
"libloading 0.8.5",
|
||||
"nac3core",
|
||||
"parking_lot",
|
||||
|
@ -1135,6 +1136,17 @@ dependencies = [
|
|||
"winit",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "egui_plot"
|
||||
version = "0.28.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c7acc4fe778c41b91d57e04c1a2cf5765b3dc977f9f8384d2bb2eb4254855365"
|
||||
dependencies = [
|
||||
"ahash",
|
||||
"egui",
|
||||
"emath",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "either"
|
||||
version = "1.13.0"
|
||||
|
|
|
@ -6,6 +6,7 @@ edition = "2021"
|
|||
[dependencies]
|
||||
eframe = "0.28"
|
||||
egui_extras = { version = "0.28", features = ["syntect"]}
|
||||
egui_plot = "0.28"
|
||||
parking_lot = "0.12"
|
||||
tempfile = "3.12"
|
||||
libloading = "0.8"
|
||||
|
|
14
src/main.rs
14
src/main.rs
|
@ -499,6 +499,20 @@ pub extern "C" fn __nac3_cells_slider(prev: f64) -> f64 {
|
|||
value
|
||||
}
|
||||
|
||||
pub struct List {
|
||||
data: *mut f64,
|
||||
length: usize,
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn __nac3_cells_plot(data: *const List) {
|
||||
let ui = unsafe { CELL_UI.as_mut().unwrap() };
|
||||
let data_slice = unsafe { std::slice::from_raw_parts((*data).data, (*data).length) };
|
||||
let points: Vec<[f64; 2]> = (0..data_slice.len()).map(|i| [i as f64, data_slice[i]]).collect();
|
||||
let line = egui_plot::Line::new(points);
|
||||
egui_plot::Plot::new("my_plot").view_aspect(2.0).show(ui, |plot_ui| plot_ui.line(line));
|
||||
}
|
||||
|
||||
impl Cells {
|
||||
fn new() -> Self {
|
||||
Self {
|
||||
|
|
Loading…
Reference in New Issue