Fixed bugs / style issues to please Lord Travis Squashed commit of the following: commitf25048a1e1
Author: Luke Campagnola <luke.campagnola@gmail.com> Date: Sun Mar 30 02:40:47 2014 -0400 syntax commitcc8b69695a
Author: Luke Campagnola <luke.campagnola@gmail.com> Date: Sun Mar 30 02:36:49 2014 -0400 add size check, diff style check commit5d5ea065a4
Author: Luke Campagnola <luke.campagnola@gmail.com> Date: Sun Mar 30 02:16:05 2014 -0400 travis fix commitb154c6d997
Author: Luke Campagnola <luke.campagnola@gmail.com> Date: Sun Mar 30 02:09:41 2014 -0400 travis, flake colored output commit46921dcd87
Author: Luke Campagnola <luke.campagnola@gmail.com> Date: Wed Mar 26 12:37:54 2014 -0400 fix pyside+py3 bugs to satisfy CI commit1d30f3c5c7
Author: Luke Campagnola <luke.campagnola@gmail.com> Date: Wed Mar 26 11:13:18 2014 -0400 fix py3 tests commit426578fa4c
Author: Luke Campagnola <luke.campagnola@gmail.com> Date: Wed Mar 26 07:39:19 2014 -0400 fix pytest install commit88a13c1a71
Author: Luke Campagnola <luke.campagnola@gmail.com> Date: Wed Mar 26 00:29:29 2014 -0400 qt5 updates commit51995488cc
Author: Luke Campagnola <luke.campagnola@gmail.com> Date: Wed Mar 26 00:16:04 2014 -0400 correct py.test command for py3 commite2b02fbcbd
Author: Luke Campagnola <luke.campagnola@gmail.com> Date: Tue Mar 25 23:50:38 2014 -0400 fix 2nd install test commit4b3e3ee04a
Author: Luke Campagnola <luke.campagnola@gmail.com> Date: Tue Mar 25 23:31:31 2014 -0400 syntax error commit250eabdb34
Author: Luke Campagnola <luke.campagnola@gmail.com> Date: Tue Mar 25 23:13:42 2014 -0400 look for py.test3 commit9f9bca47c1
Author: Luke Campagnola <luke.campagnola@gmail.com> Date: Tue Mar 25 22:54:19 2014 -0400 fix syntax commit0a871c6f36
Author: Luke Campagnola <luke.campagnola@gmail.com> Date: Tue Mar 25 22:47:58 2014 -0400 output pip build log commitdbce58d8cd
Author: Luke Campagnola <luke.campagnola@gmail.com> Date: Tue Mar 25 22:38:55 2014 -0400 no comments allowed between shall lines commitb79c06121d
Author: Luke Campagnola <luke.campagnola@gmail.com> Date: Tue Mar 25 20:56:35 2014 -0400 another pip try commit09f4f5d82a
Author: Luke Campagnola <luke.campagnola@gmail.com> Date: Tue Mar 25 13:36:09 2014 -0400 pip correction commit0eedb5c18e
Author: Luke Campagnola <luke.campagnola@gmail.com> Date: Tue Mar 25 13:29:00 2014 -0400 correct py version output commitd9fd039be2
Author: Luke Campagnola <luke.campagnola@gmail.com> Date: Tue Mar 25 11:55:43 2014 -0400 apt checks commitcf95ccef86
Author: Luke Campagnola <luke.campagnola@gmail.com> Date: Tue Mar 25 10:23:10 2014 -0400 alternate pip install method commitbee0bcddfe
Author: Luke Campagnola <luke.campagnola@gmail.com> Date: Mon Mar 24 23:51:45 2014 -0400 correct deps install commit963a4211fc
Author: Luke Campagnola <luke.campagnola@gmail.com> Date: Mon Mar 24 23:47:30 2014 -0400 fixes commit0c86cd1dc2
Author: Luke Campagnola <luke.campagnola@gmail.com> Date: Mon Mar 24 23:31:06 2014 -0400 permission fix commit5d04ef53b8
Author: Luke Campagnola <luke.campagnola@gmail.com> Date: Mon Mar 24 23:30:19 2014 -0400 Fix py.test version selection commitb0e6c7cb94
Author: Luke Campagnola <luke.campagnola@gmail.com> Date: Mon Mar 24 23:25:34 2014 -0400 try another pyqt5 install method commit422a792866
Author: Luke Campagnola <luke.campagnola@gmail.com> Date: Mon Mar 24 23:12:36 2014 -0400 syntax error commit533133905a
Author: Luke Campagnola <luke.campagnola@gmail.com> Date: Mon Mar 24 23:04:37 2014 -0400 fixes commit8d65211ba4
Author: Luke Campagnola <luke.campagnola@gmail.com> Date: Mon Mar 24 22:40:18 2014 -0400 Add Qt5 test minor fixes commit4484efaefe
Author: Luke Campagnola <luke.campagnola@gmail.com> Date: Mon Mar 24 22:31:56 2014 -0400 use correct py.test for python version commit5d2441a29b
Author: Luke Campagnola <luke.campagnola@gmail.com> Date: Mon Mar 24 22:24:27 2014 -0400 add setup tests commit9291db64f2
Author: Luke Campagnola <luke.campagnola@gmail.com> Date: Mon Mar 24 21:48:43 2014 -0400 fix py3-pyqt install commita7aa675c5a
Author: Luke Campagnola <luke.campagnola@gmail.com> Date: Mon Mar 24 21:31:33 2014 -0400 travis tests commite71cd2b23a
Author: Luke Campagnola <luke.campagnola@gmail.com> Date: Mon Mar 24 21:17:15 2014 -0400 more corrections commit527df3bca8
Author: Luke Campagnola <luke.campagnola@gmail.com> Date: Mon Mar 24 20:56:01 2014 -0400 travis corrections commit87d65cac4a
Author: Luke Campagnola <luke.campagnola@gmail.com> Date: Mon Mar 24 20:48:02 2014 -0400 Add flake tests Correct style in a few files to please Lord Travis commit537028f88f
Author: Luke Campagnola <luke.campagnola@gmail.com> Date: Mon Mar 24 17:36:24 2014 -0400 minimize pyside package install correct line endings to satisfy Lord Travis commit1e3cc95e37
Author: Luke Campagnola <luke.campagnola@gmail.com> Date: Mon Mar 24 17:23:03 2014 -0400 enable pyside, line ending check fix test commitd7df4517f9
Author: Luke Campagnola <luke.campagnola@gmail.com> Date: Mon Mar 24 17:12:06 2014 -0400 syntax fix commit1ad77a2155
Author: Luke Campagnola <luke.campagnola@gmail.com> Date: Mon Mar 24 17:00:30 2014 -0400 alt. pytest install commit5edcc02072
Author: Luke Campagnola <luke.campagnola@gmail.com> Date: Mon Mar 24 16:52:33 2014 -0400 Added initial travis.yml
113 lines
4.3 KiB
Python
113 lines
4.3 KiB
Python
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)
|
|
|
|
|