From 8edea03fe77260be6b02d74e4e894a782ebb20e0 Mon Sep 17 00:00:00 2001 From: Sebastian Wehling-Benatelli Date: Thu, 13 Mar 2014 13:27:34 +0100 Subject: [PATCH] cleanup, switched to PySide (more flexible licensing), started to implement the filter options depending on the phase to be picked --- README | 2 +- pylot/QtPyLoT.py | 108 +++++++++++++++--------------------- pylot/core/util/__init__.py | 1 + 3 files changed, 47 insertions(+), 64 deletions(-) diff --git a/README b/README index 01953a71..c5452495 100644 --- a/README +++ b/README @@ -6,7 +6,7 @@ The Python picking and Localisation Tool This python library contains a graphical user interfaces for picking seismic phases. This software needs ObsPy (http://github.com/obspy/obspy/wiki) -and the Qt4 libraries to be installed first. +and the PySide Qt4 bindings for python to be installed first. PILOT has originally been developed in Mathworks' MatLab. In order to distribute PILOT without facing portability problems, it has been decided diff --git a/pylot/QtPyLoT.py b/pylot/QtPyLoT.py index 34b5375a..7948e27e 100755 --- a/pylot/QtPyLoT.py +++ b/pylot/QtPyLoT.py @@ -1,101 +1,83 @@ +#!/usr/bin/env python +# +# # Main program: QtPyLoT.py -# -# -# -# -# -# -# -# -# -# -# -# import os import platform import sys -from PyQt4.QtCore import * -from PyQt4.QtGui import * +from PySide.QtCore import * +from PySide.QtGui import * import helpform from pylot.core.util import _getVersionString +from pylot.core.read.inputs import FilterOptions +from pylot.core.util import FILTERDEFAULTS # Version information __version__ = _getVersionString() + class MainWindow(QMainWindow): - + def __init__(self, parent=None): super(MainWindow, self).__init__(parent) - - filterDefaults - self.filterOptions = FilterOptions(filterDefaults) - - filterDockWidget = FilterOptionsDock("Filter Options", self) - - - class PickWindow(QDialog): + + 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) + self. + + +class PickWindow(QDialog): def __init__(self, station=None, parent=None): - super(PickWindow, self).__init__(parent) + super(PickWindow, self).__init__(parent) + + filterDockWidget = FilterOptionsDock(titleString="Filter Options", + parent=self, + filterOptions=filteroptions) - filterDockWidget = FilterOptionsDock() class PropertiesWindow(QDialog): def __init__(self, parent=None): - super(PropertiesWindow, self).__init__(parent) + super(PropertiesWindow, self).__init__(parent) + class FilterOptionsDock(QDockWidget): - def __init__(self, titleString="Filter options", filterOptions=None): - super(FilterOptionsDock, self).__init__() + def __init__(self, parent=None, titleString="Filter options", + filterOptions=None): + super(FilterOptionsDock, self).__init__() - if filterOptions and not isinstance(filterOptions, FilterOptions): - try: - fOptions = FilterOptions(filterOptions) - except e: - raise OptionsError, '%s' % e + if filterOptions and not isinstance(filterOptions, FilterOptions): + try: + fOptions = FilterOptions(**filterOptions) + filterOptions = fOptions + except e: + raise OptionsError('%s' % e) -class FilterOptions(object): + - def __init__(self, filtertype=None, freq=None, order=None): - self.__filterInformation = {} - self._setfilterType(filtertype) - self._setFreq(freq) - self._setOrder(order) - - def _getFreq(self): - return self.__filterInformation['freq'] - def _setFreq(self, freq): - self.__filterInformation['freq'] = freq - - def _getOrder(self): - return self.__filterInformation['order'] +class OptionsError(Exception): + pass - def _setOrder(self, order): - self.__filterInformation['order'] = order - - def _getFilterType(self): - return self.__filterInformation['filtertype'] - - def _setFilterType(self, filtertype): - self.__filterInformation['filtertype'] = filtertype - - filterType = property(fget=_getFilterType, fset=_setFilterType) - order = property(fget=_getOrder, fset=_setOrder) - freq = property(fget=_getFreq, fset=_setFreq) - -class OptionsError(Exception): pass if __name__ == '__main__': - ##Creating a Qt application + # Creating a Qt application pylot_app = QApplication(sys.argv) pylot_main = MainWindow() pylot_main.setWindowTitle('PyLoT-The Picking and Localization Tool') - # Show window and run the app + # Show main window and run the app pylot_main.show() pylot_app.exec_() diff --git a/pylot/core/util/__init__.py b/pylot/core/util/__init__.py index 2d4a37e4..e0301057 100755 --- a/pylot/core/util/__init__.py +++ b/pylot/core/util/__init__.py @@ -1 +1,2 @@ from pylot.core.util.version import get_git_version as _getVersionString +from pylot.core.util.defaults import FILTERDEFAULTS