From d572231a7183c8105fbcd8b2a74d52d73afff8d3 Mon Sep 17 00:00:00 2001 From: Glen Whitney Date: Mon, 22 Sep 2025 07:44:14 -0700 Subject: [PATCH] feat: add final struts and dump the coordinates --- app-proto/src/components/outline.rs | 27 ++++++++++++++++++- .../src/components/test_assembly_chooser.rs | 23 ++++++++++------ 2 files changed, 41 insertions(+), 9 deletions(-) diff --git a/app-proto/src/components/outline.rs b/app-proto/src/components/outline.rs index 79781fa..ed6c921 100644 --- a/app-proto/src/components/outline.rs +++ b/app-proto/src/components/outline.rs @@ -1,7 +1,7 @@ use itertools::Itertools; use std::rc::Rc; use sycamore::prelude::*; -use web_sys::{KeyboardEvent, MouseEvent, wasm_bindgen::JsCast}; +use web_sys::{KeyboardEvent, MouseEvent, wasm_bindgen::{JsCast,}}; use crate::{ AppState, @@ -261,6 +261,31 @@ pub fn Outline() -> View { on:click = { let state = use_context::(); move |_| state.selection.update(|sel| sel.clear()) + }, + on:keydown = { + let rep_list = state.assembly.elements.map( + |elts| elts + .clone() + .into_iter() + .map(|elt| format!("{}: {}", elt.id(), elt.representation())) + .collect::>() + ); + + move |event: KeyboardEvent| { + match event.key().as_str() { + "c" => { + console_log!("Dumping all coordinates"); + rep_list.map( + |reps| { + for item in reps { + console_log!("{}", item); + } + } + ); + }, + _ => {}, + } + } } ) { Keyed( diff --git a/app-proto/src/components/test_assembly_chooser.rs b/app-proto/src/components/test_assembly_chooser.rs index f6e1f84..c80e2ba 100644 --- a/app-proto/src/components/test_assembly_chooser.rs +++ b/app-proto/src/components/test_assembly_chooser.rs @@ -898,17 +898,17 @@ fn load_554aug2(assembly: &Assembly) { -0.5*(4. + 2.*SQRT_2) ]; // Now process the acron data - for (id, v, pinned, l, _neighbors) in ACRON554_COMMON { + for (id, v, pinned, l, neighbors) in ACRON554_COMMON { let pt = Point::new(id, id, LEVEL_COLORS[l], point(v[0], v[1], v[2])); assembly.try_insert_element(pt); + // QUESTION: Would there be a way to insert an Rc into + // an assembly to avoid the need to re-lookup pt in the assembly + // after just inserting it? Or could/should try_insert_element return + // the Rc ? + let pt_rc = assembly.find_element(id); + if pinned { // regulate each coordinate to its given value let mut freeze = Vec::>::new(); - // QUESTION: Would there be a way to insert an Rc into - // an assembly to avoid the need to re-lookup pt in the assembly - // after just inserting it? - let pt_rc = assembly.elements_by_id.with_untracked( - |elts| elts[id].clone() - ); // filter the three coordinate regulators into freeze pt_rc.regulators().with_untracked( |regs| { for reg in regs { @@ -927,7 +927,6 @@ fn load_554aug2(assembly: &Assembly) { } // If part of the octagon, make incident to the plane: if l == 8 { - let pt_rc = assembly.find_element(id); let oct_index = oct_verts.len(); oct_verts.push(pt_rc.clone()); let incidence = InversiveDistanceRegulator::new( @@ -951,6 +950,14 @@ fn load_554aug2(assembly: &Assembly) { } } } + // Finally, add any specified neighbors + for id in neighbors.split(",") { + if id.len() == 0 { continue; } + let strut = InversiveDistanceRegulator::new( + [assembly.find_element(id), pt_rc.clone()]); + strut.set_to(-0.5); + assembly.insert_regulator(Rc::new(strut)); + } } }