Don't enable curve coord cache unless in step mode
You can get a weird "last line segment" artifact if *only* that segment is drawn and the cache is enabled, so just disable unless in step mode at startup and re-flash as normal when new path data is appended. Add a `.disable_cache()` method for the multi-use in the update method. Use line style on the `._last_line: QLineF` segment as well.windows_fixes_yo
parent
228f21d7b0
commit
71f9b5c000
|
@ -116,6 +116,7 @@ class FastAppendCurve(pg.PlotCurveItem):
|
||||||
color: str = 'default_lightest',
|
color: str = 'default_lightest',
|
||||||
fill_color: Optional[str] = None,
|
fill_color: Optional[str] = None,
|
||||||
style: str = 'solid',
|
style: str = 'solid',
|
||||||
|
name: Optional[str] = None,
|
||||||
|
|
||||||
**kwargs
|
**kwargs
|
||||||
|
|
||||||
|
@ -124,7 +125,7 @@ class FastAppendCurve(pg.PlotCurveItem):
|
||||||
# TODO: we can probably just dispense with the parent since
|
# TODO: we can probably just dispense with the parent since
|
||||||
# we're basically only using the pen setting now...
|
# we're basically only using the pen setting now...
|
||||||
super().__init__(*args, **kwargs)
|
super().__init__(*args, **kwargs)
|
||||||
|
self._name = name
|
||||||
self._xrange: tuple[int, int] = self.dataBounds(ax=0)
|
self._xrange: tuple[int, int] = self.dataBounds(ax=0)
|
||||||
|
|
||||||
# all history of curve is drawn in single px thickness
|
# all history of curve is drawn in single px thickness
|
||||||
|
@ -137,7 +138,9 @@ class FastAppendCurve(pg.PlotCurveItem):
|
||||||
self.setPen(pen)
|
self.setPen(pen)
|
||||||
|
|
||||||
# last segment is drawn in 2px thickness for emphasis
|
# last segment is drawn in 2px thickness for emphasis
|
||||||
self.last_step_pen = pg.mkPen(hcolor(color), width=2)
|
# self.last_step_pen = pg.mkPen(hcolor(color), width=2)
|
||||||
|
self.last_step_pen = pg.mkPen(pen, width=2)
|
||||||
|
|
||||||
self._last_line: QLineF = None
|
self._last_line: QLineF = None
|
||||||
self._last_step_rect: QRectF = None
|
self._last_step_rect: QRectF = None
|
||||||
|
|
||||||
|
@ -151,6 +154,11 @@ class FastAppendCurve(pg.PlotCurveItem):
|
||||||
# interactions slower (such as zooming) and if so maybe if/when
|
# interactions slower (such as zooming) and if so maybe if/when
|
||||||
# we implement a "history" mode for the view we disable this in
|
# we implement a "history" mode for the view we disable this in
|
||||||
# that mode?
|
# that mode?
|
||||||
|
if step_mode:
|
||||||
|
# don't enable caching by default for the case where the
|
||||||
|
# only thing drawn is the "last" line segment which can
|
||||||
|
# have a weird artifact where it won't be fully drawn to its
|
||||||
|
# endpoint (something we saw on trade rate curves)
|
||||||
self.setCacheMode(QtWidgets.QGraphicsItem.DeviceCoordinateCache)
|
self.setCacheMode(QtWidgets.QGraphicsItem.DeviceCoordinateCache)
|
||||||
|
|
||||||
def update_from_array(
|
def update_from_array(
|
||||||
|
@ -261,10 +269,13 @@ class FastAppendCurve(pg.PlotCurveItem):
|
||||||
# self.path.connectPath(append_path)
|
# self.path.connectPath(append_path)
|
||||||
path.connectPath(append_path)
|
path.connectPath(append_path)
|
||||||
|
|
||||||
# XXX: pretty annoying but, without this there's little
|
self.disable_cache()
|
||||||
# artefacts on the append updates to the curve...
|
flip_cache = True
|
||||||
self.setCacheMode(QtWidgets.QGraphicsItem.NoCache)
|
|
||||||
self.prepareGeometryChange()
|
if (
|
||||||
|
self._step_mode
|
||||||
|
):
|
||||||
|
self.disable_cache()
|
||||||
flip_cache = True
|
flip_cache = True
|
||||||
|
|
||||||
# print(f"update br: {self.path.boundingRect()}")
|
# print(f"update br: {self.path.boundingRect()}")
|
||||||
|
@ -304,6 +315,12 @@ class FastAppendCurve(pg.PlotCurveItem):
|
||||||
# XXX: seems to be needed to avoid artifacts (see above).
|
# XXX: seems to be needed to avoid artifacts (see above).
|
||||||
self.setCacheMode(QtWidgets.QGraphicsItem.DeviceCoordinateCache)
|
self.setCacheMode(QtWidgets.QGraphicsItem.DeviceCoordinateCache)
|
||||||
|
|
||||||
|
def disable_cache(self) -> None:
|
||||||
|
# XXX: pretty annoying but, without this there's little
|
||||||
|
# artefacts on the append updates to the curve...
|
||||||
|
self.setCacheMode(QtWidgets.QGraphicsItem.NoCache)
|
||||||
|
self.prepareGeometryChange()
|
||||||
|
|
||||||
def boundingRect(self):
|
def boundingRect(self):
|
||||||
if self.path is None:
|
if self.path is None:
|
||||||
return QtGui.QPainterPath().boundingRect()
|
return QtGui.QPainterPath().boundingRect()
|
||||||
|
|
Loading…
Reference in New Issue