summaryrefslogtreecommitdiff
path: root/crates/wipfel/src
diff options
context:
space:
mode:
authorJohannes Hofmann <Johannes.Hofmann@gmx.de>2026-10-28 09:42:59 +0100
committerJohannes Hofmann <Johannes.Hofmann@gmx.de>2026-10-28 10:34:53 +0100
commitd91f4022a48fb2468f307026b44cb4555eade7a4 (patch)
tree44627d3b3abb4d9fa73de2135a6e0f3256bcd502 /crates/wipfel/src
parent8b87a9d31c966b431e9547bcc411f9da7f3c527a (diff)
web: sync orientation and focal sliders with the fitted values
do_refit only updated the fit-info text; the Azimuth/Pitch/Roll/Focal sliders kept showing their pre-fit values because the slider state (vp) was never synced from the panorama after a fit. Long-standing wipfel bug, independent of the recent focal-constant change. The compass strip was unaffected (it reads the panorama at render time).
Diffstat (limited to 'crates/wipfel/src')
-rw-r--r--crates/wipfel/src/app.rs28
1 files changed, 21 insertions, 7 deletions
diff --git a/crates/wipfel/src/app.rs b/crates/wipfel/src/app.rs
index fbe49c4..4194789 100644
--- a/crates/wipfel/src/app.rs
+++ b/crates/wipfel/src/app.rs
@@ -311,6 +311,8 @@ pub fn app() -> Html {
let pan = pan.clone();
let fit_info = fit_info.clone();
let fit_distortion = fit_distortion.clone();
+ let vp = vp.clone();
+ let img_size = img_size.clone();
Rc::new(move |mk: &[Marker]| {
if mk.is_empty() {
fit_info.set(String::new());
@@ -319,13 +321,25 @@ pub fn app() -> Html {
let info = {
let mut p = pan.borrow_mut();
match markers::refit(&mut p, mk, *fit_distortion) {
- Ok(()) => format!(
- "fit: az {:.2}° · pitch {:.2}° · roll {:.2}° · scale {:.1}",
- p.get_center_angle(),
- p.get_pitch_angle(),
- p.get_roll_angle(),
- p.get_scale()
- ),
+ Ok(()) => {
+ // push the fitted values into the slider state,
+ // otherwise Azimuth/Pitch/Roll/Focal keep showing
+ // the pre-fit numbers
+ let mut u = *vp;
+ u.az = p.get_center_angle().rem_euclid(360.0);
+ u.pitch = p.get_pitch_angle();
+ u.roll = p.get_roll_angle();
+ let w = img_size.0.max(1) as f64;
+ u.focal = (p.get_scale() * 36.0 / w).clamp(1.0, 300.0);
+ vp.set(u);
+ format!(
+ "fit: az {:.2}° · pitch {:.2}° · roll {:.2}° · scale {:.1}",
+ p.get_center_angle(),
+ p.get_pitch_angle(),
+ p.get_roll_angle(),
+ p.get_scale()
+ )
+ }
Err(e) => format!("fit failed: {e}"),
}
};