Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 35 additions & 13 deletions app.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,30 @@
import pyvista as pv
import sys

version = "v0.1.0"
version = "v0.1.2"

st_mode = "-gui" not in sys.argv

print("Starting OpenWorm 3D Viewer (%s)" % version)

def print_(msg, print_it=True): # print_it=False when not verbose
if print_it:
pre = "Worm3DViewer >>> "
print("%s %s" % (pre, msg.replace("\n", "\n" + pre)))


print_("Starting OpenWorm 3D Viewer (%s)" % version)

if st_mode:
import streamlit as st

print_("Streamlit mode detected...")

st.set_page_config(layout="wide")

from stpyvista.utils import start_xvfb

if "IS_XVFB_RUNNING" not in st.session_state:
print("Starting XVFB...")
print_("Starting XVFB...")
start_xvfb()
st.session_state.IS_XVFB_RUNNING = True

Expand All @@ -38,34 +47,47 @@

plotter = pv.Plotter()

adding_sibernetic_model = False
adding_neuroml_model = True
adding_virtualworm_muscles = True
adding_virtualworm_neurons = False

spacing = 50
"""
add_sibernetic_model(
plotter, swap_y_z=True, offset3d=(spacing, -50, -100), show_footprint=False
)

add_neuroml_model(

if adding_sibernetic_model:
print_("Adding Sibernetic model...")
add_sibernetic_model(
plotter, swap_y_z=True, offset3d=(spacing, -50, -100), show_footprint=False
)

if adding_neuroml_model:
print_("Adding NeuroML model...")
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))
if adding_virtualworm_muscles:
print_("Adding VirtualWorm muscles...")
add_virtualworm_muscles(plotter, translate=(-1 * spacing, 0, 0))

if adding_virtualworm_neurons:
print_("Adding VirtualWorm neurons...")
add_virtualworm_neurons(plotter, translate=(-1.8 * spacing, 0, 0))

plotter.set_viewup([0, 10, 0])


print("Created the scene...")
print_("Created the scene...")

if st_mode:
##
if True:
print("Pass a key to avoid re-rendering at each page change")
print_("Pass a key to avoid re-rendering at each page change")
from stpyvista import stpyvista

stpyvista(plotter, key="pv_cube")
Expand Down
Loading