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

Missing serializer for ... #14

Open
1 task
jourdain opened this issue Sep 12, 2024 · 1 comment
Open
1 task

Missing serializer for ... #14

jourdain opened this issue Sep 12, 2024 · 1 comment

Comments

@jourdain
Copy link
Collaborator

jourdain commented Sep 12, 2024

Please add a comment with class name and small but complete example making use of it.

  • vtkOpenGLTextActor - PR
@Fevola
Copy link

Fevola commented Sep 14, 2024

Hello, the TextActor was not supported in VtkLocalView, it's also cannot be serialized, Is it planned to be added in vtklocal?

class name:vtkOpenGLTextActor

code example
from trame.app import get_server
from trame.ui.vuetify3 import SinglePageLayout
from trame.widgets import vuetify3

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

from vtkmodules.vtkCommonColor import vtkNamedColors

from vtkmodules.vtkFiltersCore import vtkTriangleFilter
from vtkmodules.vtkFiltersSources import vtkPlaneSource
from vtkmodules.vtkRenderingCore import (
    vtkActor,
    vtkPolyDataMapper,
    vtkRenderWindow,
    vtkRenderWindowInteractor,
    vtkRenderer,
    vtkTextActor
)

from trame_vtklocal.widgets import vtklocal

def create_text_actor(myText):
    colors = vtkNamedColors()
    txt = vtkTextActor()
    txt.SetInput(myText)
    txtprop = txt.GetTextProperty()
    txtprop.SetFontFamilyToArial()
    txtprop.BoldOn()
    txtprop.SetFontSize(36)
    txtprop.ShadowOn()
    txtprop.SetShadowOffset(4, 4)
    txtprop.SetColor(colors.GetColor3d('Cornsilk'))
    txt.SetDisplayPosition(20, 30)
    return txt
    
def setup_vtk():

    colors = vtkNamedColors()

    plane_source = vtkPlaneSource()
    plane_source.Update()

    triangle_filter = vtkTriangleFilter()
    triangle_filter.SetInputConnection(plane_source.GetOutputPort())
    triangle_filter.Update()

    mapper = vtkPolyDataMapper()
    mapper.SetInputConnection(triangle_filter.GetOutputPort())

    actor = vtkActor()
    actor.GetProperty().SetColor(colors.GetColor3d('SeaGreen'))
    actor.SetMapper(mapper)

    renderer = vtkRenderer()
    ren_win = vtkRenderWindow()
    ren_win.AddRenderer(renderer)
    ren_win.SetWindowName('CellPicking')
    iren = vtkRenderWindowInteractor()
    iren.SetRenderWindow(ren_win)
    # add text actor
    renderer.AddActor(create_text_actor("hello trame"))
    
    renderer.AddActor(actor)
    renderer.ResetCamera()
    renderer.SetBackground(colors.GetColor3d('PaleTurquoise'))

    return ren_win


class App:
    def __init__(self, server=None):
        self.server = get_server(server, client_type="vue3")

        # enable shared array buffer
        self.server.http_headers.shared_array_buffer = True

        self.render_window = setup_vtk()
        self.ui = self._build_ui()

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

            with layout.content:
                with vuetify3.VContainer(
                    fluid=True,
                    classes="pa-0 fill-height",
                ):
                    with vuetify3.VCol(classes="pa-0 ma-1 fill-height"):
                        vtklocal.LocalView(self.render_window,
                                           throttle_rate=20,)

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

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