diff --git a/fsl/fslview/gl/lightboxcanvas.py b/fsl/fslview/gl/lightboxcanvas.py index 06de7ef3ebeb01d2608f73dfbe82838b8842c9ab..5d5141c9ba91de7ecad732b3d3bed00e955241e1 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))