App: use element insertion method in test
This commit is contained in:
parent
b08dbd6f93
commit
28b1ecb8e9
@ -31,43 +31,43 @@ impl AppState {
|
||||
fn main() {
|
||||
sycamore::render(|| {
|
||||
let state = AppState::new();
|
||||
let key_a = state.assembly.elements.update(
|
||||
|elts| elts.insert(
|
||||
Element {
|
||||
id: String::from("wing_a"),
|
||||
label: String::from("Wing A"),
|
||||
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]),
|
||||
constraints: BTreeSet::default()
|
||||
}
|
||||
)
|
||||
let assemb = &state.assembly;
|
||||
let _ = assemb.try_insert_element(
|
||||
Element {
|
||||
id: String::from("wing_a"),
|
||||
label: String::from("Wing A"),
|
||||
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]),
|
||||
constraints: BTreeSet::default()
|
||||
}
|
||||
);
|
||||
let key_b = state.assembly.elements.update(
|
||||
|elts| elts.insert(
|
||||
Element {
|
||||
id: String::from("wing_b"),
|
||||
label: String::from("Wing B"),
|
||||
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]),
|
||||
constraints: BTreeSet::default()
|
||||
},
|
||||
)
|
||||
let _ = assemb.try_insert_element(
|
||||
Element {
|
||||
id: String::from("wing_b"),
|
||||
label: String::from("Wing B"),
|
||||
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]),
|
||||
constraints: BTreeSet::default()
|
||||
}
|
||||
);
|
||||
state.assembly.elements.update(
|
||||
|elts| elts.insert(
|
||||
Element {
|
||||
id: String::from("central"),
|
||||
label: String::from("Central"),
|
||||
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]),
|
||||
constraints: BTreeSet::default()
|
||||
}
|
||||
)
|
||||
let _ = assemb.try_insert_element(
|
||||
Element {
|
||||
id: String::from("central"),
|
||||
label: String::from("Central"),
|
||||
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]),
|
||||
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);
|
||||
|
||||
view! {
|
||||
|
Loading…
Reference in New Issue
Block a user