diff --git a/mne_qt_browser/_pg_figure.py b/mne_qt_browser/_pg_figure.py index 574af468..179a2f25 100644 --- a/mne_qt_browser/_pg_figure.py +++ b/mne_qt_browser/_pg_figure.py @@ -1296,6 +1296,7 @@ def mouseDragEvent(self, event, axis=None): plot_onset, duration, self.mne.current_description, region=self._drag_region) self._drag_region.select(True) + self._drag_region.setZValue(2) # Update Overview-Bar self.mne.overview_bar.update_annotations() @@ -2088,8 +2089,10 @@ def mouseClickEvent(self, event): event.accept() elif event.button() == Qt.RightButton and self.movable: self.remove() - # Propagate remove request to lower annotations if overlapping - event.ignore() + # the annotation removed should be the one on top of all others, which + # should correspond to the one of the type currently selected and with + # the highest zValue + event.accept() else: event.ignore() @@ -2228,7 +2231,7 @@ def _init_ui(self): self.description_cmbx = QComboBox() self.description_cmbx.setSizeAdjustPolicy(QComboBox.AdjustToContents) - self.description_cmbx.activated.connect(self._description_changed) + self.description_cmbx.currentIndexChanged.connect(self._description_changed) self._update_description_cmbx() layout.addWidget(self.description_cmbx) @@ -2461,6 +2464,12 @@ def _select_annotations(self): def _description_changed(self, descr_idx): new_descr = self.description_cmbx.itemText(descr_idx) self.mne.current_description = new_descr + # increase zValue of currently selected annotation and decrease all the others + for region in self.mne.regions: + if region.description == self.mne.current_description: + region.setZValue(2) + else: + region.setZValue(1) def _start_changed(self): start = self.start_bx.value() @@ -4196,7 +4205,9 @@ def _change_annot_mode(self): for region in self.mne.regions: region.setMovable(self.mne.annotation_mode) if self.mne.annotation_mode: - region.setZValue(2) + region.setZValue( + 2 if region.description == self.mne.current_description else 1 + ) else: region.setZValue(0) diff --git a/mne_qt_browser/conftest.py b/mne_qt_browser/conftest.py index d832356b..586fa5f1 100644 --- a/mne_qt_browser/conftest.py +++ b/mne_qt_browser/conftest.py @@ -17,7 +17,7 @@ def pytest_configure(config): """Configure pytest options.""" # Markers - for marker in ('benchmark',): + for marker in ('benchmark', 'pgtest', 'slowtest'): config.addinivalue_line('markers', marker) diff --git a/mne_qt_browser/tests/test_pg_specific.py b/mne_qt_browser/tests/test_pg_specific.py index 36fdb186..9fcebd48 100644 --- a/mne_qt_browser/tests/test_pg_specific.py +++ b/mne_qt_browser/tests/test_pg_specific.py @@ -24,7 +24,7 @@ def test_annotations_interactions(raw_orig, pg_backend): fig._fake_keypress('a') # Set current description to index 1 - annot_dock.description_cmbx.activated.emit(1) + annot_dock.description_cmbx.setCurrentIndex(1) assert fig.mne.current_description == 'B' # Draw additional annotation diff --git a/mne_qt_browser/tests/test_speed.py b/mne_qt_browser/tests/test_speed.py index 80a3a214..bf7e64e5 100644 --- a/mne_qt_browser/tests/test_speed.py +++ b/mne_qt_browser/tests/test_speed.py @@ -146,7 +146,7 @@ def test_scroll_speed_epochs_unicolor(raw_orig, benchmark_param, store, # Prevent problems with info's locked-stated epochs.info._unlocked = True - fig = epochs.plot(show=False, block=False, **benchmark_param) + fig = epochs.plot(show=False, block=False, events=False, **benchmark_param) _Benchmark(fig, qapp, store, request) @@ -189,6 +189,6 @@ def test_scroll_speed_epochs_multicolor(raw_orig, benchmark_param, store, if sys.platform == 'darwin': benchmark_param['use_opengl'] = True - fig = epochs.plot(show=False, block=False, epoch_colors=epoch_colors, + fig = epochs.plot(show=False, block=False, events=False, epoch_colors=epoch_colors, **benchmark_param) _Benchmark(fig, qapp, store, request)