Skip to content

Commit

Permalink
fix(ExodusViewer): Disable exodus viewer when ParaView is not installed
Browse files Browse the repository at this point in the history
  • Loading branch information
schencej committed Mar 9, 2023
1 parent 1061596 commit 45ef46e
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 4 deletions.
8 changes: 7 additions & 1 deletion peacock_trame/app/core/exodusViewer/time_step.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
from trame.widgets import vuetify, html
from trame.app import asynchronous

from paraview import simple
try:
from paraview import simple
except ModuleNotFoundError:
# The Exodus Viewer is disabled when ParaView is not installed
# So, no extra handling is needed in this file
# But, this file is still imported, so this try/catch is required
pass

import asyncio

Expand Down
36 changes: 33 additions & 3 deletions peacock_trame/app/exodusViewer.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,24 @@

from trame.widgets import vuetify, html, paraview

from paraview import simple

from .core.common.utils import throttled_run

from .core.exodusViewer.time_step import TimeStepController

try:
from paraview import simple
PARAVIEW_INSTALLED = True
except ModuleNotFoundError:
PARAVIEW_INSTALLED = False


CHECKER_BACKGROUND = "url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAoAAAAKCAYAAACNMs+9AAAAGElEQVQYlWNgYGCQwoKxgqGgcJA5h3yFAAs8BRWVSwooAAAAAElFTkSuQmCC) repeat"


class ExodusViewer:
def __init__(self, server):
if not PARAVIEW_INSTALLED:
return

self._server = server
self.state = server.state
self.ctrl = server.controller
Expand All @@ -32,6 +38,27 @@ def __init__(self, server):
self.time_ctrl = TimeStepController(server)

def get_ui(self):
if not PARAVIEW_INSTALLED:
# This page cannot work with VTK alone, for now
with html.Div(
style="""
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
width: 100%;
height: 100%;
""",
) as container:
html.H1("This page requires ParaView.")
html.A(
"https://github.com/kitware/peacock#running-the-software",
href="https://github.com/kitware/peacock#running-the-software",
target="_blank",
)

return container

with vuetify.VCol(
classes="fill-height ma-0 pa-0 d-flex",
) as container:
Expand Down Expand Up @@ -329,6 +356,9 @@ def on_color_change(self, rgba_obj, viz_type, viz_id):
self.ctrl.update_exodus_view()

def check_file(self):
if not PARAVIEW_INSTALLED:
return False

state = self.state
if state.ex2_exists:
return
Expand Down

0 comments on commit 45ef46e

Please sign in to comment.