Make element vectors reactive

This commit is contained in:
Aaron Fenyes 2024-11-01 19:01:14 -07:00
parent e42b8da897
commit 5ce5f855d5
3 changed files with 63 additions and 39 deletions

View file

@ -12,7 +12,7 @@ pub struct Element {
pub id: String,
pub label: String,
pub color: [f32; 3],
pub rep: DVector<f64>,
pub rep: Signal<DVector<f64>>,
pub constraints: Signal<BTreeSet<usize>>,
// internal properties, not reflected in any view
@ -30,7 +30,7 @@ impl Element {
id: id,
label: label,
color: color,
rep: rep,
rep: create_signal(rep),
constraints: create_signal(BTreeSet::default()),
index: 0
}
@ -151,7 +151,7 @@ impl Assembly {
for (_, elt) in elts {
let index = elt.index;
gram_to_be.push_sym(index, index, 1.0);
guess_to_be.set_column(index, &elt.rep);
guess_to_be.set_column(index, &elt.rep.get_clone());
}
(gram_to_be, guess_to_be)
@ -193,11 +193,11 @@ impl Assembly {
if success {
// read out the solution
self.elements.update(|elts| {
for (_, elt) in elts.iter_mut() {
elt.rep.set_column(0, &config.column(elt.index));
}
});
for (_, elt) in self.elements.get_clone() {
elt.rep.update(
|rep| rep.set_column(0, &config.column(elt.index))
);
}
}
}
}