Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ENH: Improve vline #181

Merged
merged 14 commits into from
Aug 2, 2023
18 changes: 14 additions & 4 deletions mne_qt_browser/_pg_figure.py
Original file line number Diff line number Diff line change
Expand Up @@ -1340,7 +1340,7 @@ class VLineLabel(InfLineLabel):

def __init__(self, vline):
super().__init__(vline, text='{value:.3f} s', position=0.98,
fill='g', color='b', movable=True)
fill=(0, 191, 0), color='k', movable=True)
marsipu marked this conversation as resolved.
Show resolved Hide resolved
self.cursorOffset = None

def mouseDragEvent(self, ev):
Expand Down Expand Up @@ -1376,16 +1376,25 @@ def valueChanged(self):
self.setText(self.format.format(value=value))
self.updatePosition()

def hoverEvent(self, ev):
_methpartial(self.line.hoverEvent)(ev)


class VLine(InfiniteLine):
"""Marker to be placed inside the Trace-Plot."""

def __init__(self, mne, pos, bounds):
super().__init__(pos, pen='g', hoverPen='y',
super().__init__(pos, pen={"color": (0, 191, 0), "width": 2}, hoverPen='y',
movable=True, bounds=bounds)
self.mne = mne
self.label = VLineLabel(self)

def setMouseHover(self, hover):
super().setMouseHover(hover)
# Also change color of label
self.label.fill = self.currentPen.color()
self.label.border = self.currentPen


def _q_font(point_size, bold=False):
font = QFont()
Expand Down Expand Up @@ -3411,6 +3420,7 @@ def __init__(self, **kwargs):
# disable histogram of epoch PTP amplitude
del self.mne.keyboard_shortcuts["h"]


def _hidpi_mkPen(self, *args, **kwargs):
kwargs['width'] = self._pixel_ratio * kwargs.get('width', 1.)
return mkPen(*args, **kwargs)
Expand Down Expand Up @@ -4706,10 +4716,10 @@ def closeEvent(self, event):
if getattr(self.mne, 'vline', None) is not None:
if self.mne.is_epochs:
for vl in self.mne.vline:
_disconnect(vl.sigPositionChangeFinished)
_disconnect(vl.sigPositionChangeFinished, allow_error=True)
self.mne.vline.clear()
else:
_disconnect(self.mne.vline.sigPositionChangeFinished)
_disconnect(self.mne.vline.sigPositionChangeFinished, allow_error=True)
marsipu marked this conversation as resolved.
Show resolved Hide resolved
marsipu marked this conversation as resolved.
Show resolved Hide resolved
if getattr(self, 'load_thread', None) is not None:
self.load_thread.clean()
self.load_thread = None
Expand Down