Skip to content

Commit

Permalink
ENH: Add FXAA option (#295)
Browse files Browse the repository at this point in the history
* ENH: Add FXAA option

* FIX: Mayavi for VTK9
  • Loading branch information
larsoner authored Jun 11, 2020
1 parent 09513f9 commit b0ca3a1
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 10 deletions.
2 changes: 1 addition & 1 deletion appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ install:
- "SET PATH=%PYTHON%;%PYTHON%\\Scripts;%PATH%"
- "python --version"
- "pip install numpy scipy matplotlib nose pillow pytest pytest-cov pytest-faulthandler coverage imageio imageio-ffmpeg codecov pyqt5==5.9"
- "pip install traits traitsui pyface vtk mayavi nibabel"
- "pip install traits traitsui pyface vtk https://github.com/enthought/mayavi/archive/master.zip nibabel"
- "powershell make/get_fsaverage.ps1"
- "python setup.py develop"
- "SET SUBJECTS_DIR=%CD%\\subjects"
Expand Down
2 changes: 1 addition & 1 deletion azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ jobs:
displayName: Cache pip packages
- powershell: |
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)
pip install traits traitsui pyface vtk mayavi nibabel --cache-dir $(PIP_CACHE_FOLDER)
pip install traits traitsui pyface vtk https://github.com/enthought/mayavi/archive/master.zip nibabel --cache-dir $(PIP_CACHE_FOLDER)
displayName: 'Install pip dependencies'
- powershell: |
powershell make/get_fsaverage.ps1
Expand Down
22 changes: 14 additions & 8 deletions surfer/viz.py
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ def _force_render(figures):


def _make_viewer(figure, n_row, n_col, title, scene_size, offscreen,
interaction='trackball'):
interaction='trackball', antialias=True):
"""Triage viewer creation
If n_row == n_col == 1, then we can use a Mayavi figure, which
Expand Down Expand Up @@ -229,11 +229,13 @@ def _make_viewer(figure, n_row, n_col, title, scene_size, offscreen,
for f in figure:
f.scene.interactor.interactor_style = \
tvtk.InteractorStyleTerrain()
for figure in figures:
for f in figure:
# on a non-testing backend, and using modern VTK/Mayavi
if hasattr(getattr(f.scene, 'renderer', None), 'use_fxaa'):
f.scene.renderer.use_fxaa = True
if antialias:
for figure in figures:
for f in figure:
# on a non-testing backend, and using modern VTK/Mayavi
if hasattr(getattr(f.scene, 'renderer', None),
'use_fxaa'):
f.scene.renderer.use_fxaa = True
else:
if isinstance(figure, int): # use figure with specified id
figure = [mlab.figure(figure, size=scene_size)]
Expand Down Expand Up @@ -374,6 +376,9 @@ class Brain(object):
camera.
units : str
Can be 'm' or 'mm' (default).
antialias : bool
If True (default), turn on antialiasing. Can be problematic for
some renderers (e.g., software rendering with MESA).
Attributes
----------
Expand All @@ -397,7 +402,8 @@ 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='auto', interaction='trackball', units='mm'):
offscreen='auto', interaction='trackball', units='mm',
antialias=True):

if not isinstance(interaction, string_types) or \
interaction not in ('trackball', 'terrain'):
Expand Down Expand Up @@ -448,7 +454,7 @@ def __init__(self, subject_id, hemi, surf, title=None,
del background, foreground
figures, _v = _make_viewer(figure, n_row, n_col, title,
self._scene_size, offscreen,
interaction)
interaction, antialias)
self._figures = figures
self._v = _v
self._window_backend = 'Mayavi' if self._v is None else 'TraitsUI'
Expand Down

0 comments on commit b0ca3a1

Please sign in to comment.