Treat paths like input/output vars

incremental_update_paths
Tyler Goodlet 2022-05-18 08:53:35 -04:00
parent 1dab77ca0b
commit b5b9ecf4b1
1 changed files with 17 additions and 31 deletions

View File

@ -843,6 +843,9 @@ class Flow(msgspec.Struct): # , frozen=True):
# - determine downsampling ops if needed # - determine downsampling ops if needed
# - (incrementally) update ``QPainterPath`` # - (incrementally) update ``QPainterPath``
path = graphics.path
fast_path = graphics.fast_path
if ( if (
use_vr use_vr
# and not self._in_ds # and not self._in_ds
@ -940,21 +943,19 @@ class Flow(msgspec.Struct): # , frozen=True):
should_ds = False should_ds = False
showing_src_data = True showing_src_data = True
# no_path_yet = self.path is None
fast_path = graphics.fast_path
if ( if (
graphics.path is None path is None
or should_redraw or should_redraw
or new_sample_rate or new_sample_rate
or prepend_length > 0 or prepend_length > 0
): ):
if should_redraw: if should_redraw:
if graphics.path: if path:
graphics.path.clear() path.clear()
profiler('cleared paths due to `should_redraw=True`') profiler('cleared paths due to `should_redraw=True`')
if graphics.fast_path: if fast_path:
graphics.fast_path.clear() fast_path.clear()
profiler('cleared paths due to `should_redraw` set') profiler('cleared paths due to `should_redraw` set')
@ -976,12 +977,12 @@ class Flow(msgspec.Struct): # , frozen=True):
profiler(f'FULL PATH downsample redraw={should_ds}') profiler(f'FULL PATH downsample redraw={should_ds}')
self._in_ds = True self._in_ds = True
graphics.path = pg.functions.arrayToQPath( path = pg.functions.arrayToQPath(
x_out, x_out,
y_out, y_out,
connect='all', connect='all',
finiteCheck=False, finiteCheck=False,
path=graphics.path, path=path,
) )
graphics.prepareGeometryChange() graphics.prepareGeometryChange()
profiler( profiler(
@ -1047,7 +1048,7 @@ class Flow(msgspec.Struct): # , frozen=True):
new_y, new_y,
connect='all', connect='all',
finiteCheck=False, finiteCheck=False,
path=graphics.fast_path, path=fast_path,
) )
profiler('generated append qpath') profiler('generated append qpath')
@ -1055,8 +1056,8 @@ class Flow(msgspec.Struct): # , frozen=True):
print("USING FPATH") print("USING FPATH")
# an attempt at trying to make append-updates faster.. # an attempt at trying to make append-updates faster..
if fast_path is None: if fast_path is None:
graphics.fast_path = append_path fast_path = append_path
# self.fast_path.reserve(int(6e3)) # fast_path.reserve(int(6e3))
else: else:
fast_path.connectPath(append_path) fast_path.connectPath(append_path)
size = fast_path.capacity() size = fast_path.capacity()
@ -1073,25 +1074,6 @@ class Flow(msgspec.Struct): # , frozen=True):
profiler(f'connected history path w size: {size}') profiler(f'connected history path w size: {size}')
graphics.path.connectPath(append_path) graphics.path.connectPath(append_path)
# graphics.update_from_array(
# x=x,
# y=y,
# x_iv=x_iv,
# y_iv=y_iv,
# view_range=(ivl, ivr) if use_vr else None,
# # NOTE: already passed through by display loop.
# # do_append=uppx < 16,
# do_append=do_append,
# slice_to_head=slice_to_head,
# should_redraw=should_redraw,
# profiler=profiler,
# **kwargs
# )
if draw_last: if draw_last:
graphics.draw_last(x, y) graphics.draw_last(x, y)
profiler('draw last segment') profiler('draw last segment')
@ -1099,6 +1081,10 @@ class Flow(msgspec.Struct): # , frozen=True):
graphics.update() graphics.update()
profiler('.update()') profiler('.update()')
# assign output paths to graphicis obj
graphics.path = path
graphics.fast_path = fast_path
profiler('`graphics.update_from_array()` complete') profiler('`graphics.update_from_array()` complete')
return graphics return graphics