fix color ignored in GLGridItem. Issue #283 solved

This commit is contained in:
Vanessa 2018-03-19 12:09:49 +01:00
parent ee0877170d
commit 27f37d0fd1

View File

@ -13,7 +13,7 @@ class GLGridItem(GLGraphicsItem):
Displays a wire-grame grid.
"""
def __init__(self, size=None, color=None, antialias=True, glOptions='translucent'):
def __init__(self, size=None, color=(1, 1, 1, .3), antialias=True, glOptions='translucent'):
GLGraphicsItem.__init__(self)
self.setGLOptions(glOptions)
self.antialias = antialias
@ -21,6 +21,7 @@ class GLGridItem(GLGraphicsItem):
size = QtGui.QVector3D(20,20,1)
self.setSize(size=size)
self.setSpacing(1, 1, 1)
self.color = color
def setSize(self, x=None, y=None, z=None, size=None):
"""
@ -66,8 +67,8 @@ class GLGridItem(GLGraphicsItem):
x,y,z = self.size()
xs,ys,zs = self.spacing()
xvals = np.arange(-x/2., x/2. + xs*0.001, xs)
yvals = np.arange(-y/2., y/2. + ys*0.001, ys)
glColor4f(1, 1, 1, .3)
yvals = np.arange(-y/2., y/2. + ys*0.001, ys)
glColor4f(*self.color)
for x in xvals:
glVertex3f(x, yvals[0], 0)
glVertex3f(x, yvals[-1], 0)