def refresh_colorbar(self, cb_min, cb_max, width = None, height = None, xMin = None, yMin = None):
""" Refresh the appearance of the colorbar for a changed count range.
@param float cb_min: The minimal count value should be passed here.
@param float cb_max: The maximal count value should be passed here.
@param float width: optional, with that you can change the width of the
colorbar in the display.
"""
if width is None:
width = self.width
else:
self.width = width
# FIXME: Until now, if you want to refresh the colorbar, a new QPainter
# object has been created, but I think that it is not necassary.
# I have to figure out how to use the created object properly.
p = pg.QtGui.QPainter(self.pic)
p.drawRect(self.boundingRect())
p.setPen(pg.mkPen('k'))
grad = pg.QtGui.QLinearGradient(width/2.0, cb_min*1.0, width/2.0, cb_max*1.0)
for stop, color in zip(self.stops, self.colors):
grad.setColorAt(1.0 - stop, pg.QtGui.QColor(*[255*c for c in color]))
p.setBrush(pg.QtGui.QBrush(grad))
if xMin is None:
p.drawRect(pg.QtCore.QRectF(0, cb_min, width, cb_max-cb_min))
else:
# If this picture whants to be set in a plot, which is going to be
# saved:
p.drawRect(pg.QtCore.QRectF(xMin, yMin, width, height))
p.end()
vb = self.getViewBox()
# check whether a viewbox is already created for this object. If yes,
# then it should be adjusted according to the full screen.
if vb is not None:
vb.updateAutoRange()
vb.enableAutoRange()
评论列表
文章目录