Name constraint Lorentz product more descriptively

This commit is contained in:
Aaron Fenyes 2024-11-11 00:26:53 -08:00
parent a4ec52a4e7
commit 5839882ed7
3 changed files with 17 additions and 17 deletions

View File

@ -214,13 +214,13 @@ pub fn AddRemove() -> View {
(subject_vec[0].clone(), subject_vec[1].clone()) (subject_vec[0].clone(), subject_vec[1].clone())
} }
); );
let rep = create_signal(0.0); let lorentz_prod = create_signal(0.0);
let active = create_signal(true); let active = create_signal(true);
state.assembly.insert_constraint(Constraint { state.assembly.insert_constraint(Constraint {
subjects: subjects, subjects: subjects,
rep: rep, lorentz_prod: lorentz_prod,
rep_text: create_signal(String::new()), lorentz_prod_text: create_signal(String::new()),
rep_valid: create_signal(false), lorentz_prod_valid: create_signal(false),
active: active, active: active,
}); });
state.assembly.realize(); state.assembly.realize();
@ -236,7 +236,7 @@ pub fn AddRemove() -> View {
&JsValue::from(cst.subjects.0), &JsValue::from(cst.subjects.0),
&JsValue::from(cst.subjects.1), &JsValue::from(cst.subjects.1),
&JsValue::from(":"), &JsValue::from(":"),
&JsValue::from(cst.rep.get_untracked()) &JsValue::from(cst.lorentz_prod.get_untracked())
); );
} }
}); });
@ -244,10 +244,10 @@ pub fn AddRemove() -> View {
// update the realization when the constraint activated, or // update the realization when the constraint activated, or
// edited while active // edited while active
create_effect(move || { create_effect(move || {
rep.track(); lorentz_prod.track();
console::log_2( console::log_2(
&JsValue::from("Lorentz product updated to"), &JsValue::from("Lorentz product updated to"),
&JsValue::from(rep.get_untracked()) &JsValue::from(lorentz_prod.get_untracked())
); );
if active.get() { if active.get() {
state.assembly.realize(); state.assembly.realize();

View File

@ -32,9 +32,9 @@ pub struct Element {
#[derive(Clone)] #[derive(Clone)]
pub struct Constraint { pub struct Constraint {
pub subjects: (ElementKey, ElementKey), pub subjects: (ElementKey, ElementKey),
pub rep: Signal<f64>, pub lorentz_prod: Signal<f64>,
pub rep_text: Signal<String>, pub lorentz_prod_text: Signal<String>,
pub rep_valid: Signal<bool>, pub lorentz_prod_valid: Signal<bool>,
pub active: Signal<bool> pub active: Signal<bool>
} }
@ -128,11 +128,11 @@ impl Assembly {
let mut gram_to_be = PartialMatrix::new(); let mut gram_to_be = PartialMatrix::new();
self.constraints.with_untracked(|csts| { self.constraints.with_untracked(|csts| {
for (_, cst) in csts { for (_, cst) in csts {
if cst.active.get_untracked() && cst.rep_valid.get_untracked() { if cst.active.get_untracked() && cst.lorentz_prod_valid.get_untracked() {
let subjects = cst.subjects; let subjects = cst.subjects;
let row = elts[subjects.0].index; let row = elts[subjects.0].index;
let col = elts[subjects.1].index; let col = elts[subjects.1].index;
gram_to_be.push_sym(row, col, cst.rep.get_untracked()); gram_to_be.push_sym(row, col, cst.lorentz_prod.get_untracked());
} }
} }
}); });

View File

@ -17,15 +17,15 @@ fn LorentzProductInput(constraint: Constraint) -> View {
view! { view! {
input( input(
r#type="text", r#type="text",
bind:value=constraint.rep_text, bind:value=constraint.lorentz_prod_text,
on:change=move |event: Event| { on:change=move |event: Event| {
let target: HtmlInputElement = event.target().unwrap().unchecked_into(); let target: HtmlInputElement = event.target().unwrap().unchecked_into();
match target.value().parse::<f64>() { match target.value().parse::<f64>() {
Ok(rep) => batch(|| { Ok(lorentz_prod) => batch(|| {
constraint.rep.set(rep); constraint.lorentz_prod.set(lorentz_prod);
constraint.rep_valid.set(true); constraint.lorentz_prod_valid.set(true);
}), }),
Err(_) => constraint.rep_valid.set(false) Err(_) => constraint.lorentz_prod_valid.set(false)
}; };
} }
) )