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

vtkOrientationMarkerWidget fails to render properly or update #412

Closed
6 of 14 tasks
spookylukey opened this issue Jan 12, 2024 · 3 comments
Closed
6 of 14 tasks

vtkOrientationMarkerWidget fails to render properly or update #412

spookylukey opened this issue Jan 12, 2024 · 3 comments

Comments

@spookylukey
Copy link

Describe the bug

Using vtkOrientationMarkerWidget with trame, the orientation widget does not display properly or update.

I think vtkCameraOrientationWidget is similarly broken (it fails to display at all) but I haven't investigated fully.

To Reproduce

See the code below, which produces the following screenshot:

Screenshot from 2024-01-12 15-46-12

If I uncomment out the lines indicated (this doesn't make sense, just for debugging this), then I first get an interactive window, with the axes displaying properly. After closing this, the trame app appears in a browser window, looking like this:

Screenshot from 2024-01-12 15-55-30

So the axes look correct here, but they still don't move when you change the camera position with the mouse.

Code
The code here is based on a minimal trame app (from https://github.com/Kitware/trame-tutorial/blob/master/01_vtk/solution_cone.py ) combined with https://examples.vtk.org/site/Python/Visualization/DisplayCoordinateAxes/

from trame.app import get_server
from trame.ui.vuetify import SinglePageLayout
from trame.widgets import vtk, vuetify

from vtkmodules.vtkFiltersSources import vtkConeSource
from vtkmodules.vtkRenderingCore import (
    vtkActor,
    vtkPolyDataMapper,
    vtkRenderer,
    vtkRenderWindow,
    vtkRenderWindowInteractor,
)

# Required for interactor initialization
from vtkmodules.vtkInteractionStyle import vtkInteractorStyleSwitch  # noqa

# Required for rendering initialization, not necessary for
# local rendering, but doesn't hurt to include it
import vtkmodules.vtkRenderingOpenGL2  # noqa

from vtkmodules.vtkInteractionWidgets import vtkOrientationMarkerWidget
from vtkmodules.vtkRenderingAnnotation import vtkAxesActor

renderer = vtkRenderer()
renderWindow = vtkRenderWindow()
renderWindow.AddRenderer(renderer)

renderWindowInteractor = vtkRenderWindowInteractor()
renderWindowInteractor.SetRenderWindow(renderWindow)
renderWindowInteractor.GetInteractorStyle().SetCurrentStyleToTrackballCamera()

cone_source = vtkConeSource()
mapper = vtkPolyDataMapper()
mapper.SetInputConnection(cone_source.GetOutputPort())
actor = vtkActor()
actor.SetMapper(mapper)

renderer.AddActor(actor)

axes = vtkAxesActor()

widget = vtkOrientationMarkerWidget()
widget.SetOrientationMarker(axes)
widget.SetInteractor(renderWindowInteractor)
widget.SetViewport(0.0, 0.0, 0.4, 0.4)
widget.SetEnabled(1)
widget.InteractiveOn()

renderer.GetActiveCamera().Azimuth(50)
renderer.GetActiveCamera().Elevation(-30)

renderer.ResetCamera()

# Un-comment these to show a normal VTK app with desired behavior:
# renderWindow.Render()
# renderWindowInteractor.Start()


server = get_server(client_type="vue2")
ctrl = server.controller

with SinglePageLayout(server) as layout:
    layout.title.set_text("Hello trame")

    with layout.content:
        with vuetify.VContainer(
            fluid=True,
            classes="pa-0 fill-height",
        ):
            view = vtk.VtkLocalView(renderWindow)

if __name__ == "__main__":
    server.start()

Expected behavior

It should display an axes that moves when you move the camera around.

Screenshots

If applicable, add screenshots to help explain your problem (drag and drop the image).

Platform:

I have ticked only those that I have checked, but based on Chrome+Firefox on both Windows+Linux being affected and the symptoms, I expect all platforms/devices are affected.

Device:

  • Desktop
  • Mobile

OS:

  • Windows
  • MacOS
  • Linux
  • Android
  • iOS

Browsers Affected:

  • Chrome
  • Firefox
  • Microsoft Edge
  • Safari
  • Opera
  • Brave
  • IE 11
@jourdain
Copy link
Collaborator

You need to provide the widgets=[...] argument.

@spookylukey
Copy link
Author

@jourdain Thanks for the pointer!

To be clear for the next person, the following code got it to work:

view = vtk.VtkLocalView(renderWindow, widgets=[widget])

where widget is the vtkOrientationMarkerWidget instance.

As far as I can see, this isn't documented anywhere e.g. https://trame.readthedocs.io/en/latest/trame.widgets.vtk.html#trame.widgets.vtk.VtkLocalView .

@jourdain
Copy link
Collaborator

True, it is listed on the API but not explained. Also, not all the widgets are supported.
It is an advanced feature that still needs to mature to be really considered mainstream.

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