Repository navigation
Expand file tree
/
Copy pathapp.py
More file actions
73 lines (50 loc) · 1.66 KB
/
Copy pathapp.py
File metadata and controls
73 lines (50 loc) · 1.66 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
from neuromlmodel import add_neuroml_model # noqa: F401
from SiberneticReplay import add_sibernetic_model # noqa: F401
from virtualworm import add_virtualworm_muscles # noqa: F401
from virtualworm import add_virtualworm_neurons # noqa: F401
import pyvista as pv
import sys
version = "v0.0.8"
st_mode = "-gui" not in sys.argv
print("Starting OpenWorm 3D Viewer (%s)" % version)
if st_mode:
import streamlit as st
st.set_page_config(layout="wide")
from stpyvista.utils import start_xvfb
if "IS_XVFB_RUNNING" not in st.session_state:
print("Starting XVFB...")
start_xvfb()
st.session_state.IS_XVFB_RUNNING = True
st.title("OpenWorm 3D Viewer (%s)" % version)
st.markdown(
"This is a 3D viewer for a number of OpenWorm _C. elegans_ models and datasets. It uses PyVista for rendering..."
)
## Initialize a plotter object
plotter = pv.Plotter(window_size=[800, 600])
print("Read objs...")
plotter = pv.Plotter()
spacing = 50
"""
add_sibernetic_model(
plotter, swap_y_z=True, offset3d=(spacing, -50, -100), show_footprint=False
)
add_neuroml_model(
plotter,
"NeuroML2/c302_D_Full.net.nml",
somas_only=False,
factor=0.2,
rotate_x=-90,
) # at 0..."""
add_virtualworm_muscles(plotter, translate=(-1 * spacing, 0, 0))
# add_virtualworm_neurons(plotter, translate=(-1.8*spacing, 0, 0))
plotter.set_viewup([0, 10, 0])
print("Created the scene...")
if st_mode:
##
if True:
print("Pass a key to avoid re-rendering at each page change")
from stpyvista import stpyvista
stpyvista(plotter, key="pv_cube")
pass
else:
plotter.show()