Corrected use of setGLOptions for image, axis, and box
This commit is contained in:
parent
09bc17bdb5
commit
fde4267ccc
@ -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), (4,4,4))
|
||||||
data += ndi.gaussian_filter(np.random.normal(size=shape), (15,15,15))*15
|
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)
|
levels = (-0.08, 0.08)
|
||||||
tex1 = pg.makeRGBA(data[shape[0]/2], levels=levels)[0] # yz plane
|
tex1 = pg.makeRGBA(data[shape[0]/2], levels=levels)[0] # yz plane
|
||||||
tex2 = pg.makeRGBA(data[:,shape[1]/2], levels=levels)[0] # xz 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
|
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
|
## Create three image items from textures, add to view
|
||||||
v1 = gl.GLImageItem(tex1)
|
v1 = gl.GLImageItem(tex1)
|
||||||
|
@ -116,11 +116,11 @@ class GLGraphicsItem(QtCore.QObject):
|
|||||||
Items with negative depth values are drawn before their parent.
|
Items with negative depth values are drawn before their parent.
|
||||||
(This is analogous to QGraphicsItem.zValue)
|
(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.
|
The depthValue does NOT affect the position of the item or the values it imparts to the GL depth buffer.
|
||||||
'"""
|
"""
|
||||||
self.__depthValue = value
|
self.__depthValue = value
|
||||||
|
|
||||||
def depthValue(self):
|
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
|
return self.__depthValue
|
||||||
|
|
||||||
def setTransform(self, tr):
|
def setTransform(self, tr):
|
||||||
@ -134,9 +134,12 @@ class GLGraphicsItem(QtCore.QObject):
|
|||||||
def applyTransform(self, tr, local):
|
def applyTransform(self, tr, local):
|
||||||
"""
|
"""
|
||||||
Multiply this object's transform by *tr*.
|
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
|
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
|
newTransform = tr * transform
|
||||||
"""
|
"""
|
||||||
if local:
|
if local:
|
||||||
|
@ -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)
|
GLGraphicsItem.__init__(self)
|
||||||
if size is None:
|
if size is None:
|
||||||
size = QtGui.QVector3D(1,1,1)
|
size = QtGui.QVector3D(1,1,1)
|
||||||
self.antialias = antialias
|
self.antialias = antialias
|
||||||
self.setSize(size=size)
|
self.setSize(size=size)
|
||||||
|
self.setGLOptions(glOptions)
|
||||||
|
|
||||||
def setSize(self, x=None, y=None, z=None, size=None):
|
def setSize(self, x=None, y=None, z=None, size=None):
|
||||||
"""
|
"""
|
||||||
@ -37,9 +38,10 @@ class GLAxisItem(GLGraphicsItem):
|
|||||||
|
|
||||||
def paint(self):
|
def paint(self):
|
||||||
|
|
||||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA)
|
#glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA)
|
||||||
glEnable( GL_BLEND )
|
#glEnable( GL_BLEND )
|
||||||
glEnable( GL_ALPHA_TEST )
|
#glEnable( GL_ALPHA_TEST )
|
||||||
|
self.setupGLState()
|
||||||
|
|
||||||
if self.antialias:
|
if self.antialias:
|
||||||
glEnable(GL_LINE_SMOOTH)
|
glEnable(GL_LINE_SMOOTH)
|
||||||
|
@ -11,7 +11,7 @@ class GLBoxItem(GLGraphicsItem):
|
|||||||
|
|
||||||
Displays a wire-frame box.
|
Displays a wire-frame box.
|
||||||
"""
|
"""
|
||||||
def __init__(self, size=None, color=None):
|
def __init__(self, size=None, color=None, glOptions='translucent'):
|
||||||
GLGraphicsItem.__init__(self)
|
GLGraphicsItem.__init__(self)
|
||||||
if size is None:
|
if size is None:
|
||||||
size = QtGui.QVector3D(1,1,1)
|
size = QtGui.QVector3D(1,1,1)
|
||||||
@ -19,6 +19,7 @@ class GLBoxItem(GLGraphicsItem):
|
|||||||
if color is None:
|
if color is None:
|
||||||
color = (255,255,255,80)
|
color = (255,255,255,80)
|
||||||
self.setColor(color)
|
self.setColor(color)
|
||||||
|
self.setGLOptions(glOptions)
|
||||||
|
|
||||||
def setSize(self, x=None, y=None, z=None, size=None):
|
def setSize(self, x=None, y=None, z=None, size=None):
|
||||||
"""
|
"""
|
||||||
@ -43,12 +44,14 @@ class GLBoxItem(GLGraphicsItem):
|
|||||||
return self.__color
|
return self.__color
|
||||||
|
|
||||||
def paint(self):
|
def paint(self):
|
||||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA)
|
#glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA)
|
||||||
glEnable( GL_BLEND )
|
#glEnable( GL_BLEND )
|
||||||
glEnable( GL_ALPHA_TEST )
|
#glEnable( GL_ALPHA_TEST )
|
||||||
#glAlphaFunc( GL_ALWAYS,0.5 )
|
##glAlphaFunc( GL_ALWAYS,0.5 )
|
||||||
glEnable( GL_POINT_SMOOTH )
|
#glEnable( GL_POINT_SMOOTH )
|
||||||
glDisable( GL_DEPTH_TEST )
|
#glDisable( GL_DEPTH_TEST )
|
||||||
|
self.setupGLState()
|
||||||
|
|
||||||
glBegin( GL_LINES )
|
glBegin( GL_LINES )
|
||||||
|
|
||||||
glColor4f(*self.color().glColor())
|
glColor4f(*self.color().glColor())
|
||||||
|
@ -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.smooth = smooth
|
||||||
self.data = data
|
self.data = data
|
||||||
GLGraphicsItem.__init__(self)
|
GLGraphicsItem.__init__(self)
|
||||||
|
self.setGLOptions(glOptions)
|
||||||
|
|
||||||
def initializeGL(self):
|
def initializeGL(self):
|
||||||
glEnable(GL_TEXTURE_2D)
|
glEnable(GL_TEXTURE_2D)
|
||||||
@ -66,11 +67,13 @@ class GLImageItem(GLGraphicsItem):
|
|||||||
glEnable(GL_TEXTURE_2D)
|
glEnable(GL_TEXTURE_2D)
|
||||||
glBindTexture(GL_TEXTURE_2D, self.texture)
|
glBindTexture(GL_TEXTURE_2D, self.texture)
|
||||||
|
|
||||||
glEnable(GL_DEPTH_TEST)
|
self.setupGLState()
|
||||||
#glDisable(GL_CULL_FACE)
|
|
||||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA)
|
#glEnable(GL_DEPTH_TEST)
|
||||||
glEnable( GL_BLEND )
|
##glDisable(GL_CULL_FACE)
|
||||||
glEnable( GL_ALPHA_TEST )
|
#glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA)
|
||||||
|
#glEnable( GL_BLEND )
|
||||||
|
#glEnable( GL_ALPHA_TEST )
|
||||||
glColor4f(1,1,1,1)
|
glColor4f(1,1,1,1)
|
||||||
|
|
||||||
glBegin(GL_QUADS)
|
glBegin(GL_QUADS)
|
||||||
|
Loading…
Reference in New Issue
Block a user