Use pixel buffers on axis labels
							parent
							
								
									1e09b0f08f
								
							
						
					
					
						commit
						f3a0b1e91e
					
				|  | @ -22,7 +22,7 @@ from typing import List, Tuple, Optional | |||
| 
 | ||||
| import pandas as pd | ||||
| import pyqtgraph as pg | ||||
| from PyQt5 import QtCore, QtGui | ||||
| from PyQt5 import QtCore, QtGui, QtWidgets | ||||
| from PyQt5.QtCore import QPointF | ||||
| 
 | ||||
| from ._style import DpiAwareFont, hcolor, _font | ||||
|  | @ -44,6 +44,10 @@ class Axis(pg.AxisItem): | |||
|     ) -> None: | ||||
| 
 | ||||
|         super().__init__(**kwargs) | ||||
| 
 | ||||
|         # XXX: pretty sure this makes things slower | ||||
|         # self.setCacheMode(QtGui.QGraphicsItem.DeviceCoordinateCache) | ||||
| 
 | ||||
|         self.linked_charts = linked_charts | ||||
|         self._min_tick = min_tick | ||||
| 
 | ||||
|  | @ -158,9 +162,12 @@ class AxisLabel(pg.GraphicsObject): | |||
|         fg_color: str = 'black', | ||||
|         opacity: int = 0, | ||||
|         font_size_inches: Optional[float] = None, | ||||
|     ): | ||||
|     ) -> None: | ||||
| 
 | ||||
|         super().__init__(parent) | ||||
|         self.setFlag(self.ItemIgnoresTransformations) | ||||
|         # XXX: pretty sure this is faster | ||||
|         self.setCacheMode(QtGui.QGraphicsItem.DeviceCoordinateCache) | ||||
| 
 | ||||
|         self.parent = parent | ||||
|         self.opacity = opacity | ||||
|  | @ -177,7 +184,12 @@ class AxisLabel(pg.GraphicsObject): | |||
| 
 | ||||
|         self.rect = None | ||||
| 
 | ||||
|     def paint(self, p, option, widget): | ||||
|     def paint( | ||||
|         self, | ||||
|         p: QtGui.QPainter, | ||||
|         opt: QtWidgets.QStyleOptionGraphicsItem, | ||||
|         w: QtWidgets.QWidget | ||||
|     ) -> None: | ||||
|         # p.setCompositionMode(QtGui.QPainter.CompositionMode_SourceOver) | ||||
| 
 | ||||
|         if self.label_str: | ||||
|  |  | |||
|  | @ -218,7 +218,6 @@ class CrossHair(pg.GraphicsObject): | |||
|         self.active_plot = None | ||||
|         self.digits = digits | ||||
|         self._lastx = None | ||||
|         # self.setCacheMode(QtGui.QGraphicsItem.DeviceCoordinateCache) | ||||
| 
 | ||||
|     def add_plot( | ||||
|         self, | ||||
|  | @ -240,7 +239,6 @@ class CrossHair(pg.GraphicsObject): | |||
|             opacity=_ch_label_opac, | ||||
|             bg_color='default', | ||||
|         ) | ||||
|         yl.setCacheMode(QtGui.QGraphicsItem.DeviceCoordinateCache) | ||||
|         yl.hide()  # on startup if mouse is off screen | ||||
| 
 | ||||
|         # TODO: checkout what ``.sigDelayed`` can be used for | ||||
|  | @ -283,8 +281,6 @@ class CrossHair(pg.GraphicsObject): | |||
|         ) | ||||
|         # place label off-screen during startup | ||||
|         self.xaxis_label.setPos(self.plots[0].mapFromView(QPointF(0, 0))) | ||||
|         self.xaxis_label.setCacheMode( | ||||
|             QtGui.QGraphicsItem.DeviceCoordinateCache) | ||||
| 
 | ||||
|     def add_curve_cursor( | ||||
|         self, | ||||
|  |  | |||
|  | @ -25,6 +25,7 @@ from PyQt5 import QtCore, QtGui, QtWidgets | |||
| from ..._profile import pg_profile_enabled | ||||
| 
 | ||||
| 
 | ||||
| # TODO: got a feeling that dropping this inheritance gets us even more speedups | ||||
| class FastAppendCurve(pg.PlotCurveItem): | ||||
| 
 | ||||
|     def __init__(self, *args, **kwargs): | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue