trying to get the picking of plot coordinates working (pending for poster preparation)
This commit is contained in:
parent
486449fbb5
commit
a0bbe8ca04
50
QtPyLoT.py
50
QtPyLoT.py
@ -25,7 +25,8 @@ https://www.iconfinder.com/iconsets/flavour
|
|||||||
|
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
from PySide.QtCore import QCoreApplication, QSettings, Signal, QFile, QFileInfo
|
from PySide.QtCore import QCoreApplication, QSettings, Signal, QFile, \
|
||||||
|
QFileInfo, Qt
|
||||||
from PySide.QtGui import QMainWindow, QInputDialog, QIcon, QFileDialog, \
|
from PySide.QtGui import QMainWindow, QInputDialog, QIcon, QFileDialog, \
|
||||||
QWidget, QHBoxLayout, QStyle, QKeySequence, QLabel, QFrame, QAction, \
|
QWidget, QHBoxLayout, QStyle, QKeySequence, QLabel, QFrame, QAction, \
|
||||||
QDialog, QErrorMessage, QApplication
|
QDialog, QErrorMessage, QApplication
|
||||||
@ -37,8 +38,7 @@ from pylot.core.util import _getVersionString, FILTERDEFAULTS, fnConstructor, \
|
|||||||
NewEventDlg, createEvent, MPLWidget, PropertiesDlg, HelpForm, \
|
NewEventDlg, createEvent, MPLWidget, PropertiesDlg, HelpForm, \
|
||||||
DatastructureError, createAction, getLogin, createCreationInfo, PickDlg
|
DatastructureError, createAction, getLogin, createCreationInfo, PickDlg
|
||||||
from pylot.core.util.structure import DATASTRUCTURE
|
from pylot.core.util.structure import DATASTRUCTURE
|
||||||
|
import qrc_resources
|
||||||
|
|
||||||
|
|
||||||
# Version information
|
# Version information
|
||||||
__version__ = _getVersionString()
|
__version__ = _getVersionString()
|
||||||
@ -60,6 +60,7 @@ class MainWindow(QMainWindow):
|
|||||||
settings.setValue("user/Login", getLogin())
|
settings.setValue("user/Login", getLogin())
|
||||||
if settings.value("agency_id", None) is None:
|
if settings.value("agency_id", None) is None:
|
||||||
agency = QInputDialog.getText(self, "Enter authority name (e.g. BUG):", "Authority")
|
agency = QInputDialog.getText(self, "Enter authority name (e.g. BUG):", "Authority")
|
||||||
|
settings.setValue("agency_id", agency)
|
||||||
self.recentEvents = settings.value("data/recentEvents", [])
|
self.recentEvents = settings.value("data/recentEvents", [])
|
||||||
self.fnames = None
|
self.fnames = None
|
||||||
self.dataStructure = DATASTRUCTURE[
|
self.dataStructure = DATASTRUCTURE[
|
||||||
@ -106,6 +107,7 @@ class MainWindow(QMainWindow):
|
|||||||
xlab = self.startTime.strftime('seconds since %d %b %Y %H:%M:%S (%Z)')
|
xlab = self.startTime.strftime('seconds since %d %b %Y %H:%M:%S (%Z)')
|
||||||
|
|
||||||
_widget = QWidget()
|
_widget = QWidget()
|
||||||
|
_widget.setCursor(Qt.CrossCursor)
|
||||||
_layout = QHBoxLayout()
|
_layout = QHBoxLayout()
|
||||||
|
|
||||||
plottitle = "Overview: {0} components ".format(self.getComponent())
|
plottitle = "Overview: {0} components ".format(self.getComponent())
|
||||||
@ -121,24 +123,29 @@ class MainWindow(QMainWindow):
|
|||||||
saveIcon = self.style().standardIcon(QStyle.SP_DriveHDIcon)
|
saveIcon = self.style().standardIcon(QStyle.SP_DriveHDIcon)
|
||||||
helpIcon = self.style().standardIcon(QStyle.SP_DialogHelpButton)
|
helpIcon = self.style().standardIcon(QStyle.SP_DialogHelpButton)
|
||||||
newIcon = self.style().standardIcon(QStyle.SP_FileIcon)
|
newIcon = self.style().standardIcon(QStyle.SP_FileIcon)
|
||||||
|
pickIcon = QIcon(':/pick.png')
|
||||||
newEventAction = self.createAction(self, "&New event ...",
|
newEventAction = self.createAction(self, "&New event ...",
|
||||||
self.createNewEvent,
|
self.createNewEvent,
|
||||||
QKeySequence.New, newIcon,
|
QKeySequence.New, newIcon,
|
||||||
"Create a new event.")
|
"Create a new event.")
|
||||||
openEventAction = self.createAction(self, "&Open event ...", self.loadData,
|
openEventAction = self.createAction(self, "&Open event ...",
|
||||||
QKeySequence.Open, openIcon,
|
self.loadData, QKeySequence.Open,
|
||||||
"Open an event.")
|
openIcon, "Open an event.")
|
||||||
openEventAction.setData(None)
|
openEventAction.setData(None)
|
||||||
saveEventAction = self.createAction(self, "&Save event ...", self.saveData,
|
saveEventAction = self.createAction(self, "&Save event ...",
|
||||||
QKeySequence.Save, saveIcon,
|
self.saveData, QKeySequence.Save,
|
||||||
"Save actual event data.")
|
saveIcon, "Save actual event data.")
|
||||||
openWFDataAction = self.createAction(self, "Open &waveforms ...",
|
openWFDataAction = self.createAction(self, "Open &waveforms ...",
|
||||||
self.loadWaveformData,
|
self.loadWaveformData,
|
||||||
"Ctrl+W", QIcon(":/wfIcon.png"),
|
"Ctrl+W", QIcon(":/wfIcon.png"),
|
||||||
"""Open waveform data (event will
|
"""Open waveform data (event will
|
||||||
be closed).""")
|
be closed).""")
|
||||||
|
selectStation = self.createAction(self, "Select station",
|
||||||
prefsEventAction = self.createAction(self, "Preferences", self.PyLoTprefs,
|
self.pickOnStation, "Alt+P", pickIcon,
|
||||||
|
"Select a station from overview "
|
||||||
|
"plot for picking")
|
||||||
|
prefsEventAction = self.createAction(self, "Preferences",
|
||||||
|
self.PyLoTprefs,
|
||||||
QKeySequence.Preferences,
|
QKeySequence.Preferences,
|
||||||
QIcon(None),
|
QIcon(None),
|
||||||
"Edit PyLoT app preferences.")
|
"Edit PyLoT app preferences.")
|
||||||
@ -197,6 +204,11 @@ class MainWindow(QMainWindow):
|
|||||||
phaseToolBar.setObjectName("PhaseTools")
|
phaseToolBar.setObjectName("PhaseTools")
|
||||||
self.addActions(phaseToolBar, phaseToolActions)
|
self.addActions(phaseToolBar, phaseToolActions)
|
||||||
|
|
||||||
|
pickToolBar = self.addToolBar("PickTools")
|
||||||
|
pickToolActions = (selectStation, )
|
||||||
|
pickToolBar.setObjectName("PickTools")
|
||||||
|
self.addActions(pickToolBar, pickToolActions)
|
||||||
|
|
||||||
self.eventLabel = QLabel()
|
self.eventLabel = QLabel()
|
||||||
self.eventLabel.setFrameStyle(QFrame.StyledPanel | QFrame.Sunken)
|
self.eventLabel.setFrameStyle(QFrame.StyledPanel | QFrame.Sunken)
|
||||||
status = self.statusBar()
|
status = self.statusBar()
|
||||||
@ -205,8 +217,9 @@ class MainWindow(QMainWindow):
|
|||||||
status.showMessage("Ready", 500)
|
status.showMessage("Ready", 500)
|
||||||
|
|
||||||
_widget.setLayout(_layout)
|
_widget.setLayout(_layout)
|
||||||
self.setCentralWidget(_widget)
|
_widget.showFullScreen()
|
||||||
|
|
||||||
|
self.setCentralWidget(_widget)
|
||||||
|
|
||||||
def updateFileMenu(self):
|
def updateFileMenu(self):
|
||||||
|
|
||||||
@ -323,8 +336,13 @@ class MainWindow(QMainWindow):
|
|||||||
def getPlotWidget(self):
|
def getPlotWidget(self):
|
||||||
return self.DataPlot
|
return self.DataPlot
|
||||||
|
|
||||||
def getWFID(self):
|
def getWFID(self, event):
|
||||||
return self.getPlotWidget().getStatID()
|
|
||||||
|
ycoord = event.ydata
|
||||||
|
|
||||||
|
statID = round(ycoord)
|
||||||
|
|
||||||
|
return statID
|
||||||
|
|
||||||
def addActions(self, target, actions):
|
def addActions(self, target, actions):
|
||||||
for action in actions:
|
for action in actions:
|
||||||
@ -433,9 +451,9 @@ class MainWindow(QMainWindow):
|
|||||||
self.updateStatus('Seismic phase changed to '
|
self.updateStatus('Seismic phase changed to '
|
||||||
'{0}'.format(self.getSeismicPhase()))
|
'{0}'.format(self.getSeismicPhase()))
|
||||||
|
|
||||||
def pickOnStation(self):
|
def pickOnStation(self, event):
|
||||||
|
|
||||||
wfID = self.getWFID()
|
wfID = self.getWFID(event)
|
||||||
|
|
||||||
station = self.getStationName(wfID)
|
station = self.getStationName(wfID)
|
||||||
self.pickDlgs[wfID] = PickDlg(self,
|
self.pickDlgs[wfID] = PickDlg(self,
|
||||||
|
BIN
icons/pick.png
Normal file
BIN
icons/pick.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 22 KiB |
@ -97,6 +97,7 @@ class Data(object):
|
|||||||
|
|
||||||
def plotWFData(self, widget):
|
def plotWFData(self, widget):
|
||||||
wfst = self.getWFData().select(component=self.getComp())
|
wfst = self.getWFData().select(component=self.getComp())
|
||||||
|
widget.axes.cla()
|
||||||
for n, trace in enumerate(wfst):
|
for n, trace in enumerate(wfst):
|
||||||
stime = trace.stats.starttime - self.getCutTimes()[0]
|
stime = trace.stats.starttime - self.getCutTimes()[0]
|
||||||
etime = trace.stats.endtime - self.getCutTimes()[1]
|
etime = trace.stats.endtime - self.getCutTimes()[1]
|
||||||
|
@ -13,6 +13,7 @@ matplotlib.rcParams['backend.qt4'] = 'PySide'
|
|||||||
|
|
||||||
from matplotlib.figure import Figure
|
from matplotlib.figure import Figure
|
||||||
from matplotlib.backends.backend_qt4agg import FigureCanvasQTAgg as FigureCanvas
|
from matplotlib.backends.backend_qt4agg import FigureCanvasQTAgg as FigureCanvas
|
||||||
|
from matplotlib.widgets import MultiCursor
|
||||||
from PySide.QtGui import (QAction,
|
from PySide.QtGui import (QAction,
|
||||||
QApplication,
|
QApplication,
|
||||||
QComboBox,
|
QComboBox,
|
||||||
@ -70,25 +71,13 @@ class MPLWidget(FigureCanvas):
|
|||||||
self.setParent(parent)
|
self.setParent(parent)
|
||||||
self.figure = Figure()
|
self.figure = Figure()
|
||||||
self.canvas = FigureCanvas(self.figure)
|
self.canvas = FigureCanvas(self.figure)
|
||||||
self.canvas.mpl_connect('button_press_event', self.emitSelection)
|
|
||||||
self.axes = self.figure.add_subplot(111)
|
self.axes = self.figure.add_subplot(111)
|
||||||
self.axes.autoscale(tight=True)
|
self.axes.autoscale(tight=True)
|
||||||
self._statID = None
|
self._statID = None
|
||||||
|
self.multiCursor = MultiCursor(self.canvas, (self.axes,), horizOn=True,
|
||||||
|
color='m', lw=1)
|
||||||
self.updateWidget(xlabel, ylabel, title)
|
self.updateWidget(xlabel, ylabel, title)
|
||||||
|
|
||||||
def emitSelection(self, event):
|
|
||||||
|
|
||||||
self._statID = round(event.ydata)
|
|
||||||
if self.getParent():
|
|
||||||
self.getParent().pickOnStation()
|
|
||||||
|
|
||||||
def getStatID(self):
|
|
||||||
if self._statID is None:
|
|
||||||
return
|
|
||||||
else:
|
|
||||||
return self._statID
|
|
||||||
|
|
||||||
def getParent(self):
|
def getParent(self):
|
||||||
return self._parent
|
return self._parent
|
||||||
|
|
||||||
@ -119,7 +108,6 @@ class multiComponentPlot(FigureCanvas):
|
|||||||
self.figure = Figure()
|
self.figure = Figure()
|
||||||
self.canvas = FigureCanvas(self.figure)
|
self.canvas = FigureCanvas(self.figure)
|
||||||
self.noc = len(components)
|
self.noc = len(components)
|
||||||
|
|
||||||
self.axeslist = []
|
self.axeslist = []
|
||||||
|
|
||||||
def plotData(self, components, data):
|
def plotData(self, components, data):
|
||||||
@ -145,6 +133,7 @@ class multiComponentPlot(FigureCanvas):
|
|||||||
self.updateXLabel(self.noc, xlabel)
|
self.updateXLabel(self.noc, xlabel)
|
||||||
else:
|
else:
|
||||||
self.updateXLabel(n, '')
|
self.updateXLabel(n, '')
|
||||||
|
self.multiCursor = MultiCursor(self.canvas, tuple(self.axeslist))
|
||||||
|
|
||||||
def insertLabel(self, pos, text):
|
def insertLabel(self, pos, text):
|
||||||
subax = self.axeslist[pos]
|
subax = self.axeslist[pos]
|
||||||
|
File diff suppressed because one or more lines are too long
@ -1,9 +1,12 @@
|
|||||||
<RCC>
|
<RCC>
|
||||||
<qresource>
|
<qresource>
|
||||||
<file alias="icon.ico">icons/pylot.ico</file>
|
<file>icons/pylot.ico</file>
|
||||||
<file alias="printer.png">icons/printer.png</file>
|
<file>icons/printer.png</file>
|
||||||
<file alias="picon.png">icons/picon.png</file>
|
<file>icons/picon.png</file>
|
||||||
<file alias="sicon.png">icons/sicon.png</file>
|
<file>icons/sicon.png</file>
|
||||||
<file alias="help.html">help/index.html</file>
|
<file>icons/pick.png</file>
|
||||||
|
</qresource>
|
||||||
|
<qresource prefix="/help">
|
||||||
|
<file>help/index.html</file>
|
||||||
</qresource>
|
</qresource>
|
||||||
</RCC>
|
</RCC>
|
||||||
|
Loading…
Reference in New Issue
Block a user