Skip to content

Commit

Permalink
add missing file, cat->category
Browse files Browse the repository at this point in the history
  • Loading branch information
bertiqwerty committed Jan 28, 2025
1 parent af0a9ba commit 89da7d8
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 5 deletions.
9 changes: 4 additions & 5 deletions rvimage/src/rvlib/menu/annotations_menu.rs
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ impl ToolChoice {
};
Ok(())
}
fn run_name<'a>(
fn run<'a>(
tool_name: &'static str,
tdm: &'a ToolsDataMap,
mut f_bbox: impl FnMut(&'a ToolsDataMap) -> RvResult<()>,
Expand Down Expand Up @@ -695,7 +695,7 @@ fn collect_stats(
}
Ok(())
};
trace_ok_err(ToolChoice::run_name(tool_name, tdm, f_bbox, f_brush));
trace_ok_err(ToolChoice::run(tool_name, tdm, f_bbox, f_brush));
}
let li_bbox = get_labelinfo_from_tdm!(BBOX_NAME, tdm, bbox);
let li_brush = get_labelinfo_from_tdm!(BRUSH_NAME, tdm, brush);
Expand Down Expand Up @@ -750,12 +750,11 @@ fn anno_stats(
.num_columns(4)
.show(ui, |ui| {
ui.label(RichText::new("tool").strong());
ui.label(RichText::new("cat").strong())
.on_hover_text("category, not the pet");
ui.label(RichText::new("category").strong());
ui.label(RichText::new("count").strong());
ui.label(RichText::new("mean count").strong());
ui.label(RichText::new("# files").strong()).on_hover_text(
"number of filtered files that contain or contained any annotations of the respective tool",
"number of files in the filtered filelist that contain or contained any annotations of the respective tool",
);
for record in stats_compute_results.iter() {
ui.end_row();
Expand Down
41 changes: 41 additions & 0 deletions rvimage/src/rvlib/test_helpers.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
use std::{
fs,
path::{Path, PathBuf},
thread,
time::Duration,
};

use crate::{
control::Control, defer_file_removal, tracing_setup::init_tracing_for_tests, ToolsDataMap,
};

pub fn get_ctrl() -> Control {
let mut ctrl = Control::default();
ctrl.cfg.usr.home_folder = Some(ctrl.cfg.tmpdir().to_string());
ctrl
}

pub fn tmp_copy(src: &Path) -> PathBuf {
let tmp_file_stem = src.file_stem().unwrap().to_str().unwrap();
let tmp_file = get_test_folder().join(format!("tmp-{tmp_file_stem}"));
tracing::debug!("Copying {src:?} to {tmp_file:?}");
fs::copy(src, &tmp_file).unwrap();
tmp_file
}

pub fn get_test_folder() -> PathBuf {
PathBuf::from(env!("CARGO_MANIFEST_DIR")).join("resources/test_data")
}
pub fn prj_load(file: &str) -> ToolsDataMap {
init_tracing_for_tests();
let mut ctrl = get_ctrl();
let test_file_src = get_test_folder().join(get_test_folder().join(file));
let test_file = tmp_copy(&test_file_src);
defer_file_removal!(&test_file);
let mut tdm = ctrl.load(test_file.clone()).unwrap();
let pre_tdm = tdm.clone();
ctrl.import_annos(&test_file, &mut tdm).unwrap();
thread::sleep(Duration::from_millis(5));
assert_eq!(tdm, pre_tdm);
tdm
}

0 comments on commit 89da7d8

Please # to comment.