Skip to content

Commit b0ca3a1

Browse files
authored
ENH: Add FXAA option (#295)
* ENH: Add FXAA option * FIX: Mayavi for VTK9
1 parent 09513f9 commit b0ca3a1

File tree

3 files changed

+16
-10
lines changed

3 files changed

+16
-10
lines changed

appveyor.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ install:
77
- "SET PATH=%PYTHON%;%PYTHON%\\Scripts;%PATH%"
88
- "python --version"
99
- "pip install numpy scipy matplotlib nose pillow pytest pytest-cov pytest-faulthandler coverage imageio imageio-ffmpeg codecov pyqt5==5.9"
10-
- "pip install traits traitsui pyface vtk mayavi nibabel"
10+
- "pip install traits traitsui pyface vtk https://github.com/enthought/mayavi/archive/master.zip nibabel"
1111
- "powershell make/get_fsaverage.ps1"
1212
- "python setup.py develop"
1313
- "SET SUBJECTS_DIR=%CD%\\subjects"

azure-pipelines.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ jobs:
3030
displayName: Cache pip packages
3131
- powershell: |
3232
pip install numpy scipy matplotlib nose pillow pytest pytest-cov pytest-faulthandler coverage imageio imageio-ffmpeg codecov pyqt5==5.9 --cache-dir $(PIP_CACHE_FOLDER)
33-
pip install traits traitsui pyface vtk mayavi nibabel --cache-dir $(PIP_CACHE_FOLDER)
33+
pip install traits traitsui pyface vtk https://github.com/enthought/mayavi/archive/master.zip nibabel --cache-dir $(PIP_CACHE_FOLDER)
3434
displayName: 'Install pip dependencies'
3535
- powershell: |
3636
powershell make/get_fsaverage.ps1

surfer/viz.py

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ def _force_render(figures):
190190

191191

192192
def _make_viewer(figure, n_row, n_col, title, scene_size, offscreen,
193-
interaction='trackball'):
193+
interaction='trackball', antialias=True):
194194
"""Triage viewer creation
195195
196196
If n_row == n_col == 1, then we can use a Mayavi figure, which
@@ -229,11 +229,13 @@ def _make_viewer(figure, n_row, n_col, title, scene_size, offscreen,
229229
for f in figure:
230230
f.scene.interactor.interactor_style = \
231231
tvtk.InteractorStyleTerrain()
232-
for figure in figures:
233-
for f in figure:
234-
# on a non-testing backend, and using modern VTK/Mayavi
235-
if hasattr(getattr(f.scene, 'renderer', None), 'use_fxaa'):
236-
f.scene.renderer.use_fxaa = True
232+
if antialias:
233+
for figure in figures:
234+
for f in figure:
235+
# on a non-testing backend, and using modern VTK/Mayavi
236+
if hasattr(getattr(f.scene, 'renderer', None),
237+
'use_fxaa'):
238+
f.scene.renderer.use_fxaa = True
237239
else:
238240
if isinstance(figure, int): # use figure with specified id
239241
figure = [mlab.figure(figure, size=scene_size)]
@@ -374,6 +376,9 @@ class Brain(object):
374376
camera.
375377
units : str
376378
Can be 'm' or 'mm' (default).
379+
antialias : bool
380+
If True (default), turn on antialiasing. Can be problematic for
381+
some renderers (e.g., software rendering with MESA).
377382
378383
Attributes
379384
----------
@@ -397,7 +402,8 @@ def __init__(self, subject_id, hemi, surf, title=None,
397402
cortex="classic", alpha=1.0, size=800, background="black",
398403
foreground=None, figure=None, subjects_dir=None,
399404
views=['lat'], offset=True, show_toolbar=False,
400-
offscreen='auto', interaction='trackball', units='mm'):
405+
offscreen='auto', interaction='trackball', units='mm',
406+
antialias=True):
401407

402408
if not isinstance(interaction, string_types) or \
403409
interaction not in ('trackball', 'terrain'):
@@ -448,7 +454,7 @@ def __init__(self, subject_id, hemi, surf, title=None,
448454
del background, foreground
449455
figures, _v = _make_viewer(figure, n_row, n_col, title,
450456
self._scene_size, offscreen,
451-
interaction)
457+
interaction, antialias)
452458
self._figures = figures
453459
self._v = _v
454460
self._window_backend = 'Mayavi' if self._v is None else 'TraitsUI'

0 commit comments

Comments
 (0)