adding some tabs for map_projection, WIP
This commit is contained in:
parent
62876dd01d
commit
fd70ef2251
49
QtPyLoT.py
49
QtPyLoT.py
@ -36,7 +36,7 @@ from PySide.QtGui import QMainWindow, QInputDialog, QIcon, QFileDialog, \
|
|||||||
QWidget, QHBoxLayout, QVBoxLayout, QStyle, QKeySequence, QLabel, QFrame, QAction, \
|
QWidget, QHBoxLayout, QVBoxLayout, QStyle, QKeySequence, QLabel, QFrame, QAction, \
|
||||||
QDialog, QErrorMessage, QApplication, QPixmap, QMessageBox, QSplashScreen, \
|
QDialog, QErrorMessage, QApplication, QPixmap, QMessageBox, QSplashScreen, \
|
||||||
QActionGroup, QListWidget, QDockWidget, QLineEdit, QListView, QAbstractItemView, \
|
QActionGroup, QListWidget, QDockWidget, QLineEdit, QListView, QAbstractItemView, \
|
||||||
QTreeView, QComboBox
|
QTreeView, QComboBox, QTabWidget
|
||||||
import numpy as np
|
import numpy as np
|
||||||
from obspy import UTCDateTime
|
from obspy import UTCDateTime
|
||||||
|
|
||||||
@ -87,6 +87,10 @@ class MainWindow(QMainWindow):
|
|||||||
else:
|
else:
|
||||||
self.infile = infile
|
self.infile = infile
|
||||||
|
|
||||||
|
self.project = None
|
||||||
|
self.array_map = None
|
||||||
|
self._metadata = None
|
||||||
|
|
||||||
# UI has to be set up before(!) children widgets are about to show up
|
# UI has to be set up before(!) children widgets are about to show up
|
||||||
self.createAction = createAction
|
self.createAction = createAction
|
||||||
# read settings
|
# read settings
|
||||||
@ -121,10 +125,6 @@ class MainWindow(QMainWindow):
|
|||||||
self.picks = {}
|
self.picks = {}
|
||||||
self.autopicks = {}
|
self.autopicks = {}
|
||||||
self.loc = False
|
self.loc = False
|
||||||
self._metadata = None
|
|
||||||
self.project = None
|
|
||||||
|
|
||||||
self.array_map = None
|
|
||||||
|
|
||||||
# initialize event data
|
# initialize event data
|
||||||
if self.recentfiles:
|
if self.recentfiles:
|
||||||
@ -154,30 +154,39 @@ class MainWindow(QMainWindow):
|
|||||||
|
|
||||||
_widget = QWidget()
|
_widget = QWidget()
|
||||||
_widget.setCursor(Qt.CrossCursor)
|
_widget.setCursor(Qt.CrossCursor)
|
||||||
_layout = QVBoxLayout()
|
self._main_layout = QVBoxLayout()
|
||||||
|
|
||||||
|
|
||||||
# add event combo box
|
# add event combo box
|
||||||
self.eventBox = QComboBox()
|
self.eventBox = QComboBox()
|
||||||
self.eventBox.setMaxVisibleItems(30)
|
self.eventBox.setMaxVisibleItems(30)
|
||||||
self.eventBox.setEnabled(False)
|
self.eventBox.setEnabled(False)
|
||||||
_event_layout = QHBoxLayout()
|
self._event_layout = QHBoxLayout()
|
||||||
_event_layout.addWidget(QLabel('Event: '))
|
self._event_layout.addWidget(QLabel('Event: '))
|
||||||
_event_layout.addWidget(self.eventBox)
|
self._event_layout.addWidget(self.eventBox)
|
||||||
_event_layout.setStretch(1,1) #set stretch of item 1 to 1
|
self._event_layout.setStretch(1,1) #set stretch of item 1 to 1
|
||||||
_layout.addLayout(_event_layout)
|
self._main_layout.addLayout(self._event_layout)
|
||||||
self.eventBox.activated.connect(self.loadWaveformDataThread)
|
self.eventBox.activated.connect(self.loadWaveformDataThread)
|
||||||
|
|
||||||
plottitle = "Overview: {0} components ".format(self.getComponent())
|
# add tabs
|
||||||
|
self.tabs = QTabWidget()
|
||||||
|
self._main_layout.addWidget(self.tabs)
|
||||||
|
|
||||||
|
# init Map
|
||||||
|
#self.init_array_map()
|
||||||
|
|
||||||
# create central matplotlib figure canvas widget
|
# create central matplotlib figure canvas widget
|
||||||
|
plottitle = "Overview: {0} components ".format(self.getComponent())
|
||||||
self.DataPlot = WaveformWidget(parent=self, xlabel=xlab, ylabel=None,
|
self.DataPlot = WaveformWidget(parent=self, xlabel=xlab, ylabel=None,
|
||||||
title=plottitle)
|
title=plottitle)
|
||||||
self.DataPlot.mpl_connect('button_press_event',
|
self.DataPlot.mpl_connect('button_press_event',
|
||||||
self.pickOnStation)
|
self.pickOnStation)
|
||||||
self.DataPlot.mpl_connect('axes_enter_event',
|
self.DataPlot.mpl_connect('axes_enter_event',
|
||||||
lambda event: self.tutor_user())
|
lambda event: self.tutor_user())
|
||||||
_layout.addWidget(self.DataPlot)
|
self.tabs.addTab(self.DataPlot, 'Waveform Plot')
|
||||||
|
#self.tabs.addTab(self.array_map, 'Array Map')
|
||||||
|
|
||||||
|
|
||||||
quitIcon = self.style().standardIcon(QStyle.SP_MediaStop)
|
quitIcon = self.style().standardIcon(QStyle.SP_MediaStop)
|
||||||
saveIcon = self.style().standardIcon(QStyle.SP_DriveHDIcon)
|
saveIcon = self.style().standardIcon(QStyle.SP_DriveHDIcon)
|
||||||
openIcon = self.style().standardIcon(QStyle.SP_DirOpenIcon)
|
openIcon = self.style().standardIcon(QStyle.SP_DirOpenIcon)
|
||||||
@ -415,7 +424,7 @@ class MainWindow(QMainWindow):
|
|||||||
status.addPermanentWidget(self.eventLabel)
|
status.addPermanentWidget(self.eventLabel)
|
||||||
status.showMessage("Ready", 500)
|
status.showMessage("Ready", 500)
|
||||||
|
|
||||||
_widget.setLayout(_layout)
|
_widget.setLayout(self._main_layout)
|
||||||
_widget.showFullScreen()
|
_widget.showFullScreen()
|
||||||
|
|
||||||
self.setCentralWidget(_widget)
|
self.setCentralWidget(_widget)
|
||||||
@ -1121,14 +1130,20 @@ class MainWindow(QMainWindow):
|
|||||||
self.get_data().applyEVTData(lt.read_location(locpath), type='event')
|
self.get_data().applyEVTData(lt.read_location(locpath), type='event')
|
||||||
self.get_data().applyEVTData(self.calc_magnitude(), type='event')
|
self.get_data().applyEVTData(self.calc_magnitude(), type='event')
|
||||||
|
|
||||||
def show_array_map(self):
|
def init_array_map(self):
|
||||||
if not self.array_map:
|
if not self.array_map:
|
||||||
self.get_metadata()
|
self.get_metadata()
|
||||||
if not self.metadata:
|
if not self.metadata:
|
||||||
return
|
return
|
||||||
self.array_map = map_projection(self)
|
self.array_map = map_projection(self)
|
||||||
else:
|
|
||||||
self.array_map.show()
|
def show_array_map(self, container=None):
|
||||||
|
if not self.array_map:
|
||||||
|
print('No array map found. Init array map first!')
|
||||||
|
return
|
||||||
|
if self.container:
|
||||||
|
container.addWidget(self.array_map)
|
||||||
|
self.array_map.show()
|
||||||
|
|
||||||
def get_metadata(self):
|
def get_metadata(self):
|
||||||
def set_inv(settings):
|
def set_inv(settings):
|
||||||
|
@ -1 +1 @@
|
|||||||
3092-dirty
|
6287-dirty
|
||||||
|
@ -12,10 +12,16 @@ from pylot.core.util.widgets import PickDlg
|
|||||||
plt.interactive(False)
|
plt.interactive(False)
|
||||||
|
|
||||||
class map_projection(QtGui.QWidget):
|
class map_projection(QtGui.QWidget):
|
||||||
def __init__(self, mainwindow):
|
def __init__(self, mainwindow, figure=None, picked=False):
|
||||||
|
'''
|
||||||
|
:param: picked, can be False, auto, manual
|
||||||
|
:value: str
|
||||||
|
'''
|
||||||
QtGui.QWidget.__init__(self)
|
QtGui.QWidget.__init__(self)
|
||||||
self.pyl_mainwindow = mainwindow
|
self.pyl_mainwindow = mainwindow
|
||||||
self.parser = mainwindow.metadata[1]
|
self.parser = mainwindow.metadata[1]
|
||||||
|
self.picked = picked
|
||||||
|
self.figure = figure
|
||||||
self.init_graphics()
|
self.init_graphics()
|
||||||
self.init_stations()
|
self.init_stations()
|
||||||
self.init_lat_lon_dimensions()
|
self.init_lat_lon_dimensions()
|
||||||
@ -24,7 +30,7 @@ class map_projection(QtGui.QWidget):
|
|||||||
self.init_x_y_dimensions()
|
self.init_x_y_dimensions()
|
||||||
self.connectSignals()
|
self.connectSignals()
|
||||||
self.draw_everything()
|
self.draw_everything()
|
||||||
self.show()
|
#self.show()
|
||||||
|
|
||||||
def onpick(self, event):
|
def onpick(self, event):
|
||||||
ind = event.ind
|
ind = event.ind
|
||||||
@ -71,8 +77,11 @@ class map_projection(QtGui.QWidget):
|
|||||||
self.combobox.insertItem(1, 'S')
|
self.combobox.insertItem(1, 'S')
|
||||||
self.top_row.addWidget(QtGui.QLabel('Select a phase: '))
|
self.top_row.addWidget(QtGui.QLabel('Select a phase: '))
|
||||||
self.top_row.addWidget(self.combobox)
|
self.top_row.addWidget(self.combobox)
|
||||||
|
|
||||||
fig = plt.figure()
|
if not self.figure:
|
||||||
|
fig = plt.figure()
|
||||||
|
else:
|
||||||
|
fig = self.figure
|
||||||
self.main_ax = fig.add_subplot(111)
|
self.main_ax = fig.add_subplot(111)
|
||||||
self.canvas = fig.canvas
|
self.canvas = fig.canvas
|
||||||
self.main_box.addWidget(self.canvas)
|
self.main_box.addWidget(self.canvas)
|
||||||
@ -221,15 +230,17 @@ class map_projection(QtGui.QWidget):
|
|||||||
self.draw_everything()
|
self.draw_everything()
|
||||||
|
|
||||||
def draw_everything(self):
|
def draw_everything(self):
|
||||||
self.init_picks()
|
if self.picked:
|
||||||
self.init_picks_active()
|
self.init_picks()
|
||||||
self.init_stations_active()
|
self.init_picks_active()
|
||||||
self.init_picksgrid()
|
self.init_stations_active()
|
||||||
self.draw_contour_filled()
|
self.init_picksgrid()
|
||||||
|
self.draw_contour_filled()
|
||||||
self.scatter_all_stations()
|
self.scatter_all_stations()
|
||||||
self.scatter_picked_stations()
|
if self.picked:
|
||||||
|
self.scatter_picked_stations()
|
||||||
|
self.cbar = self.add_cbar(label='Time relative to first onset [s]')
|
||||||
self.annotate_ax()
|
self.annotate_ax()
|
||||||
self.cbar = self.add_cbar(label='Time relative to first onset [s]')
|
|
||||||
self.canvas.draw()
|
self.canvas.draw()
|
||||||
|
|
||||||
def remove_drawings(self):
|
def remove_drawings(self):
|
||||||
|
Loading…
Reference in New Issue
Block a user