From 9cf09264ace112c16924ccd09b43fe26bf737c48 Mon Sep 17 00:00:00 2001 From: Thomas White Date: Mon, 2 Mar 2020 16:00:25 +0100 Subject: Preserve view position and zoom across image reload --- src/crystfelimageview.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'src/crystfelimageview.c') diff --git a/src/crystfelimageview.c b/src/crystfelimageview.c index 65698a64..4fd2a97c 100644 --- a/src/crystfelimageview.c +++ b/src/crystfelimageview.c @@ -369,7 +369,7 @@ GtkWidget *crystfel_image_view_new() /* All values initially meaningless */ iv->detector_w = 1.0; iv->detector_h = 1.0; - iv->zoom = 1.0; + iv->zoom = -1.0; iv->filename = NULL; iv->event = NULL; iv->image = NULL; @@ -491,9 +491,12 @@ static int reload_image(CrystFELImageView *iv) border = iv->detector_w * 0.1; iv->detector_w += border; iv->detector_h += border; - iv->offs_x = -min_x + border/2.0; - iv->offs_y = max_y + border/2.0; - iv->zoom = 1.0/iv->image->detgeom->panels[0].pixel_pitch; + if ( iv->zoom < 0.0 ) { + /* Set initial values */ + iv->offs_x = -min_x + border/2.0; + iv->offs_y = max_y + border/2.0; + iv->zoom = 1.0/iv->image->detgeom->panels[0].pixel_pitch; + } configure_scroll_adjustments(iv); return 0; -- cgit v1.2.3