Rename constraints to observables

This commit is contained in:
Aaron Fenyes 2025-01-26 10:50:15 -08:00
parent fb8e391587
commit 677ef47544
4 changed files with 78 additions and 78 deletions

View file

@ -6,8 +6,8 @@ use crate::{
AppState,
assembly::{
Assembly,
Constraint,
ConstraintRole,
Observable,
ObservableRole,
Element
},
engine::Q
@ -210,8 +210,8 @@ pub fn AddRemove() -> View {
}
);
let desired = create_signal(0.0);
let role = create_signal(ConstraintRole::Measure);
state.assembly.insert_constraint(Constraint {
let role = create_signal(ObservableRole::Measure);
state.assembly.insert_observable(Observable {
subjects: subjects,
measured: measured,
desired: desired,
@ -221,16 +221,16 @@ pub fn AddRemove() -> View {
state.selection.update(|sel| sel.clear());
/* DEBUG */
// print updated constraint list
console::log_1(&JsValue::from("Constraints:"));
state.assembly.constraints.with(|csts| {
for (_, cst) in csts.into_iter() {
// print updated observable list
console::log_1(&JsValue::from("Observables:"));
state.assembly.observables.with(|obsls| {
for (_, obs) in obsls.into_iter() {
console::log_5(
&JsValue::from(" "),
&JsValue::from(cst.subjects.0),
&JsValue::from(cst.subjects.1),
&JsValue::from(obs.subjects.0),
&JsValue::from(obs.subjects.1),
&JsValue::from(":"),
&JsValue::from(cst.desired.get_untracked())
&JsValue::from(obs.desired.get_untracked())
);
}
});
@ -239,10 +239,10 @@ pub fn AddRemove() -> View {
// constrained, or is edited while constrained
create_effect(move || {
console::log_1(&JsValue::from(
format!("Constraint ({}, {}) updated", subjects.0, subjects.1)
format!("Updated constraint with subjects ({}, {})", subjects.0, subjects.1)
));
desired.track();
if role.with(|r| matches!(r, ConstraintRole::Constrain)) {
if role.with(|r| matches!(r, ObservableRole::Constrain)) {
state.assembly.realize();
}
});