Skip to content
Merged
3 changes: 3 additions & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,9 @@ exclude .github/ISSUE_TEMPLATE/bug_report.md
exclude .github/ISSUE_TEMPLATE/feature_request.md
exclude .github/PULL_REQUEST_TEMPLATE.md

exclude mne.qrc
prune mne/images

# Test files

recursive-exclude mne/io/tests/data *
Expand Down
13 changes: 13 additions & 0 deletions mne.qrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<!DOCTYPE RCC><RCC version="1.0">
<qresource>
<file alias="visibility_on.svg">mne/images/visibility_on-black-18dp.svg</file>
<file alias="visibility_off.svg">mne/images/visibility_off-black-18dp.svg</file>
<file alias="help.svg">mne/images/help-black-18dp.svg</file>
<file alias="play.svg">mne/images/play-black-18dp.svg</file>
<file alias="pause.svg">mne/images/pause-black-18dp.svg</file>
<file alias="scale.svg">mne/images/scale-black-18dp.svg</file>
<file alias="restore.svg">mne/images/restore-black-18dp.svg</file>
<file alias="clear.svg">mne/images/clear-black-18dp.svg</file>
<file alias="screenshot.svg">mne/images/screenshot-black-18dp.svg</file>
</qresource>
</RCC>
1 change: 1 addition & 0 deletions mne/images/clear-black-18dp.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions mne/images/help-black-18dp.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions mne/images/pause-black-18dp.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions mne/images/play-black-18dp.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions mne/images/restore-black-18dp.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions mne/images/scale-black-18dp.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions mne/images/screenshot-black-18dp.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions mne/images/visibility_off-black-18dp.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions mne/images/visibility_on-black-18dp.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
74 changes: 74 additions & 0 deletions mne/viz/_brain/_timeviewer.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,11 @@
from ...source_space import vertex_to_mni
from ...utils import _ReuseCycle

# all icons are stored in mne/viz/_brain/resources.py, which must be
# automatically generated with:
# "pyrcc5 -o mne/viz/_brain/resources.py mne.qrc"
from . import resources # noqa


@decorator
def safe_event(fun, *args, **kwargs):
Expand Down Expand Up @@ -329,6 +334,8 @@ def __init__(self, brain, show_traces=False):
self.color_cycle = None
self.picked_points = {'lh': list(), 'rh': list()}
self._mouse_no_mvt = -1
self.icons = dict()
self.actions = dict()
self.orientation = [
'lateral',
'medial',
Expand Down Expand Up @@ -359,6 +366,7 @@ def __init__(self, brain, show_traces=False):
self.plotter = brain._renderer.plotter
self.main_menu = self.plotter.main_menu
self.window = self.plotter.app_window
self.tool_bar = self.window.addToolBar("toolbar")
self.status_bar = self.window.statusBar()
self.interactor = self.plotter.interactor
self.interactor.keyPressEvent = self.keyPressEvent
Expand All @@ -374,12 +382,14 @@ def __init__(self, brain, show_traces=False):
self.show_traces = show_traces
self.separate_canvas = False

self.load_icons()
self.configure_time_label()
self.configure_sliders()
self.configure_scalar_bar()
self.configure_playback()
self.configure_point_picking()
self.configure_menu()
self.configure_tool_bar()

# show everything at the end
self.toggle_interface()
Expand All @@ -394,6 +404,12 @@ def keyPressEvent(self, event):
def toggle_interface(self):
self.visibility = not self.visibility

# update tool bar icon
if self.visibility:
self.actions["visibility"].setIcon(self.icons["visibility_on"])
else:
self.actions["visibility"].setIcon(self.icons["visibility_off"])

# manage sliders
for slider in self.plotter.slider_widgets:
slider_rep = slider.GetRepresentation()
Expand Down Expand Up @@ -432,6 +448,13 @@ def restore_user_scaling(self):

def toggle_playback(self):
self.playback = not self.playback

# update tool bar icon
if self.playback:
self.actions["play"].setIcon(self.icons["pause"])
else:
self.actions["play"].setIcon(self.icons["play"])

if self.playback:
time_data = self.brain._data['time']
max_time = np.max(time_data)
Expand Down Expand Up @@ -755,6 +778,56 @@ def configure_point_picking(self):
self.on_pick
)

def load_icons(self):
from PyQt5.QtGui import QIcon
resources.qInitResources()
self.icons["help"] = QIcon(":/help.svg")
self.icons["play"] = QIcon(":/play.svg")
self.icons["pause"] = QIcon(":/pause.svg")
self.icons["scale"] = QIcon(":/scale.svg")
self.icons["clear"] = QIcon(":/clear.svg")
self.icons["restore"] = QIcon(":/restore.svg")
self.icons["screenshot"] = QIcon(":/screenshot.svg")
self.icons["visibility_on"] = QIcon(":/visibility_on.svg")
self.icons["visibility_off"] = QIcon(":/visibility_off.svg")

def configure_tool_bar(self):
self.actions["screenshot"] = self.tool_bar.addAction(
self.icons["screenshot"],
"Take a screenshot",
self.plotter._qt_screenshot
)
self.actions["visibility"] = self.tool_bar.addAction(
self.icons["visibility_on"],
"Toggle Visibility",
self.toggle_interface
)
self.actions["play"] = self.tool_bar.addAction(
self.icons["play"],
"Play/Pause",
self.toggle_playback
)
self.actions["scale"] = self.tool_bar.addAction(
self.icons["scale"],
"Auto-Scale",
self.apply_auto_scaling
)
self.actions["restore"] = self.tool_bar.addAction(
self.icons["restore"],
"Restore scaling",
self.restore_user_scaling
)
self.actions["clear"] = self.tool_bar.addAction(
self.icons["clear"],
"Clear traces",
self.clear_points
)
self.actions["help"] = self.tool_bar.addAction(
self.icons["help"],
"Help",
self.help
)

def configure_menu(self):
# remove default picking menu
to_remove = list()
Expand Down Expand Up @@ -973,6 +1046,7 @@ def clean(self):
self.act_data["lh"] = None
self.act_data["rh"] = None
self.act_data = None
resources.qCleanupResources()


class _LinkViewer(object):
Expand Down
Loading