Drop px-cache-resets, failed try at path appends

Comments out the pixel-cache resetting since it doesn't seem we need it
any more to avoid draw oddities?

For `.fast_path` appends, this nearly got it working except the new path
segments are either not being connected correctly (step curve) or not
being drawn in full since the history path (plain line).

Leaving the attempted code commented in for a retry in the future; my
best guesses are that maybe,
- `.connectPath()` call is being done with incorrect segment length
  and/or start point.
- the "appended" data: `appended = array[-append_len-1:slice_to_head]`
  (done inside the formatter) isn't correct (i.e. endpoint handling
  considering a path append) and needs special handling for different
  curve types?
epoch_index_backup
Tyler Goodlet 2022-11-23 14:17:18 -05:00
parent 07714c5cbd
commit 0442945ce5
2 changed files with 65 additions and 32 deletions

View File

@ -565,26 +565,27 @@ class Flow(msgspec.Struct): # , frozen=True):
# XXX: SUPER UGGGHHH... without this we get stale cache # XXX: SUPER UGGGHHH... without this we get stale cache
# graphics that don't update until you downsampler again.. # graphics that don't update until you downsampler again..
if reset: # reset = False
with graphics.reset_cache(): # if reset:
# assign output paths to graphicis obj # with graphics.reset_cache():
graphics.path = r.path # # assign output paths to graphicis obj
graphics.fast_path = r.fast_path # graphics.path = r.path
# graphics.fast_path = r.fast_path
# XXX: we don't need this right? # # XXX: we don't need this right?
# graphics.draw_last_datum( # # graphics.draw_last_datum(
# path, # # path,
# src_array, # # src_array,
# data, # # data,
# reset, # # reset,
# array_key, # # array_key,
# ) # # )
# graphics.update() # # graphics.update()
# profiler('.update()') # # profiler('.update()')
else: # else:
# assign output paths to graphicis obj # assign output paths to graphicis obj
graphics.path = r.path graphics.path = r.path
graphics.fast_path = r.fast_path graphics.fast_path = r.fast_path
graphics.draw_last_datum( graphics.draw_last_datum(
path, path,
@ -810,6 +811,7 @@ class Renderer(msgspec.Struct):
prepend_length, prepend_length,
append_length, append_length,
view_changed, view_changed,
# append_tres,
) = fmt_out ) = fmt_out
@ -817,8 +819,11 @@ class Renderer(msgspec.Struct):
if ( if (
prepend_length > 0 prepend_length > 0
or new_sample_rate or new_sample_rate
or append_length > 0
or view_changed or view_changed
# NOTE: comment this to try and make "append paths"
# work below..
or append_length > 0
): ):
should_redraw = True should_redraw = True
@ -869,7 +874,6 @@ class Renderer(msgspec.Struct):
# TODO: get this piecewise prepend working - right now it's # TODO: get this piecewise prepend working - right now it's
# giving heck on vwap... # giving heck on vwap...
# elif prepend_length: # elif prepend_length:
# breakpoint()
# prepend_path = pg.functions.arrayToQPath( # prepend_path = pg.functions.arrayToQPath(
# x[0:prepend_length], # x[0:prepend_length],
@ -886,18 +890,22 @@ class Renderer(msgspec.Struct):
elif ( elif (
append_length > 0 append_length > 0
and do_append and do_append
and not should_redraw
): ):
print(f'{array_key} append len: {append_length}') print(f'{array_key} append len: {append_length}')
new_x = x_1d[-append_length - 2:] # slice_to_head] # new_x = x_1d[-append_length - 2:] # slice_to_head]
new_y = y_1d[-append_length - 2:] # slice_to_head] # new_y = y_1d[-append_length - 2:] # slice_to_head]
profiler('sliced append path') profiler('sliced append path')
# (
# x_1d,
# y_1d,
# connect,
# ) = append_tres
profiler( profiler(
f'diffed array input, append_length={append_length}' f'diffed array input, append_length={append_length}'
) )
# if should_ds: # if should_ds and uppx > 1:
# new_x, new_y = xy_downsample( # new_x, new_y = xy_downsample(
# new_x, # new_x,
# new_y, # new_y,
@ -906,15 +914,15 @@ class Renderer(msgspec.Struct):
# profiler(f'fast path downsample redraw={should_ds}') # profiler(f'fast path downsample redraw={should_ds}')
append_path = self.draw_path( append_path = self.draw_path(
x=new_x, x=x_1d,
y=new_y, y=y_1d,
connect=connect, connect=connect,
path=fast_path, path=fast_path,
) )
profiler('generated append qpath') profiler('generated append qpath')
if use_fpath: if use_fpath:
print(f'{self.flow.name}: FAST PATH') # print(f'{self.flow.name}: FAST PATH')
# 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:
fast_path = append_path fast_path = append_path
@ -924,7 +932,12 @@ class Renderer(msgspec.Struct):
size = fast_path.capacity() size = fast_path.capacity()
profiler(f'connected fast path w size: {size}') profiler(f'connected fast path w size: {size}')
# print(f"append_path br: {append_path.boundingRect()}") print(
f"append_path br: {append_path.boundingRect()}\n"
f"path size: {size}\n"
f"append_path len: {append_path.length()}\n"
f"fast_path len: {fast_path.length()}\n"
)
# graphics.path.moveTo(new_x[0], new_y[0]) # graphics.path.moveTo(new_x[0], new_y[0])
# path.connectPath(append_path) # path.connectPath(append_path)

View File

@ -355,6 +355,25 @@ class IncrementalFormatter(msgspec.Struct):
view_range, view_range,
) )
# app_tres = None
# if append_len:
# appended = array[-append_len-1:slice_to_head]
# app_tres = self.format_xy_nd_to_1d(
# appended,
# array_key,
# (
# view_range[1] - append_len + slice_to_head,
# view_range[1]
# ),
# )
# # assert (len(appended) - 1) == append_len
# # assert len(appended) == append_len
# print(
# f'{self.flow.name} APPEND LEN: {append_len}\n'
# f'{self.flow.name} APPENDED: {appended}\n'
# f'{self.flow.name} app_tres: {app_tres}\n'
# )
# update the last "in view data range" # update the last "in view data range"
if len(x_1d): if len(x_1d):
self._last_ivdr = x_1d[0], x_1d[slice_to_head] self._last_ivdr = x_1d[0], x_1d[slice_to_head]
@ -373,6 +392,7 @@ class IncrementalFormatter(msgspec.Struct):
prepend_len, prepend_len,
append_len, append_len,
view_changed, view_changed,
# app_tres,
) )
############################### ###############################
@ -767,12 +787,12 @@ class StepCurveFmtr(IncrementalFormatter):
np.ndarray, np.ndarray,
str, str,
]: ]:
lasts = array[['index', array_key]]
last = lasts[array_key][-1]
# 2 more datum-indexes to capture zero at end # 2 more datum-indexes to capture zero at end
x_step = self.x_nd[self.xy_nd_start:self.xy_nd_stop+2] x_step = self.x_nd[self.xy_nd_start:self.xy_nd_stop+2]
y_step = self.y_nd[self.xy_nd_start:self.xy_nd_stop+2] y_step = self.y_nd[self.xy_nd_start:self.xy_nd_stop+2]
lasts = array[['index', array_key]]
last = lasts[array_key][-1]
y_step[-1] = last y_step[-1] = last
# slice out in-view data # slice out in-view data