Cache scatter-plot items by hashable properties (#1560)

* Cache scatter-plot items by hashable properties

* use qpainterpath boundingRect+elementCount for key
This commit is contained in:
Ogi Moore 2021-02-08 10:59:51 -08:00 committed by GitHub
parent 6d3de52773
commit 2e1514d711
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -224,7 +224,14 @@ class SymbolAtlas(object):
squareness=1.0 if n == 0 else 2 * w * h / (w**2 + h**2))
def _keys(self, styles):
return [(id(symbol), size, id(pen), id(brush)) for symbol, size, pen, brush in styles]
return [
(
symbol if isinstance(symbol, (str, int)) else f"{symbol.boundingRect()} + {symbol.elementCount()} elements",
size,
(pen.style(), pen.capStyle(), pen.joinStyle()),
(brush.color().rgba(), brush.style())
) for symbol, size, pen, brush in styles
]
def _itemData(self, keys):
for key in keys: