From 051dfe0d31b2855b3b6ae9f2f9518448f61b16d7 Mon Sep 17 00:00:00 2001 From: vladimir-kraus Date: Fri, 18 Nov 2016 14:55:39 +0100 Subject: [PATCH] added method clear() to GLViewWidget --- pyqtgraph/opengl/GLViewWidget.py | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/pyqtgraph/opengl/GLViewWidget.py b/pyqtgraph/opengl/GLViewWidget.py index e0fee046..83876ae9 100644 --- a/pyqtgraph/opengl/GLViewWidget.py +++ b/pyqtgraph/opengl/GLViewWidget.py @@ -15,7 +15,6 @@ class GLViewWidget(QtOpenGL.QGLWidget): - Rotation/scale controls - Axis/grid display - Export options - """ def __init__(self, parent=None): @@ -61,10 +60,21 @@ class GLViewWidget(QtOpenGL.QGLWidget): self.update() def removeItem(self, item): + """ + Remove the item from the scene. + """ self.items.remove(item) item._setView(None) self.update() - + + def clear(self): + """ + Remove all items from the scene. + """ + for item in self.items: + item._setView(None) + self.items = [] + self.update() def initializeGL(self): self.resizeGL(self.width(), self.height()) @@ -230,8 +240,6 @@ class GLViewWidget(QtOpenGL.QGLWidget): self.opts['azimuth'] = azimuth self.update() - - def cameraPosition(self): """Return current position of camera based on center, dist, elevation, and azimuth""" center = self.opts['center'] @@ -322,7 +330,6 @@ class GLViewWidget(QtOpenGL.QGLWidget): #self.paintGL(region=region) #self.swapBuffers() - def wheelEvent(self, ev): delta = 0 if not USE_PYQT5: @@ -386,8 +393,6 @@ class GLViewWidget(QtOpenGL.QGLWidget): else: raise - - def readQImage(self): """ Read the current buffer pixels out as a QImage. @@ -411,7 +416,6 @@ class GLViewWidget(QtOpenGL.QGLWidget): img = fn.makeQImage(pixels, transpose=False) return img - def renderToArray(self, size, format=GL_BGRA, type=GL_UNSIGNED_BYTE, textureSize=1024, padding=256): w,h = map(int, size) @@ -466,6 +470,4 @@ class GLViewWidget(QtOpenGL.QGLWidget): glfbo.glDeleteFramebuffers([fb]) return output - - - + \ No newline at end of file