Added GLVolumeItem.setData

This commit is contained in:
Luke Campagnola 2014-06-20 23:04:21 -04:00
parent 9a5e526c61
commit 3c2d1d4a0d
2 changed files with 23 additions and 5 deletions

View File

@ -53,6 +53,7 @@ pyqtgraph-0.9.9 [unreleased]
- Added ViewBox.invertX()
- Docks now have optional close button
- Added InfiniteLine.setHoverPen
- Added GLVolumeItem.setData
Bugfixes:
- PlotCurveItem now has correct clicking behavior--clicks within a few px

View File

@ -2,6 +2,7 @@ from OpenGL.GL import *
from .. GLGraphicsItem import GLGraphicsItem
from ...Qt import QtGui
import numpy as np
from ... import debug
__all__ = ['GLVolumeItem']
@ -25,13 +26,22 @@ class GLVolumeItem(GLGraphicsItem):
self.sliceDensity = sliceDensity
self.smooth = smooth
self.data = data
self.data = None
self._needUpload = False
self.texture = None
GLGraphicsItem.__init__(self)
self.setGLOptions(glOptions)
self.setData(data)
def initializeGL(self):
def setData(self, data):
self.data = data
self._needUpload = True
self.update()
def _uploadData(self):
glEnable(GL_TEXTURE_3D)
self.texture = glGenTextures(1)
if self.texture is None:
self.texture = glGenTextures(1)
glBindTexture(GL_TEXTURE_3D, self.texture)
if self.smooth:
glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_MIN_FILTER, GL_LINEAR)
@ -60,9 +70,16 @@ class GLVolumeItem(GLGraphicsItem):
glNewList(l, GL_COMPILE)
self.drawVolume(ax, d)
glEndList()
self._needUpload = False
def paint(self):
if self.data is None:
return
if self._needUpload:
self._uploadData()
self.setupGLState()
glEnable(GL_TEXTURE_3D)