Revert "refactor: Well struct in web"

This reverts commit 63790c2145.
This commit is contained in:
Emilia Allison 2024-08-10 01:40:14 -04:00
parent 7031ae33dc
commit deac725fdb
Signed by: emilia
GPG Key ID: 7A3F8997BFE894E0
5 changed files with 15 additions and 24 deletions

View File

@ -38,9 +38,3 @@ impl Into<Well> for (u8, u8) {
} }
} }
} }
impl Into<(u8,u8)> for Well {
fn into(self) -> (u8,u8) {
(self.col, self.row)
}
}

View File

@ -1,6 +1,5 @@
use std::collections::HashSet; use std::collections::HashSet;
use plate_tool_lib::well::Well;
use wasm_bindgen::{prelude::*, JsCast}; use wasm_bindgen::{prelude::*, JsCast};
use web_sys::{ use web_sys::{
FileReader, HtmlButtonElement, HtmlDialogElement, HtmlElement, HtmlFormElement, FileReader, HtmlButtonElement, HtmlDialogElement, HtmlElement, HtmlFormElement,
@ -239,7 +238,7 @@ pub fn import_transfer_csv_submit_callback(
let from_dest = from_dest.value(); let from_dest = from_dest.value();
let to_dest = to_dest.value(); let to_dest = to_dest.value();
let records: Vec<(Well, Well)> = records let records: Vec<((u8, u8), (u8, u8))> = records
.iter() .iter()
.filter(|record| record.source_plate == from_source) .filter(|record| record.source_plate == from_source)
.filter(|record| record.destination_plate == from_dest) .filter(|record| record.destination_plate == from_dest)

View File

@ -7,7 +7,6 @@ use yewdux::prelude::*;
use crate::components::states::{CurrentTransfer, MainState}; use crate::components::states::{CurrentTransfer, MainState};
use plate_tool_lib::plate::PlateType; use plate_tool_lib::plate::PlateType;
use plate_tool_lib::transfer::Transfer; use plate_tool_lib::transfer::Transfer;
use plate_tool_lib::well::Well;
use plate_tool_lib::transfer_region::Region; use plate_tool_lib::transfer_region::Region;
// Color Palette for the Source Plates, can be changed here // Color Palette for the Source Plates, can be changed here
@ -33,8 +32,8 @@ pub fn Plate(props: &PlateProps) -> Html {
PlateType::Destination => ct_state.transfer.transfer_region.dest_region.clone(), PlateType::Destination => ct_state.transfer.transfer_region.dest_region.clone(),
}; };
let (pt1, pt2) = match region { let (pt1, pt2) = match region {
Region::Point(Well {col: x, row: y}) => ((x, y), (x, y)), Region::Point((x, y)) => ((x, y), (x, y)),
Region::Rect(c1, c2) => (c1.into(), c2.into()), Region::Rect(c1, c2) => (c1, c2),
Region::Custom(_) => ((0, 0), (0, 0)), Region::Custom(_) => ((0, 0), (0, 0)),
}; };
m_start_handle.set(Some(pt1)); m_start_handle.set(Some(pt1));
@ -58,15 +57,15 @@ pub fn Plate(props: &PlateProps) -> Html {
PlateType::Destination => transfer.transfer_region.get_destination_wells(), PlateType::Destination => transfer.transfer_region.get_destination_wells(),
}; };
for well in wells { for well in wells {
if let Some(val) = tooltip_map_temp.get_mut(&well.into()) { if let Some(val) = tooltip_map_temp.get_mut(&well) {
val.push(transfer); val.push(transfer);
} else { } else {
tooltip_map_temp.insert(well.into(), vec![transfer]); tooltip_map_temp.insert(well, vec![transfer]);
} }
if let Some(val) = volume_map_temp.get_mut(&well.into()) { if let Some(val) = volume_map_temp.get_mut(&well) {
*val += transfer.volume; *val += transfer.volume;
} else { } else {
volume_map_temp.insert(well.into(), transfer.volume); volume_map_temp.insert(well, transfer.volume);
} }
volume_max_temp = f32::max(volume_max_temp, transfer.volume); volume_max_temp = f32::max(volume_max_temp, transfer.volume);
} }
@ -163,7 +162,7 @@ pub fn Plate(props: &PlateProps) -> Html {
<PlateCell i={i} j={j} <PlateCell i={i} j={j}
selected={in_rect(*m_start_handle.clone(), *m_end_handle.clone(), (i,j))} selected={in_rect(*m_start_handle.clone(), *m_end_handle.clone(), (i,j))}
mouse={mouse_callback.clone()} mouse={mouse_callback.clone()}
in_transfer={wells.contains(&Well {col: i, row: j}) && main_state.preferences.in_transfer_hashes} in_transfer={wells.contains(&(i,j)) && main_state.preferences.in_transfer_hashes}
color={ color } color={ color }
cell_height={props.cell_height} cell_height={props.cell_height}
title={title} title={title}

View File

@ -1,7 +1,6 @@
#![allow(non_snake_case)] #![allow(non_snake_case)]
use lazy_static::lazy_static; use lazy_static::lazy_static;
use plate_tool_lib::well::Well;
use regex::Regex; use regex::Regex;
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use yew::prelude::*; use yew::prelude::*;
@ -234,10 +233,10 @@ impl TryFrom<&str> for RegionDisplay {
impl From<&Region> for RegionDisplay { impl From<&Region> for RegionDisplay {
fn from(value: &Region) -> Self { fn from(value: &Region) -> Self {
match *value { match *value {
Region::Point(Well { col, row }) => { Region::Point((col, row)) => {
RegionDisplay::try_from((col, row, col, row)).ok().unwrap() RegionDisplay::try_from((col, row, col, row)).ok().unwrap()
} }
Region::Rect(c1, c2) => RegionDisplay::try_from((c1.col, c1.row, c2.col, c2.row)) Region::Rect(c1, c2) => RegionDisplay::try_from((c1.0, c1.1, c2.0, c2.1))
.ok() .ok()
.unwrap(), .unwrap(),
Region::Custom(_) => RegionDisplay { Region::Custom(_) => RegionDisplay {
@ -253,11 +252,11 @@ impl From<&Region> for RegionDisplay {
impl From<&RegionDisplay> for Region { impl From<&RegionDisplay> for Region {
fn from(value: &RegionDisplay) -> Self { fn from(value: &RegionDisplay) -> Self {
if value.col_start == value.col_end && value.row_start == value.row_end { if value.col_start == value.col_end && value.row_start == value.row_end {
Region::Point((value.col_start, value.row_start).into()) Region::Point((value.col_start, value.row_start))
} else { } else {
Region::Rect( Region::Rect(
(value.col_start, value.row_start).into(), (value.col_start, value.row_start),
(value.col_end, value.row_end).into(), (value.col_end, value.row_end),
) )
} }
} }

View File

@ -25,9 +25,9 @@ pub fn plate_test() {
let transfer = transfer_region::TransferRegion { let transfer = transfer_region::TransferRegion {
source_plate: source, source_plate: source,
source_region: transfer_region::Region::Rect((1, 1).into(), (2, 2).into()), source_region: transfer_region::Region::Rect((1, 1), (2, 2)),
dest_plate: destination, dest_plate: destination,
dest_region: transfer_region::Region::Rect((2, 2).into(), (11, 11).into()), dest_region: transfer_region::Region::Rect((2, 2), (11, 11)),
interleave_source: (1, 1), interleave_source: (1, 1),
interleave_dest: (3, 3), interleave_dest: (3, 3),
}; };