Mask profile points and drop rect `.united()` attempts
parent
f139e4f273
commit
07714c5cbd
|
@ -253,11 +253,11 @@ class Curve(pg.GraphicsObject):
|
||||||
Post init ``.boundingRect()```.
|
Post init ``.boundingRect()```.
|
||||||
|
|
||||||
'''
|
'''
|
||||||
profiler = Profiler(
|
# profiler = Profiler(
|
||||||
msg=f'Curve.boundingRect(): `{self._name}`',
|
# msg=f'Curve.boundingRect(): `{self._name}`',
|
||||||
disabled=not pg_profile_enabled(),
|
# disabled=not pg_profile_enabled(),
|
||||||
ms_threshold=ms_slower_then,
|
# ms_threshold=ms_slower_then,
|
||||||
)
|
# )
|
||||||
pr = self.path.controlPointRect()
|
pr = self.path.controlPointRect()
|
||||||
hb_tl, hb_br = (
|
hb_tl, hb_br = (
|
||||||
pr.topLeft(),
|
pr.topLeft(),
|
||||||
|
@ -267,7 +267,7 @@ class Curve(pg.GraphicsObject):
|
||||||
mx_y = hb_br.y()
|
mx_y = hb_br.y()
|
||||||
most_left = hb_tl.x()
|
most_left = hb_tl.x()
|
||||||
most_right = hb_br.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
|
# TODO: if/when we get fast path appends working in the
|
||||||
# `Renderer`, then we might need to actually use this..
|
# `Renderer`, then we might need to actually use this..
|
||||||
|
@ -298,23 +298,7 @@ class Curve(pg.GraphicsObject):
|
||||||
ymx = max(y1, y2, mx_y)
|
ymx = max(y1, y2, mx_y)
|
||||||
most_left = min(x1, x2, most_left)
|
most_left = min(x1, x2, most_left)
|
||||||
most_right = max(x1, x2, most_right)
|
most_right = max(x1, x2, most_right)
|
||||||
|
# profiler('calc last line vertices')
|
||||||
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
|
|
||||||
|
|
||||||
return QRectF(
|
return QRectF(
|
||||||
most_left,
|
most_left,
|
||||||
|
@ -339,7 +323,7 @@ class Curve(pg.GraphicsObject):
|
||||||
|
|
||||||
sub_paint = self.sub_paint
|
sub_paint = self.sub_paint
|
||||||
if sub_paint:
|
if sub_paint:
|
||||||
sub_paint(p, profiler)
|
sub_paint(p)
|
||||||
|
|
||||||
p.setPen(self.last_step_pen)
|
p.setPen(self.last_step_pen)
|
||||||
p.drawLine(self._last_line)
|
p.drawLine(self._last_line)
|
||||||
|
@ -358,7 +342,6 @@ class Curve(pg.GraphicsObject):
|
||||||
|
|
||||||
fp = self.fast_path
|
fp = self.fast_path
|
||||||
if fp:
|
if fp:
|
||||||
# print("DRAWING PATH")
|
|
||||||
p.drawPath(fp)
|
p.drawPath(fp)
|
||||||
profiler('.drawPath(fast_path)')
|
profiler('.drawPath(fast_path)')
|
||||||
|
|
||||||
|
@ -470,13 +453,11 @@ class StepCurve(Curve):
|
||||||
def sub_paint(
|
def sub_paint(
|
||||||
self,
|
self,
|
||||||
p: QPainter,
|
p: QPainter,
|
||||||
profiler: Profiler,
|
|
||||||
|
|
||||||
) -> None:
|
) -> None:
|
||||||
# p.drawLines(*tuple(filter(bool, self._last_step_lines)))
|
# p.drawLines(*tuple(filter(bool, self._last_step_lines)))
|
||||||
# p.drawRect(self._last_step_rect)
|
# p.drawRect(self._last_step_rect)
|
||||||
p.fillRect(self._last_step_rect, self._brush)
|
p.fillRect(self._last_step_rect, self._brush)
|
||||||
profiler('.fillRect()')
|
|
||||||
|
|
||||||
# def sub_br(
|
# def sub_br(
|
||||||
# self,
|
# self,
|
||||||
|
|
|
@ -123,11 +123,11 @@ class BarItems(pg.GraphicsObject):
|
||||||
|
|
||||||
# Qt docs: https://doc.qt.io/qt-5/qgraphicsitem.html#boundingRect
|
# Qt docs: https://doc.qt.io/qt-5/qgraphicsitem.html#boundingRect
|
||||||
def boundingRect(self):
|
def boundingRect(self):
|
||||||
profiler = Profiler(
|
# profiler = Profiler(
|
||||||
msg=f'BarItems.boundingRect(): `{self._name}`',
|
# msg=f'BarItems.boundingRect(): `{self._name}`',
|
||||||
disabled=not pg_profile_enabled(),
|
# disabled=not pg_profile_enabled(),
|
||||||
ms_threshold=ms_slower_then,
|
# ms_threshold=ms_slower_then,
|
||||||
)
|
# )
|
||||||
|
|
||||||
# TODO: Can we do rect caching to make this faster
|
# TODO: Can we do rect caching to make this faster
|
||||||
# like `pg.PlotCurveItem` does? In theory it's just
|
# like `pg.PlotCurveItem` does? In theory it's just
|
||||||
|
@ -151,7 +151,7 @@ class BarItems(pg.GraphicsObject):
|
||||||
mx_y = hb_br.y()
|
mx_y = hb_br.y()
|
||||||
most_left = hb_tl.x()
|
most_left = hb_tl.x()
|
||||||
most_right = hb_br.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
|
# need to include last bar height or BR will be off
|
||||||
# OHLC line segments: [hl, o, c]
|
# OHLC line segments: [hl, o, c]
|
||||||
|
@ -171,23 +171,7 @@ class BarItems(pg.GraphicsObject):
|
||||||
ymx = max(y1, y2)
|
ymx = max(y1, y2)
|
||||||
mx_y = max(ymx, mx_y)
|
mx_y = max(ymx, mx_y)
|
||||||
mn_y = min(ymn, mn_y)
|
mn_y = min(ymn, mn_y)
|
||||||
|
# profiler('calc last bar vertices')
|
||||||
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
|
|
||||||
|
|
||||||
return QRectF(
|
return QRectF(
|
||||||
most_left,
|
most_left,
|
||||||
|
|
Loading…
Reference in New Issue