Skip to content

MRG: Add auto offscreen mode #245

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 12, 2018
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
23 changes: 14 additions & 9 deletions surfer/viz.py
Original file line number Diff line number Diff line change
Expand Up @@ -200,13 +200,17 @@ def _make_viewer(figure, n_row, n_col, title, scene_size, offscreen,
if figure is None:
# spawn scenes
h, w = scene_size
if offscreen is True:
if offscreen == 'auto':
offscreen = mlab.options.offscreen
if offscreen:
orig_val = mlab.options.offscreen
mlab.options.offscreen = True
with warnings.catch_warnings(record=True): # traits
figures = [[mlab.figure(size=(h / n_row, w / n_col))
for _ in range(n_col)] for __ in range(n_row)]
mlab.options.offscreen = orig_val
try:
mlab.options.offscreen = True
with warnings.catch_warnings(record=True): # traits
figures = [[mlab.figure(size=(h / n_row, w / n_col))
for _ in range(n_col)] for __ in range(n_row)]
finally:
mlab.options.offscreen = orig_val
_v = None
else:
# Triage: don't make TraitsUI if we don't have to
Expand Down Expand Up @@ -356,10 +360,11 @@ class Brain(object):
surface where hemispheres typically overlap (Default: True)
show_toolbar : bool
If True, toolbars will be shown for each view.
offscreen : bool
offscreen : bool | str
If True, rendering will be done offscreen (not shown). Useful
mostly for generating images or screenshots, but can be buggy.
Use at your own risk.
Use at your own risk. Can be "auto" (default) to use
``mlab.options.offscreen``.
interaction : str
Can be "trackball" (default) or "terrain", i.e. a turntable-style
camera.
Expand Down Expand Up @@ -387,7 +392,7 @@ def __init__(self, subject_id, hemi, surf, title=None,
cortex="classic", alpha=1.0, size=800, background="black",
foreground=None, figure=None, subjects_dir=None,
views=['lat'], offset=True, show_toolbar=False,
offscreen=False, interaction='trackball', units='mm'):
offscreen='auto', interaction='trackball', units='mm'):

if not isinstance(interaction, string_types) or \
interaction not in ('trackball', 'terrain'):
Expand Down