Added support for GL_LINES in GLLinePlotItem
This commit is contained in:
parent
5488f9ec84
commit
c8ee4a86be
@ -16,6 +16,7 @@ class GLLinePlotItem(GLGraphicsItem):
|
|||||||
glopts = kwds.pop('glOptions', 'additive')
|
glopts = kwds.pop('glOptions', 'additive')
|
||||||
self.setGLOptions(glopts)
|
self.setGLOptions(glopts)
|
||||||
self.pos = None
|
self.pos = None
|
||||||
|
self.mode = 'line_strip'
|
||||||
self.width = 1.
|
self.width = 1.
|
||||||
self.color = (1.0,1.0,1.0,1.0)
|
self.color = (1.0,1.0,1.0,1.0)
|
||||||
self.setData(**kwds)
|
self.setData(**kwds)
|
||||||
@ -35,9 +36,13 @@ class GLLinePlotItem(GLGraphicsItem):
|
|||||||
a single color for the entire item.
|
a single color for the entire item.
|
||||||
width float specifying line width
|
width float specifying line width
|
||||||
antialias enables smooth line drawing
|
antialias enables smooth line drawing
|
||||||
|
mode 'lines': Each pair of vertexes draws a single line
|
||||||
|
segment.
|
||||||
|
'line_strip': All vertexes are drawn as a
|
||||||
|
continuous set of line segments.
|
||||||
==================== ==================================================
|
==================== ==================================================
|
||||||
"""
|
"""
|
||||||
args = ['pos', 'color', 'width', 'connected', 'antialias']
|
args = ['pos', 'color', 'width', 'mode', 'antialias']
|
||||||
for k in kwds.keys():
|
for k in kwds.keys():
|
||||||
if k not in args:
|
if k not in args:
|
||||||
raise Exception('Invalid keyword argument: %s (allowed arguments are %s)' % (k, str(args)))
|
raise Exception('Invalid keyword argument: %s (allowed arguments are %s)' % (k, str(args)))
|
||||||
@ -93,7 +98,13 @@ class GLLinePlotItem(GLGraphicsItem):
|
|||||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA)
|
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA)
|
||||||
glHint(GL_LINE_SMOOTH_HINT, GL_NICEST);
|
glHint(GL_LINE_SMOOTH_HINT, GL_NICEST);
|
||||||
|
|
||||||
glDrawArrays(GL_LINE_STRIP, 0, int(self.pos.size / self.pos.shape[-1]))
|
if self.mode == 'line_strip':
|
||||||
|
glDrawArrays(GL_LINE_STRIP, 0, int(self.pos.size / self.pos.shape[-1]))
|
||||||
|
elif self.mode == 'lines':
|
||||||
|
glDrawArrays(GL_LINES, 0, int(self.pos.size / self.pos.shape[-1]))
|
||||||
|
else:
|
||||||
|
raise Exception("Unknown line mode '%s'. (must be 'lines' or 'line_strip')" % self.mode)
|
||||||
|
|
||||||
finally:
|
finally:
|
||||||
glDisableClientState(GL_COLOR_ARRAY)
|
glDisableClientState(GL_COLOR_ARRAY)
|
||||||
glDisableClientState(GL_VERTEX_ARRAY)
|
glDisableClientState(GL_VERTEX_ARRAY)
|
||||||
|
Loading…
Reference in New Issue
Block a user