From 4b22325ffcfef763ce809d228f5b107f4b043b57 Mon Sep 17 00:00:00 2001 From: Tyler Goodlet Date: Wed, 23 Nov 2022 14:15:06 -0500 Subject: [PATCH] Mask profile points and drop rect `.united()` attempts --- piker/ui/_curve.py | 35 ++++++++--------------------------- piker/ui/_ohlc.py | 30 +++++++----------------------- 2 files changed, 15 insertions(+), 50 deletions(-) diff --git a/piker/ui/_curve.py b/piker/ui/_curve.py index def90be8..b9a143a2 100644 --- a/piker/ui/_curve.py +++ b/piker/ui/_curve.py @@ -253,11 +253,11 @@ class Curve(pg.GraphicsObject): Post init ``.boundingRect()```. ''' - profiler = Profiler( - msg=f'Curve.boundingRect(): `{self._name}`', - disabled=not pg_profile_enabled(), - ms_threshold=ms_slower_then, - ) + # profiler = Profiler( + # msg=f'Curve.boundingRect(): `{self._name}`', + # disabled=not pg_profile_enabled(), + # ms_threshold=ms_slower_then, + # ) pr = self.path.controlPointRect() hb_tl, hb_br = ( pr.topLeft(), @@ -267,7 +267,7 @@ class Curve(pg.GraphicsObject): mx_y = hb_br.y() most_left = hb_tl.x() most_right = hb_br.x() - profiler('calc path vertices') + # profiler('calc path vertices') # TODO: if/when we get fast path appends working in the # `Renderer`, then we might need to actually use this.. @@ -298,23 +298,7 @@ class Curve(pg.GraphicsObject): ymx = max(y1, y2, mx_y) most_left = min(x1, x2, most_left) most_right = max(x1, x2, most_right) - - profiler('calc last line vertices') - # ll_br = QRectF( - # x1, - # ymn, - # # NOTE: a legacy snippet, not sure if it still applies? - # # only on a plane line do we include - # # and extra index step's worth of width - # # since in the step case the end of the curve - # # actually terminates earlier so we don't need - # # this for the last step. - # x2 - x1 + 1, - # ymx, - # ) - # br = br.united(ll_br) - # profiler('calc united rects') - # return br + # profiler('calc last line vertices') return QRectF( most_left, @@ -339,7 +323,7 @@ class Curve(pg.GraphicsObject): sub_paint = self.sub_paint if sub_paint: - sub_paint(p, profiler) + sub_paint(p) p.setPen(self.last_step_pen) p.drawLine(self._last_line) @@ -358,7 +342,6 @@ class Curve(pg.GraphicsObject): fp = self.fast_path if fp: - # print("DRAWING PATH") p.drawPath(fp) profiler('.drawPath(fast_path)') @@ -470,13 +453,11 @@ class StepCurve(Curve): def sub_paint( self, p: QPainter, - profiler: Profiler, ) -> None: # p.drawLines(*tuple(filter(bool, self._last_step_lines))) # p.drawRect(self._last_step_rect) p.fillRect(self._last_step_rect, self._brush) - profiler('.fillRect()') # def sub_br( # self, diff --git a/piker/ui/_ohlc.py b/piker/ui/_ohlc.py index 88240b21..b2ff6e10 100644 --- a/piker/ui/_ohlc.py +++ b/piker/ui/_ohlc.py @@ -123,11 +123,11 @@ class BarItems(pg.GraphicsObject): # Qt docs: https://doc.qt.io/qt-5/qgraphicsitem.html#boundingRect def boundingRect(self): - profiler = Profiler( - msg=f'BarItems.boundingRect(): `{self._name}`', - disabled=not pg_profile_enabled(), - ms_threshold=ms_slower_then, - ) + # profiler = Profiler( + # msg=f'BarItems.boundingRect(): `{self._name}`', + # disabled=not pg_profile_enabled(), + # ms_threshold=ms_slower_then, + # ) # TODO: Can we do rect caching to make this faster # like `pg.PlotCurveItem` does? In theory it's just @@ -151,7 +151,7 @@ class BarItems(pg.GraphicsObject): mx_y = hb_br.y() most_left = hb_tl.x() most_right = hb_br.x() - profiler('calc path vertices') + # profiler('calc path vertices') # need to include last bar height or BR will be off # OHLC line segments: [hl, o, c] @@ -171,23 +171,7 @@ class BarItems(pg.GraphicsObject): ymx = max(y1, y2) mx_y = max(ymx, mx_y) mn_y = min(ymn, mn_y) - - profiler('calc last bar vertices') - # TODO: see if this br uniting works faster? - # last_bar_rect = QRectF( - # o.x1(), - # ymn, - # c.x2() - o.x1() + 1, - # ymx, - # ) - # tot_br = hb.united(last_bar_rect) - # print( - # f'last datum bar br: {last_bar_rect}\n' - # f'path br: {hb}\n' - # f'sum br: {tot_br}\n' - # ) - # profiler('calc united rects') - # return tot_br + # profiler('calc last bar vertices') return QRectF( most_left,