Application prototype #14

Merged
glen merged 101 commits from app-proto into main 2024-10-21 23:38:28 +00:00
Showing only changes of commit 28b1ecb8e9 - Show all commits

View File

@ -31,8 +31,8 @@ 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"),
@ -40,21 +40,17 @@ fn main() {
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"),
@ -62,12 +58,16 @@ fn main() {
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()
} }
)
); );
state.assembly.insert_constraint(Constraint { assemb.insert_constraint(
args: (key_a, key_b), 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 rep: 0.5
}); }
);
provide_context(state); provide_context(state);
view! { view! {