From 31066dd6f6967c1d9945f9e9a12395f01a754d02 Mon Sep 17 00:00:00 2001 From: Emilia Date: Tue, 25 Nov 2025 21:38:54 -0500 Subject: [PATCH] Show total volume as text on each well --- plate-tool-eframe/src/plate.rs | 46 +++++++++++++++++++++++++++------- 1 file changed, 37 insertions(+), 9 deletions(-) diff --git a/plate-tool-eframe/src/plate.rs b/plate-tool-eframe/src/plate.rs index 9c8937e..32409a3 100644 --- a/plate-tool-eframe/src/plate.rs +++ b/plate-tool-eframe/src/plate.rs @@ -176,18 +176,24 @@ 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) { + + let volume = match &transfer.volume { + plate_tool_lib::transfer_volume::TransferVolume::Single(x) => *x, + plate_tool_lib::transfer_volume::TransferVolume::WellMap(wm) => { + match plate_type { + plate_tool_lib::plate::PlateType::Source => wm.source_only[well], + plate_tool_lib::plate::PlateType::Destination => wm.destination_only[well], + } + }, + _ => 0.0, + }; + if let Some(Some(mut x)) = well_infos.get_mut( (well.row - 1) as usize * columns as usize + (well.col - 1) as usize, ) { + // Well info already existed. x.volume += volume; x.color = if display_options.show_volume_heatmap { @@ -196,6 +202,7 @@ fn calculate_shading_for_wells( PALETTE.get_ordered(transfer.id, ordered_ids) }; } else { + // Well info does not already exist, we need to make it. if let Some(mut wi) = well_infos.get_mut( (well.row - 1) as usize * columns as usize + (well.col - 1) as usize, ) { @@ -325,8 +332,15 @@ 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, display_options); + let mut well_infos = 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> = { @@ -406,6 +420,20 @@ fn add_plate_sub( } } + // Draw volume text + + if let Some(well_info) = + well_infos[(c_row - 1) as usize * columns as usize + (c_column - 1) as usize] + { + painter.text( + center, + egui::Align2::CENTER_CENTER, + format!("{:.1}", well_info.volume), + egui::FontId::proportional(radius * 0.6), + egui::Color32::BLACK, + ); + } + // // Draw stroke on top //