Skip to content
Snippets Groups Projects
Commit a97b1d90 authored by Paul McCarthy's avatar Paul McCarthy
Browse files

Setting the camera location to zmin is required when the image Y axis is...

Setting the camera location to zmin is required when the image Y axis is depth. I don't know why, and this makes me sad.
parent 99a24619
No related branches found
No related tags found
No related merge requests found
...@@ -57,24 +57,8 @@ class GLImageData(object): ...@@ -57,24 +57,8 @@ class GLImageData(object):
- canvas: The SliceCanvas object which is rendering the image. - canvas: The SliceCanvas object which is rendering the image.
""" """
self.image = image self.image = image
self.canvas = canvas self.canvas = canvas
# Here, x,y, and z refer to screen
# coordinates, not image coordinates:
# - x: horizontal
# - y: vertical
# - z: depth
# number of voxels along each axis
self.xdim = image.shape[ canvas.xax]
self.ydim = image.shape[ canvas.yax]
self.zdim = image.shape[ canvas.zax]
# length of a voxel along each axis
self.xlen = image.pixdim[canvas.xax]
self.ylen = image.pixdim[canvas.yax]
self.zlen = image.pixdim[canvas.zax]
# Maximum number of colours used to draw image data # Maximum number of colours used to draw image data
self.colourResolution = 256 self.colourResolution = 256
...@@ -113,7 +97,8 @@ class GLImageData(object): ...@@ -113,7 +97,8 @@ class GLImageData(object):
# times - we are drawing row-wise, and opengl does not # times - we are drawing row-wise, and opengl does not
# allow us to loop over a VBO in a single instance # allow us to loop over a VBO in a single instance
# rendering call # rendering call
voxData[canvas.xax] = np.tile(voxData[canvas.xax], self.ydim) voxData[canvas.xax] = np.tile(voxData[ canvas.xax],
image.shape[canvas.yax])
xBuffer = vbo.VBO(voxData[0], gl.GL_STATIC_DRAW) xBuffer = vbo.VBO(voxData[0], gl.GL_STATIC_DRAW)
yBuffer = vbo.VBO(voxData[1], gl.GL_STATIC_DRAW) yBuffer = vbo.VBO(voxData[1], gl.GL_STATIC_DRAW)
...@@ -121,11 +106,11 @@ class GLImageData(object): ...@@ -121,11 +106,11 @@ class GLImageData(object):
geomBuffer = vbo.VBO(geomData, gl.GL_STATIC_DRAW) geomBuffer = vbo.VBO(geomData, gl.GL_STATIC_DRAW)
self.dataBuffer = self.initImageBuffer() self.dataBuffer = self.initImageBuffer()
self.voxXBuffer = xBuffer self.voxXBuffer = xBuffer
self.voxYBuffer = yBuffer self.voxYBuffer = yBuffer
self.voxZBuffer = zBuffer self.voxZBuffer = zBuffer
self.geomBuffer = geomBuffer self.geomBuffer = geomBuffer
# Add listeners to this image so the view can be # Add listeners to this image so the view can be
# updated when its display properties are changed # updated when its display properties are changed
...@@ -495,12 +480,6 @@ class SliceCanvas(wxgl.GLCanvas): ...@@ -495,12 +480,6 @@ class SliceCanvas(wxgl.GLCanvas):
glData = GLImageData(image, self) glData = GLImageData(image, self)
image.setAttribute(self.name, glData) image.setAttribute(self.name, glData)
print 'bounds: '
print 'X: {} {}'.format(self.xmin, self.xmax)
print 'Y: {} {}'.format(self.ymin, self.ymax)
print 'Z: {} {}'.format(self.zmin, self.zmax)
self.Refresh() self.Refresh()
...@@ -559,7 +538,7 @@ class SliceCanvas(wxgl.GLCanvas): ...@@ -559,7 +538,7 @@ class SliceCanvas(wxgl.GLCanvas):
size = self.GetSize() size = self.GetSize()
# set up 2D drawing # set up 2D orthographic drawing
gl.glViewport(0, 0, size.width, size.height) gl.glViewport(0, 0, size.width, size.height)
gl.glMatrixMode(gl.GL_PROJECTION) gl.glMatrixMode(gl.GL_PROJECTION)
gl.glLoadIdentity() gl.glLoadIdentity()
...@@ -572,6 +551,10 @@ class SliceCanvas(wxgl.GLCanvas): ...@@ -572,6 +551,10 @@ class SliceCanvas(wxgl.GLCanvas):
eye[self.zax] = self.zmax eye[self.zax] = self.zmax
up[ self.yax] = 1 up[ self.yax] = 1
# I don't know why this is necessary :(
if self.zax == 1:
eye[self.zax] = self.zmin
gl.glMatrixMode(gl.GL_MODELVIEW) gl.glMatrixMode(gl.GL_MODELVIEW)
gl.glLoadIdentity() gl.glLoadIdentity()
glu.gluLookAt( glu.gluLookAt(
...@@ -625,9 +608,9 @@ class SliceCanvas(wxgl.GLCanvas): ...@@ -625,9 +608,9 @@ class SliceCanvas(wxgl.GLCanvas):
voxZBuffer = glImageData.voxZBuffer voxZBuffer = glImageData.voxZBuffer
geomBuffer = glImageData.geomBuffer geomBuffer = glImageData.geomBuffer
xdim = glImageData.xdim xdim = image.shape[self.xax]
ydim = glImageData.ydim ydim = image.shape[self.yax]
zdim = glImageData.zdim zdim = image.shape[self.zax]
# Don't draw the slice if this # Don't draw the slice if this
# image display is disabled # image display is disabled
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment