Skip to content
Merged
Show file tree
Hide file tree
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
9 changes: 8 additions & 1 deletion mne/viz/backends/_pyvista.py
Original file line number Diff line number Diff line change
Expand Up @@ -651,6 +651,7 @@ def _compute_normals(mesh):

def _add_mesh(plotter, *args, **kwargs):
"""Patch PyVista add_mesh."""
from . import renderer
_process_events(plotter)
mesh = kwargs.get('mesh')
if 'smooth_shading' in kwargs:
Expand All @@ -661,6 +662,8 @@ def _add_mesh(plotter, *args, **kwargs):
if smooth_shading and 'Normals' in mesh.point_arrays:
prop = actor.GetProperty()
prop.SetInterpolationToPhong()
if renderer.MNE_3D_BACKEND_TESTING:
actor.SetVisibility(False)
return actor


Expand Down Expand Up @@ -1072,16 +1075,20 @@ def _testing_context(interactive):
from . import renderer
orig_offscreen = pyvista.OFF_SCREEN
orig_testing = renderer.MNE_3D_BACKEND_TESTING
orig_interactive = renderer.MNE_3D_BACKEND_INTERACTIVE
renderer.MNE_3D_BACKEND_TESTING = True
if interactive:
pyvista.OFF_SCREEN = False
renderer.MNE_3D_BACKEND_TESTING = False
renderer.MNE_3D_BACKEND_INTERACTIVE = True
else:
pyvista.OFF_SCREEN = True
renderer.MNE_3D_BACKEND_INTERACTIVE = False
try:
yield
finally:
pyvista.OFF_SCREEN = orig_offscreen
renderer.MNE_3D_BACKEND_TESTING = orig_testing
renderer.MNE_3D_BACKEND_INTERACTIVE = orig_interactive


@contextmanager
Expand Down
1 change: 1 addition & 0 deletions mne/viz/backends/renderer.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

MNE_3D_BACKEND = None
MNE_3D_BACKEND_TESTING = False
MNE_3D_BACKEND_INTERACTIVE = False


_backend_name_map = dict(
Expand Down