refactor: Well struct in web
This commit is contained in:
parent
7e321a78c4
commit
63790c2145
|
@ -38,3 +38,9 @@ impl Into<Well> for (u8, u8) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl Into<(u8,u8)> for Well {
|
||||||
|
fn into(self) -> (u8,u8) {
|
||||||
|
(self.col, self.row)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
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,
|
||||||
|
@ -238,7 +239,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<((u8, u8), (u8, u8))> = records
|
let records: Vec<(Well, Well)> = 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)
|
||||||
|
|
|
@ -7,6 +7,7 @@ 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
|
||||||
|
@ -32,8 +33,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((x, y)) => ((x, y), (x, y)),
|
Region::Point(Well {col: x, row: y}) => ((x, y), (x, y)),
|
||||||
Region::Rect(c1, c2) => (c1, c2),
|
Region::Rect(c1, c2) => (c1.into(), c2.into()),
|
||||||
Region::Custom(_) => ((0, 0), (0, 0)),
|
Region::Custom(_) => ((0, 0), (0, 0)),
|
||||||
};
|
};
|
||||||
m_start_handle.set(Some(pt1));
|
m_start_handle.set(Some(pt1));
|
||||||
|
@ -57,15 +58,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) {
|
if let Some(val) = tooltip_map_temp.get_mut(&well.into()) {
|
||||||
val.push(transfer);
|
val.push(transfer);
|
||||||
} else {
|
} else {
|
||||||
tooltip_map_temp.insert(well, vec![transfer]);
|
tooltip_map_temp.insert(well.into(), vec![transfer]);
|
||||||
}
|
}
|
||||||
if let Some(val) = volume_map_temp.get_mut(&well) {
|
if let Some(val) = volume_map_temp.get_mut(&well.into()) {
|
||||||
*val += transfer.volume;
|
*val += transfer.volume;
|
||||||
} else {
|
} else {
|
||||||
volume_map_temp.insert(well, transfer.volume);
|
volume_map_temp.insert(well.into(), transfer.volume);
|
||||||
}
|
}
|
||||||
volume_max_temp = f32::max(volume_max_temp, transfer.volume);
|
volume_max_temp = f32::max(volume_max_temp, transfer.volume);
|
||||||
}
|
}
|
||||||
|
@ -162,7 +163,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(&(i,j)) && main_state.preferences.in_transfer_hashes}
|
in_transfer={wells.contains(&Well {col: i, row: 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}
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
#![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::*;
|
||||||
|
@ -233,10 +234,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((col, row)) => {
|
Region::Point(Well { 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.0, c1.1, c2.0, c2.1))
|
Region::Rect(c1, c2) => RegionDisplay::try_from((c1.col, c1.row, c2.col, c2.row))
|
||||||
.ok()
|
.ok()
|
||||||
.unwrap(),
|
.unwrap(),
|
||||||
Region::Custom(_) => RegionDisplay {
|
Region::Custom(_) => RegionDisplay {
|
||||||
|
@ -252,11 +253,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))
|
Region::Point((value.col_start, value.row_start).into())
|
||||||
} else {
|
} else {
|
||||||
Region::Rect(
|
Region::Rect(
|
||||||
(value.col_start, value.row_start),
|
(value.col_start, value.row_start).into(),
|
||||||
(value.col_end, value.row_end),
|
(value.col_end, value.row_end).into(),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -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), (2, 2)),
|
source_region: transfer_region::Region::Rect((1, 1).into(), (2, 2).into()),
|
||||||
dest_plate: destination,
|
dest_plate: destination,
|
||||||
dest_region: transfer_region::Region::Rect((2, 2), (11, 11)),
|
dest_region: transfer_region::Region::Rect((2, 2).into(), (11, 11).into()),
|
||||||
interleave_source: (1, 1),
|
interleave_source: (1, 1),
|
||||||
interleave_dest: (3, 3),
|
interleave_dest: (3, 3),
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue