[adresses 195] preparing GUI elements for a new dialog widget for interactive comparison
This commit is contained in:
@@ -29,7 +29,10 @@ class Comparison(object):
|
||||
names = list()
|
||||
self._pdfs = dict()
|
||||
for name, fn in kwargs.items():
|
||||
self._pdfs[name] = PDFDictionary.from_quakeml(fn)
|
||||
if not isinstance(PDFDictionary, fn):
|
||||
self._pdfs[name] = PDFDictionary.from_quakeml(fn)
|
||||
else:
|
||||
self._pdfs[name] = fn
|
||||
names.append(name)
|
||||
if len(names) > 2:
|
||||
raise ValueError('Comparison is only defined for two '
|
||||
@@ -101,14 +104,19 @@ class Comparison(object):
|
||||
|
||||
return compare_pdfs
|
||||
|
||||
def plot(self):
|
||||
nstations = self.nstations
|
||||
stations = self.stations
|
||||
def plot(self, stations=None):
|
||||
if stations is None:
|
||||
nstations = self.nstations
|
||||
stations = self.stations
|
||||
else:
|
||||
nstations = len(stations)
|
||||
istations = range(nstations)
|
||||
fig, axarr = plt.subplots(nstations, 2, sharex='col', sharey='row')
|
||||
|
||||
for n in istations:
|
||||
station = stations[n]
|
||||
if station not in self.comparison.keys():
|
||||
continue
|
||||
compare_pdf = self.comparison[station]
|
||||
for l, phase in enumerate(compare_pdf.keys()):
|
||||
axarr[n, l].plot(compare_pdf[phase].axis,
|
||||
|
||||
@@ -64,8 +64,86 @@ def createAction(parent, text, slot=None, shortcut=None, icon=None,
|
||||
action.setCheckable(True)
|
||||
return action
|
||||
|
||||
class ComparsionDialog(QDialog):
|
||||
def __init__(self, c, parent=None):
|
||||
self._data = c
|
||||
self._stats = c.keys()
|
||||
self._canvas = PlotWidget(parent)
|
||||
super(ComparsionDialog, self).__init__(parent)
|
||||
self
|
||||
|
||||
class MPLWidget(FigureCanvas):
|
||||
def setupUI(self):
|
||||
pass
|
||||
|
||||
@property
|
||||
def canvas(self):
|
||||
return self._canvas
|
||||
|
||||
@property
|
||||
def stations(self):
|
||||
return self._stats
|
||||
|
||||
@stations.setter
|
||||
def stations(self, stations):
|
||||
self._stats = stations
|
||||
|
||||
@property
|
||||
def data(self):
|
||||
return self._data
|
||||
|
||||
@data.setter
|
||||
def data(self, data):
|
||||
self.stations = data.keys()
|
||||
self._data = data
|
||||
|
||||
|
||||
class PlotWidget(FigureCanvas):
|
||||
def __init__(self, parent=None, xlabel='x', ylabel='y', title='Title'):
|
||||
self._parent = parent
|
||||
self._fig = Figure()
|
||||
self._xl = xlabel
|
||||
self._yl = ylabel
|
||||
self._title = title
|
||||
super(PlotWidget, self).__init__(self.figure)
|
||||
|
||||
@property
|
||||
def figure(self):
|
||||
return self._fig
|
||||
|
||||
@figure.setter
|
||||
def figure(self, fig):
|
||||
self._fig = fig
|
||||
|
||||
@property
|
||||
def xlabel(self):
|
||||
return self._xl
|
||||
|
||||
@xlabel.setter
|
||||
def xlabel(self, label):
|
||||
self._xl = label
|
||||
|
||||
@property
|
||||
def ylabel(self):
|
||||
return self._yl
|
||||
|
||||
@ylabel.setter
|
||||
def ylabel(self, label):
|
||||
self._yl = label
|
||||
|
||||
@property
|
||||
def title(self):
|
||||
return self._title
|
||||
|
||||
@title.setter
|
||||
def title(self, title):
|
||||
self._title = title
|
||||
|
||||
@property
|
||||
def parent(self):
|
||||
return self._parent
|
||||
|
||||
|
||||
class WaveformWidget(FigureCanvas):
|
||||
def __init__(self, parent=None, xlabel='x', ylabel='y', title='Title'):
|
||||
|
||||
self._parent = None
|
||||
@@ -79,7 +157,7 @@ class MPLWidget(FigureCanvas):
|
||||
# clear axes each time plot is called
|
||||
self.axes.hold(True)
|
||||
# initialize super class
|
||||
super(MPLWidget, self).__init__(self.figure)
|
||||
super(WaveformWidget, self).__init__(self.figure)
|
||||
# add an cursor for station selection
|
||||
self.multiCursor = MultiCursor(self.figure.canvas, (self.axes,),
|
||||
horizOn=True,
|
||||
@@ -223,7 +301,7 @@ class PickDlg(QDialog):
|
||||
self.stime, self.etime = getGlobalTimes(self.getWFData())
|
||||
|
||||
# initialize plotting widget
|
||||
self.multicompfig = MPLWidget(self)
|
||||
self.multicompfig = WaveformWidget(self)
|
||||
|
||||
# setup ui
|
||||
self.setupUi()
|
||||
|
||||
Reference in New Issue
Block a user