Skip to content

Commit

Permalink
Finished README, removed JSON tab from exports
Browse files Browse the repository at this point in the history
  • Loading branch information
redindelible committed Apr 27, 2024
1 parent adc551f commit 7b2a06f
Show file tree
Hide file tree
Showing 2 changed files with 74 additions and 93 deletions.
20 changes: 19 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@
2. Install the MIDAS Data Viewer locally using `cargo install --git https://github.com/redindelible/MIDAS-Launch`. This builds a local copy of the resulting executable.
3. Run the Data Viewer executable by typing `midas-launch` into your command line.

### Updating

If a new version of this software is available, you can update it by re-running step 3 above.

## Usage
The workflow for using this software can be divided into 4 steps:
1. Load data from either a raw launch file or from a CSV.
Expand Down Expand Up @@ -80,4 +84,18 @@ then only rows with a value above the provided bound are retained. If 'Upper' is
with a value below the provided are retained. Both can be selected at the same time.
* Sort: Sort the rows of the table by the value of the chosen column, in either ascending or descending order.

### Plotting
### Plotting

To plot the data, simply switch to the 'Plot' tab and select columns to plot on the X and Y axes.
Points from the data set are sampled to improve performance. The 'Resolution' slider can be moved to
change the balance between fidelity and performance, with lower resolutions improving performance.

> [!NOTE]
> Applying a Sort and a Fill before plotting improves results.
### Exporting

Processed data can be re-exported in CSV form. Switch to the 'Export' tab, choose a file to export to using
the 'Choose File' button, and then press 'Export'. If the chosen file already exists, this will replace the
contents of the file. If you want to append this data to the pre-existing data in the chosen file instead,
check the 'Append' box before exporting.
147 changes: 55 additions & 92 deletions src/export.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use crate::file_picker::FilePicker;

#[derive(Copy, Clone, Eq, PartialEq)]
enum ExportFormats {
Json,
// Json,
Csv
}

Expand All @@ -34,21 +34,21 @@ struct CsvExport {

pub struct ExportTab {
export: ExportFormats,
json: JsonExport,
// json: JsonExport,
csv: CsvExport
}

impl ExportTab {
pub fn new(_cc: &eframe::CreationContext) -> ExportTab {
ExportTab {
export: ExportFormats::Csv,
json: JsonExport {
path: String::new(),
omit_null: true,

export: None,
msg: None
},
// json: JsonExport {
// path: String::new(),
// omit_null: true,
//
// export: None,
// msg: None
// },
csv: CsvExport {
path: String::new(),
append_mode: false,
Expand All @@ -64,16 +64,16 @@ impl ExportTab {
pub fn show(&mut self, ui: &mut Ui, shared: &mut Option<DataShared>) {
ui.add_space(3.0);

ui.columns(2, |cols| {
cols[0].vertical_centered_justified(|ui| {
ui.selectable_value(&mut self.export, ExportFormats::Csv, "CSV")
});
cols[1].vertical_centered_justified(|ui| {
ui.selectable_value(&mut self.export, ExportFormats::Json, "JSON")
});
});

ui.add_space(3.0);
// ui.columns(2, |cols| {
// cols[0].vertical_centered_justified(|ui| {
// ui.selectable_value(&mut self.export, ExportFormats::Csv, "CSV")
// });
// cols[1].vertical_centered_justified(|ui| {
// ui.selectable_value(&mut self.export, ExportFormats::Json, "JSON")
// });
// });
//
// ui.add_space(3.0);

if let Some(csv_export) = &self.csv.export {
if csv_export.is_finished() {
Expand All @@ -87,17 +87,17 @@ impl ExportTab {
}
}

if let Some(json_export) = &self.json.export {
if json_export.is_finished() {
let result = self.json.export.take().unwrap().handle.join().unwrap();
match result {
Ok(()) => (),
Err(e) => {
self.json.msg = Some(e.to_string());
}
}
}
}
// if let Some(json_export) = &self.json.export {
// if json_export.is_finished() {
// let result = self.json.export.take().unwrap().handle.join().unwrap();
// match result {
// Ok(()) => (),
// Err(e) => {
// self.json.msg = Some(e.to_string());
// }
// }
// }
// }

match self.export {
ExportFormats::Csv => {
Expand Down Expand Up @@ -173,68 +173,31 @@ impl ExportTab {
});
}

ExportFormats::Json => {
ui.horizontal(|ui| {
ui.label("Path");
ui.add(FilePicker::new("json-picker", &mut self.json.path)
.add_filter("JSON", &["json"])
.set_is_save(true)
.dialog_title("Save"));
});

ui.horizontal(|ui| {
if let Some(export) = &self.json.export {
ui.add_enabled(false, egui::Button::new("Export"));

ui.add(egui::ProgressBar::new(export.progress()));
} else {
// if ui.button("Export").clicked() {
// let data = shared.as_ref().unwrap().shown_data.clone().unwrap_or_else(|| shared.as_ref().unwrap().complete_data.clone());
// let path = PathBuf::from(self.json.path.clone());
//
// self.json.export = Some(ProgressTask::new(ui.ctx(), |progress| {
// let mut file = BufWriter::new(File::create(&path)?);
//
// let mut col_iterator = data.col_names();
// if let Some(name) = col_iterator.next() {
// write!(&mut file, "{}", name)?;
//
// while let Some(name) = col_iterator.next() {
// write!(&mut file, ",{}", name)?;
// }
//
// file.write(&[b'\n'])?;
// }
//
// let total_rows = data.shape().rows;
// for idx in 0..total_rows {
// let mut row_iterator = data.row_iter(idx);
// if let Some(data) = row_iterator.next() {
// write!(&mut file, "{}", data)?;
//
// while let Some(data) = row_iterator.next() {
// write!(&mut file, ",{}", data)?;
// }
// }
// file.write(&[b'\n'])?;
//
// if idx % 3000 == 0 {
// progress.set(idx as f32 / total_rows as f32);
// }
// }
//
// file.flush()?;
//
// Ok(())
// }));
// }

if let Some(msg) = &self.json.msg {
ui.colored_label(Color32::RED, msg);
}
}
});
}
// ExportFormats::Json => {
// ui.horizontal(|ui| {
// ui.label("Path");
// ui.add(FilePicker::new("json-picker", &mut self.json.path)
// .add_filter("JSON", &["json"])
// .set_is_save(true)
// .dialog_title("Save"));
// });
//
// ui.horizontal(|ui| {
// if let Some(export) = &self.json.export {
// ui.add_enabled(false, egui::Button::new("Export"));
//
// ui.add(egui::ProgressBar::new(export.progress()));
// } else {
// // if ui.button("Export").clicked() {
//
// // }
//
// if let Some(msg) = &self.json.msg {
// ui.colored_label(Color32::RED, msg);
// }
// }
// });
// }
}
}
}

0 comments on commit 7b2a06f

Please sign in to comment.