Skip to content

Commit aa957c8

Browse files
fix: Default trame visualization in Jupyter environments (#904)
Co-authored-by: Roberto Pastor Muela <[email protected]>
1 parent 92be44b commit aa957c8

File tree

5 files changed

+16
-4
lines changed

5 files changed

+16
-4
lines changed

doc/source/conf.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919

2020
from ansys.geometry.core import __version__
2121

22+
os.environ["PYANSYS_GEOMETRY_DOC_BUILD"] = "true"
23+
2224
LaTeXBuilder.supported_image_types = ["image/png", "image/pdf", "image/svg+xml"]
2325

2426

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ doc = [
8080
"notebook==7.0.6",
8181
"numpydoc==1.6.0",
8282
"panel==1.3.6",
83-
"pyvista[trame]==0.43.1",
83+
"pyvista[jupyter]==0.43.1",
8484
"requests==2.31.0",
8585
"sphinx==7.2.5",
8686
"sphinx-autoapi==3.0.0", # "sphinx-autoapi @ git+https://github.com/jorgepiloto/sphinx-autoapi@feat/single-page-option", ---> Installed directly in workflow

src/ansys/geometry/core/__init__.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@
3232
# Ease import statements
3333
# ------------------------------------------------------------------------------
3434

35+
import os
36+
3537
from ansys.geometry.core.connection.launcher import (
3638
launch_local_modeler,
3739
launch_modeler,
@@ -60,3 +62,7 @@
6062
Only set this to false if you are sure you want to disable this check and you will ONLY
6163
be working with one design.
6264
"""
65+
66+
DOCUMENTATION_BUILD: bool = os.environ.get("PYANSYS_GEOMETRY_DOC_BUILD", "false").lower() == "true"
67+
"""Global flag to set when building the documentation to use the proper PyVista Jupyter
68+
backend."""

src/ansys/geometry/core/plotting/plotter.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
from pyvista.plotting.plotter import Plotter as PyVistaPlotter
2929
from pyvista.plotting.tools import create_axes_marker
3030

31+
from ansys.geometry.core import DOCUMENTATION_BUILD
3132
from ansys.geometry.core.designer.body import Body, MasterBody
3233
from ansys.geometry.core.designer.component import Component
3334
from ansys.geometry.core.designer.design import Design
@@ -547,7 +548,10 @@ def show(
547548
# Conditionally set the Jupyter backend as not all users will be within
548549
# a notebook environment to avoid a pyvista warning
549550
if self.scene.notebook and jupyter_backend is None:
550-
# TODO revert this once the dynamic plotters in documentation are back.
551+
jupyter_backend = "trame"
552+
553+
# Override jupyter backend in case we are building docs
554+
if DOCUMENTATION_BUILD:
551555
jupyter_backend = "static"
552556

553557
# Enabling anti-aliasing by default on scene

src/ansys/geometry/core/tools/repair_tools.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ def find_split_edges(
7878
The maximum length of the edges.
7979
8080
Returns
81-
----------
81+
-------
8282
List[SplitEdgeProblemAreas]
8383
List of objects representing split edge problem areas.
8484
"""
@@ -111,7 +111,7 @@ def find_extra_edges(self, bodies: List["Body"]) -> List[ExtraEdgeProblemAreas]:
111111
List of bodies that extra edges are investigated on.
112112
113113
Returns
114-
----------
114+
-------
115115
List[ExtraEdgeProblemArea]
116116
List of objects representing extra edge problem areas.
117117
"""

0 commit comments

Comments
 (0)