Skip to content

Commit a15631f

Browse files
committed
fix pv example
1 parent 3b66bc3 commit a15631f

1 file changed

Lines changed: 25 additions & 14 deletions

File tree

05_paraview/StateLoader.py

Lines changed: 25 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,32 @@
1-
from paraview.web import venv # Available in PV 5.10
2-
3-
import os
1+
from paraview.web import venv # Available in PV 5.10-RC2+
2+
from paraview import simple
43

4+
from pathlib import Path
55
from trame.app import get_server
6-
from trame.widgets import vuetify, paraview
6+
from trame.widgets import vuetify, paraview, client
77
from trame.ui.vuetify import SinglePageLayout
88

9-
from paraview import simple
10-
119
# -----------------------------------------------------------------------------
12-
# trame setup
10+
# Trame setup
1311
# -----------------------------------------------------------------------------
1412

1513
server = get_server()
1614
state, ctrl = server.state, server.controller
1715

16+
# Preload paraview modules onto server
17+
paraview.initialize(server)
18+
1819
# -----------------------------------------------------------------------------
1920
# ParaView code
2021
# -----------------------------------------------------------------------------
2122

22-
layout = None
23-
2423

25-
def load_data():
24+
def load_data(**kwargs):
2625
# CLI
27-
server.cli.add_argument("--data", help="Path to state file", dest="data")
2826
args, _ = server.cli.parse_known_args()
2927

30-
full_path = os.path.abspath(args.data)
31-
working_directory = os.path.dirname(full_path)
28+
full_path = str(Path(args.data).resolve().absolute())
29+
working_directory = str(Path(args.data).parent.resolve().absolute())
3230

3331
# ParaView
3432
simple.LoadState(
@@ -38,28 +36,41 @@ def load_data():
3836
)
3937
view = simple.GetActiveView()
4038
view.MakeRenderWindowInteractor(True)
39+
simple.Render(view)
4140

4241
# HTML
43-
with layout:
42+
with SinglePageLayout(server) as layout:
43+
layout.icon.click = ctrl.view_reset_camera
44+
layout.title.set_text("ParaView State Viewer")
45+
4446
with layout.content:
4547
with vuetify.VContainer(fluid=True, classes="pa-0 fill-height"):
4648
html_view = paraview.VtkRemoteView(view)
4749
ctrl.view_reset_camera = html_view.reset_camera
4850
ctrl.view_update = html_view.update
4951

5052

53+
ctrl.on_server_ready.add(load_data)
54+
5155
# -----------------------------------------------------------------------------
5256
# GUI
5357
# -----------------------------------------------------------------------------
58+
5459
state.trame__title = "State Viewer"
5560

5661
with SinglePageLayout(server) as layout:
5762
layout.icon.click = ctrl.view_reset_camera
5863
layout.title.set_text("ParaView State Viewer")
5964

65+
with layout.content:
66+
with vuetify.VContainer(fluid=True, classes="pa-0 fill-height"):
67+
client.Loading("Loading state")
68+
69+
6070
# -----------------------------------------------------------------------------
6171
# Main
6272
# -----------------------------------------------------------------------------
6373

6474
if __name__ == "__main__":
75+
server.cli.add_argument("--data", help="Path to state file", dest="data")
6576
server.start()

0 commit comments

Comments
 (0)