From fde4267ccc420cb3a7f41c7804d3c8812f808e2b Mon Sep 17 00:00:00 2001 From: Luke Campagnola Date: Sun, 7 Apr 2013 09:16:21 -0400 Subject: [PATCH] Corrected use of setGLOptions for image, axis, and box --- examples/GLImageItem.py | 5 ++++- pyqtgraph/opengl/GLGraphicsItem.py | 11 +++++++---- pyqtgraph/opengl/items/GLAxisItem.py | 10 ++++++---- pyqtgraph/opengl/items/GLBoxItem.py | 17 ++++++++++------- pyqtgraph/opengl/items/GLImageItem.py | 15 +++++++++------ 5 files changed, 36 insertions(+), 22 deletions(-) diff --git a/examples/GLImageItem.py b/examples/GLImageItem.py index 8b52ac09..dfdaad0c 100644 --- a/examples/GLImageItem.py +++ b/examples/GLImageItem.py @@ -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) diff --git a/pyqtgraph/opengl/GLGraphicsItem.py b/pyqtgraph/opengl/GLGraphicsItem.py index 9babec3a..f73b0a7a 100644 --- a/pyqtgraph/opengl/GLGraphicsItem.py +++ b/pyqtgraph/opengl/GLGraphicsItem.py @@ -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: diff --git a/pyqtgraph/opengl/items/GLAxisItem.py b/pyqtgraph/opengl/items/GLAxisItem.py index 9dbcd443..860ac497 100644 --- a/pyqtgraph/opengl/items/GLAxisItem.py +++ b/pyqtgraph/opengl/items/GLAxisItem.py @@ -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) diff --git a/pyqtgraph/opengl/items/GLBoxItem.py b/pyqtgraph/opengl/items/GLBoxItem.py index af888e91..bc25afd1 100644 --- a/pyqtgraph/opengl/items/GLBoxItem.py +++ b/pyqtgraph/opengl/items/GLBoxItem.py @@ -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()) diff --git a/pyqtgraph/opengl/items/GLImageItem.py b/pyqtgraph/opengl/items/GLImageItem.py index b292a7b7..aca68f3d 100644 --- a/pyqtgraph/opengl/items/GLImageItem.py +++ b/pyqtgraph/opengl/items/GLImageItem.py @@ -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)