Volume heatmap, checkboxes

This commit is contained in:
Emilia Allison 2025-01-12 19:48:08 -05:00
parent 418bf4a79e
commit 4a9bec7d5d
Signed by: emilia
GPG Key ID: 05D5D1107E5100A1
2 changed files with 55 additions and 15 deletions

View File

@ -103,15 +103,27 @@ impl eframe::App for PlateToolEframe {
});
ui.menu_button("Options", |ui| {
ui.menu_button("Styles", |ui| {
if ui.button("Toggle transfer hashes").clicked() {
self.main_window_state.plate_display_options.show_transfer_hashes ^= true;
}
if ui.button("Toggle volume heatmap").clicked() {
self.main_window_state.plate_display_options.show_volume_heatmap ^= true;
}
if ui.button("Toggle current coordinates view").clicked() {
self.main_window_state.plate_display_options.show_coordinates ^= true;
}
ui.checkbox(
&mut self
.main_window_state
.plate_display_options
.show_transfer_hashes,
"Toggle transfer hashes",
);
ui.checkbox(
&mut self
.main_window_state
.plate_display_options
.show_volume_heatmap,
"Toggle volume heatmap",
);
ui.checkbox(
&mut self
.main_window_state
.plate_display_options
.show_coordinates,
"Toggle coordinate highlighting",
);
});
ui.menu_button("Exports", |ui| {
if ui.button("Change CSV export type").clicked() {}

View File

@ -153,11 +153,22 @@ fn calculate_shading_for_wells(
plate_type: plate_tool_lib::plate::PlateType,
ordered_ids: &[Uuid],
cache: &plate_tool_lib::transfer_region_cache::TransferRegionCache,
display_options: PlateDisplayOptions,
) -> Box<[Option<WellInfo>]> {
let box_size: usize = rows as usize * columns as usize;
let mut well_infos: Box<[Option<WellInfo>]> = vec![None; box_size].into_boxed_slice();
if let Some(transfers) = transfers {
// Needed for palette
let max_volume: f32 = transfers
.iter()
.flat_map(|v| match v.volume {
plate_tool_lib::transfer_volume::TransferVolume::Single(x) => Some(x),
_ => None,
})
.fold(f32::MIN, f32::max)
.max(1.0f32); // Otherwise f32::MIN is return value
for transfer in transfers {
let cache_result = match plate_type {
plate_tool_lib::plate::PlateType::Source => cache.get_or_calculate_source(transfer),
@ -165,20 +176,36 @@ fn calculate_shading_for_wells(
cache.get_or_calculate_destination(transfer)
}
};
let volume = if let plate_tool_lib::transfer_volume::TransferVolume::Single(x) =
transfer.volume
{
x
} else {
0.0
};
if let Some(wells) = cache_result {
for well in wells.iter().filter(|x| x.row <= rows && x.col <= columns) {
if let Some(Some(mut x)) = well_infos.get_mut(
(well.row - 1) as usize * columns as usize + (well.col - 1) as usize,
) {
x.volume += 5.0;
x.color = PALETTE.get_ordered(transfer.id, ordered_ids);
x.volume += volume;
x.color = if display_options.show_volume_heatmap {
PALETTE.get_linear(volume.into(), max_volume.into())
} else {
PALETTE.get_ordered(transfer.id, ordered_ids)
};
} else {
if let Some(mut wi) = well_infos.get_mut(
(well.row - 1) as usize * columns as usize + (well.col - 1) as usize,
) {
*wi = Some(WellInfo::new(
5.0,
PALETTE.get_ordered(transfer.id, ordered_ids),
volume,
if display_options.show_volume_heatmap {
PALETTE.get_linear(volume.into(), max_volume.into())
} else {
PALETTE.get_ordered(transfer.id, ordered_ids)
},
));
}
}
@ -299,7 +326,7 @@ fn add_plate_sub(
let well_infos = {
// Get non-active transfer info
let mut well_infos =
calculate_shading_for_wells(rows, columns, transfers, plate_type, ordered_ids, cache);
calculate_shading_for_wells(rows, columns, transfers, plate_type, ordered_ids, cache, display_options);
// Get wells in the current transfer to tack on to well_infos separately
let current_transfer_wells: Option<Box<[(usize, usize)]>> = {
@ -440,7 +467,8 @@ fn add_plate_sub(
}
for c_column in 0..columns {
let text_color = {
if display_options.show_coordinates && hovered_well.is_some_and(|x| x.1 == c_column + 1) {
if display_options.show_coordinates && hovered_well.is_some_and(|x| x.1 == c_column + 1)
{
*HIGHLIGHT_TEXT_COLOR
} else {
*DEFAULT_TEXT_COLOR