trying to get the picking of plot coordinates working (pending for poster preparation)

This commit is contained in:
Sebastian Wehling-Benatelli 2015-03-11 12:05:52 +01:00
parent 486449fbb5
commit a0bbe8ca04
6 changed files with 51 additions and 40 deletions

View File

@ -25,7 +25,8 @@ https://www.iconfinder.com/iconsets/flavour
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, \
QWidget, QHBoxLayout, QStyle, QKeySequence, QLabel, QFrame, QAction, \
QDialog, QErrorMessage, QApplication
@ -37,8 +38,7 @@ from pylot.core.util import _getVersionString, FILTERDEFAULTS, fnConstructor, \
NewEventDlg, createEvent, MPLWidget, PropertiesDlg, HelpForm, \
DatastructureError, createAction, getLogin, createCreationInfo, PickDlg
from pylot.core.util.structure import DATASTRUCTURE
import qrc_resources
# Version information
__version__ = _getVersionString()
@ -60,6 +60,7 @@ class MainWindow(QMainWindow):
settings.setValue("user/Login", getLogin())
if settings.value("agency_id", None) is None:
agency = QInputDialog.getText(self, "Enter authority name (e.g. BUG):", "Authority")
settings.setValue("agency_id", agency)
self.recentEvents = settings.value("data/recentEvents", [])
self.fnames = None
self.dataStructure = DATASTRUCTURE[
@ -106,6 +107,7 @@ class MainWindow(QMainWindow):
xlab = self.startTime.strftime('seconds since %d %b %Y %H:%M:%S (%Z)')
_widget = QWidget()
_widget.setCursor(Qt.CrossCursor)
_layout = QHBoxLayout()
plottitle = "Overview: {0} components ".format(self.getComponent())
@ -121,24 +123,29 @@ class MainWindow(QMainWindow):
saveIcon = self.style().standardIcon(QStyle.SP_DriveHDIcon)
helpIcon = self.style().standardIcon(QStyle.SP_DialogHelpButton)
newIcon = self.style().standardIcon(QStyle.SP_FileIcon)
pickIcon = QIcon(':/pick.png')
newEventAction = self.createAction(self, "&New event ...",
self.createNewEvent,
QKeySequence.New, newIcon,
"Create a new event.")
openEventAction = self.createAction(self, "&Open event ...", self.loadData,
QKeySequence.Open, openIcon,
"Open an event.")
openEventAction = self.createAction(self, "&Open event ...",
self.loadData, QKeySequence.Open,
openIcon, "Open an event.")
openEventAction.setData(None)
saveEventAction = self.createAction(self, "&Save event ...", self.saveData,
QKeySequence.Save, saveIcon,
"Save actual event data.")
saveEventAction = self.createAction(self, "&Save event ...",
self.saveData, QKeySequence.Save,
saveIcon, "Save actual event data.")
openWFDataAction = self.createAction(self, "Open &waveforms ...",
self.loadWaveformData,
"Ctrl+W", QIcon(":/wfIcon.png"),
"""Open waveform data (event will
be closed).""")
prefsEventAction = self.createAction(self, "Preferences", self.PyLoTprefs,
selectStation = self.createAction(self, "Select station",
self.pickOnStation, "Alt+P", pickIcon,
"Select a station from overview "
"plot for picking")
prefsEventAction = self.createAction(self, "Preferences",
self.PyLoTprefs,
QKeySequence.Preferences,
QIcon(None),
"Edit PyLoT app preferences.")
@ -197,6 +204,11 @@ class MainWindow(QMainWindow):
phaseToolBar.setObjectName("PhaseTools")
self.addActions(phaseToolBar, phaseToolActions)
pickToolBar = self.addToolBar("PickTools")
pickToolActions = (selectStation, )
pickToolBar.setObjectName("PickTools")
self.addActions(pickToolBar, pickToolActions)
self.eventLabel = QLabel()
self.eventLabel.setFrameStyle(QFrame.StyledPanel | QFrame.Sunken)
status = self.statusBar()
@ -205,8 +217,9 @@ class MainWindow(QMainWindow):
status.showMessage("Ready", 500)
_widget.setLayout(_layout)
self.setCentralWidget(_widget)
_widget.showFullScreen()
self.setCentralWidget(_widget)
def updateFileMenu(self):
@ -323,8 +336,13 @@ class MainWindow(QMainWindow):
def getPlotWidget(self):
return self.DataPlot
def getWFID(self):
return self.getPlotWidget().getStatID()
def getWFID(self, event):
ycoord = event.ydata
statID = round(ycoord)
return statID
def addActions(self, target, actions):
for action in actions:
@ -433,9 +451,9 @@ class MainWindow(QMainWindow):
self.updateStatus('Seismic phase changed to '
'{0}'.format(self.getSeismicPhase()))
def pickOnStation(self):
def pickOnStation(self, event):
wfID = self.getWFID()
wfID = self.getWFID(event)
station = self.getStationName(wfID)
self.pickDlgs[wfID] = PickDlg(self,

BIN
icons/pick.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 22 KiB

View File

@ -97,6 +97,7 @@ class Data(object):
def plotWFData(self, widget):
wfst = self.getWFData().select(component=self.getComp())
widget.axes.cla()
for n, trace in enumerate(wfst):
stime = trace.stats.starttime - self.getCutTimes()[0]
etime = trace.stats.endtime - self.getCutTimes()[1]

View File

@ -13,6 +13,7 @@ matplotlib.rcParams['backend.qt4'] = 'PySide'
from matplotlib.figure import Figure
from matplotlib.backends.backend_qt4agg import FigureCanvasQTAgg as FigureCanvas
from matplotlib.widgets import MultiCursor
from PySide.QtGui import (QAction,
QApplication,
QComboBox,
@ -70,25 +71,13 @@ class MPLWidget(FigureCanvas):
self.setParent(parent)
self.figure = Figure()
self.canvas = FigureCanvas(self.figure)
self.canvas.mpl_connect('button_press_event', self.emitSelection)
self.axes = self.figure.add_subplot(111)
self.axes.autoscale(tight=True)
self._statID = None
self.multiCursor = MultiCursor(self.canvas, (self.axes,), horizOn=True,
color='m', lw=1)
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):
return self._parent
@ -119,7 +108,6 @@ class multiComponentPlot(FigureCanvas):
self.figure = Figure()
self.canvas = FigureCanvas(self.figure)
self.noc = len(components)
self.axeslist = []
def plotData(self, components, data):
@ -145,6 +133,7 @@ class multiComponentPlot(FigureCanvas):
self.updateXLabel(self.noc, xlabel)
else:
self.updateXLabel(n, '')
self.multiCursor = MultiCursor(self.canvas, tuple(self.axeslist))
def insertLabel(self, pos, text):
subax = self.axeslist[pos]

File diff suppressed because one or more lines are too long

View File

@ -1,9 +1,12 @@
<RCC>
<qresource>
<file alias="icon.ico">icons/pylot.ico</file>
<file alias="printer.png">icons/printer.png</file>
<file alias="picon.png">icons/picon.png</file>
<file alias="sicon.png">icons/sicon.png</file>
<file alias="help.html">help/index.html</file>
<file>icons/pylot.ico</file>
<file>icons/printer.png</file>
<file>icons/picon.png</file>
<file>icons/sicon.png</file>
<file>icons/pick.png</file>
</qresource>
<qresource prefix="/help">
<file>help/index.html</file>
</qresource>
</RCC>