2014-03-13 13:27:34 +01:00
|
|
|
#!/usr/bin/env python
|
2014-01-09 10:43:40 +01:00
|
|
|
#
|
|
|
|
#
|
2014-03-13 13:27:34 +01:00
|
|
|
# Main program: QtPyLoT.py
|
2014-01-09 10:43:40 +01:00
|
|
|
|
|
|
|
import os
|
|
|
|
import platform
|
|
|
|
import sys
|
2014-03-13 13:27:34 +01:00
|
|
|
from PySide.QtCore import *
|
|
|
|
from PySide.QtGui import *
|
2014-01-09 10:43:40 +01:00
|
|
|
import helpform
|
|
|
|
from pylot.core.util import _getVersionString
|
2014-03-13 13:27:34 +01:00
|
|
|
from pylot.core.read.inputs import FilterOptions
|
|
|
|
from pylot.core.util import FILTERDEFAULTS
|
2014-03-19 12:16:41 +01:00
|
|
|
from pylot.core.util import MPLWidget
|
2014-01-09 10:43:40 +01:00
|
|
|
|
|
|
|
# Version information
|
|
|
|
__version__ = _getVersionString()
|
|
|
|
|
2014-03-13 13:27:34 +01:00
|
|
|
|
2014-01-10 05:45:03 +01:00
|
|
|
class MainWindow(QMainWindow):
|
2014-03-13 13:27:34 +01:00
|
|
|
|
2014-01-10 05:45:03 +01:00
|
|
|
def __init__(self, parent=None):
|
|
|
|
super(MainWindow, self).__init__(parent)
|
2014-03-13 13:27:34 +01:00
|
|
|
|
2014-03-19 12:16:41 +01:00
|
|
|
# create central matplotlib figure widget
|
|
|
|
dataPlot = setupPlot()
|
|
|
|
self.setCentralWidget(dataPlot)
|
|
|
|
|
2014-03-13 13:27:34 +01:00
|
|
|
filterOptionsP = FILTERDEFAULTS['P']
|
|
|
|
filterOptionsS = FILTERDEFAULTS['S']
|
|
|
|
self.filterOptionsP = FilterOptions(**filterOptionsP)
|
|
|
|
self.filterOptionsS = FilterOptions(**filterOptionsS)
|
|
|
|
|
|
|
|
filteroptions = [self.filterOptionsP if not self.seismicPhase == 'S'
|
|
|
|
else self.filterOptionsS]
|
|
|
|
filterDockWidget = FilterOptionsDock(titleString="Filter Options",
|
|
|
|
parent=self,
|
|
|
|
filterOptions=filteroptions)
|
2014-03-19 12:16:41 +01:00
|
|
|
|
|
|
|
def setupPlot(self):
|
|
|
|
# create a matplotlib widget
|
|
|
|
self.DataPlot = MPLWidget()
|
|
|
|
# create a layout inside the blank widget and add the matplotlib widget
|
|
|
|
layout = QtGui.QVBoxLayout(self.ui.widget_PlotArea)
|
|
|
|
layout.addWidget(self.DataPlot, 1)
|
2014-03-13 13:27:34 +01:00
|
|
|
|
|
|
|
|
|
|
|
class PickWindow(QDialog):
|
2014-01-24 14:31:57 +01:00
|
|
|
|
2014-02-03 12:51:23 +01:00
|
|
|
def __init__(self, station=None, parent=None):
|
2014-03-13 13:27:34 +01:00
|
|
|
super(PickWindow, self).__init__(parent)
|
|
|
|
|
|
|
|
filterDockWidget = FilterOptionsDock(titleString="Filter Options",
|
|
|
|
parent=self,
|
|
|
|
filterOptions=filteroptions)
|
2014-02-03 12:51:23 +01:00
|
|
|
|
2014-01-24 14:31:57 +01:00
|
|
|
|
|
|
|
class PropertiesWindow(QDialog):
|
2014-02-03 12:51:23 +01:00
|
|
|
|
|
|
|
def __init__(self, parent=None):
|
2014-03-13 13:27:34 +01:00
|
|
|
super(PropertiesWindow, self).__init__(parent)
|
2014-02-03 12:51:23 +01:00
|
|
|
|
|
|
|
|
2014-03-13 13:27:34 +01:00
|
|
|
class FilterOptionsDock(QDockWidget):
|
2014-02-03 12:51:23 +01:00
|
|
|
|
2014-03-13 13:27:34 +01:00
|
|
|
def __init__(self, parent=None, titleString="Filter options",
|
|
|
|
filterOptions=None):
|
|
|
|
super(FilterOptionsDock, self).__init__()
|
2014-02-03 12:51:23 +01:00
|
|
|
|
2014-03-13 13:27:34 +01:00
|
|
|
if filterOptions and not isinstance(filterOptions, FilterOptions):
|
|
|
|
try:
|
|
|
|
fOptions = FilterOptions(**filterOptions)
|
|
|
|
filterOptions = fOptions
|
|
|
|
except e:
|
|
|
|
raise OptionsError('%s' % e)
|
2014-02-03 12:51:23 +01:00
|
|
|
|
|
|
|
|
2014-03-13 13:27:34 +01:00
|
|
|
class OptionsError(Exception):
|
|
|
|
pass
|
2014-02-03 12:51:23 +01:00
|
|
|
|
2014-01-10 05:45:03 +01:00
|
|
|
|
2014-01-30 13:11:44 +01:00
|
|
|
if __name__ == '__main__':
|
2014-03-13 13:27:34 +01:00
|
|
|
# Creating a Qt application
|
2014-01-30 13:11:44 +01:00
|
|
|
pylot_app = QApplication(sys.argv)
|
2014-01-09 10:43:40 +01:00
|
|
|
|
2014-01-30 13:11:44 +01:00
|
|
|
pylot_main = MainWindow()
|
2014-02-03 12:51:23 +01:00
|
|
|
pylot_main.setWindowTitle('PyLoT-The Picking and Localization Tool')
|
2014-01-09 10:43:40 +01:00
|
|
|
|
2014-03-13 13:27:34 +01:00
|
|
|
# Show main window and run the app
|
2014-02-03 12:51:23 +01:00
|
|
|
pylot_main.show()
|
|
|
|
pylot_app.exec_()
|