diff --git a/plate-tool-eframe/src/plate.rs b/plate-tool-eframe/src/plate.rs index 32409a3..4a9e5e8 100644 --- a/plate-tool-eframe/src/plate.rs +++ b/plate-tool-eframe/src/plate.rs @@ -178,42 +178,46 @@ fn calculate_shading_for_wells( }; 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], + plate_tool_lib::plate::PlateType::Destination => { + wm.destination_only[well] + } } - }, + } _ => 0.0, }; - if let Some(Some(mut x)) = well_infos.get_mut( + if let Some(well_info_slot) = well_infos.get_mut( (well.row - 1) as usize * columns as usize + (well.col - 1) as usize, ) { - // Well info already existed. - x.volume += volume; + if let Some(ref mut x) = well_info_slot { + // Well info already existed. + x.volume += volume; - x.color = if display_options.show_volume_heatmap { - PALETTE.get_linear(volume.into(), max_volume.into()) + x.color = if display_options.show_volume_heatmap { + PALETTE.get_linear(x.volume.into(), max_volume.into()) + } else { + PALETTE.get_ordered(transfer.id, ordered_ids) + }; } else { - 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, - ) { - *wi = Some(WellInfo::new( - volume, - if display_options.show_volume_heatmap { - PALETTE.get_linear(volume.into(), max_volume.into()) - } else { - PALETTE.get_ordered(transfer.id, ordered_ids) - }, - )); + // 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, + ) { + *wi = Some(WellInfo::new( + volume, + if display_options.show_volume_heatmap { + PALETTE.get_linear(volume.into(), max_volume.into()) + } else { + PALETTE.get_ordered(transfer.id, ordered_ids) + }, + )); + } } } } @@ -363,17 +367,13 @@ fn add_plate_sub( if let Some(mut well_info) = well_infos.get_mut((w.0 - 1) * columns as usize + (w.1 - 1)) { - let volume = well_info.map(|x| x.volume).unwrap_or(0.0) - + current_transfer_state - .and_then(|x| x.lock().ok()) - .map(|x| x.volume) - .unwrap_or(0.0); + let volume = well_info.map(|x| x.volume).unwrap_or(0.0); let color = well_info.map(|x| x.color).unwrap_or([255.0, 255.0, 255.0]); let fill = well_info.map(|x| x.color).is_some(); *well_info = Some(WellInfo { color, - volume: 1.0, + volume: volume, fill, highlight: true, }) diff --git a/plate-tool-eframe/src/transfer_menu.rs b/plate-tool-eframe/src/transfer_menu.rs index 74191bf..36cf79b 100644 --- a/plate-tool-eframe/src/transfer_menu.rs +++ b/plate-tool-eframe/src/transfer_menu.rs @@ -116,9 +116,7 @@ impl CurrentTransferStateInterior { if let Some(transfer) = transfer { let volume: f32 = match transfer.volume { plate_tool_lib::transfer_volume::TransferVolume::Single(x) => x, - plate_tool_lib::transfer_volume::TransferVolume::WellMap(_) => { - f32::NAN - } + plate_tool_lib::transfer_volume::TransferVolume::WellMap(_) => f32::NAN, _ => unreachable!(), }; return Some(Self { @@ -321,6 +319,13 @@ pub fn transfer_menu( { transfer.transfer_region = state.generate_transfer_region(); transfer.name = state.transfer_name.clone(); + if matches!( + transfer.volume, + plate_tool_lib::transfer_volume::TransferVolume::Single(_) + ) { + transfer.volume = + plate_tool_lib::transfer_volume::TransferVolume::Single(state.volume); + } main_state.transfer_region_cache.invalidate(&transfer); } } else {