Added GLViewWidget.setBackgroundColor()
This commit is contained in:
parent
7d32ef85be
commit
5b6bc6715c
@ -36,6 +36,7 @@ class GLViewWidget(QtOpenGL.QGLWidget):
|
|||||||
## (rotation around z-axis 0 points along x-axis)
|
## (rotation around z-axis 0 points along x-axis)
|
||||||
'viewport': None, ## glViewport params; None == whole widget
|
'viewport': None, ## glViewport params; None == whole widget
|
||||||
}
|
}
|
||||||
|
self.setBackgroundColor('k')
|
||||||
self.items = []
|
self.items = []
|
||||||
self.noRepeatKeys = [QtCore.Qt.Key_Right, QtCore.Qt.Key_Left, QtCore.Qt.Key_Up, QtCore.Qt.Key_Down, QtCore.Qt.Key_PageUp, QtCore.Qt.Key_PageDown]
|
self.noRepeatKeys = [QtCore.Qt.Key_Right, QtCore.Qt.Key_Left, QtCore.Qt.Key_Up, QtCore.Qt.Key_Down, QtCore.Qt.Key_PageUp, QtCore.Qt.Key_PageDown]
|
||||||
self.keysPressed = {}
|
self.keysPressed = {}
|
||||||
@ -64,9 +65,16 @@ class GLViewWidget(QtOpenGL.QGLWidget):
|
|||||||
|
|
||||||
|
|
||||||
def initializeGL(self):
|
def initializeGL(self):
|
||||||
glClearColor(0.0, 0.0, 0.0, 0.0)
|
|
||||||
self.resizeGL(self.width(), self.height())
|
self.resizeGL(self.width(), self.height())
|
||||||
|
|
||||||
|
def setBackgroundColor(self, *args, **kwds):
|
||||||
|
"""
|
||||||
|
Set the background color of the widget. Accepts the same arguments as
|
||||||
|
pg.mkColor().
|
||||||
|
"""
|
||||||
|
self.opts['bgcolor'] = fn.mkColor(*args, **kwds)
|
||||||
|
self.update()
|
||||||
|
|
||||||
def getViewport(self):
|
def getViewport(self):
|
||||||
vp = self.opts['viewport']
|
vp = self.opts['viewport']
|
||||||
if vp is None:
|
if vp is None:
|
||||||
@ -164,6 +172,8 @@ class GLViewWidget(QtOpenGL.QGLWidget):
|
|||||||
glViewport(*viewport)
|
glViewport(*viewport)
|
||||||
self.setProjection(region=region)
|
self.setProjection(region=region)
|
||||||
self.setModelview()
|
self.setModelview()
|
||||||
|
bgcolor = self.opts['bgcolor']
|
||||||
|
glClearColor(bgcolor.red(), bgcolor.green(), bgcolor.blue(), 1.0)
|
||||||
glClear( GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT )
|
glClear( GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT )
|
||||||
self.drawItemTree(useItemNames=useItemNames)
|
self.drawItemTree(useItemNames=useItemNames)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user