added method clear() to GLViewWidget

This commit is contained in:
vladimir-kraus 2016-11-18 14:55:39 +01:00
parent 4cdc3ac7e5
commit 051dfe0d31

View File

@ -15,7 +15,6 @@ class GLViewWidget(QtOpenGL.QGLWidget):
- Rotation/scale controls - Rotation/scale controls
- Axis/grid display - Axis/grid display
- Export options - Export options
""" """
def __init__(self, parent=None): def __init__(self, parent=None):
@ -61,10 +60,21 @@ class GLViewWidget(QtOpenGL.QGLWidget):
self.update() self.update()
def removeItem(self, item): def removeItem(self, item):
"""
Remove the item from the scene.
"""
self.items.remove(item) self.items.remove(item)
item._setView(None) item._setView(None)
self.update() 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): def initializeGL(self):
self.resizeGL(self.width(), self.height()) self.resizeGL(self.width(), self.height())
@ -230,8 +240,6 @@ class GLViewWidget(QtOpenGL.QGLWidget):
self.opts['azimuth'] = azimuth self.opts['azimuth'] = azimuth
self.update() self.update()
def cameraPosition(self): def cameraPosition(self):
"""Return current position of camera based on center, dist, elevation, and azimuth""" """Return current position of camera based on center, dist, elevation, and azimuth"""
center = self.opts['center'] center = self.opts['center']
@ -322,7 +330,6 @@ class GLViewWidget(QtOpenGL.QGLWidget):
#self.paintGL(region=region) #self.paintGL(region=region)
#self.swapBuffers() #self.swapBuffers()
def wheelEvent(self, ev): def wheelEvent(self, ev):
delta = 0 delta = 0
if not USE_PYQT5: if not USE_PYQT5:
@ -386,8 +393,6 @@ class GLViewWidget(QtOpenGL.QGLWidget):
else: else:
raise raise
def readQImage(self): def readQImage(self):
""" """
Read the current buffer pixels out as a QImage. Read the current buffer pixels out as a QImage.
@ -411,7 +416,6 @@ class GLViewWidget(QtOpenGL.QGLWidget):
img = fn.makeQImage(pixels, transpose=False) img = fn.makeQImage(pixels, transpose=False)
return img return img
def renderToArray(self, size, format=GL_BGRA, type=GL_UNSIGNED_BYTE, textureSize=1024, padding=256): def renderToArray(self, size, format=GL_BGRA, type=GL_UNSIGNED_BYTE, textureSize=1024, padding=256):
w,h = map(int, size) w,h = map(int, size)
@ -467,5 +471,3 @@ class GLViewWidget(QtOpenGL.QGLWidget):
return output return output