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
							parent
							
								
									72a9af21ac
								
							
						
					
					
						commit
						33df4f9927
					
				|  | @ -658,7 +658,11 @@ class Viz(msgspec.Struct):  # , frozen=True): | |||
| 
 | ||||
|         **kwargs, | ||||
| 
 | ||||
|     ) -> pg.GraphicsObject: | ||||
|     ) -> tuple[ | ||||
|         bool, | ||||
|         tuple[int, int], | ||||
|         pg.GraphicsObject, | ||||
|     ]: | ||||
|         ''' | ||||
|         Read latest datums from shm and render to (incrementally) | ||||
|         render to graphics. | ||||
|  | @ -688,8 +692,9 @@ class Viz(msgspec.Struct):  # , frozen=True): | |||
|             not in_view.size | ||||
|             or not render | ||||
|         ): | ||||
|             # print('exiting early') | ||||
|             # print(f'{self.name} not in view (exiting early)') | ||||
|             return ( | ||||
|                 False, | ||||
|                 (ivl, ivr), | ||||
|                 graphics, | ||||
|             ) | ||||
|  | @ -810,6 +815,7 @@ class Viz(msgspec.Struct):  # , frozen=True): | |||
|         if not out: | ||||
|             log.warning(f'{self.name} failed to render!?') | ||||
|             return ( | ||||
|                 False, | ||||
|                 (ivl, ivr), | ||||
|                 graphics, | ||||
|             ) | ||||
|  | @ -865,6 +871,7 @@ class Viz(msgspec.Struct):  # , frozen=True): | |||
|         self._in_ds = r._in_ds | ||||
| 
 | ||||
|         return ( | ||||
|             True, | ||||
|             (ivl, ivr), | ||||
|             graphics, | ||||
|         ) | ||||
|  | @ -1053,7 +1060,9 @@ class Viz(msgspec.Struct):  # , frozen=True): | |||
|                 l_reset = r_reset - rl_diff | ||||
| 
 | ||||
|             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: | ||||
|             # maintain the l->r view distance | ||||
|  |  | |||
|  | @ -557,7 +557,7 @@ def graphics_update_cycle( | |||
|         (liv and do_px_step) | ||||
|         or trigger_all | ||||
|     ): | ||||
|         i_read_range, _ = main_viz.update_graphics() | ||||
|         _, i_read_range, _ = main_viz.update_graphics() | ||||
|         profiler('`Viz.update_graphics()` call') | ||||
| 
 | ||||
|         ( | ||||
|  |  | |||
|  | @ -707,7 +707,7 @@ async def open_vlm_displays( | |||
| 
 | ||||
|         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', | ||||
|         ) | ||||
| 
 | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue