diff --git a/piker/ui/_curve.py b/piker/ui/_curve.py index 01b57c30..7fc43e4e 100644 --- a/piker/ui/_curve.py +++ b/piker/ui/_curve.py @@ -116,6 +116,7 @@ class FastAppendCurve(pg.PlotCurveItem): color: str = 'default_lightest', fill_color: Optional[str] = None, style: str = 'solid', + name: Optional[str] = None, **kwargs @@ -124,7 +125,7 @@ class FastAppendCurve(pg.PlotCurveItem): # TODO: we can probably just dispense with the parent since # we're basically only using the pen setting now... super().__init__(*args, **kwargs) - + self._name = name self._xrange: tuple[int, int] = self.dataBounds(ax=0) # all history of curve is drawn in single px thickness @@ -137,7 +138,9 @@ class FastAppendCurve(pg.PlotCurveItem): self.setPen(pen) # 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_step_rect: QRectF = None @@ -151,7 +154,12 @@ class FastAppendCurve(pg.PlotCurveItem): # interactions slower (such as zooming) and if so maybe if/when # we implement a "history" mode for the view we disable this in # that mode? - self.setCacheMode(QtWidgets.QGraphicsItem.DeviceCoordinateCache) + 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) def update_from_array( self, @@ -261,10 +269,13 @@ class FastAppendCurve(pg.PlotCurveItem): # self.path.connectPath(append_path) path.connectPath(append_path) - # XXX: pretty annoying but, without this there's little - # artefacts on the append updates to the curve... - self.setCacheMode(QtWidgets.QGraphicsItem.NoCache) - self.prepareGeometryChange() + self.disable_cache() + flip_cache = True + + if ( + self._step_mode + ): + self.disable_cache() flip_cache = True # 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). 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): if self.path is None: return QtGui.QPainterPath().boundingRect()