Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 12 additions & 3 deletions src/trame_vtklocal/widgets/vtklocal.py
Original file line number Diff line number Diff line change
Expand Up @@ -209,11 +209,20 @@ def update_throttle(self):
"""
return self._update_throttle

def update(self, push_camera=False):
"""Sync view by pushing updates to client"""
def update(self, push_camera=False, obj_to_update=None):
"""Sync view by pushing updates to client.

:param push_camera: If ``True``, include camera state in the update.
:param obj_to_update: Pass objects registered with :meth:`register_vtk_object`
when you only want to update a specific subset of the scene. When not provided,
the default behavior is to update the render window together with all
registered objects tracked by this view.
"""
if obj_to_update is None:
obj_to_update = [self._render_window, *self.__registered_obj]
self.api.update(
push_camera=push_camera,
obj_to_update=[self._render_window, *self.__registered_obj],
obj_to_update=obj_to_update,

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it ok if it is not a list?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure if the following would be better?

if obj_to_update is None:
    obj_to_update = [self._render_window, *self.__registered_obj]

if not isinstance(obj_to_update, list|tuple):
    obj_to_update = [obj_to_update]

self.api.update(
    push_camera=push_camera,
    obj_to_update=obj_to_update,
)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could also be if not isinstance(obj_to_update, list|tuple): => if isinstance(obj_to_update, str): if those ids are str?

)
self.server.js_call(self.__ref, "update")

Expand Down
Loading