some changes in dataPlot resizing/height adjustments

This commit is contained in:
Marcel Paffrath 2017-05-29 16:21:36 +02:00
parent 5115705c4e
commit 41a870d720
3 changed files with 28 additions and 17 deletions

View File

@ -107,6 +107,9 @@ class MainWindow(QMainWindow):
self.ae_id = None self.ae_id = None
self.scroll_id = None self.scroll_id = None
# default factor for dataplot e.g. enabling/disabling scrollarea
self.height_factor = 12
# default colors for ref/test event # default colors for ref/test event
self._colors = { self._colors = {
'ref': QtGui.QColor(200, 210, 230, 255), 'ref': QtGui.QColor(200, 210, 230, 255),
@ -1090,20 +1093,26 @@ class MainWindow(QMainWindow):
''' '''
Load new data and plot if necessary. Load new data and plot if necessary.
''' '''
self.loadWaveformDataThread(plot) self.loadWaveformDataThread(plot=plot)
if plot: if plot:
self._eventChanged[0] = False self._eventChanged[0] = False
def loadWaveformDataThread(self, plot=True): def loadWaveformDataThread(self, plot=True, load=True):
''' '''
Generates a modal thread to load waveform data and optionally Generates a modal thread to load waveform data and
calls modal plot thread method when finished. call modal plot thread method when finished.
''' '''
wfd_thread = Thread(self, self.loadWaveformData, if load:
progressText='Reading data input...') wfd_thread = Thread(self, self.loadWaveformData,
if plot: progressText='Reading data input...')
if load and plot:
wfd_thread.finished.connect(self.plotWaveformDataThread) wfd_thread.finished.connect(self.plotWaveformDataThread)
wfd_thread.start()
if load:
wfd_thread.start()
if plot and not load:
self.plotWaveformDataThread()
def loadWaveformData(self): def loadWaveformData(self):
''' '''
@ -1207,12 +1216,8 @@ class MainWindow(QMainWindow):
alter_comp = str(alter_comp[0]) alter_comp = str(alter_comp[0])
wfst = self.get_data().getWFData().select(component=comp) wfst = self.get_data().getWFData().select(component=comp)
wfst += self.get_data().getWFData().select(component=alter_comp) wfst += self.get_data().getWFData().select(component=alter_comp)
height_need = len(self.data.getWFData())*12
plotWidget = self.getPlotWidget() plotWidget = self.getPlotWidget()
if self.tabs.widget(0).frameSize().height() < height_need: self.adjustPlotHeight()
plotWidget.setMinimumHeight(height_need)
else:
plotWidget.setMinimumHeight(0)
plotWidget.plotWFData(wfdata=wfst, title=title, mapping=False) plotWidget.plotWFData(wfdata=wfst, title=title, mapping=False)
plotDict = plotWidget.getPlotDict() plotDict = plotWidget.getPlotDict()
pos = plotDict.keys() pos = plotDict.keys()
@ -1223,6 +1228,14 @@ class MainWindow(QMainWindow):
except: except:
pass pass
def adjustPlotHeight(self):
height_need = len(self.data.getWFData())*self.height_factor
plotWidget = self.getPlotWidget()
if self.tabs.widget(0).frameSize().height() < height_need:
plotWidget.setMinimumHeight(height_need)
else:
plotWidget.setMinimumHeight(0)
def plotZ(self): def plotZ(self):
self.setComponent('Z') self.setComponent('Z')
self.plotWaveformDataThread() self.plotWaveformDataThread()

View File

@ -1 +1 @@
cb91-dirty 5115-dirty

View File

@ -405,13 +405,11 @@ class WaveformWidget(FigureCanvas):
self.plotdict = dict() self.plotdict = dict()
# create axes # create axes
self.axes = self.figure.add_subplot(111) self.axes = self.figure.add_subplot(111)
# clear axes each time plot is called
self.axes.hold(True)
# initialize super class # initialize super class
super(WaveformWidget, self).__init__(self.figure) super(WaveformWidget, self).__init__(self.figure)
# add an cursor for station selection # add an cursor for station selection
self.multiCursor = MultiCursor(self.figure.canvas, (self.axes,), self.multiCursor = MultiCursor(self.figure.canvas, (self.axes,),
horizOn=True, horizOn=True, useblit=True,
color='m', lw=1) color='m', lw=1)
# update labels of the entire widget # update labels of the entire widget
self.updateWidget(xlabel, ylabel, title) self.updateWidget(xlabel, ylabel, title)