Kitware / trame-vtklocal

VTK Local Rendering using VTK/WASM to match server side rendering pipeline on the client side.
Other
17 stars 0 forks source link

Missing serializer for ... #14

Open jourdain opened 2 months ago

jourdain commented 2 months ago

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

Fevola commented 2 months ago

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() ```