From 61b054b99bb80c48255382bc21db959afe8bef3e Mon Sep 17 00:00:00 2001 From: Paul McCarthy <pauld.mccarthy@gmail.com> Date: Tue, 20 May 2014 10:50:23 +0100 Subject: [PATCH] Voxels do need to be centered at [0.0,0.0] for the transformation to work correctly. --- fsl/fslview/slicecanvas.py | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/fsl/fslview/slicecanvas.py b/fsl/fslview/slicecanvas.py index b6aa6769e..46e6fad4b 100644 --- a/fsl/fslview/slicecanvas.py +++ b/fsl/fslview/slicecanvas.py @@ -79,10 +79,10 @@ class GLImageData(object): # the geometry of a single voxel, rendered as # a triangle strip. geomData = np.zeros((4, 3), dtype=np.float32) - geomData[:, [canvas.xax, canvas.yax]] = [[0, 0], - [1, 0], - [0, 1], - [1, 1]] + geomData[:, [canvas.xax, canvas.yax]] = [[-0.5, -0.5], + [ 0.5, -0.5], + [-0.5, 0.5], + [ 0.5, 0.5]] geomData = geomData.ravel('C') @@ -257,7 +257,6 @@ attribute float voxX; attribute float voxY; attribute float voxZ; - /* Voxel value passed through to fragment shader */ varying float fragVoxValue; @@ -556,14 +555,21 @@ class SliceCanvas(wxgl.GLCanvas): gl.glViewport(0, 0, size.width, size.height) gl.glMatrixMode(gl.GL_PROJECTION) gl.glLoadIdentity() - gl.glOrtho(self.xmin, self.xmax, self.ymin, self.ymax, self.zmin-1, self.zmax+1) - + gl.glOrtho(self.xmin, self.xmax, + self.ymin, self.ymax, + self.zmin - 1, self.zmax + 1) gl.glMatrixMode(gl.GL_MODELVIEW) - gl.glLoadIdentity() + gl.glLoadIdentity() + + # TODO There's got to be a more generic way + # to perform this rotation. This will break + # if I add functionality allowing the user + # to specifty the x/y axes on initialisation. if self.zax == 0: gl.glRotatef(-90, 1, 0, 0) gl.glRotatef(-90, 0, 0, 1) + elif self.zax == 1: gl.glRotatef(270, 1, 0, 0) -- GitLab