From a485ac8d82fa7270f920839d10f485aacf2beb91 Mon Sep 17 00:00:00 2001 From: Guillaume Favelier Date: Mon, 19 Apr 2021 14:40:00 +0200 Subject: [PATCH 1/7] Touch example --- tutorials/source-modeling/plot_source_alignment.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tutorials/source-modeling/plot_source_alignment.py b/tutorials/source-modeling/plot_source_alignment.py index 64b595a1f81..35cfb978e5f 100644 --- a/tutorials/source-modeling/plot_source_alignment.py +++ b/tutorials/source-modeling/plot_source_alignment.py @@ -95,7 +95,7 @@ # Note that all three coordinate systems are **RAS** coordinate frames and # hence are also `right-handed`_ coordinate systems. Finally, note that the # ``coord_frame`` parameter sets which coordinate frame the camera -# should initially be aligned with. Let's take a look: +# should initially be aligned with. Let's have a look: fig = mne.viz.plot_alignment(raw.info, trans=trans, subject='sample', subjects_dir=subjects_dir, surfaces='head-dense', From 7c630971309fb3b13a1c9603b427857c680ece5d Mon Sep 17 00:00:00 2001 From: Guillaume Favelier Date: Mon, 19 Apr 2021 14:59:48 +0200 Subject: [PATCH 2/7] Touch example --- tutorials/sample-datasets/plot_phantom_4DBTi.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tutorials/sample-datasets/plot_phantom_4DBTi.py b/tutorials/sample-datasets/plot_phantom_4DBTi.py index f24a0574fce..5f7e2f87766 100644 --- a/tutorials/sample-datasets/plot_phantom_4DBTi.py +++ b/tutorials/sample-datasets/plot_phantom_4DBTi.py @@ -64,7 +64,7 @@ print("errors (mm) : %s" % errors) ############################################################################### -# Plot the dipoles in 3D +# Plot the dipoles in 3D: actual_amp = np.ones(len(dip)) # misc amp to create Dipole instance actual_gof = np.ones(len(dip)) # misc GOF to create Dipole instance dip = mne.Dipole(dip.times, pos, actual_amp, ori, actual_gof) From 5ac2141dacd673c7b7b775114a58f162538cac03 Mon Sep 17 00:00:00 2001 From: Guillaume Favelier Date: Mon, 19 Apr 2021 15:16:52 +0200 Subject: [PATCH 3/7] Revert _qt_disable_paint[skip azp][skip github] --- mne/viz/backends/_qt.py | 7 +++---- mne/viz/backends/_utils.py | 10 ---------- 2 files changed, 3 insertions(+), 14 deletions(-) diff --git a/mne/viz/backends/_qt.py b/mne/viz/backends/_qt.py index 7009225dc87..38d0dc77eb1 100644 --- a/mne/viz/backends/_qt.py +++ b/mne/viz/backends/_qt.py @@ -28,7 +28,7 @@ _AbstractStatusBar, _AbstractLayout, _AbstractWidget, _AbstractWindow, _AbstractMplCanvas, _AbstractPlayback, _AbstractBrainMplCanvas, _AbstractMplInterface) -from ._utils import _init_qt_resources, _qt_disable_paint +from ._utils import _init_qt_resources from ..utils import logger @@ -503,9 +503,8 @@ def __init__(self, *args, **kwargs): def show(self): super().show() - with _qt_disable_paint(self.plotter): - with self._window_ensure_minimum_sizes(): - self.plotter.app_window.show() + with self._window_ensure_minimum_sizes(): + self.plotter.app_window.show() self.plotter.update() diff --git a/mne/viz/backends/_utils.py b/mne/viz/backends/_utils.py index c95ae881486..674ab44b2dd 100644 --- a/mne/viz/backends/_utils.py +++ b/mne/viz/backends/_utils.py @@ -79,13 +79,3 @@ def run_once(fun, *args, **kwargs): def _init_qt_resources(): from ...icons import resources resources.qInitResources() - - -@contextmanager -def _qt_disable_paint(widget): - paintEvent = widget.paintEvent - widget.paintEvent = lambda *args, **kwargs: None - try: - yield - finally: - widget.paintEvent = paintEvent From 8c59f3456f5cdad34ce9e765f5d56b43ae85cf7e Mon Sep 17 00:00:00 2001 From: Guillaume Favelier Date: Mon, 19 Apr 2021 15:30:57 +0200 Subject: [PATCH 4/7] Revert "Revert _qt_disable_paint[skip azp][skip github]" This reverts commit 5ac2141dacd673c7b7b775114a58f162538cac03. --- mne/viz/backends/_qt.py | 7 ++++--- mne/viz/backends/_utils.py | 10 ++++++++++ 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/mne/viz/backends/_qt.py b/mne/viz/backends/_qt.py index 38d0dc77eb1..7009225dc87 100644 --- a/mne/viz/backends/_qt.py +++ b/mne/viz/backends/_qt.py @@ -28,7 +28,7 @@ _AbstractStatusBar, _AbstractLayout, _AbstractWidget, _AbstractWindow, _AbstractMplCanvas, _AbstractPlayback, _AbstractBrainMplCanvas, _AbstractMplInterface) -from ._utils import _init_qt_resources +from ._utils import _init_qt_resources, _qt_disable_paint from ..utils import logger @@ -503,8 +503,9 @@ def __init__(self, *args, **kwargs): def show(self): super().show() - with self._window_ensure_minimum_sizes(): - self.plotter.app_window.show() + with _qt_disable_paint(self.plotter): + with self._window_ensure_minimum_sizes(): + self.plotter.app_window.show() self.plotter.update() diff --git a/mne/viz/backends/_utils.py b/mne/viz/backends/_utils.py index 674ab44b2dd..c95ae881486 100644 --- a/mne/viz/backends/_utils.py +++ b/mne/viz/backends/_utils.py @@ -79,3 +79,13 @@ def run_once(fun, *args, **kwargs): def _init_qt_resources(): from ...icons import resources resources.qInitResources() + + +@contextmanager +def _qt_disable_paint(widget): + paintEvent = widget.paintEvent + widget.paintEvent = lambda *args, **kwargs: None + try: + yield + finally: + widget.paintEvent = paintEvent From 944b0892faf69c3f8e04f7898cd200594bfcd5f1 Mon Sep 17 00:00:00 2001 From: Guillaume Favelier Date: Mon, 19 Apr 2021 15:46:34 +0200 Subject: [PATCH 5/7] Update & ProcessEvents? [skip azp][skip github] --- mne/viz/backends/_pyvista.py | 3 ++- mne/viz/backends/_qt.py | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/mne/viz/backends/_pyvista.py b/mne/viz/backends/_pyvista.py index 8e7cfac9be2..421c2df13ab 100644 --- a/mne/viz/backends/_pyvista.py +++ b/mne/viz/backends/_pyvista.py @@ -661,7 +661,8 @@ def _actor(self, mapper=None): return actor def _process_events(self): - _process_events(self.plotter) + for plotter in self._all_plotters: + _process_events(plotter) def _update_picking_callback(self, on_mouse_move, diff --git a/mne/viz/backends/_qt.py b/mne/viz/backends/_qt.py index 7009225dc87..0aac0513123 100644 --- a/mne/viz/backends/_qt.py +++ b/mne/viz/backends/_qt.py @@ -506,7 +506,8 @@ def show(self): with _qt_disable_paint(self.plotter): with self._window_ensure_minimum_sizes(): self.plotter.app_window.show() - self.plotter.update() + self._update() + self._process_events() def _create_dock_widget(window, name, area): From a1599615fc1df9049aa4f5549658ea7524d92a1f Mon Sep 17 00:00:00 2001 From: Guillaume Favelier Date: Mon, 19 Apr 2021 16:19:41 +0200 Subject: [PATCH 6/7] Again but this time with other tests From 531986ba03e6138d4a58f116255fe5c42c27b773 Mon Sep 17 00:00:00 2001 From: Guillaume Favelier Date: Mon, 19 Apr 2021 16:44:59 +0200 Subject: [PATCH 7/7] Fix --- mne/viz/_3d.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mne/viz/_3d.py b/mne/viz/_3d.py index 9939f5e82ff..d3da119ecbd 100644 --- a/mne/viz/_3d.py +++ b/mne/viz/_3d.py @@ -2872,7 +2872,7 @@ def plot_dipole_locations(dipoles, trans=None, subject=None, subjects_dir=None, u, v, w = ori.T renderer.quiver3d(x, y, z, u, v, w, scale=3 * scale, color=color, mode='arrow') - + renderer.show() fig = renderer.scene() else: raise ValueError('Mode must be "cone", "arrow" or orthoview", '