Skip to content

Commit

Permalink
docs(example): Fix SimpleCone/RemoteRendering
Browse files Browse the repository at this point in the history
  • Loading branch information
jourdain committed Jun 7, 2022
1 parent 9e51275 commit 498fd78
Showing 1 changed file with 13 additions and 9 deletions.
22 changes: 13 additions & 9 deletions examples/06_vtk/01_SimpleCone/RemoteRendering.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
state.trame__title = "VTK Remote rendering"

# -----------------------------------------------------------------------------
# VTK code
# Custom / Advanced event handling
# -----------------------------------------------------------------------------

VTK_VIEW_EVENTS = [
Expand Down Expand Up @@ -74,13 +74,21 @@
DEFAULT_RESOLUTION = 6


def on_event(*args, **kwargs):
print("event", args, kwargs)


def event_listeners(events):
result = {}
for event in events:
result[event] = (event, "[utils.vtk.event($event)]")
result[event] = (on_event, "[utils.vtk.event($event)]")
return result


# -----------------------------------------------------------------------------
# VTK code
# -----------------------------------------------------------------------------

renderer = vtkRenderer()
renderWindow = vtkRenderWindow()
renderWindow.AddRenderer(renderer)
Expand Down Expand Up @@ -114,11 +122,6 @@ def update_reset_resolution():
# GUI
# -----------------------------------------------------------------------------


def event(*args, **kwargs):
print("event", args, kwargs)


with SinglePageLayout(server) as layout:
layout.icon.click = ctrl.view_reset_camera
layout.title.set_text("Cone Application")
Expand Down Expand Up @@ -146,8 +149,9 @@ def event(*args, **kwargs):
view = vtk.VtkRemoteView(
renderWindow,
ref="view",
interactor_events=("event_types", VTK_VIEW_EVENTS),
**event_listeners(VTK_VIEW_EVENTS),
# For Custom / Advanced event handling
# interactor_events=("event_types", VTK_VIEW_EVENTS),
# **event_listeners(VTK_VIEW_EVENTS),
)
ctrl.view_update = view.update
ctrl.view_reset_camera = view.reset_camera
Expand Down

0 comments on commit 498fd78

Please sign in to comment.