/usr/lib/python2.7/dist-packages/pyqtgraph/opengl/items/GLLinePlotItem.py is in python-pyqtgraph 0.9.10-5.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 | from OpenGL.GL import *
from OpenGL.arrays import vbo
from .. GLGraphicsItem import GLGraphicsItem
from .. import shaders
from ... import QtGui
import numpy as np
__all__ = ['GLLinePlotItem']
class GLLinePlotItem(GLGraphicsItem):
"""Draws line plots in 3D."""
def __init__(self, **kwds):
"""All keyword arguments are passed to setData()"""
GLGraphicsItem.__init__(self)
glopts = kwds.pop('glOptions', 'additive')
self.setGLOptions(glopts)
self.pos = None
self.mode = 'line_strip'
self.width = 1.
self.color = (1.0,1.0,1.0,1.0)
self.setData(**kwds)
def setData(self, **kwds):
"""
Update the data displayed by this item. All arguments are optional;
for example it is allowed to update vertex positions while leaving
colors unchanged, etc.
==================== ==================================================
**Arguments:**
------------------------------------------------------------------------
pos (N,3) array of floats specifying point locations.
color (N,4) array of floats (0.0-1.0) or
tuple of floats specifying
a single color for the entire item.
width float specifying line width
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', 'mode', 'antialias']
for k in kwds.keys():
if k not in args:
raise Exception('Invalid keyword argument: %s (allowed arguments are %s)' % (k, str(args)))
self.antialias = False
for arg in args:
if arg in kwds:
setattr(self, arg, kwds[arg])
#self.vbo.pop(arg, None)
self.update()
def initializeGL(self):
pass
#def setupGLState(self):
#"""Prepare OpenGL state for drawing. This function is called immediately before painting."""
##glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA) ## requires z-sorting to render properly.
#glBlendFunc(GL_SRC_ALPHA, GL_ONE)
#glEnable( GL_BLEND )
#glEnable( GL_ALPHA_TEST )
#glDisable( GL_DEPTH_TEST )
##glEnable( GL_POINT_SMOOTH )
##glHint(GL_POINT_SMOOTH_HINT, GL_NICEST)
##glPointParameterfv(GL_POINT_DISTANCE_ATTENUATION, (0, 0, -1e-3))
##glPointParameterfv(GL_POINT_SIZE_MAX, (65500,))
##glPointParameterfv(GL_POINT_SIZE_MIN, (0,))
def paint(self):
if self.pos is None:
return
self.setupGLState()
glEnableClientState(GL_VERTEX_ARRAY)
try:
glVertexPointerf(self.pos)
if isinstance(self.color, np.ndarray):
glEnableClientState(GL_COLOR_ARRAY)
glColorPointerf(self.color)
else:
if isinstance(self.color, QtGui.QColor):
glColor4f(*fn.glColor(self.color))
else:
glColor4f(*self.color)
glLineWidth(self.width)
#glPointSize(self.width)
if self.antialias:
glEnable(GL_LINE_SMOOTH)
glEnable(GL_BLEND)
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA)
glHint(GL_LINE_SMOOTH_HINT, GL_NICEST)
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:
glDisableClientState(GL_COLOR_ARRAY)
glDisableClientState(GL_VERTEX_ARRAY)
|