diff --git a/fsl/fslview/orthopanel.py b/fsl/fslview/orthopanel.py index c6ca3c2e07580ac81c4274cb176fcac02002a1f6..4c5bce9d54c87e3a9656d600a3c46fe24d49a33c 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):