From 5a0d54d0b08f953466b12f7ced16fd86725006ee Mon Sep 17 00:00:00 2001 From: Paul McCarthy <pauld.mccarthy@gmail.com> Date: Mon, 26 May 2014 09:35:13 +0100 Subject: [PATCH] Fixed zooming (only on x axis right now) --- fsl/fslview/orthopanel.py | 36 ++++++++++++++++++++---------------- 1 file changed, 20 insertions(+), 16 deletions(-) diff --git a/fsl/fslview/orthopanel.py b/fsl/fslview/orthopanel.py index c6ca3c2e0..4c5bce9d5 100644 --- a/fsl/fslview/orthopanel.py +++ b/fsl/fslview/orthopanel.py @@ -189,23 +189,27 @@ class OrthoPanel(wx.Panel, props.HasProperties): newxmin = canvas.xmin + xshift newxmax = canvas.xmax + xshift - newymin = canvas.ymin + xshift - newymax = canvas.ymax + xshift - - if newxmin < imgxmin: xshift = newxmin - imgxmin - elif newxmax > imgxmax: xshift = newxmax - imgxmax + newymin = canvas.ymin + yshift + newymax = canvas.ymax + yshift + + if newxmin < imgxmin: + newxmin = imgxmin + newxmax = imgxmin + abs(canvas.xmax - canvas.xmin) + elif newxmax > imgxmax: + newxmax = imgxmax + newxmin = imgxmax - abs(canvas.xmax - canvas.xmin) - if newymin < imgymin: yshift = newymin - imgymin - elif newymax > imgymax: yshift = newymax - imgymax - - if xshift != 0: - print 'xshift {}'.format(xshift) - canvas.xmin = canvas.xmin + xshift - canvas.xmax = canvas.xmax + xshift - if yshift != 0: - print 'yshift {}'.format(yshift) - canvas.ymin = canvas.ymin + yshift - canvas.ymax = canvas.ymax + yshift + if newymin < imgymin: + newymin = imgymin + newymax = imgymin + abs(canvas.ymax - canvas.ymin) + elif newymax > imgymax: + newymax = imgymax + newymin = imgymax - abs(canvas.ymax - canvas.ymin) + + canvas.xmin = newxmin + canvas.xmax = newxmax + canvas.ymin = newymin + canvas.ymax = newymax def _setCanvasPosition(self, ev): -- GitLab