Outline: include constraints in element diff key
This tells Sycamore that the outline view of an element should update when the element's constraint set has changed. To make the constraint set hashable, so we can include it in the diff key, we store it as a `BTreeSet` instead of an `FxHashSet`.
This commit is contained in:
parent
f5486fb0dd
commit
9b39fe56b8
@ -1,6 +1,6 @@
|
|||||||
use nalgebra::DVector;
|
use nalgebra::DVector;
|
||||||
use rustc_hash::FxHashSet;
|
|
||||||
use slab::Slab;
|
use slab::Slab;
|
||||||
|
use std::collections::BTreeSet;
|
||||||
use sycamore::prelude::*;
|
use sycamore::prelude::*;
|
||||||
|
|
||||||
#[derive(Clone, PartialEq)]
|
#[derive(Clone, PartialEq)]
|
||||||
@ -9,7 +9,7 @@ pub struct Element {
|
|||||||
pub label: String,
|
pub label: String,
|
||||||
pub color: [f32; 3],
|
pub color: [f32; 3],
|
||||||
pub rep: DVector<f64>,
|
pub rep: DVector<f64>,
|
||||||
pub constraints: FxHashSet<usize>
|
pub constraints: BTreeSet<usize>
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
|
@ -5,6 +5,7 @@ mod outline;
|
|||||||
|
|
||||||
use nalgebra::DVector;
|
use nalgebra::DVector;
|
||||||
use rustc_hash::FxHashSet;
|
use rustc_hash::FxHashSet;
|
||||||
|
use std::collections::BTreeSet;
|
||||||
use sycamore::prelude::*;
|
use sycamore::prelude::*;
|
||||||
|
|
||||||
use add_remove::AddRemove;
|
use add_remove::AddRemove;
|
||||||
@ -37,7 +38,7 @@ fn main() {
|
|||||||
label: String::from("Wing A"),
|
label: String::from("Wing A"),
|
||||||
color: [1.00_f32, 0.25_f32, 0.00_f32],
|
color: [1.00_f32, 0.25_f32, 0.00_f32],
|
||||||
rep: DVector::<f64>::from_column_slice(&[0.5, 0.5, 0.0, 0.5, -0.25]),
|
rep: DVector::<f64>::from_column_slice(&[0.5, 0.5, 0.0, 0.5, -0.25]),
|
||||||
constraints: FxHashSet::default()
|
constraints: BTreeSet::default()
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
@ -48,7 +49,7 @@ fn main() {
|
|||||||
label: String::from("Wing B"),
|
label: String::from("Wing B"),
|
||||||
color: [0.00_f32, 0.25_f32, 1.00_f32],
|
color: [0.00_f32, 0.25_f32, 1.00_f32],
|
||||||
rep: DVector::<f64>::from_column_slice(&[-0.5, -0.5, 0.0, 0.5, -0.25]),
|
rep: DVector::<f64>::from_column_slice(&[-0.5, -0.5, 0.0, 0.5, -0.25]),
|
||||||
constraints: FxHashSet::default()
|
constraints: BTreeSet::default()
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
@ -59,7 +60,7 @@ fn main() {
|
|||||||
label: String::from("Central"),
|
label: String::from("Central"),
|
||||||
color: [0.75_f32, 0.75_f32, 0.75_f32],
|
color: [0.75_f32, 0.75_f32, 0.75_f32],
|
||||||
rep: DVector::<f64>::from_column_slice(&[0.0, 0.0, 0.0, 0.4, -0.625]),
|
rep: DVector::<f64>::from_column_slice(&[0.0, 0.0, 0.0, 0.4, -0.625]),
|
||||||
constraints: FxHashSet::default()
|
constraints: BTreeSet::default()
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
@ -148,7 +148,7 @@ pub fn Outline() -> View {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
key=|(key, _)| key.clone()
|
key=|(key, elt)| (key.clone(), elt.constraints.clone())
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user