App: use element insertion method in test

This commit is contained in:
Aaron Fenyes 2024-09-28 13:28:53 -07:00
parent b08dbd6f93
commit 28b1ecb8e9

View File

@ -31,43 +31,43 @@ impl AppState {
fn main() { fn main() {
sycamore::render(|| { sycamore::render(|| {
let state = AppState::new(); let state = AppState::new();
let key_a = state.assembly.elements.update( let assemb = &state.assembly;
|elts| elts.insert( let _ = assemb.try_insert_element(
Element { Element {
id: String::from("wing_a"), id: String::from("wing_a"),
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: BTreeSet::default() constraints: BTreeSet::default()
} }
)
); );
let key_b = state.assembly.elements.update( let _ = assemb.try_insert_element(
|elts| elts.insert( Element {
Element { id: String::from("wing_b"),
id: String::from("wing_b"), 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: BTreeSet::default()
constraints: BTreeSet::default() }
},
)
); );
state.assembly.elements.update( let _ = assemb.try_insert_element(
|elts| elts.insert( Element {
Element { id: String::from("central"),
id: String::from("central"), 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: BTreeSet::default()
constraints: BTreeSet::default() }
} );
) assemb.insert_constraint(
Constraint {
args: (
assemb.elements_by_id.with(|elts_by_id| elts_by_id["wing_a"]),
assemb.elements_by_id.with(|elts_by_id| elts_by_id["wing_b"])
),
rep: 0.5
}
); );
state.assembly.insert_constraint(Constraint {
args: (key_a, key_b),
rep: 0.5
});
provide_context(state); provide_context(state);
view! { view! {