Skip to content

Commit

Permalink
pile_viewer: fix live update of marker_editor
Browse files Browse the repository at this point in the history
  • Loading branch information
Marius Kriegerowski committed May 8, 2018
1 parent 2b6fea9 commit ea2e3ee
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 10 deletions.
1 change: 0 additions & 1 deletion src/gui/marker.py
Original file line number Diff line number Diff line change
Expand Up @@ -856,7 +856,6 @@ def from_attributes(vals, version='0.3'):
uncertainty = str_to_float_or_none(vals[-1])
else:
uncertainty = None
raise Exception("Unsupported version %s" % version)

nslc_ids, tmin, tmax, kind = Marker.parse_attributes(
vals[1:1+nbasicvals])
Expand Down
16 changes: 7 additions & 9 deletions src/gui/pile_viewer.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
import pyrocko.plot
import pyrocko.gui.snuffling
import pyrocko.gui.snufflings
import pyrocko.gui.marker_editor

from pyrocko.util import hpfloat, gmtime_x, mystrftime

Expand Down Expand Up @@ -1820,7 +1819,7 @@ def mousePressEvent(self, mouse_ev):
self.track_start = mouse_ev.x(), mouse_ev.y()
self.track_trange = self.tmin, self.tmax

if mouse_ev.modifiers() & qc.Qt.ShiftModifier:
if mouse_ev.modifiers() & qc.Qt.ControlModifier:
self.set_uncertainty_y = self.time_projection(point.y())

if mouse_ev.button() == qc.Qt.RightButton:
Expand Down Expand Up @@ -1892,6 +1891,8 @@ def update_uncertainty(self, y):
if isinstance(m, PhaseMarker):
m._uncertainty = m._uncertainty or 0.
m._uncertainty = max(0., m._uncertainty + d)

self.emit_selected_markers()
self._last_y = y

def nslc_ids_under_cursor(self, x, y):
Expand Down Expand Up @@ -1984,12 +1985,14 @@ def keyPressEvent(self, key_event):
if isinstance(m, PhaseMarker):
p = 1 if m.get_polarity() != 1 else None
m.set_polarity(p)
self.emit_selected_markers()

elif key_event.key() == qc.Qt.Key_Down:
for m in self.selected_markers():
if isinstance(m, PhaseMarker):
p = -1 if m.get_polarity() != -1 else None
m.set_polarity(p)
self.emit_selected_markers()

elif keytext == 'b':
dt = self.tmax - self.tmin
Expand Down Expand Up @@ -2190,6 +2193,8 @@ def handle_fkeys(self, key):
self.emit_selected_markers()

def emit_selected_markers(self):
'''Emits indices of selected markers and triggers an update
of according entries in the marker_editor.'''
_indexes = []
selected_markers = self.selected_markers()
markers = self.get_markers()
Expand Down Expand Up @@ -4123,13 +4128,6 @@ def controls(self):
self.adjust_controls()
return frame

def marker_editor(self):
editor = pyrocko.gui.marker_editor.MarkerEditor(self)
editor.set_viewer(self.get_view())
editor.get_marker_model().dataChanged.connect(
self.update_contents)
return editor

def adjust_controls(self):
dtmin, dtmax = self.viewer.content_deltat_range()
maxfreq = 0.5/dtmin
Expand Down

0 comments on commit ea2e3ee

Please sign in to comment.