Merge pull request #1212 from erikmansson/fix-pv-cache
Fix PixelVectors cache
This commit is contained in:
commit
2d59ce8532
@ -188,24 +188,23 @@ class GraphicsItem(object):
|
||||
## (such as when looking at unix timestamps), we can get floating-point errors.
|
||||
dt.setMatrix(dt.m11(), dt.m12(), 0, dt.m21(), dt.m22(), 0, 0, 0, 1)
|
||||
|
||||
if direction is None:
|
||||
direction = QtCore.QPointF(1, 0)
|
||||
elif direction.manhattanLength() == 0:
|
||||
raise Exception("Cannot compute pixel length for 0-length vector.")
|
||||
|
||||
key = (dt.m11(), dt.m21(), dt.m12(), dt.m22(), direction.x(), direction.y())
|
||||
|
||||
## check local cache
|
||||
if direction is None and dt == self._pixelVectorCache[0]:
|
||||
if key == self._pixelVectorCache[0]:
|
||||
return tuple(map(Point, self._pixelVectorCache[1])) ## return a *copy*
|
||||
|
||||
|
||||
## check global cache
|
||||
#key = (dt.m11(), dt.m21(), dt.m31(), dt.m12(), dt.m22(), dt.m32(), dt.m31(), dt.m32())
|
||||
key = (dt.m11(), dt.m21(), dt.m12(), dt.m22())
|
||||
pv = self._pixelVectorGlobalCache.get(key, None)
|
||||
if direction is None and pv is not None:
|
||||
self._pixelVectorCache = [dt, pv]
|
||||
if pv is not None:
|
||||
self._pixelVectorCache = [key, pv]
|
||||
return tuple(map(Point,pv)) ## return a *copy*
|
||||
|
||||
|
||||
if direction is None:
|
||||
direction = QtCore.QPointF(1, 0)
|
||||
if direction.manhattanLength() == 0:
|
||||
raise Exception("Cannot compute pixel length for 0-length vector.")
|
||||
|
||||
## attempt to re-scale direction vector to fit within the precision of the coordinate system
|
||||
## Here's the problem: we need to map the vector 'direction' from the item to the device, via transform 'dt'.
|
||||
## In some extreme cases, this mapping can fail unless the length of 'direction' is cleverly chosen.
|
||||
|
Loading…
Reference in New Issue
Block a user