Return `in_view: bool` from `Viz.update_graphics()`

Allows callers to know if they should care about a particular viz
rendering call by immediately knowing if the graphics are in view. This
turns out super useful particularly when doing dynamic y-ranging overlay
calcs.
overlays_interaction_latency_tuning
Tyler Goodlet 2023-01-22 15:45:56 -05:00
parent 72a9af21ac
commit 33df4f9927
3 changed files with 14 additions and 5 deletions

View File

@ -658,7 +658,11 @@ class Viz(msgspec.Struct): # , frozen=True):
**kwargs, **kwargs,
) -> pg.GraphicsObject: ) -> tuple[
bool,
tuple[int, int],
pg.GraphicsObject,
]:
''' '''
Read latest datums from shm and render to (incrementally) Read latest datums from shm and render to (incrementally)
render to graphics. render to graphics.
@ -688,8 +692,9 @@ class Viz(msgspec.Struct): # , frozen=True):
not in_view.size not in_view.size
or not render or not render
): ):
# print('exiting early') # print(f'{self.name} not in view (exiting early)')
return ( return (
False,
(ivl, ivr), (ivl, ivr),
graphics, graphics,
) )
@ -810,6 +815,7 @@ class Viz(msgspec.Struct): # , frozen=True):
if not out: if not out:
log.warning(f'{self.name} failed to render!?') log.warning(f'{self.name} failed to render!?')
return ( return (
False,
(ivl, ivr), (ivl, ivr),
graphics, graphics,
) )
@ -865,6 +871,7 @@ class Viz(msgspec.Struct): # , frozen=True):
self._in_ds = r._in_ds self._in_ds = r._in_ds
return ( return (
True,
(ivl, ivr), (ivl, ivr),
graphics, graphics,
) )
@ -1053,7 +1060,9 @@ class Viz(msgspec.Struct): # , frozen=True):
l_reset = r_reset - rl_diff l_reset = r_reset - rl_diff
else: else:
raise RuntimeError(f'Unknown view state {vl} -> {vr}') log.warning(f'Unknown view state {vl} -> {vr}')
# return
# raise RuntimeError(f'Unknown view state {vl} -> {vr}')
else: else:
# maintain the l->r view distance # maintain the l->r view distance

View File

@ -557,7 +557,7 @@ def graphics_update_cycle(
(liv and do_px_step) (liv and do_px_step)
or trigger_all or trigger_all
): ):
i_read_range, _ = main_viz.update_graphics() _, i_read_range, _ = main_viz.update_graphics()
profiler('`Viz.update_graphics()` call') profiler('`Viz.update_graphics()` call')
( (

View File

@ -707,7 +707,7 @@ async def open_vlm_displays(
last_val_sticky.update_from_data(-1, value) last_val_sticky.update_from_data(-1, value)
_, vlm_curve = vlm_chart.update_graphics_from_flow( _, _, vlm_curve = vlm_chart.update_graphics_from_flow(
'volume', 'volume',
) )