Skip to content

Commit

Permalink
modified: src/cutter/cut_handler.rs
Browse files Browse the repository at this point in the history
	modified:   src/cutter/cuts.rs
	modified:   src/egui_plot_stuff/colors.rs
	modified:   src/egui_plot_stuff/egui_polygon.rs
	modified:   src/histoer/histogrammer.rs
	deleted:    src/histogram_scripter/configure_lazyframes.rs
	modified:   src/histogram_scripter/histogram_script.rs
	modified:   src/histogram_scripter/mod.rs
	modified:   src/util/processer.rs
  • Loading branch information
alconley committed Nov 12, 2024
1 parent 7303508 commit bad96c4
Show file tree
Hide file tree
Showing 9 changed files with 483 additions and 402 deletions.
12 changes: 2 additions & 10 deletions src/cutter/cut_handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,12 @@ impl CutHandler {
{
let file = File::open(file_path)?;
let reader = BufReader::new(file);
let mut cut: Cut = serde_json::from_reader(reader)?;
cut.selected = true;
let cut: Cut = serde_json::from_reader(reader)?;
self.cuts.push(cut);
}
Ok(())
}

pub fn cuts_are_selected(&self) -> bool {
self.cuts.iter().any(|cut| cut.selected)
}

pub fn cut_ui(&mut self, ui: &mut egui::Ui, histogrammer: &mut Histogrammer) {
ui.collapsing("Cuts", |ui| {
ui.horizontal(|ui| {
Expand Down Expand Up @@ -68,7 +63,6 @@ impl CutHandler {
cut.ui(ui);

ui.horizontal(|ui| {
ui.checkbox(&mut cut.selected, "");
if ui.button("🗙").clicked() {
index_to_remove = Some(index);
}
Expand Down Expand Up @@ -98,9 +92,7 @@ impl CutHandler {

// Iterate through all cuts and apply their respective filters.
for cut in &mut self.cuts {
if cut.selected {
filtered_lf = cut.filter_lf_with_cut(&filtered_lf)?;
}
filtered_lf = cut.filter_lf_with_cut(&filtered_lf)?;
}

Ok(filtered_lf)
Expand Down
39 changes: 32 additions & 7 deletions src/cutter/cuts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,23 +7,49 @@ use std::io::{BufReader, Write};

use crate::egui_plot_stuff::egui_polygon::EguiPolygon;

#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize, PartialEq)]
pub struct Cut {
pub polygon: EguiPolygon,
pub x_column: String,
pub y_column: String,
#[serde(skip)]
pub selected: bool,
}

impl Default for Cut {
fn default() -> Self {
Cut {
polygon: EguiPolygon::default(),
x_column: "".to_string(),
y_column: "".to_string(),
}
}
}

impl Cut {
pub fn ui(&mut self, ui: &mut egui::Ui) {
// putting this in a grid
ui.text_edit_singleline(&mut self.x_column);
// ui.text_edit_singleline(&mut self.x_column);

// ui.text_edit_singleline(&mut self.y_column);

ui.text_edit_singleline(&mut self.y_column);
// self.polygon.polygon_info_menu_button(ui);

ui.add(
egui::TextEdit::singleline(&mut self.polygon.name)
.hint_text("Name")
.clip_text(false),
);

self.polygon.polygon_info_menu_button(ui);
ui.add(
egui::TextEdit::singleline(&mut self.x_column)
.hint_text("X Column Name")
.clip_text(false),
);

ui.add(
egui::TextEdit::singleline(&mut self.y_column)
.hint_text("Y Column Name")
.clip_text(false),
);
}

pub fn menu_button(&mut self, ui: &mut egui::Ui) {
Expand Down Expand Up @@ -217,7 +243,6 @@ impl HistogramCuts {
polygon: new_cut,
x_column: "".to_string(),
y_column: "".to_string(),
selected: false,
};
self.cuts.push(new_cut);
}
Expand Down
2 changes: 1 addition & 1 deletion src/egui_plot_stuff/colors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ pub const COLOR_OPTIONS: &[(Color32, &str)] = &[
(Color32::LIGHT_BLUE, "Light Blue"),
];

#[derive(Debug, Clone, Copy, serde::Deserialize, serde::Serialize)]
#[derive(Debug, Clone, Copy, serde::Deserialize, serde::Serialize, PartialEq)]
pub struct Rgb {
pub r: u8,
pub g: u8,
Expand Down
2 changes: 1 addition & 1 deletion src/egui_plot_stuff/egui_polygon.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use geo::Contains;

use crate::egui_plot_stuff::colors::{Rgb, COLOR_OPTIONS};

#[derive(Debug, Clone, serde::Deserialize, serde::Serialize)]
#[derive(Debug, Clone, serde::Deserialize, serde::Serialize, PartialEq)]
pub struct EguiPolygon {
pub draw: bool,
pub name_in_legend: bool,
Expand Down
Loading

0 comments on commit bad96c4

Please sign in to comment.