Rename ObservableRole variants

Also rename corresponding CSS classes and add methods to check roles.
This commit is contained in:
Aaron Fenyes 2025-01-26 17:48:32 -08:00
parent 677ef47544
commit af2724f934
4 changed files with 30 additions and 16 deletions

View file

@ -112,9 +112,17 @@ impl Element {
}
pub enum ObservableRole {
Measure,
Constrain,
Invalid
Measurement,
Constraint(bool)
}
impl ObservableRole {
pub fn is_valid_constraint(&self) -> bool {
match self {
ObservableRole::Measurement => false,
ObservableRole::Constraint(valid) => *valid
}
}
}
#[derive(Clone)]
@ -126,6 +134,12 @@ pub struct Observable {
pub role: Signal<ObservableRole>
}
impl Observable {
fn role_is_valid_constraint_untracked(&self) -> bool {
self.role.with_untracked(|role| role.is_valid_constraint())
}
}
// the velocity is expressed in uniform coordinates
pub struct ElementMotion<'a> {
pub key: ElementKey,
@ -236,7 +250,7 @@ impl Assembly {
let mut gram_to_be = PartialMatrix::new();
self.observables.with_untracked(|obsls| {
for (_, obs) in obsls {
if obs.role.with_untracked(|role| matches!(role, ObservableRole::Constrain)) {
if obs.role_is_valid_constraint_untracked() {
let subjects = obs.subjects;
let row = elts[subjects.0].column_index.unwrap();
let col = elts[subjects.1].column_index.unwrap();