Name constraint Lorentz product more descriptively
This commit is contained in:
parent
a4ec52a4e7
commit
5839882ed7
@ -214,13 +214,13 @@ pub fn AddRemove() -> View {
|
||||
(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);
|
||||
state.assembly.insert_constraint(Constraint {
|
||||
subjects: subjects,
|
||||
rep: rep,
|
||||
rep_text: create_signal(String::new()),
|
||||
rep_valid: create_signal(false),
|
||||
lorentz_prod: lorentz_prod,
|
||||
lorentz_prod_text: create_signal(String::new()),
|
||||
lorentz_prod_valid: create_signal(false),
|
||||
active: active,
|
||||
});
|
||||
state.assembly.realize();
|
||||
@ -236,7 +236,7 @@ pub fn AddRemove() -> View {
|
||||
&JsValue::from(cst.subjects.0),
|
||||
&JsValue::from(cst.subjects.1),
|
||||
&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
|
||||
// edited while active
|
||||
create_effect(move || {
|
||||
rep.track();
|
||||
lorentz_prod.track();
|
||||
console::log_2(
|
||||
&JsValue::from("Lorentz product updated to"),
|
||||
&JsValue::from(rep.get_untracked())
|
||||
&JsValue::from(lorentz_prod.get_untracked())
|
||||
);
|
||||
if active.get() {
|
||||
state.assembly.realize();
|
||||
|
@ -32,9 +32,9 @@ pub struct Element {
|
||||
#[derive(Clone)]
|
||||
pub struct Constraint {
|
||||
pub subjects: (ElementKey, ElementKey),
|
||||
pub rep: Signal<f64>,
|
||||
pub rep_text: Signal<String>,
|
||||
pub rep_valid: Signal<bool>,
|
||||
pub lorentz_prod: Signal<f64>,
|
||||
pub lorentz_prod_text: Signal<String>,
|
||||
pub lorentz_prod_valid: Signal<bool>,
|
||||
pub active: Signal<bool>
|
||||
}
|
||||
|
||||
@ -128,11 +128,11 @@ impl Assembly {
|
||||
let mut gram_to_be = PartialMatrix::new();
|
||||
self.constraints.with_untracked(|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 row = elts[subjects.0].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());
|
||||
}
|
||||
}
|
||||
});
|
||||
|
@ -17,15 +17,15 @@ fn LorentzProductInput(constraint: Constraint) -> View {
|
||||
view! {
|
||||
input(
|
||||
r#type="text",
|
||||
bind:value=constraint.rep_text,
|
||||
bind:value=constraint.lorentz_prod_text,
|
||||
on:change=move |event: Event| {
|
||||
let target: HtmlInputElement = event.target().unwrap().unchecked_into();
|
||||
match target.value().parse::<f64>() {
|
||||
Ok(rep) => batch(|| {
|
||||
constraint.rep.set(rep);
|
||||
constraint.rep_valid.set(true);
|
||||
Ok(lorentz_prod) => batch(|| {
|
||||
constraint.lorentz_prod.set(lorentz_prod);
|
||||
constraint.lorentz_prod_valid.set(true);
|
||||
}),
|
||||
Err(_) => constraint.rep_valid.set(false)
|
||||
Err(_) => constraint.lorentz_prod_valid.set(false)
|
||||
};
|
||||
}
|
||||
)
|
||||
|
Loading…
Reference in New Issue
Block a user