aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorThomas White <taw@physics.org>2021-03-02 14:13:34 +0100
committerThomas White <taw@physics.org>2021-03-02 14:13:34 +0100
commit1287b1d1a109b3c5110f0ceadda9027b10842e49 (patch)
tree1b51cf15d998e146ef1fe1e6137bfeb3fc3bf45b /src
parentebad23faea94b2cf88e37dbb1237dd225a244eb1 (diff)
CrystFELImageView: Set limits on zooming
Diffstat (limited to 'src')
-rw-r--r--src/crystfelimageview.c10
1 files 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;