Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

view_update might be throttling? #52

Open
banesullivan-kobold opened this issue Oct 24, 2023 · 3 comments
Open

view_update might be throttling? #52

banesullivan-kobold opened this issue Oct 24, 2023 · 3 comments

Comments

@banesullivan-kobold
Copy link

banesullivan-kobold commented Oct 24, 2023

I'm experiencing an issue where calling view_update() for VtkRemoteView does not always work. It seems like the call might be throttled?

It results in a clunky user interface in this slicing example. After moving the plane widget in the scene on the left, the scene on the right should immediately update. However it does not always update, sometimes requireing a user-click in either of the two views for the one on the right to update

import pyvista as pv
from trame.app import get_server
from trame.ui.vuetify import SinglePageLayout
from trame.widgets import vtk as vtk_widgets
from trame.widgets import vuetify

pv.OFF_SCREEN = True

server = get_server()
state, ctrl = server.state, server.controller

state.trame__title = "Multi Plotters"


mesh = pv.Wavelet()

pl1 = pv.Plotter()
pl1.add_mesh(mesh.contour())
pl1.reset_camera()

pl2 = pv.Plotter()
pl2.add_mesh(mesh.outline(), color='black')
pl2.reset_camera()

def my_callback(normal, origin):
    pl2.add_mesh(mesh.slice(normal, origin), name="slice")
    ctrl.view2_update()  # <-- is this being throttled?

pl1.add_plane_widget(my_callback)


with SinglePageLayout(server) as layout:
    layout.title.set_text("Multi Views")
    layout.icon.click = ctrl.view_reset_camera

    with layout.content:
        with vuetify.VContainer(
            fluid=True,
            classes="pa-0 fill-height",
        ):
            with vuetify.VCol(classes="pa-0 fill-height"):
                view = vtk_widgets.VtkRemoteView(pl1.render_window, ref="view1")
                ctrl.view1_update = view.update
            with vuetify.VCol(classes="pa-0 fill-height"):
                view = vtk_widgets.VtkRemoteView(pl2.render_window, ref="view2")
                ctrl.view2_update = view.update

server.start()
view-update.mov
@jourdain
Copy link
Collaborator

So it is a timing issue. Both views end up in animation, which makes the view.update() a NoOp. But then the animation get canceled before the encoding queue get fully flushed/consumed.

Can you make the callback happen when you actually drag the widget?

@banesullivan-kobold
Copy link
Author

banesullivan-kobold commented Oct 24, 2023

Hm. Using interaction_event='always' (vtk.vtkCommand.InteractionEvent) in PyVista's add_plane_widget() fixes it for this case. However we don't always want to use this as slicing large data sets in this fashion would have serious performance implications.

ref https://docs.pyvista.org/version/stable/api/plotting/_autosummary/pyvista.Plotter.add_plane_widget.html

I'm wondering if there is another VTK event trigger we could use?

Or is there a way to force update the view?

@jourdain
Copy link
Collaborator

I was not providing a fix here. I was just explaining what was happening so we/I could figure out a solution down the road when I get back to it. ;-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants