From 0b85e7989eacb26d3496cdb98ed3221868a4013f Mon Sep 17 00:00:00 2001 From: Johannes Hofmann Date: Tue, 27 Oct 2026 13:41:53 +0100 Subject: web: hidden-peak heuristics in the UI with Show-hidden toggle MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The core already ran both visibility heuristics (height/distance threshold via the Visibility slider, occlusion via mark_hidden with the cone-visibility slope test) — the web UI just ignored FLAG_HIDDEN. - guide dots: hidden peaks are filtered out by default; with the new Display > Show hidden peaks toggle they appear grey instead of green - hover and click hit-testing skip hidden peaks unless the toggle is on - Find Peak picker is unchanged (it lists pan.close, which always includes hidden peaks — same as desktop) --- crates/gipfel-web/src/app.rs | 41 +++++++++++++++++++++++++++++++++-------- 1 file changed, 33 insertions(+), 8 deletions(-) (limited to 'crates/gipfel-web/src/app.rs') diff --git a/crates/gipfel-web/src/app.rs b/crates/gipfel-web/src/app.rs index e4fd435..f4b0de4 100644 --- a/crates/gipfel-web/src/app.rs +++ b/crates/gipfel-web/src/app.rs @@ -5,7 +5,7 @@ use std::io::Read; use std::rc::Rc; use flate2::read::GzDecoder; -use gipfel_core::hill::{FLAG_DUPLIC, FLAG_TRACK_POINT}; +use gipfel_core::hill::{FLAG_DUPLIC, FLAG_HIDDEN, FLAG_TRACK_POINT}; use gipfel_core::metadata::{apply_image_metadata, ImageMetaData}; use gipfel_core::panorama::Panorama; use wasm_bindgen::closure::Closure; @@ -161,6 +161,7 @@ pub fn app() -> Html { let vp = use_state(UiParams::default); let img_size = use_state(|| (0u32, 0u32)); let find_peak = use_state(|| Option::::None); + let show_hidden = use_state(|| false); // force a redraw when the window is resized so the canvas backing // store tracks its CSS size (listener lives as long as the app) @@ -441,6 +442,13 @@ pub fn app() -> Html { vp.set(u); }) }; + let on_show_hidden = { + let show_hidden = show_hidden.clone(); + Callback::from(move |e: Event| { + let input: HtmlInputElement = e.target_unchecked_into(); + show_hidden.set(input.checked()); + }) + }; // compass strip: shares the image transform, drag changes azimuth let compass_data = { @@ -555,13 +563,14 @@ pub fn app() -> Html { let mark = mark_peak.clone(); let find_peak = find_peak.clone(); let img_size = img_size.clone(); + let show_hidden = show_hidden.clone(); Callback::from(move |(ix, iy): (f64, f64)| { let scale = view.scale; // unambiguous click right on a peak: mark directly // (borrow must be released before mark -> do_refit!) let near = { let p = pan.borrow(); - markers::nearest_hill(&p, ix, iy, 10.0 / scale) + markers::nearest_hill(&p, ix, iy, 10.0 / scale, *show_hidden) }; if let Some(idx) = near { find_peak.set(None); @@ -620,12 +629,14 @@ pub fn app() -> Html { let pan = pan.clone(); let view = view.clone(); let hover = hover.clone(); + let show_hidden = show_hidden.clone(); Callback::from(move |(ix, iy): (f64, f64)| { let p = pan.borrow(); - let name = markers::nearest_hill(&p, ix, iy, 20.0 / view.scale).map(|i| { - let h = &p.hills[i]; - format!("{} · {:.0} m", h.name, h.height) - }); + let name = markers::nearest_hill(&p, ix, iy, 20.0 / view.scale, *show_hidden) + .map(|i| { + let h = &p.hills[i]; + format!("{} · {:.0} m", h.name, h.height) + }); hover.set(name); }) }, @@ -647,9 +658,19 @@ pub fn app() -> Html { }) .collect() }; - let candidates: Vec<(f64, f64)> = { + let candidates: Vec<(f64, f64, bool)> = { let p = pan.borrow(); - p.visible.iter().map(|&i| (p.hills[i].x, p.hills[i].y)).collect() + p.visible + .iter() + .filter(|&&i| *show_hidden || p.hills[i].flags & FLAG_HIDDEN == 0) + .map(|&i| { + ( + p.hills[i].x, + p.hills[i].y, + p.hills[i].flags & FLAG_HIDDEN != 0, + ) + }) + .collect() }; let zoom_pct = (view.scale * 100.0).round(); @@ -695,6 +716,10 @@ pub fn app() -> Html { { "Fit distortion (needs ≥ 4 markers)" }
{ "Display" }
+