diff --git a/examples/ScatterPlotSpeedTest.py b/examples/ScatterPlotSpeedTest.py index ef6483d7..e0edefca 100644 --- a/examples/ScatterPlotSpeedTest.py +++ b/examples/ScatterPlotSpeedTest.py @@ -27,7 +27,7 @@ param = ptree.Parameter.create(name=translate('ScatterPlot', 'Parameters'), type dict(name='_USE_QRECT', title='_USE_QRECT: ', type='bool', value=pyqtgraph.graphicsItems.ScatterPlotItem._USE_QRECT), dict(name='pxMode', title='pxMode: ', type='bool', value=True), dict(name='useCache', title='useCache: ', type='bool', value=True), - dict(name='mode', title=translate('ScatterPlot', 'Mode: '), type='list', values={'New Item': 'newItem', 'Reuse Item': 'reuseItem', 'Simulate Pan/Zoom': 'panZoom'}, value='reuseItem'), + dict(name='mode', title=translate('ScatterPlot', 'Mode: '), type='list', values={translate('ScatterPlot', 'New Item'): 'newItem', translate('ScatterPlot', 'Reuse Item'): 'reuseItem', translate('ScatterPlot', 'Simulate Pan/Zoom'): 'panZoom', translate('ScatterPlot', 'Simulate Hover'): 'hover'}, value='reuseItem'), ]) for c in param.children(): c.setDefault(c.value()) @@ -42,6 +42,7 @@ splitter.show() data = {} item = pg.ScatterPlotItem() +hoverBrush = pg.mkBrush('y') ptr = 0 lastTime = time() fps = None @@ -88,13 +89,21 @@ def getData(): def update(): global ptr, lastTime, fps - if param['mode'] == 'newItem': + mode = param['mode'] + if mode == 'newItem': mkItem() - elif param['mode'] == 'reuseItem': + elif mode == 'reuseItem': item.setData(**getData()) - elif param['mode'] == 'panZoom': + elif mode == 'panZoom': item.viewTransformChanged() item.update() + elif mode == 'hover': + pts = item.points() + old = pts[(ptr - 1) % len(pts)] + new = pts[ptr % len(pts)] + item.pointsAt(new.pos()) + old.resetBrush() # reset old's brush before setting new's to better simulate hovering + new.setBrush(hoverBrush) ptr += 1 now = time() diff --git a/pyqtgraph/graphicsItems/ScatterPlotItem.py b/pyqtgraph/graphicsItems/ScatterPlotItem.py index 9c235304..3c2b5cd0 100644 --- a/pyqtgraph/graphicsItems/ScatterPlotItem.py +++ b/pyqtgraph/graphicsItems/ScatterPlotItem.py @@ -776,14 +776,21 @@ class ScatterPlotItem(GraphicsObject): mask = dataSet['sourceRect']['w'] == 0 if np.any(mask): invalidate = True - dataSet['sourceRect'][mask] = self.fragmentAtlas[ + coords = self.fragmentAtlas[ list(zip(*self._style(['symbol', 'size', 'pen', 'brush'], data=dataSet, idx=mask))) ] + dataSet['sourceRect'][mask] = coords if _USE_QRECT: - sr = dataSet['sourceRect'][mask] - sru = np.unique(sr) - list(imap(self._sourceQRect.__setitem__, imap(tuple, sru), imap(QtCore.QRectF, *zip(*sru)))) - dataSet['sourceQRect'][mask] = list(imap(self._sourceQRect.__getitem__, imap(tuple, sr))) + rects = [] + for c in coords: + try: + rect = self._sourceQRect[c] + except KeyError: + rect = QtCore.QRectF(*c) + self._sourceQRect[c] = rect + rects.append(rect) + + dataSet['sourceQRect'][mask] = rects dataSet['targetQRectValid'][mask] = False self._maybeRebuildAtlas() diff --git a/pyqtgraph/widgets/GraphicsView.py b/pyqtgraph/widgets/GraphicsView.py index 951d7b04..3054f0e7 100644 --- a/pyqtgraph/widgets/GraphicsView.py +++ b/pyqtgraph/widgets/GraphicsView.py @@ -123,11 +123,6 @@ class GraphicsView(QtGui.QGraphicsView): self.scaleCenter = False ## should scaling center around view center (True) or mouse click (False) self.clickAccepted = False - # Set a transparent background QPalette! - palette = self.palette() - palette.setColor(QtGui.QPalette.Window, QtCore.Qt.transparent) - self.setPalette(palette) - def setAntialiasing(self, aa): """Enable or disable default antialiasing. Note that this will only affect items that do not specify their own antialiasing options.""" diff --git a/pyqtgraph/widgets/tests/test_graphics_view.py b/pyqtgraph/widgets/tests/test_graphics_view.py index a142e10e..0871ee63 100644 --- a/pyqtgraph/widgets/tests/test_graphics_view.py +++ b/pyqtgraph/widgets/tests/test_graphics_view.py @@ -9,10 +9,6 @@ def test_basics_graphics_view(): background_role = view.backgroundRole() assert background_role == QtGui.QPalette.Window - palette = view.palette() - - assert palette.isBrushSet(QtGui.QPalette.Active, QtGui.QPalette.Window) - assert palette.color(QtGui.QPalette.Window) == QtCore.Qt.transparent assert view.backgroundBrush().color() == QtGui.QColor(0, 0, 0, 255) assert view.focusPolicy() == QtCore.Qt.StrongFocus @@ -37,9 +33,6 @@ def test_basics_graphics_view(): # -------------------------------------- view.setBackground("w") assert view._background == "w" - palette = view.palette() - assert palette.isBrushSet(QtGui.QPalette.Active, QtGui.QPalette.Window) - assert palette.color(QtGui.QPalette.Window) == QtCore.Qt.transparent assert view.backgroundBrush().color() == QtCore.Qt.white # Set anti aliasing