From f1c8b7d8a011b637fa7c94c5311bda02c10c34e0 Mon Sep 17 00:00:00 2001 From: Paul McCarthy <pauld.mccarthy@gmail.com> Date: Fri, 17 Oct 2014 11:06:18 +0100 Subject: [PATCH] Cursor not drawn out of bounds on lb canvas --- fsl/fslview/gl/lightboxcanvas.py | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/fsl/fslview/gl/lightboxcanvas.py b/fsl/fslview/gl/lightboxcanvas.py index 06de7ef3e..5d5141c9b 100644 --- a/fsl/fslview/gl/lightboxcanvas.py +++ b/fsl/fslview/gl/lightboxcanvas.py @@ -162,6 +162,12 @@ class LightBoxCanvas(slicecanvas.SliceCanvas): return tuple(pos) + def getTotalRows(self): + """Returns the total number of rows that may be displayed. + """ + return self._totalRows + + def __init__(self, imageList, zax=0): """Create a :class:`LightBoxCanvas` object. @@ -213,12 +219,6 @@ class LightBoxCanvas(slicecanvas.SliceCanvas): '{}_zPosChanged'.format(self.name), self._zPosChanged) - - def getTotalRows(self): - """Returns the total number of rows that may be displayed. - """ - return self._totalRows - def _slicePropsChanged(self, *a): """Called when any of the slice properties change. Regenerates slice @@ -515,9 +515,18 @@ class LightBoxCanvas(slicecanvas.SliceCanvas): ylen = self.imageList.bounds.getLen(self.yax) xmin = self.imageList.bounds.getLo( self.xax) ymin = self.imageList.bounds.getLo( self.yax) - row = self._totalRows - int(np.floor(sliceno / self.ncols)) - 1 + row = int(np.floor(sliceno / self.ncols)) col = int(np.floor(sliceno % self.ncols)) + # don't draw the cursor if it is on a + # non-existent or non-displayed slice + if sliceno > self._nslices: return + if row < self.topRow: return + if row > self.topRow + self.nrows: return + + # in GL space, the top row is actually the bottom row + row = self._totalRows - row - 1 + xpos, ypos = self.worldToCanvas(*self.pos.xyz) xverts = np.zeros((2, 3)) -- GitLab