Skip to content

Commit

Permalink
Delay updates to multiscatter if _update_scatter is called without up…
Browse files Browse the repository at this point in the history
…date being called first
  • Loading branch information
astrofrog committed Aug 16, 2024
1 parent 4f0db45 commit 111cfa2
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 19 deletions.
39 changes: 20 additions & 19 deletions glue_vispy_viewers/scatter/layer_artist.py
Original file line number Diff line number Diff line change
Expand Up @@ -315,32 +315,33 @@ def _update_scatter(self, force=False, **kwargs):
self._last_viewer_state.update(self._viewer_state.as_dict())
self._last_layer_state.update(self.state.as_dict())

if force or len(changed & DATA_PROPERTIES) > 0:
self._update_data()
force = True
with self._multiscat.delay_update():

if force or len(changed & DATA_PROPERTIES) > 0:
self._update_data()
force = True

if force or len(changed & SIZE_PROPERTIES) > 0:
self._update_sizes()
if force or len(changed & SIZE_PROPERTIES) > 0:
self._update_sizes()

if force or len(changed & ERROR_PROPERTIES) > 0:
self._update_errors()
if force or len(changed & ERROR_PROPERTIES) > 0:
self._update_errors()

if force or len(changed & VECTOR_PROPERTIES) > 0:
self._update_vectors()
if force or len(changed & VECTOR_PROPERTIES) > 0:
self._update_vectors()

if force or len(changed & COLOR_PROPERTIES) > 0:
self._update_colors()
if force or len(changed & COLOR_PROPERTIES) > 0:
self._update_colors()

if force or len(changed & ALPHA_PROPERTIES) > 0:
self._update_alpha()
if force or len(changed & ALPHA_PROPERTIES) > 0:
self._update_alpha()

if force or len(changed & VISIBLE_PROPERTIES) > 0:
self._update_visibility()
if force or len(changed & VISIBLE_PROPERTIES) > 0:
self._update_visibility()

if force or len(changed & ARROW_PROPERTIES) > 0:
self._update_arrow_head()
if force or len(changed & ARROW_PROPERTIES) > 0:
self._update_arrow_head()

def update(self):
with self._multiscat.delay_update():
self._update_scatter(force=True)
self._update_scatter(force=True)
self.redraw()
5 changes: 5 additions & 0 deletions glue_vispy_viewers/scatter/multi_scatter.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,18 @@ def __init__(self, *args, **kwargs):
self.layers = {}
self._combined_data = None
self._skip_update = False
self._update_called = False
self._error_vector_widget = None
super(MultiColorScatter, self).__init__(*args, **kwargs)

@contextmanager
def delay_update(self):
self._skip_update = True
self._update_called = False
yield
self._skip_update = False
if self._update_called:
self._update()

def allocate(self, label):
if label in self.layers:
Expand Down Expand Up @@ -102,6 +106,7 @@ def update_line_width(self, width):
def _update(self):

if self._skip_update:
self._update_called = True
return

data = []
Expand Down

0 comments on commit 111cfa2

Please sign in to comment.