Add `.x_last()` meth to flow graphics

epoch_indexing_and_dataviz_layer
Tyler Goodlet 2022-12-07 12:22:07 -05:00
parent 98438e29ef
commit e252f70253
2 changed files with 17 additions and 2 deletions

View File

@ -133,7 +133,7 @@ class Curve(pg.GraphicsObject):
# self.last_step_pen = pg.mkPen(hcolor(color), width=2)
self.last_step_pen = pg.mkPen(pen, width=2)
self._last_line = QLineF()
self._last_line: QLineF = QLineF()
# flat-top style histogram-like discrete curve
# self._step_mode: bool = step_mode
@ -182,6 +182,13 @@ class Curve(pg.GraphicsObject):
else:
return 0
def x_last(self) -> float:
'''
Return the last most x value of the last line segment.
'''
return self._last_line.x2()
def px_width(self) -> float:
vb = self.getViewBox()

View File

@ -114,12 +114,20 @@ class BarItems(pg.GraphicsObject):
self.setCacheMode(QtWidgets.QGraphicsItem.DeviceCoordinateCache)
self.path = QPainterPath()
self._last_bar_lines: Optional[tuple[QLineF, ...]] = None
self._last_bar_lines: tuple[QLineF, ...] | None = None
def x_uppx(self) -> int:
# we expect the downsample curve report this.
return 0
def x_last(self) -> float:
'''
Return the last most x value of the close line segment.
'''
return self._last_bar_lines[-1].x2()
# Qt docs: https://doc.qt.io/qt-5/qgraphicsitem.html#boundingRect
def boundingRect(self):
# profiler = Profiler(