def _plotPendingDataPoints(self):
pm=self.graphPixmap
penw=self._penWidth
points=self._pendingPoints
# Return if nothing to plot
if (len(points)==0): return
# Wait for lock on the list
# Plot only if we can lock the graph mutex
if (not(self._plotPointsMutex.tryLock())):
return
# Amount of pixels to scroll
scroll=penw*len(points)
# The first point is not plotted now, so don't shift the graph for it
if (self.firstPoint()):
scroll-=1
p.setPen(QtCore.Qt.NoPen)
# Scroll graph and fill in new area
pm.scroll(0-scroll, 0, scroll, 0, pm.width()-scroll, pm.height())
p.drawRect(pm.width()-scroll, 0, scroll, pm.height())
# Turn on antialiasing
p.
setRenderHint(QtGui.
QPainter.
Antialiasing)
# Set up pen for drawing lines
pen.setWidth(penw)
p.setPen(pen)
offset=scroll
for point in points:
yValNew = self.graphHeight - (self.scalePoint(point))
# Skip first point
if (not(self.firstPoint())):
p.drawLine(pm.width()-offset-penw, self.yVal, pm.width()-offset, yValNew)
self.yVal = yValNew
offset-=penw
# Queue update
self.update()
# Clear pending points
self._pendingPoints=[]
# Unlock the mutex
self._plotPointsMutex.unlock()
def _plotPendingDataPoints(self):
pm=self.graphPixmap
penw=self._penWidth
points=self._pendingPoints
# Return if nothing to plot
if (len(points)==0): return
# Wait for lock on the list
_ml=QtCore.QMutexLocker(self._pendingPointsMutex)
# Plot only if we can lock the graph mutex
if (not(self._plotPointsMutex.tryLock())):
return
# Amount of pixels to scroll
scroll=penw*len(points)
# The first point is not plotted now, so don't shift the graph for it
if (self.firstPoint()):
scroll-=1
p=QtGui.QPainter(pm)
p.setBrush(QtGui.QBrush(QtGui.QColor("white")))
p.setPen(QtCore.Qt.NoPen)
# Scroll graph and fill in new area
pm.scroll(0-scroll, 0, scroll, 0, pm.width()-scroll, pm.height())
p.drawRect(pm.width()-scroll, 0, scroll, pm.height())
# Turn on antialiasing
p.setRenderHint(QtGui.QPainter.Antialiasing)
# Set up pen for drawing lines
pen = QtGui.QPen(QtGui.QColor("black"))
pen.setWidth(penw)
p.setPen(pen)
offset=scroll
for point in points:
yValNew = self.graphHeight - (self.scalePoint(point))
# Skip first point
if (not(self.firstPoint())):
p.drawLine(pm.width()-offset-penw, self.yVal, pm.width()-offset, yValNew)
self.yVal = yValNew
offset-=penw
# Queue update
self.update()
# Clear pending points
self._pendingPoints=[]
# Unlock the mutex
self._plotPointsMutex.unlock()
To copy to clipboard, switch view to plain text mode
Bookmarks