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

"Text Actors" won't show up in "Local" rendering #608

Open
4 of 14 tasks
hmralavi opened this issue Oct 7, 2024 · 3 comments
Open
4 of 14 tasks

"Text Actors" won't show up in "Local" rendering #608

hmralavi opened this issue Oct 7, 2024 · 3 comments

Comments

@hmralavi
Copy link

hmralavi commented Oct 7, 2024

Describe the bug

Vtk Text Actors won't show up when using "Local" rendering method.

To Reproduce

Steps to reproduce the behavior:

  1. run the python code
  2. switch between "local" and "remote" rendering using the provided switch in the toolbar.
  3. you can see the text actors when "remote" rendering is ON, but they dissapear when switching to "local" rendering.

Code

from trame.app import get_server
from trame.decorators import TrameApp
from trame.widgets import html, vuetify, vtk as trame_vtk_widgets
from trame.ui.vuetify import SinglePageLayout

from vtkmodules.vtkRenderingCore import (
    vtkRenderer,
    vtkRenderWindow,
    vtkRenderWindowInteractor,
    vtkTextActor,
)

from vtkmodules.vtkInteractionStyle import (
    vtkInteractorStyleTrackballActor,
    vtkInteractorStyleTrackballCamera,
)

from vtkmodules.vtkRenderingAnnotation import vtkAxesActor

# VTK factory initialization
from vtkmodules.vtkInteractionStyle import vtkInteractorStyleSwitch  # noqa
import vtkmodules.vtkRenderingOpenGL2  # noqa


@TrameApp()
class MainApp:
    def __init__(self, server_or_name=None) -> None:
        self.server = get_server(server_or_name, client_type="vue2")
        self.state.trame__title = "Text actor issue"

        self._render_window = self._setup_render_window()
        self._origin_axes_actor = self._setup_origin_axes_actor()
        self._logo_actor = self._setup_text_actor()
        self.renderer.ResetCamera()

        self.ui = self._setup_ui()

    def _setup_render_window(self) -> vtkRenderWindow:
        renderer = vtkRenderer()
        renderWindow = vtkRenderWindow()
        renderWindow.AddRenderer(renderer)
        interactor = vtkRenderWindowInteractor()
        interactor.SetInteractorStyle(vtkInteractorStyleTrackballCamera())
        interactor.SetRenderWindow(renderWindow)

        return renderWindow

    def _setup_origin_axes_actor(self) -> vtkAxesActor:
        axes = vtkAxesActor()
        self.renderer.AddActor(axes)

        return axes

    def _setup_text_actor(self) -> vtkTextActor:
        text_actor = vtkTextActor()
        text_actor.SetInput("My Text")
        text_actor.GetTextProperty().SetFontSize(24)
        text_actor.GetTextProperty().BoldOn()
        text_actor.GetTextProperty().SetColor(1.0, 0.0, 0.0)
        text_actor.SetPosition(10, 10)
        self.renderer.AddActor(text_actor)

        return text_actor

    def _setup_ui(self):
        with SinglePageLayout(self.server) as layout:
            layout.title.set_text("Text actor issue")
            with layout.toolbar as toolbar:
                toolbar.dense = True
                vuetify.VSpacer()
                html.Div("Switch between remote/local rendering: ")
                vuetify.VCheckbox(
                    v_model=("viewMode", "local"),
                    on_icon="mdi-lan-disconnect",
                    off_icon="mdi-lan-connect",
                    true_value="local",
                    false_value="remote",
                    classes="mx-1",
                    hide_details=True,
                    dense=True,
                )
                vuetify.VSpacer()
                with vuetify.VBtn(icon=True, click=self.ctrl.view_reset_camera):
                    vuetify.VIcon("mdi-crop-free")

            with layout.content:
                with vuetify.VContainer(fluid=True, classes="pa-0 fill-height"):
                    view = trame_vtk_widgets.VtkRemoteLocalView(
                        self._render_window,
                        namespace="view",
                        mode="local",
                        interactive_ratio=1,
                    )
                    self.ctrl.view_update = view.update
                    self.ctrl.view_reset_camera = view.reset_camera
        return layout

    @property
    def ctrl(self):
        return self.server.controller

    @property
    def state(self):
        return self.server.state

    @property
    def renderer(self) -> vtkRenderer:
        return self._render_window.GetRenderers().GetFirstRenderer()


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

Expected behavior

It is expected that the text actors show up in the "local" rendering mode as well as "remote" rendering

Screenshots

image

Platform:

Device:

  • Desktop
  • Mobile

OS:

  • Windows
  • MacOS
  • Linux
  • Android
  • iOS

Browsers Affected:

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

jourdain commented Oct 7, 2024

Thanks for the detailed report issue. What you are describing is a known limitation of vtk.js which we are aiming to fix by using WASM. You can see the work progress on that topic here.

@hmralavi
Copy link
Author

hmralavi commented Oct 8, 2024

Thank you Sebastien.

Is there a list of all current known limitations of trame/vtk.js?

@jourdain
Copy link
Collaborator

jourdain commented Oct 8, 2024

vtk.js mainly focus on vtkPolyData rendering. Anything on the side, may be different or have a mismatch feature set.

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