-
Notifications
You must be signed in to change notification settings - Fork 17
Expand file tree
/
Copy pathPyVistaLookupTable.py
More file actions
81 lines (62 loc) · 2.51 KB
/
PyVistaLookupTable.py
File metadata and controls
81 lines (62 loc) · 2.51 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
"""Validate vtkLookupTable serializer with N Colors."""
import pyvista as pv
from trame.app import get_server
from trame.ui.vuetify3 import SinglePageLayout
from trame.widgets import vuetify3 as vuetify, html, vtk as vtk_widgets
# Just for using this script in testing
from trame_client.utils.testing import enable_testing
server = enable_testing(get_server(), "local_rendering_ready")
server.client_type = "vue2"
state, ctrl = server.state, server.controller
state.trame__title = "PyVista Lookup Table N Colors"
state.local_rendering_ready = 0
# -----------------------------------------------------------------------------
pv.set_plot_theme("document")
mesh = pv.Wavelet()
plotter = pv.Plotter(off_screen=True)
actor = plotter.add_mesh(mesh, n_colors=7)
plotter.set_background("lightgrey")
plotter.view_isometric()
# -----------------------------------------------------------------------------
# GUI
# -----------------------------------------------------------------------------
with SinglePageLayout(server) as layout:
layout.icon.click = ctrl.view_reset_camera
layout.title.set_text(state.trame__title)
with layout.toolbar:
vuetify.VSpacer()
html.Div("{{ local_rendering_ready }}", classes="readyCount")
with layout.content:
with vuetify.VContainer(
fluid=True,
classes="pa-0 fill-height",
):
with vuetify.VContainer(
fluid=True, classes="pa-0 fill-height", style="width: 50%;"
):
local = vtk_widgets.VtkLocalView(
plotter.ren_win,
on_ready="local_rendering_ready++",
)
with vuetify.VContainer(
fluid=True, classes="pa-0 fill-height", style="width: 50%;"
):
remote = vtk_widgets.VtkRemoteView(
plotter.ren_win,
)
def view_update(**kwargs):
local.update(**kwargs)
remote.update(**kwargs)
def view_reset_camera(**kwargs):
local.reset_camera(**kwargs)
remote.reset_camera(**kwargs)
ctrl.view_update = view_update
ctrl.view_reset_camera = view_reset_camera
ctrl.on_server_ready.add(view_update)
# hide footer
layout.footer.hide()
# -----------------------------------------------------------------------------
# Main
# -----------------------------------------------------------------------------
if __name__ == "__main__":
server.start()