Corrected use of setGLOptions for image, axis, and box

This commit is contained in:
Luke Campagnola 2013-04-07 09:16:21 -04:00
parent 09bc17bdb5
commit fde4267ccc
5 changed files with 36 additions and 22 deletions

View File

@ -25,11 +25,14 @@ shape = (100,100,70)
data = ndi.gaussian_filter(np.random.normal(size=shape), (4,4,4))
data += ndi.gaussian_filter(np.random.normal(size=shape), (15,15,15))*15
## slice out three planes, convert to ARGB for OpenGL texture
## slice out three planes, convert to RGBA for OpenGL texture
levels = (-0.08, 0.08)
tex1 = pg.makeRGBA(data[shape[0]/2], levels=levels)[0] # yz plane
tex2 = pg.makeRGBA(data[:,shape[1]/2], levels=levels)[0] # xz plane
tex3 = pg.makeRGBA(data[:,:,shape[2]/2], levels=levels)[0] # xy plane
#tex1[:,:,3] = 128
#tex2[:,:,3] = 128
#tex3[:,:,3] = 128
## Create three image items from textures, add to view
v1 = gl.GLImageItem(tex1)

View File

@ -116,11 +116,11 @@ class GLGraphicsItem(QtCore.QObject):
Items with negative depth values are drawn before their parent.
(This is analogous to QGraphicsItem.zValue)
The depthValue does NOT affect the position of the item or the values it imparts to the GL depth buffer.
'"""
"""
self.__depthValue = value
def depthValue(self):
"""Return the depth value of this item. See setDepthValue for mode information."""
"""Return the depth value of this item. See setDepthValue for more information."""
return self.__depthValue
def setTransform(self, tr):
@ -134,9 +134,12 @@ class GLGraphicsItem(QtCore.QObject):
def applyTransform(self, tr, local):
"""
Multiply this object's transform by *tr*.
If local is True, then *tr* is multiplied on the right of the current transform:
If local is True, then *tr* is multiplied on the right of the current transform::
newTransform = transform * tr
If local is False, then *tr* is instead multiplied on the left:
If local is False, then *tr* is instead multiplied on the left::
newTransform = tr * transform
"""
if local:

View File

@ -12,12 +12,13 @@ class GLAxisItem(GLGraphicsItem):
"""
def __init__(self, size=None, antialias=True):
def __init__(self, size=None, antialias=True, glOptions='translucent'):
GLGraphicsItem.__init__(self)
if size is None:
size = QtGui.QVector3D(1,1,1)
self.antialias = antialias
self.setSize(size=size)
self.setGLOptions(glOptions)
def setSize(self, x=None, y=None, z=None, size=None):
"""
@ -37,9 +38,10 @@ class GLAxisItem(GLGraphicsItem):
def paint(self):
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA)
glEnable( GL_BLEND )
glEnable( GL_ALPHA_TEST )
#glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA)
#glEnable( GL_BLEND )
#glEnable( GL_ALPHA_TEST )
self.setupGLState()
if self.antialias:
glEnable(GL_LINE_SMOOTH)

View File

@ -11,7 +11,7 @@ class GLBoxItem(GLGraphicsItem):
Displays a wire-frame box.
"""
def __init__(self, size=None, color=None):
def __init__(self, size=None, color=None, glOptions='translucent'):
GLGraphicsItem.__init__(self)
if size is None:
size = QtGui.QVector3D(1,1,1)
@ -19,6 +19,7 @@ class GLBoxItem(GLGraphicsItem):
if color is None:
color = (255,255,255,80)
self.setColor(color)
self.setGLOptions(glOptions)
def setSize(self, x=None, y=None, z=None, size=None):
"""
@ -43,12 +44,14 @@ class GLBoxItem(GLGraphicsItem):
return self.__color
def paint(self):
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA)
glEnable( GL_BLEND )
glEnable( GL_ALPHA_TEST )
#glAlphaFunc( GL_ALWAYS,0.5 )
glEnable( GL_POINT_SMOOTH )
glDisable( GL_DEPTH_TEST )
#glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA)
#glEnable( GL_BLEND )
#glEnable( GL_ALPHA_TEST )
##glAlphaFunc( GL_ALWAYS,0.5 )
#glEnable( GL_POINT_SMOOTH )
#glDisable( GL_DEPTH_TEST )
self.setupGLState()
glBegin( GL_LINES )
glColor4f(*self.color().glColor())

View File

@ -13,7 +13,7 @@ class GLImageItem(GLGraphicsItem):
"""
def __init__(self, data, smooth=False):
def __init__(self, data, smooth=False, glOptions='translucent'):
"""
============== =======================================================================================
@ -27,6 +27,7 @@ class GLImageItem(GLGraphicsItem):
self.smooth = smooth
self.data = data
GLGraphicsItem.__init__(self)
self.setGLOptions(glOptions)
def initializeGL(self):
glEnable(GL_TEXTURE_2D)
@ -66,11 +67,13 @@ class GLImageItem(GLGraphicsItem):
glEnable(GL_TEXTURE_2D)
glBindTexture(GL_TEXTURE_2D, self.texture)
glEnable(GL_DEPTH_TEST)
#glDisable(GL_CULL_FACE)
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA)
glEnable( GL_BLEND )
glEnable( GL_ALPHA_TEST )
self.setupGLState()
#glEnable(GL_DEPTH_TEST)
##glDisable(GL_CULL_FACE)
#glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA)
#glEnable( GL_BLEND )
#glEnable( GL_ALPHA_TEST )
glColor4f(1,1,1,1)
glBegin(GL_QUADS)