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
|
r"""
Installation requirements:
pip install trame trame-vuetify trame-vtk
"""
# import paraview.web.venv # Available in PV 5.11
from paraview import simple
from trame.app import get_server
from trame.ui.vuetify3 import SinglePageLayout
from trame.widgets import paraview, vuetify3
# -----------------------------------------------------------------------------
server = get_server(client_type="vue3")
state, ctrl = server.state, server.controller
state.trame__title = "ParaView cone"
# -----------------------------------------------------------------------------
# ParaView code
# -----------------------------------------------------------------------------
DEFAULT_RESOLUTION = 6
cone = simple.Cone()
representation = simple.Show(cone)
view = simple.Render()
@state.change("resolution")
def update_cone(resolution, **kwargs):
cone.Resolution = resolution
ctrl.view_update()
def update_reset_resolution():
state.resolution = DEFAULT_RESOLUTION
# -----------------------------------------------------------------------------
with SinglePageLayout(server) as layout:
layout.icon.click = ctrl.view_reset_camera
layout.title.set_text("Cone Application")
with layout.toolbar:
vuetify3.VSpacer()
vuetify3.VSlider(
v_model=("resolution", DEFAULT_RESOLUTION),
min=3,
max=60,
step=1,
hide_details=True,
density="compact",
style="max-width: 300px",
)
vuetify3.VDivider(vertical=True, classes="mx-2")
vuetify3.VBtn(icon="mdi-undo-variant", click=update_reset_resolution)
with layout.content:
with vuetify3.VContainer(fluid=True, classes="pa-0 fill-height"):
html_view = paraview.VtkLocalView(view)
ctrl.view_reset_camera = html_view.reset_camera
ctrl.view_update = html_view.update
if __name__ == "__main__":
server.start()
|