Integrate engine into application prototype #15
@ -214,10 +214,11 @@ pub fn AddRemove() -> View {
|
|||||||
(arg_vec[0].clone(), arg_vec[1].clone())
|
(arg_vec[0].clone(), arg_vec[1].clone())
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
let active = create_signal(true);
|
||||||
state.assembly.insert_constraint(Constraint {
|
state.assembly.insert_constraint(Constraint {
|
||||||
args: args,
|
args: args,
|
||||||
rep: 0.0,
|
rep: 0.0,
|
||||||
active: create_signal(true)
|
active: active
|
||||||
});
|
});
|
||||||
state.assembly.realize();
|
state.assembly.realize();
|
||||||
state.selection.update(|sel| sel.clear());
|
state.selection.update(|sel| sel.clear());
|
||||||
@ -236,6 +237,13 @@ pub fn AddRemove() -> View {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// make constraint activation trigger a realization update
|
||||||
|
create_effect(move || {
|
||||||
|
if active.get() {
|
||||||
|
state.assembly.realize();
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
) { "🔗" }
|
) { "🔗" }
|
||||||
select(bind:value=assembly_name) { /* DEBUG */
|
select(bind:value=assembly_name) { /* DEBUG */
|
||||||
|
@ -97,7 +97,7 @@ impl Assembly {
|
|||||||
self.elements.update(|elts| {
|
self.elements.update(|elts| {
|
||||||
elts[args.0].constraints.insert(key);
|
elts[args.0].constraints.insert(key);
|
||||||
elts[args.1].constraints.insert(key);
|
elts[args.1].constraints.insert(key);
|
||||||
})
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// --- realization ---
|
// --- realization ---
|
||||||
@ -116,10 +116,12 @@ 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 {
|
||||||
let args = cst.args;
|
if cst.active.get_untracked() {
|
||||||
let row = elts[args.0].index;
|
let args = cst.args;
|
||||||
let col = elts[args.1].index;
|
let row = elts[args.0].index;
|
||||||
gram_to_be.push_sym(row, col, cst.rep);
|
let col = elts[args.1].index;
|
||||||
|
gram_to_be.push_sym(row, col, cst.rep);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user