From 1287b1d1a109b3c5110f0ceadda9027b10842e49 Mon Sep 17 00:00:00 2001 From: Thomas White Date: Tue, 2 Mar 2021 14:13:34 +0100 Subject: CrystFELImageView: Set limits on zooming --- src/crystfelimageview.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/crystfelimageview.c b/src/crystfelimageview.c index 7bf617e9..42d3ea4c 100644 --- a/src/crystfelimageview.c +++ b/src/crystfelimageview.c @@ -129,8 +129,9 @@ static void configure_scroll_adjustments(CrystFELImageView *iv) static gint scroll_sig(GtkWidget *window, GdkEventScroll *event, CrystFELImageView *iv) { - double zoom_scale; + double zoom_scale, ratio; int claim = FALSE; + int zoom_allowed = 1; if ( event->direction == GDK_SCROLL_UP ) { zoom_scale = 1.1; @@ -143,7 +144,12 @@ static gint scroll_sig(GtkWidget *window, GdkEventScroll *event, if ( event->direction == GDK_SCROLL_LEFT ) return TRUE; if ( event->direction == GDK_SCROLL_RIGHT ) return TRUE; - if ( claim ) { + ratio = iv->zoom / iv->image->detgeom->panels[0].pixel_pitch; + + if ( (ratio < 5e6) && (zoom_scale < 1.0) ) zoom_allowed = 0; + if ( (ratio > 1e10) && (zoom_scale > 1.0) ) zoom_allowed = 0; + + if ( claim && zoom_allowed ) { double shift_x, shift_y; double scr_x, scr_y; -- cgit v1.2.3