Allow changing source interleave
... and of course a fix to the replicate math with a source interleave.
This commit is contained in:
parent
aee565dbb3
commit
32dd3814af
|
@ -53,6 +53,36 @@ pub fn TransferMenu() -> Html {
|
|||
})
|
||||
};
|
||||
|
||||
let on_source_interleave_x_change = {
|
||||
let ct_dispatch = ct_dispatch.clone();
|
||||
|
||||
Callback::from(move |e: Event| {
|
||||
let target: Option<EventTarget> = e.target();
|
||||
let input = target.and_then(|t| t.dyn_into::<HtmlInputElement>().ok());
|
||||
if let Some(input) = input {
|
||||
if let Ok(num) = input.value().parse::<i8>() {
|
||||
ct_dispatch.reduce_mut(|state| {
|
||||
state.transfer.interleave_source = (num, state.transfer.interleave_source.1);
|
||||
});
|
||||
}
|
||||
}
|
||||
})
|
||||
};
|
||||
let on_source_interleave_y_change = {
|
||||
let ct_dispatch = ct_dispatch.clone();
|
||||
|
||||
Callback::from(move |e: Event| {
|
||||
let target: Option<EventTarget> = e.target();
|
||||
let input = target.and_then(|t| t.dyn_into::<HtmlInputElement>().ok());
|
||||
if let Some(input) = input {
|
||||
if let Ok(num) = input.value().parse::<i8>() {
|
||||
ct_dispatch.reduce_mut(|state| {
|
||||
state.transfer.interleave_source = (state.transfer.interleave_source.0, num);
|
||||
});
|
||||
}
|
||||
}
|
||||
})
|
||||
};
|
||||
let on_dest_interleave_x_change = {
|
||||
let ct_dispatch = ct_dispatch.clone();
|
||||
|
||||
|
@ -100,11 +130,22 @@ pub fn TransferMenu() -> Html {
|
|||
value={RegionDisplay::from(&ct_state.transfer.dest_region).text}/>
|
||||
</div>
|
||||
<div>
|
||||
{"Source Interleave "}
|
||||
<label for="source_interleave_x">{"Row:"}</label>
|
||||
<input type="number" name="source_interleave_x"
|
||||
onchange={on_source_interleave_x_change}
|
||||
value={ct_state.transfer.interleave_source.0.to_string()}/>
|
||||
<label for="source_interleave_y">{"Col:"}</label>
|
||||
<input type="number" name="source_interleave_y"
|
||||
onchange={on_source_interleave_y_change}
|
||||
value={ct_state.transfer.interleave_source.1.to_string()}/>
|
||||
</div>
|
||||
<div>
|
||||
{"Destination Interleave "}
|
||||
<label for="dest_interleave_x">{"X:"}</label>
|
||||
<label for="dest_interleave_x">{"Row:"}</label>
|
||||
<input type="number" name="dest_interleave_x"
|
||||
onchange={on_dest_interleave_x_change} value={ct_state.transfer.interleave_dest.0.to_string()}/>
|
||||
<label for="dest_interleave_y">{"Y:"}</label>
|
||||
<label for="dest_interleave_y">{"Col:"}</label>
|
||||
<input type="number" name="dest_interleave_y"
|
||||
onchange={on_dest_interleave_y_change} value={ct_state.transfer.interleave_dest.1.to_string()}/>
|
||||
</div>
|
||||
|
|
|
@ -157,20 +157,23 @@ impl TransferRegion {
|
|||
d_br.1.checked_sub(d_ul.1).unwrap() + 1,
|
||||
);
|
||||
let N_s = ( // Number of used source wells
|
||||
s_dims.0.div_euclid(il_source.0.abs() as u8),
|
||||
s_dims.1.div_euclid(il_source.1.abs() as u8),
|
||||
(s_dims.0 + il_source.0.abs() as u8 - 1).div_euclid(il_source.0.abs() as u8),
|
||||
(s_dims.1 + il_source.1.abs() as u8 - 1).div_euclid(il_source.1.abs() as u8),
|
||||
);
|
||||
let D_per_replicate = ( // How many wells are used per replicate?
|
||||
(s_dims.0 * (il_dest.0.abs() as u8))
|
||||
(N_s.0 * (il_dest.0.abs() as u8))
|
||||
// Conditionally subtract one to ignore the trailing interleave well
|
||||
.saturating_sub(if il_dest.0.abs() > 1 {1} else {0}),
|
||||
(s_dims.1 * (il_dest.1.abs() as u8))
|
||||
(N_s.1 * (il_dest.1.abs() as u8))
|
||||
.saturating_sub(if il_dest.1.abs() > 1 {1} else {0}),
|
||||
);
|
||||
let count = ( // How many times can we replicate?
|
||||
d_dims.0.div_euclid(D_per_replicate.0),
|
||||
d_dims.1.div_euclid(D_per_replicate.1),
|
||||
);
|
||||
let i = i.saturating_sub(s_ul.0).saturating_div(il_source.0.abs() as u8);
|
||||
let j = j.saturating_sub(s_ul.1).saturating_div(il_source.1.abs() as u8);
|
||||
log::debug!("s_dims: {:?}, N_s: {:?}", s_dims, N_s);
|
||||
|
||||
Some(
|
||||
possible_destination_wells
|
||||
|
@ -178,13 +181,13 @@ impl TransferRegion {
|
|||
.filter(|(x, _)| {
|
||||
x.checked_sub(d_ul.0).unwrap()
|
||||
% (N_s.0 * il_dest.0.abs() as u8) // Counter along x
|
||||
== ((il_dest.0.abs() as u8 *(i).checked_sub(1u8).unwrap()))
|
||||
== ((il_dest.0.abs() as u8 *i))
|
||||
% (N_s.0 * il_dest.0.abs() as u8)
|
||||
})
|
||||
.filter(|(_, y)| {
|
||||
y.checked_sub(d_ul.1).unwrap()
|
||||
% (N_s.1 * il_dest.1.abs() as u8) // Counter along u
|
||||
== ((il_dest.1.abs() as u8 *(j).checked_sub(1u8).unwrap()))
|
||||
== ((il_dest.1.abs() as u8 *j))
|
||||
% (N_s.1 * il_dest.1.abs() as u8)
|
||||
})
|
||||
.filter(|(x,y)| {
|
||||
|
|
Loading…
Reference in New Issue