plate-tool/src/components/plates/source_plate.rs

295 lines
9.3 KiB
Rust
Raw Normal View History

2023-05-11 21:49:03 +00:00
#![allow(non_snake_case)]
2023-06-06 01:33:23 +00:00
use std::collections::HashMap;
use yew::prelude::*;
2023-05-22 17:25:16 +00:00
use yewdux::prelude::*;
2023-06-06 01:33:23 +00:00
use crate::components::states::{CurrentTransfer, MainState};
2023-05-24 20:10:33 +00:00
use crate::data::plate_instances::PlateInstance;
use crate::data::transfer::Transfer;
2023-06-07 21:17:40 +00:00
use crate::data::transfer_region::Region;
2023-05-24 20:10:33 +00:00
2023-06-06 01:33:23 +00:00
// Color Palette for the Source Plates, can be changed here
use crate::components::plates::util::Palettes;
const PALETTE: super::util::ColorPalette = Palettes::RAINBOW;
2023-06-08 15:14:50 +00:00
use super::super::transfer_menu::{num_to_letters, RegionDisplay};
2023-05-11 21:49:03 +00:00
#[derive(PartialEq, Properties)]
2023-05-11 21:49:03 +00:00
pub struct SourcePlateProps {
2023-05-24 22:39:38 +00:00
pub source_plate: PlateInstance,
pub destination_plate: PlateInstance,
pub cell_height: f64,
2023-05-11 21:49:03 +00:00
}
#[function_component]
pub fn SourcePlate(props: &SourcePlateProps) -> Html {
2023-06-06 01:33:23 +00:00
let (main_state, _) = use_store::<MainState>();
2023-05-24 22:39:38 +00:00
let (ct_state, ct_dispatch) = use_store::<CurrentTransfer>();
2023-06-01 17:04:03 +00:00
let m_start_handle: UseStateHandle<Option<(u8, u8)>> = use_state_eq(|| None);
let m_end_handle: UseStateHandle<Option<(u8, u8)>> = use_state_eq(|| None);
let m_stat_handle: UseStateHandle<bool> = use_state_eq(|| false);
2023-05-24 22:39:38 +00:00
if !(*m_stat_handle) {
2023-06-01 17:04:03 +00:00
let (pt1, pt2) = match ct_state.transfer.transfer_region.source_region {
Region::Point((x, y)) => ((x, y), (x, y)),
Region::Rect(c1, c2) => (c1, c2),
Merge from import_from_csv feature branch Of course, there were other features that got tacked on... Squashed commit of the following: commit 3ee3bd2dab3ed362bf5be9acfea8db1f16f6fc9c Author: Emilia <contact@emiliaallison.com> Date: Fri Dec 29 19:12:16 2023 -0500 Superior clipboard manipulation Won't work on non-https connections, but actually works... commit 08f647cd01566e9000d71f677df0d96411ed4cd4 Author: Emilia <contact@emiliaallison.com> Date: Fri Dec 29 18:50:01 2023 -0500 Utility for copying plates as image commit 3456be2e9a07f63bf5d62ca685fe692303875888 Author: Emilia <contact@emiliaallison.com> Date: Fri Dec 29 17:46:38 2023 -0500 Change wording in options menu Father suggests that this wording is more clear to the end user. I agree! commit 4c79cc0b4dd5402a798ce8d7ac69599c03cf49d9 Author: Emilia <contact@emiliaallison.com> Date: Fri Dec 29 18:20:00 2023 -0500 Set default plate format to 96 well commit 056688c4ec690a384f57c194314cb924253770f5 Author: Emilia <contact@emiliaallison.com> Date: Fri Dec 29 18:12:00 2023 -0500 Implement in_transfer hashes toggle in plates commit 4937d4ad283b90629a80a213595a873d1a3a2615 Author: Emilia <contact@emiliaallison.com> Date: Fri Dec 29 18:11:00 2023 -0500 Preferences menu and toggle for in_transfer hashes commit 0101846b52393d1a050c2c7672274b4589c5c993 Author: Emilia <contact@emiliaallison.com> Date: Fri Dec 29 18:10:00 2023 -0500 Add preferences struct to main state commit ec37887c2f7e834ed7456625a9ec4c4cc7fea08f Author: Emilia <contact@emiliaallison.com> Date: Fri Dec 29 18:05:00 2023 -0500 Squashed commit of the following: commit 5e1137c46050d6d1d10fb1cbf842d5efd455f926 Author: Emilia <contact@emiliaallison.com> Date: Fri Dec 29 18:03:00 2023 -0500 Fix: indexing error w.r.t. logarithm argument commit 535b14a5867b15dea0e193c94829a0b99a29605c Author: Emilia <contact@emiliaallison.com> Date: Fri Dec 29 18:02:00 2023 -0500 Space colors evenly, consistently, etc Colors should now: - Not change if new transfers are added - Be evenly spaced throughout the palette - Be persistent across refreshes commit 6e08f479551315e072ec40853290d699220c9ba8 Author: Emilia <contact@emiliaallison.com> Date: Fri Dec 29 18:01:00 2023 -0500 Add palette function for ordered ids Given an id and a list of sorted ids, yields a color commit 88e838e102602f4d89ab65d8245a820158374959 Author: Emilia <contact@emiliaallison.com> Date: Fri Dec 29 18:00:00 2023 -0500 Switch to v7 UUIDs from v4 v7 UUIDs are timestamp based and thus we can establish a useful total ordering over them; will base colors on this commit 85d4b30d4795636add23a6a2c47b2068e24dbb74 Author: Emilia <contact@emiliaallison.com> Date: Tue Oct 24 21:18:10 2023 -0400 Update README.md Updated info about import/export, including the new Import Transfer from CSV feature. commit 11a561c1d447e1376e58f970f74d0778e8ed1722 Author: Emilia <contact@emiliaallison.com> Date: Tue Oct 24 20:32:51 2023 -0400 Add text to button commit 562dc2adf60b8569da579b1bb637cea344a7a596 Author: Emilia <contact@emiliaallison.com> Date: Tue Oct 24 20:32:40 2023 -0400 Change to make colors more evenly distributed commit 6b09aad289b83576bdf67882ee3f30b7f1d23619 Author: Emilia <contact@emiliaallison.com> Date: Tue Oct 24 19:27:02 2023 -0400 Implementation 1 commit a9e5f05fd9c0ebcbbb1c3cc86af8f30c92f373c5 Author: Emilia <contact@emiliaallison.com> Date: Tue Oct 24 17:18:45 2023 -0400 Hide parts of transfer menu when Custom transfer selected commit db345bfbb585c826c6f97424c5ee61337c4ffbfd Author: Emilia <contact@emiliaallison.com> Date: Tue Oct 24 17:18:08 2023 -0400 delete weird whitespace from Cargo.toml commit edcc3528aab3b17aedaf7b3424ece82ad09d591a Author: Emilia <contact@emiliaallison.com> Date: Tue Oct 24 16:41:58 2023 -0400 First implementation of custom region type commit 9a3a10c8b43e51471f74f79dfbef66b3f69ea0f5 Author: Emilia <contact@emiliaallison.com> Date: Tue Oct 24 16:21:30 2023 -0400 Transfer region no longer copy
2023-12-30 01:39:00 +00:00
Region::Custom(_) => ((0,0), (0,0)),
};
2023-05-24 22:39:38 +00:00
m_start_handle.set(Some(pt1));
m_end_handle.set(Some(pt2));
}
2023-05-22 17:25:16 +00:00
let transfer_map = {
let ts = main_state
.transfers
.iter()
.filter(|t| t.source_id == props.source_plate.get_uuid());
2023-06-16 02:23:12 +00:00
let mut tooltip_map: HashMap<(u8, u8), Vec<&Transfer>> = HashMap::new();
for t in ts {
let sws = t.transfer_region.get_source_wells();
for sw in sws {
if let Some(val) = tooltip_map.get_mut(&sw) {
val.push(t);
} else {
tooltip_map.insert(sw, vec![t]);
}
}
}
tooltip_map
};
2023-06-01 17:04:03 +00:00
let source_wells = ct_state.transfer.transfer_region.get_source_wells();
2023-05-22 17:25:16 +00:00
Merge from import_from_csv feature branch Of course, there were other features that got tacked on... Squashed commit of the following: commit 3ee3bd2dab3ed362bf5be9acfea8db1f16f6fc9c Author: Emilia <contact@emiliaallison.com> Date: Fri Dec 29 19:12:16 2023 -0500 Superior clipboard manipulation Won't work on non-https connections, but actually works... commit 08f647cd01566e9000d71f677df0d96411ed4cd4 Author: Emilia <contact@emiliaallison.com> Date: Fri Dec 29 18:50:01 2023 -0500 Utility for copying plates as image commit 3456be2e9a07f63bf5d62ca685fe692303875888 Author: Emilia <contact@emiliaallison.com> Date: Fri Dec 29 17:46:38 2023 -0500 Change wording in options menu Father suggests that this wording is more clear to the end user. I agree! commit 4c79cc0b4dd5402a798ce8d7ac69599c03cf49d9 Author: Emilia <contact@emiliaallison.com> Date: Fri Dec 29 18:20:00 2023 -0500 Set default plate format to 96 well commit 056688c4ec690a384f57c194314cb924253770f5 Author: Emilia <contact@emiliaallison.com> Date: Fri Dec 29 18:12:00 2023 -0500 Implement in_transfer hashes toggle in plates commit 4937d4ad283b90629a80a213595a873d1a3a2615 Author: Emilia <contact@emiliaallison.com> Date: Fri Dec 29 18:11:00 2023 -0500 Preferences menu and toggle for in_transfer hashes commit 0101846b52393d1a050c2c7672274b4589c5c993 Author: Emilia <contact@emiliaallison.com> Date: Fri Dec 29 18:10:00 2023 -0500 Add preferences struct to main state commit ec37887c2f7e834ed7456625a9ec4c4cc7fea08f Author: Emilia <contact@emiliaallison.com> Date: Fri Dec 29 18:05:00 2023 -0500 Squashed commit of the following: commit 5e1137c46050d6d1d10fb1cbf842d5efd455f926 Author: Emilia <contact@emiliaallison.com> Date: Fri Dec 29 18:03:00 2023 -0500 Fix: indexing error w.r.t. logarithm argument commit 535b14a5867b15dea0e193c94829a0b99a29605c Author: Emilia <contact@emiliaallison.com> Date: Fri Dec 29 18:02:00 2023 -0500 Space colors evenly, consistently, etc Colors should now: - Not change if new transfers are added - Be evenly spaced throughout the palette - Be persistent across refreshes commit 6e08f479551315e072ec40853290d699220c9ba8 Author: Emilia <contact@emiliaallison.com> Date: Fri Dec 29 18:01:00 2023 -0500 Add palette function for ordered ids Given an id and a list of sorted ids, yields a color commit 88e838e102602f4d89ab65d8245a820158374959 Author: Emilia <contact@emiliaallison.com> Date: Fri Dec 29 18:00:00 2023 -0500 Switch to v7 UUIDs from v4 v7 UUIDs are timestamp based and thus we can establish a useful total ordering over them; will base colors on this commit 85d4b30d4795636add23a6a2c47b2068e24dbb74 Author: Emilia <contact@emiliaallison.com> Date: Tue Oct 24 21:18:10 2023 -0400 Update README.md Updated info about import/export, including the new Import Transfer from CSV feature. commit 11a561c1d447e1376e58f970f74d0778e8ed1722 Author: Emilia <contact@emiliaallison.com> Date: Tue Oct 24 20:32:51 2023 -0400 Add text to button commit 562dc2adf60b8569da579b1bb637cea344a7a596 Author: Emilia <contact@emiliaallison.com> Date: Tue Oct 24 20:32:40 2023 -0400 Change to make colors more evenly distributed commit 6b09aad289b83576bdf67882ee3f30b7f1d23619 Author: Emilia <contact@emiliaallison.com> Date: Tue Oct 24 19:27:02 2023 -0400 Implementation 1 commit a9e5f05fd9c0ebcbbb1c3cc86af8f30c92f373c5 Author: Emilia <contact@emiliaallison.com> Date: Tue Oct 24 17:18:45 2023 -0400 Hide parts of transfer menu when Custom transfer selected commit db345bfbb585c826c6f97424c5ee61337c4ffbfd Author: Emilia <contact@emiliaallison.com> Date: Tue Oct 24 17:18:08 2023 -0400 delete weird whitespace from Cargo.toml commit edcc3528aab3b17aedaf7b3424ece82ad09d591a Author: Emilia <contact@emiliaallison.com> Date: Tue Oct 24 16:41:58 2023 -0400 First implementation of custom region type commit 9a3a10c8b43e51471f74f79dfbef66b3f69ea0f5 Author: Emilia <contact@emiliaallison.com> Date: Tue Oct 24 16:21:30 2023 -0400 Transfer region no longer copy
2023-12-30 01:39:00 +00:00
let ordered_ids: Vec<uuid::Uuid> = {
let mut ids: Vec<uuid::Uuid> = main_state.transfers.clone().iter()
.map(|x| x.id)
.collect();
ids.sort_unstable();
ids
};
2023-05-22 17:25:16 +00:00
let mouse_callback = {
let m_start_handle = m_start_handle.clone();
let m_end_handle = m_end_handle.clone();
let m_stat_handle = m_stat_handle.clone();
2023-06-01 17:04:03 +00:00
Callback::from(move |(i, j, t)| match t {
2023-06-08 15:57:03 +00:00
MouseEventType::Mousedown => {
2023-06-01 17:04:03 +00:00
m_start_handle.set(Some((i, j)));
m_end_handle.set(Some((i, j)));
m_stat_handle.set(true);
}
2023-06-08 15:57:03 +00:00
MouseEventType::Mouseenter => {
2023-06-01 17:04:03 +00:00
if *m_stat_handle {
m_end_handle.set(Some((i, j)));
}
2023-05-21 16:45:12 +00:00
}
2023-05-22 17:25:16 +00:00
})
};
let mouseup_callback = {
let m_start_handle = m_start_handle.clone();
let m_end_handle = m_end_handle.clone();
Callback::from(move |_: MouseEvent| {
2023-06-01 17:04:03 +00:00
m_stat_handle.set(false);
if let Some(ul) = *m_start_handle {
if let Some(br) = *m_end_handle {
if let Ok(rd) = RegionDisplay::try_from((ul.0, ul.1, br.0, br.1)) {
ct_dispatch.reduce_mut(|state| {
state.transfer.transfer_region.source_region = Region::from(&rd);
});
}
2023-05-22 17:29:19 +00:00
}
2023-05-22 17:25:16 +00:00
}
})
};
let mouseleave_callback = Callback::clone(&mouseup_callback);
Merge from import_from_csv feature branch Of course, there were other features that got tacked on... Squashed commit of the following: commit 3ee3bd2dab3ed362bf5be9acfea8db1f16f6fc9c Author: Emilia <contact@emiliaallison.com> Date: Fri Dec 29 19:12:16 2023 -0500 Superior clipboard manipulation Won't work on non-https connections, but actually works... commit 08f647cd01566e9000d71f677df0d96411ed4cd4 Author: Emilia <contact@emiliaallison.com> Date: Fri Dec 29 18:50:01 2023 -0500 Utility for copying plates as image commit 3456be2e9a07f63bf5d62ca685fe692303875888 Author: Emilia <contact@emiliaallison.com> Date: Fri Dec 29 17:46:38 2023 -0500 Change wording in options menu Father suggests that this wording is more clear to the end user. I agree! commit 4c79cc0b4dd5402a798ce8d7ac69599c03cf49d9 Author: Emilia <contact@emiliaallison.com> Date: Fri Dec 29 18:20:00 2023 -0500 Set default plate format to 96 well commit 056688c4ec690a384f57c194314cb924253770f5 Author: Emilia <contact@emiliaallison.com> Date: Fri Dec 29 18:12:00 2023 -0500 Implement in_transfer hashes toggle in plates commit 4937d4ad283b90629a80a213595a873d1a3a2615 Author: Emilia <contact@emiliaallison.com> Date: Fri Dec 29 18:11:00 2023 -0500 Preferences menu and toggle for in_transfer hashes commit 0101846b52393d1a050c2c7672274b4589c5c993 Author: Emilia <contact@emiliaallison.com> Date: Fri Dec 29 18:10:00 2023 -0500 Add preferences struct to main state commit ec37887c2f7e834ed7456625a9ec4c4cc7fea08f Author: Emilia <contact@emiliaallison.com> Date: Fri Dec 29 18:05:00 2023 -0500 Squashed commit of the following: commit 5e1137c46050d6d1d10fb1cbf842d5efd455f926 Author: Emilia <contact@emiliaallison.com> Date: Fri Dec 29 18:03:00 2023 -0500 Fix: indexing error w.r.t. logarithm argument commit 535b14a5867b15dea0e193c94829a0b99a29605c Author: Emilia <contact@emiliaallison.com> Date: Fri Dec 29 18:02:00 2023 -0500 Space colors evenly, consistently, etc Colors should now: - Not change if new transfers are added - Be evenly spaced throughout the palette - Be persistent across refreshes commit 6e08f479551315e072ec40853290d699220c9ba8 Author: Emilia <contact@emiliaallison.com> Date: Fri Dec 29 18:01:00 2023 -0500 Add palette function for ordered ids Given an id and a list of sorted ids, yields a color commit 88e838e102602f4d89ab65d8245a820158374959 Author: Emilia <contact@emiliaallison.com> Date: Fri Dec 29 18:00:00 2023 -0500 Switch to v7 UUIDs from v4 v7 UUIDs are timestamp based and thus we can establish a useful total ordering over them; will base colors on this commit 85d4b30d4795636add23a6a2c47b2068e24dbb74 Author: Emilia <contact@emiliaallison.com> Date: Tue Oct 24 21:18:10 2023 -0400 Update README.md Updated info about import/export, including the new Import Transfer from CSV feature. commit 11a561c1d447e1376e58f970f74d0778e8ed1722 Author: Emilia <contact@emiliaallison.com> Date: Tue Oct 24 20:32:51 2023 -0400 Add text to button commit 562dc2adf60b8569da579b1bb637cea344a7a596 Author: Emilia <contact@emiliaallison.com> Date: Tue Oct 24 20:32:40 2023 -0400 Change to make colors more evenly distributed commit 6b09aad289b83576bdf67882ee3f30b7f1d23619 Author: Emilia <contact@emiliaallison.com> Date: Tue Oct 24 19:27:02 2023 -0400 Implementation 1 commit a9e5f05fd9c0ebcbbb1c3cc86af8f30c92f373c5 Author: Emilia <contact@emiliaallison.com> Date: Tue Oct 24 17:18:45 2023 -0400 Hide parts of transfer menu when Custom transfer selected commit db345bfbb585c826c6f97424c5ee61337c4ffbfd Author: Emilia <contact@emiliaallison.com> Date: Tue Oct 24 17:18:08 2023 -0400 delete weird whitespace from Cargo.toml commit edcc3528aab3b17aedaf7b3424ece82ad09d591a Author: Emilia <contact@emiliaallison.com> Date: Tue Oct 24 16:41:58 2023 -0400 First implementation of custom region type commit 9a3a10c8b43e51471f74f79dfbef66b3f69ea0f5 Author: Emilia <contact@emiliaallison.com> Date: Tue Oct 24 16:21:30 2023 -0400 Transfer region no longer copy
2023-12-30 01:39:00 +00:00
let screenshot_callback = Callback::from(|_| {
let _ = js_sys::eval("copy_screenshot_src()");
});
2023-06-08 15:14:15 +00:00
let column_header = {
let headers = (1..=props.source_plate.plate.size().1)
.map(|j| {
2023-06-13 16:51:16 +00:00
html! {<th>
2023-06-16 02:23:12 +00:00
{format!("{:0>2}", j)}
</th>}
2023-06-08 15:14:15 +00:00
})
.collect::<Html>();
2023-06-08 15:14:50 +00:00
html! {<tr><th />{ headers }</tr>}
2023-06-08 15:14:15 +00:00
};
2023-06-01 17:04:03 +00:00
let rows = (1..=props.source_plate.plate.size().0)
.map(|i| {
2023-06-08 15:14:15 +00:00
let row_header = html! {<th>{num_to_letters(i)}</th>};
2023-06-01 17:04:03 +00:00
let row = (1..=props.source_plate.plate.size().1)
.map(|j| {
html! {
<SourcePlateCell i={i} j={j}
2023-06-08 15:57:03 +00:00
selected={in_rect(*m_start_handle.clone(), *m_end_handle.clone(), (i,j))}
2023-06-01 17:04:03 +00:00
mouse={mouse_callback.clone()}
Merge from import_from_csv feature branch Of course, there were other features that got tacked on... Squashed commit of the following: commit 3ee3bd2dab3ed362bf5be9acfea8db1f16f6fc9c Author: Emilia <contact@emiliaallison.com> Date: Fri Dec 29 19:12:16 2023 -0500 Superior clipboard manipulation Won't work on non-https connections, but actually works... commit 08f647cd01566e9000d71f677df0d96411ed4cd4 Author: Emilia <contact@emiliaallison.com> Date: Fri Dec 29 18:50:01 2023 -0500 Utility for copying plates as image commit 3456be2e9a07f63bf5d62ca685fe692303875888 Author: Emilia <contact@emiliaallison.com> Date: Fri Dec 29 17:46:38 2023 -0500 Change wording in options menu Father suggests that this wording is more clear to the end user. I agree! commit 4c79cc0b4dd5402a798ce8d7ac69599c03cf49d9 Author: Emilia <contact@emiliaallison.com> Date: Fri Dec 29 18:20:00 2023 -0500 Set default plate format to 96 well commit 056688c4ec690a384f57c194314cb924253770f5 Author: Emilia <contact@emiliaallison.com> Date: Fri Dec 29 18:12:00 2023 -0500 Implement in_transfer hashes toggle in plates commit 4937d4ad283b90629a80a213595a873d1a3a2615 Author: Emilia <contact@emiliaallison.com> Date: Fri Dec 29 18:11:00 2023 -0500 Preferences menu and toggle for in_transfer hashes commit 0101846b52393d1a050c2c7672274b4589c5c993 Author: Emilia <contact@emiliaallison.com> Date: Fri Dec 29 18:10:00 2023 -0500 Add preferences struct to main state commit ec37887c2f7e834ed7456625a9ec4c4cc7fea08f Author: Emilia <contact@emiliaallison.com> Date: Fri Dec 29 18:05:00 2023 -0500 Squashed commit of the following: commit 5e1137c46050d6d1d10fb1cbf842d5efd455f926 Author: Emilia <contact@emiliaallison.com> Date: Fri Dec 29 18:03:00 2023 -0500 Fix: indexing error w.r.t. logarithm argument commit 535b14a5867b15dea0e193c94829a0b99a29605c Author: Emilia <contact@emiliaallison.com> Date: Fri Dec 29 18:02:00 2023 -0500 Space colors evenly, consistently, etc Colors should now: - Not change if new transfers are added - Be evenly spaced throughout the palette - Be persistent across refreshes commit 6e08f479551315e072ec40853290d699220c9ba8 Author: Emilia <contact@emiliaallison.com> Date: Fri Dec 29 18:01:00 2023 -0500 Add palette function for ordered ids Given an id and a list of sorted ids, yields a color commit 88e838e102602f4d89ab65d8245a820158374959 Author: Emilia <contact@emiliaallison.com> Date: Fri Dec 29 18:00:00 2023 -0500 Switch to v7 UUIDs from v4 v7 UUIDs are timestamp based and thus we can establish a useful total ordering over them; will base colors on this commit 85d4b30d4795636add23a6a2c47b2068e24dbb74 Author: Emilia <contact@emiliaallison.com> Date: Tue Oct 24 21:18:10 2023 -0400 Update README.md Updated info about import/export, including the new Import Transfer from CSV feature. commit 11a561c1d447e1376e58f970f74d0778e8ed1722 Author: Emilia <contact@emiliaallison.com> Date: Tue Oct 24 20:32:51 2023 -0400 Add text to button commit 562dc2adf60b8569da579b1bb637cea344a7a596 Author: Emilia <contact@emiliaallison.com> Date: Tue Oct 24 20:32:40 2023 -0400 Change to make colors more evenly distributed commit 6b09aad289b83576bdf67882ee3f30b7f1d23619 Author: Emilia <contact@emiliaallison.com> Date: Tue Oct 24 19:27:02 2023 -0400 Implementation 1 commit a9e5f05fd9c0ebcbbb1c3cc86af8f30c92f373c5 Author: Emilia <contact@emiliaallison.com> Date: Tue Oct 24 17:18:45 2023 -0400 Hide parts of transfer menu when Custom transfer selected commit db345bfbb585c826c6f97424c5ee61337c4ffbfd Author: Emilia <contact@emiliaallison.com> Date: Tue Oct 24 17:18:08 2023 -0400 delete weird whitespace from Cargo.toml commit edcc3528aab3b17aedaf7b3424ece82ad09d591a Author: Emilia <contact@emiliaallison.com> Date: Tue Oct 24 16:41:58 2023 -0400 First implementation of custom region type commit 9a3a10c8b43e51471f74f79dfbef66b3f69ea0f5 Author: Emilia <contact@emiliaallison.com> Date: Tue Oct 24 16:21:30 2023 -0400 Transfer region no longer copy
2023-12-30 01:39:00 +00:00
in_transfer={source_wells.contains(&(i,j)) && main_state.preferences.in_transfer_hashes}
color={transfer_map.get(&(i,j))
.and_then(|t| t.last())
Merge from import_from_csv feature branch Of course, there were other features that got tacked on... Squashed commit of the following: commit 3ee3bd2dab3ed362bf5be9acfea8db1f16f6fc9c Author: Emilia <contact@emiliaallison.com> Date: Fri Dec 29 19:12:16 2023 -0500 Superior clipboard manipulation Won't work on non-https connections, but actually works... commit 08f647cd01566e9000d71f677df0d96411ed4cd4 Author: Emilia <contact@emiliaallison.com> Date: Fri Dec 29 18:50:01 2023 -0500 Utility for copying plates as image commit 3456be2e9a07f63bf5d62ca685fe692303875888 Author: Emilia <contact@emiliaallison.com> Date: Fri Dec 29 17:46:38 2023 -0500 Change wording in options menu Father suggests that this wording is more clear to the end user. I agree! commit 4c79cc0b4dd5402a798ce8d7ac69599c03cf49d9 Author: Emilia <contact@emiliaallison.com> Date: Fri Dec 29 18:20:00 2023 -0500 Set default plate format to 96 well commit 056688c4ec690a384f57c194314cb924253770f5 Author: Emilia <contact@emiliaallison.com> Date: Fri Dec 29 18:12:00 2023 -0500 Implement in_transfer hashes toggle in plates commit 4937d4ad283b90629a80a213595a873d1a3a2615 Author: Emilia <contact@emiliaallison.com> Date: Fri Dec 29 18:11:00 2023 -0500 Preferences menu and toggle for in_transfer hashes commit 0101846b52393d1a050c2c7672274b4589c5c993 Author: Emilia <contact@emiliaallison.com> Date: Fri Dec 29 18:10:00 2023 -0500 Add preferences struct to main state commit ec37887c2f7e834ed7456625a9ec4c4cc7fea08f Author: Emilia <contact@emiliaallison.com> Date: Fri Dec 29 18:05:00 2023 -0500 Squashed commit of the following: commit 5e1137c46050d6d1d10fb1cbf842d5efd455f926 Author: Emilia <contact@emiliaallison.com> Date: Fri Dec 29 18:03:00 2023 -0500 Fix: indexing error w.r.t. logarithm argument commit 535b14a5867b15dea0e193c94829a0b99a29605c Author: Emilia <contact@emiliaallison.com> Date: Fri Dec 29 18:02:00 2023 -0500 Space colors evenly, consistently, etc Colors should now: - Not change if new transfers are added - Be evenly spaced throughout the palette - Be persistent across refreshes commit 6e08f479551315e072ec40853290d699220c9ba8 Author: Emilia <contact@emiliaallison.com> Date: Fri Dec 29 18:01:00 2023 -0500 Add palette function for ordered ids Given an id and a list of sorted ids, yields a color commit 88e838e102602f4d89ab65d8245a820158374959 Author: Emilia <contact@emiliaallison.com> Date: Fri Dec 29 18:00:00 2023 -0500 Switch to v7 UUIDs from v4 v7 UUIDs are timestamp based and thus we can establish a useful total ordering over them; will base colors on this commit 85d4b30d4795636add23a6a2c47b2068e24dbb74 Author: Emilia <contact@emiliaallison.com> Date: Tue Oct 24 21:18:10 2023 -0400 Update README.md Updated info about import/export, including the new Import Transfer from CSV feature. commit 11a561c1d447e1376e58f970f74d0778e8ed1722 Author: Emilia <contact@emiliaallison.com> Date: Tue Oct 24 20:32:51 2023 -0400 Add text to button commit 562dc2adf60b8569da579b1bb637cea344a7a596 Author: Emilia <contact@emiliaallison.com> Date: Tue Oct 24 20:32:40 2023 -0400 Change to make colors more evenly distributed commit 6b09aad289b83576bdf67882ee3f30b7f1d23619 Author: Emilia <contact@emiliaallison.com> Date: Tue Oct 24 19:27:02 2023 -0400 Implementation 1 commit a9e5f05fd9c0ebcbbb1c3cc86af8f30c92f373c5 Author: Emilia <contact@emiliaallison.com> Date: Tue Oct 24 17:18:45 2023 -0400 Hide parts of transfer menu when Custom transfer selected commit db345bfbb585c826c6f97424c5ee61337c4ffbfd Author: Emilia <contact@emiliaallison.com> Date: Tue Oct 24 17:18:08 2023 -0400 delete weird whitespace from Cargo.toml commit edcc3528aab3b17aedaf7b3424ece82ad09d591a Author: Emilia <contact@emiliaallison.com> Date: Tue Oct 24 16:41:58 2023 -0400 First implementation of custom region type commit 9a3a10c8b43e51471f74f79dfbef66b3f69ea0f5 Author: Emilia <contact@emiliaallison.com> Date: Tue Oct 24 16:21:30 2023 -0400 Transfer region no longer copy
2023-12-30 01:39:00 +00:00
.map(|t| PALETTE.get_ordered(t.get_uuid(), &ordered_ids))
}
cell_height={props.cell_height}
2023-06-16 02:23:12 +00:00
title={transfer_map.get(&(i,j)).map(|transfers| format!("Used by: {}", transfers.iter().map(|t| t.name.clone())
.collect::<Vec<_>>().join(", ")))}
2023-06-01 17:04:03 +00:00
/>
}
})
.collect::<Html>();
html! {
2023-06-01 17:04:03 +00:00
<tr>
2023-06-08 15:14:15 +00:00
{ row_header }{ row }
2023-06-01 17:04:03 +00:00
</tr>
}
2023-06-01 17:04:03 +00:00
})
.collect::<Html>();
html! {
Merge from import_from_csv feature branch Of course, there were other features that got tacked on... Squashed commit of the following: commit 3ee3bd2dab3ed362bf5be9acfea8db1f16f6fc9c Author: Emilia <contact@emiliaallison.com> Date: Fri Dec 29 19:12:16 2023 -0500 Superior clipboard manipulation Won't work on non-https connections, but actually works... commit 08f647cd01566e9000d71f677df0d96411ed4cd4 Author: Emilia <contact@emiliaallison.com> Date: Fri Dec 29 18:50:01 2023 -0500 Utility for copying plates as image commit 3456be2e9a07f63bf5d62ca685fe692303875888 Author: Emilia <contact@emiliaallison.com> Date: Fri Dec 29 17:46:38 2023 -0500 Change wording in options menu Father suggests that this wording is more clear to the end user. I agree! commit 4c79cc0b4dd5402a798ce8d7ac69599c03cf49d9 Author: Emilia <contact@emiliaallison.com> Date: Fri Dec 29 18:20:00 2023 -0500 Set default plate format to 96 well commit 056688c4ec690a384f57c194314cb924253770f5 Author: Emilia <contact@emiliaallison.com> Date: Fri Dec 29 18:12:00 2023 -0500 Implement in_transfer hashes toggle in plates commit 4937d4ad283b90629a80a213595a873d1a3a2615 Author: Emilia <contact@emiliaallison.com> Date: Fri Dec 29 18:11:00 2023 -0500 Preferences menu and toggle for in_transfer hashes commit 0101846b52393d1a050c2c7672274b4589c5c993 Author: Emilia <contact@emiliaallison.com> Date: Fri Dec 29 18:10:00 2023 -0500 Add preferences struct to main state commit ec37887c2f7e834ed7456625a9ec4c4cc7fea08f Author: Emilia <contact@emiliaallison.com> Date: Fri Dec 29 18:05:00 2023 -0500 Squashed commit of the following: commit 5e1137c46050d6d1d10fb1cbf842d5efd455f926 Author: Emilia <contact@emiliaallison.com> Date: Fri Dec 29 18:03:00 2023 -0500 Fix: indexing error w.r.t. logarithm argument commit 535b14a5867b15dea0e193c94829a0b99a29605c Author: Emilia <contact@emiliaallison.com> Date: Fri Dec 29 18:02:00 2023 -0500 Space colors evenly, consistently, etc Colors should now: - Not change if new transfers are added - Be evenly spaced throughout the palette - Be persistent across refreshes commit 6e08f479551315e072ec40853290d699220c9ba8 Author: Emilia <contact@emiliaallison.com> Date: Fri Dec 29 18:01:00 2023 -0500 Add palette function for ordered ids Given an id and a list of sorted ids, yields a color commit 88e838e102602f4d89ab65d8245a820158374959 Author: Emilia <contact@emiliaallison.com> Date: Fri Dec 29 18:00:00 2023 -0500 Switch to v7 UUIDs from v4 v7 UUIDs are timestamp based and thus we can establish a useful total ordering over them; will base colors on this commit 85d4b30d4795636add23a6a2c47b2068e24dbb74 Author: Emilia <contact@emiliaallison.com> Date: Tue Oct 24 21:18:10 2023 -0400 Update README.md Updated info about import/export, including the new Import Transfer from CSV feature. commit 11a561c1d447e1376e58f970f74d0778e8ed1722 Author: Emilia <contact@emiliaallison.com> Date: Tue Oct 24 20:32:51 2023 -0400 Add text to button commit 562dc2adf60b8569da579b1bb637cea344a7a596 Author: Emilia <contact@emiliaallison.com> Date: Tue Oct 24 20:32:40 2023 -0400 Change to make colors more evenly distributed commit 6b09aad289b83576bdf67882ee3f30b7f1d23619 Author: Emilia <contact@emiliaallison.com> Date: Tue Oct 24 19:27:02 2023 -0400 Implementation 1 commit a9e5f05fd9c0ebcbbb1c3cc86af8f30c92f373c5 Author: Emilia <contact@emiliaallison.com> Date: Tue Oct 24 17:18:45 2023 -0400 Hide parts of transfer menu when Custom transfer selected commit db345bfbb585c826c6f97424c5ee61337c4ffbfd Author: Emilia <contact@emiliaallison.com> Date: Tue Oct 24 17:18:08 2023 -0400 delete weird whitespace from Cargo.toml commit edcc3528aab3b17aedaf7b3424ece82ad09d591a Author: Emilia <contact@emiliaallison.com> Date: Tue Oct 24 16:41:58 2023 -0400 First implementation of custom region type commit 9a3a10c8b43e51471f74f79dfbef66b3f69ea0f5 Author: Emilia <contact@emiliaallison.com> Date: Tue Oct 24 16:21:30 2023 -0400 Transfer region no longer copy
2023-12-30 01:39:00 +00:00
<div ondblclick={screenshot_callback}
class={classes!{"source_plate",
2023-06-13 19:51:23 +00:00
"W".to_owned()+&props.source_plate.plate.plate_format.to_string()}}>
<table
onmouseup={move |e| {
mouseup_callback.emit(e);
}}
onmouseleave={move |e| {
mouseleave_callback.emit(e);
}}>
2023-06-08 15:14:15 +00:00
{ column_header }
{ rows }
</table>
</div>
}
2023-05-11 21:49:03 +00:00
}
#[derive(PartialEq, Properties)]
pub struct SourcePlateCellProps {
i: u8,
j: u8,
selected: bool,
2023-06-01 17:04:03 +00:00
mouse: Callback<(u8, u8, MouseEventType)>,
2023-05-24 22:39:38 +00:00
in_transfer: Option<bool>,
color: Option<[f64; 3]>,
cell_height: f64,
title: Option<String>,
}
#[derive(Debug)]
pub enum MouseEventType {
2023-06-08 15:57:03 +00:00
Mousedown,
Mouseenter,
}
#[function_component]
fn SourcePlateCell(props: &SourcePlateCellProps) -> Html {
let selected_class = match props.selected {
true => Some("current_select"),
false => None,
2023-05-11 21:49:03 +00:00
};
2023-05-24 22:39:38 +00:00
let in_transfer_class = match props.in_transfer {
Some(true) => Some("in_transfer"),
2023-06-01 17:04:03 +00:00
_ => None,
};
2023-06-16 02:23:12 +00:00
let color = props.color.unwrap_or([255.0, 255.0, 255.0]);
let mouse = Callback::clone(&props.mouse);
let mouse2 = Callback::clone(&props.mouse);
2023-06-08 15:57:03 +00:00
let (i, j) = (props.i, props.j);
html! {
2023-05-24 22:39:38 +00:00
<td class={classes!("plate_cell", selected_class, in_transfer_class)}
style={format!("height: {}px;", props.cell_height)}
2023-06-06 01:33:23 +00:00
id={format!("color={:?}", props.color)}
onmousedown={move |_| {
2023-06-08 15:57:03 +00:00
mouse.emit((i,j, MouseEventType::Mousedown))
}}
onmouseenter={move |_| {
2023-06-08 15:57:03 +00:00
mouse2.emit((i,j, MouseEventType::Mouseenter))
}}>
<div class="plate_cell_inner"
style={format!("background: rgba({},{},{},1);", color[0], color[1], color[2])}
title={if let Some(text) = &props.title {
text.clone()
} else {"".to_string()}}/>
</td>
}
2023-05-11 21:49:03 +00:00
}
2023-05-22 17:46:29 +00:00
pub fn in_rect(corner1: Option<(u8, u8)>, corner2: Option<(u8, u8)>, pt: (u8, u8)) -> bool {
2023-05-11 21:49:03 +00:00
if let (Some(c1), Some(c2)) = (corner1, corner2) {
2023-06-08 15:57:03 +00:00
pt.0 <= u8::max(c1.0, c2.0)
2023-05-11 21:51:09 +00:00
&& pt.0 >= u8::min(c1.0, c2.0)
&& pt.1 <= u8::max(c1.1, c2.1)
2023-06-08 15:57:03 +00:00
&& pt.1 >= u8::min(c1.1, c2.1)
2023-05-11 21:51:09 +00:00
} else {
2023-06-08 15:57:03 +00:00
false
2023-05-11 21:51:09 +00:00
}
2023-05-11 21:49:03 +00:00
}
2023-05-12 00:39:43 +00:00
#[cfg(test)]
mod tests {
2023-05-26 20:20:52 +00:00
use wasm_bindgen_test::*;
2023-05-12 00:39:43 +00:00
use super::in_rect;
// in_rect tests
#[test]
2023-05-26 20:20:52 +00:00
#[wasm_bindgen_test]
2023-05-12 00:39:43 +00:00
fn test_in_rect1() {
// Test in center of rect
2023-05-13 23:13:03 +00:00
let c1 = (1, 1);
let c2 = (10, 10);
let pt = (5, 5);
2023-05-12 00:39:43 +00:00
assert!(in_rect(Some(c1), Some(c2), pt));
// Order of the corners should not matter:
assert!(in_rect(Some(c2), Some(c1), pt));
}
#[test]
2023-05-26 20:20:52 +00:00
#[wasm_bindgen_test]
2023-05-12 00:39:43 +00:00
fn test_in_rect2() {
// Test on top/bottom edges of rect
2023-05-13 23:13:03 +00:00
let c1 = (1, 1);
let c2 = (10, 10);
let pt1 = (1, 5);
let pt2 = (10, 5);
2023-05-12 00:39:43 +00:00
assert!(in_rect(Some(c1), Some(c2), pt1));
assert!(in_rect(Some(c1), Some(c2), pt2));
// Order of the corners should not matter:
assert!(in_rect(Some(c2), Some(c1), pt1));
assert!(in_rect(Some(c2), Some(c1), pt2));
}
#[test]
2023-05-26 20:20:52 +00:00
#[wasm_bindgen_test]
2023-05-12 00:39:43 +00:00
fn test_in_rect3() {
// Test on left/right edges of rect
2023-05-13 23:13:03 +00:00
let c1 = (1, 1);
let c2 = (10, 10);
let pt1 = (5, 1);
let pt2 = (5, 10);
2023-05-12 00:39:43 +00:00
assert!(in_rect(Some(c1), Some(c2), pt1));
assert!(in_rect(Some(c1), Some(c2), pt2));
// Order of the corners should not matter:
assert!(in_rect(Some(c2), Some(c1), pt1));
assert!(in_rect(Some(c2), Some(c1), pt2));
}
#[test]
2023-05-26 20:20:52 +00:00
#[wasm_bindgen_test]
2023-05-12 00:39:43 +00:00
fn test_in_rect4() {
2023-05-13 23:13:03 +00:00
// Test cases that should fail
let c1 = (1, 1);
let c2 = (10, 10);
let pt1 = (0, 0);
let pt2 = (15, 15);
2023-06-16 02:23:12 +00:00
assert!(!in_rect(Some(c1), Some(c2), pt1));
assert!(!in_rect(Some(c1), Some(c2), pt2));
2023-05-12 00:39:43 +00:00
}
}