successfully implemented a working version of QT postprocessing interface

This commit is contained in:
Marcel Paffrath 2016-08-24 14:58:51 +02:00
parent e51704f2b7
commit 135ac0ef80
11 changed files with 116 additions and 77 deletions

View File

@ -10,7 +10,7 @@ from PySide import QtCore, QtGui
from pylot.core.active import activeSeismoPick, surveyUtils, fmtomoUtils, seismicArrayPreparation
from pylot.core.active.gui.asp3d_layout import *
from pylot.core.active.gui.windows import Gen_SeisArray, Gen_Survey_from_SA, Gen_Survey_from_SR, Call_autopicker, Call_FMTOMO, Call_VTK_dialog, Postprocessing
from pylot.core.active.gui.windows import openFile, saveFile, browseDir, getMaxCPU
from pylot.core.active.gui.windows import openFile, saveFile, browseDir, getMaxCPU, printDialogMessage, continueDialogExists, continueDialogMessage
from matplotlib.backends.backend_qt4agg import FigureCanvasQTAgg as FigureCanvas
from matplotlib.backends.backend_qt4agg import NavigationToolbar2QT as NavigationToolbar
@ -80,10 +80,10 @@ class gui_control(object):
def gen_seisarray(self):
disconnect = False
if self.checkSeisArrayState():
if not self.continueDialogExists('Seismic Array'):
if not continueDialogExists('Seismic Array'):
return
if self.checkConnected2SurveyState():
if not self.continueDialogMessage('Seismic Array connected to present Survey.\n'
if not continueDialogMessage('Seismic Array connected to present Survey.\n'
'Continuation will disconnect the Seismic Array.'):
return
else:
@ -103,11 +103,11 @@ class gui_control(object):
def gen_survey(self):
if self.checkSurveyState():
if not self.continueDialogExists('Survey'):
if not continueDialogExists('Survey'):
return
if self.checkSeisArrayState():
if len(self.seisarray.getSourceCoordinates()) > 0:
if self.continueDialogMessage('Use geometry information of active Seismic Array?'):
if continueDialogMessage('Use geometry information of active Seismic Array?'):
if self.gssa is None:
self.gssa = Gen_Survey_from_SA(self.mainwindow, self.seisarray)
else:
@ -120,7 +120,7 @@ class gui_control(object):
self.setPickState(False)
return
else:
if not self.continueDialogMessage('Can not use current Seismic Array,'
if not continueDialogMessage('Can not use current Seismic Array,'
' because there are no sources given.'):
return
if self.gssr is None:
@ -291,7 +291,7 @@ class gui_control(object):
def interpolate_receivers(self):
if not self.checkSeisArrayState():
self.printDialogMessage('No Seismic Array defined.')
printDialogMessage('No Seismic Array defined.')
return
self.seisarray.interpolateAll()
self.refreshSeisArrayWidgets()
@ -304,13 +304,13 @@ class gui_control(object):
def connect2Survey(self):
if not self.checkSurveyState():
self.printDialogMessage('No Survey defined.')
printDialogMessage('No Survey defined.')
return
if not self.checkSeisArrayState():
self.printDialogMessage('Got no Seismic Array.')
printDialogMessage('Got no Seismic Array.')
return
if self.checkConnected2SurveyState():
if not self.continueDialogMessage('Existing Survey already got Seismic Array object. Continue?'):
if not continueDialogMessage('Existing Survey already got Seismic Array object. Continue?'):
return
self.survey.seisarray = self.seisarray
self.setConnected2SurveyState(True)
@ -320,10 +320,10 @@ class gui_control(object):
def startPicker(self):
if not self.checkSurveyState():
self.printDialogMessage('No Survey defined.')
printDialogMessage('No Survey defined.')
return
if self.checkPickState():
if not self.continueDialogMessage('Survey already picked. Continue?'):
if not continueDialogMessage('Survey already picked. Continue?'):
return
if self.autopicker is None:
@ -338,10 +338,10 @@ class gui_control(object):
def startFMTOMO(self):
if not self.checkSurveyState():
self.printDialogMessage('No Survey defined.')
printDialogMessage('No Survey defined.')
return
if not self.checkPickState():
self.printDialogMessage('Survey not picked.')
printDialogMessage('Survey not picked.')
return
if self.fmtomo is None:
@ -361,7 +361,7 @@ class gui_control(object):
def postprocessing(self):
if not self.checkSurveyState():
self.printDialogMessage('No Survey defined.')
printDialogMessage('No Survey defined.')
return
self.postprocessing = Postprocessing(self.mainwindow, self.survey)
#self.survey.plotAllPicks()
@ -370,7 +370,7 @@ class gui_control(object):
def load_survey(self):
if self.checkSurveyState():
if not self.continueDialogExists('Survey'):
if not continueDialogExists('Survey'):
return
filename = openFile()
if filename is None:
@ -378,14 +378,14 @@ class gui_control(object):
try:
survey = activeSeismoPick.Survey.from_pickle(filename)
except:
self.printDialogMessage('Could not load object %s.'%filename)
printDialogMessage('Could not load object %s.'%filename)
return
if not type(survey) == activeSeismoPick.Survey:
self.printDialogMessage('Wrong input file of type %s, expected %s.'
printDialogMessage('Wrong input file of type %s, expected %s.'
%(type(survey), activeSeismoPick.Survey))
return
if self.checkSeisArrayState() and survey.seisarray is not None:
if not self.continueDialogMessage('Survey got existing Seismic Array.'
if not continueDialogMessage('Survey got existing Seismic Array.'
' Do you want to overwrite the current Seismic Array?'):
return
self.survey = survey
@ -398,19 +398,19 @@ class gui_control(object):
self.seisarray = self.survey.seisarray
self.setConnected2SurveyState(True)
self.setSeisArrayState(True)
self.printDialogMessage('Loaded Survey with active Seismic Array.')
printDialogMessage('Loaded Survey with active Seismic Array.')
else:
self.setConnected2SurveyState(False)
self.setSeisArrayState(False)
self.printDialogMessage('Loaded Survey.')
printDialogMessage('Loaded Survey.')
def load_seisarray(self):
disconnect = False
if self.checkSeisArrayState():
if not self.continueDialogExists('Seismic Array'):
if not continueDialogExists('Seismic Array'):
return
if self.checkConnected2SurveyState():
if not self.continueDialogMessage('Seismic Array connected to present Survey.\n'
if not continueDialogMessage('Seismic Array connected to present Survey.\n'
'Continuation will disconnect the Seismic Array.'):
return
else:
@ -423,10 +423,10 @@ class gui_control(object):
try:
seisarray = seismicArrayPreparation.SeisArray.from_pickle(filename)
except:
self.printDialogMessage('Could not load object %s.'%filename)
printDialogMessage('Could not load object %s.'%filename)
return
if not type(seisarray) == seismicArrayPreparation.SeisArray:
self.printDialogMessage('Wrong input file of type %s, expected %s.'
printDialogMessage('Wrong input file of type %s, expected %s.'
%(type(seisarray), seismicArrayPreparation.SeisArray))
return
if disconnect:
@ -436,7 +436,7 @@ class gui_control(object):
def save_seisarray(self):
if not self.checkSeisArrayState():
self.printDialogMessage('No Seismic Array defined.')
printDialogMessage('No Seismic Array defined.')
return
filename = saveFile()
if filename is None:
@ -445,7 +445,7 @@ class gui_control(object):
def save_survey(self):
if not self.checkSurveyState():
self.printDialogMessage('No Survey defined.')
printDialogMessage('No Survey defined.')
return
filename = saveFile()
if filename is None:
@ -478,7 +478,7 @@ class gui_control(object):
self.enablePickedTools(True, self.survey.twoDim)
self.survey.picked = True
elif state == True and self.checkSurveyState() is False:
self.printDialogMessage('No Survey defined.')
printDialogMessage('No Survey defined.')
return
elif state == False:
self.mainUI.picked_active.setPixmap(self.cancelpixmap)
@ -514,39 +514,10 @@ class gui_control(object):
def checkPickState(self):
if not self.survey:
self.printDialogMessage('No Survey defined.')
printDialogMessage('No Survey defined.')
return
return self.survey.picked
def printDialogMessage(self, message):
qmb = QtGui.QMessageBox()
qmb.setText(message)
qmb.setStandardButtons(QtGui.QMessageBox.Ok)
qmb.setIcon(QtGui.QMessageBox.Warning)
qmb.exec_()
def continueDialogExists(self, name):
qmb = QtGui.QMessageBox()
qmb.setText('%s object already exists. Overwrite?'%name)
qmb.setStandardButtons(QtGui.QMessageBox.Ok | QtGui.QMessageBox.Cancel)
qmb.setIcon(QtGui.QMessageBox.Warning)
answer = qmb.exec_()
if answer == 1024:
return True
else:
return False
def continueDialogMessage(self, message):
qmb = QtGui.QMessageBox()
qmb.setText(message)
qmb.setStandardButtons(QtGui.QMessageBox.Ok | QtGui.QMessageBox.Cancel)
qmb.setIcon(QtGui.QMessageBox.Warning)
answer = qmb.exec_()
if answer == 1024:
return True
else:
return False
def exitApp(self):
QtCore.QCoreApplication.instance().quit()

View File

@ -2,7 +2,7 @@
# Form implementation generated from reading ui file 'asp3d_layout.ui'
#
# Created: Wed Aug 24 13:12:00 2016
# Created: Wed Aug 24 14:38:12 2016
# by: pyside-uic 0.2.15 running on PySide 1.2.2
#
# WARNING! All changes made in this file will be lost!

View File

@ -2,7 +2,7 @@
# Form implementation generated from reading ui file 'fmtomo_parameters_layout.ui'
#
# Created: Wed Aug 24 13:12:00 2016
# Created: Wed Aug 24 14:38:12 2016
# by: pyside-uic 0.2.15 running on PySide 1.2.2
#
# WARNING! All changes made in this file will be lost!

View File

@ -2,7 +2,7 @@
# Form implementation generated from reading ui file 'generate_seisarray_layout.ui'
#
# Created: Wed Aug 24 13:12:00 2016
# Created: Wed Aug 24 14:38:13 2016
# by: pyside-uic 0.2.15 running on PySide 1.2.2
#
# WARNING! All changes made in this file will be lost!

View File

@ -2,7 +2,7 @@
# Form implementation generated from reading ui file 'generate_survey_layout.ui'
#
# Created: Wed Aug 24 13:12:00 2016
# Created: Wed Aug 24 14:38:13 2016
# by: pyside-uic 0.2.15 running on PySide 1.2.2
#
# WARNING! All changes made in this file will be lost!

View File

@ -2,7 +2,7 @@
# Form implementation generated from reading ui file 'generate_survey_layout_minimal.ui'
#
# Created: Wed Aug 24 13:12:00 2016
# Created: Wed Aug 24 14:38:13 2016
# by: pyside-uic 0.2.15 running on PySide 1.2.2
#
# WARNING! All changes made in this file will be lost!

View File

@ -2,7 +2,7 @@
# Form implementation generated from reading ui file 'picking_parameters_layout.ui'
#
# Created: Wed Aug 24 13:12:00 2016
# Created: Wed Aug 24 14:38:13 2016
# by: pyside-uic 0.2.15 running on PySide 1.2.2
#
# WARNING! All changes made in this file will be lost!

View File

@ -2,7 +2,7 @@
# Form implementation generated from reading ui file 'postprocessing_layout.ui'
#
# Created: Wed Aug 24 13:12:00 2016
# Created: Wed Aug 24 14:38:13 2016
# by: pyside-uic 0.2.15 running on PySide 1.2.2
#
# WARNING! All changes made in this file will be lost!
@ -38,8 +38,11 @@ class Ui_postprocessing(object):
sizePolicy.setHeightForWidth(self.pushButton_rect.sizePolicy().hasHeightForWidth())
self.pushButton_rect.setSizePolicy(sizePolicy)
self.pushButton_rect.setMaximumSize(QtCore.QSize(16777215, 30))
self.pushButton_rect.setCheckable(True)
self.pushButton_rect.setCheckable(False)
self.pushButton_rect.setObjectName("pushButton_rect")
self.buttonGroup = QtGui.QButtonGroup(postprocessing)
self.buttonGroup.setObjectName("buttonGroup")
self.buttonGroup.addButton(self.pushButton_rect)
self.horizontalLayout_4.addWidget(self.pushButton_rect)
self.pushButton_poly = QtGui.QPushButton(postprocessing)
sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Fixed)
@ -48,9 +51,20 @@ class Ui_postprocessing(object):
sizePolicy.setHeightForWidth(self.pushButton_poly.sizePolicy().hasHeightForWidth())
self.pushButton_poly.setSizePolicy(sizePolicy)
self.pushButton_poly.setMaximumSize(QtCore.QSize(16777215, 30))
self.pushButton_poly.setCheckable(True)
self.pushButton_poly.setCheckable(False)
self.pushButton_poly.setObjectName("pushButton_poly")
self.buttonGroup.addButton(self.pushButton_poly)
self.horizontalLayout_4.addWidget(self.pushButton_poly)
self.pushButton_undo = QtGui.QPushButton(postprocessing)
sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Fixed)
sizePolicy.setHorizontalStretch(0)
sizePolicy.setVerticalStretch(0)
sizePolicy.setHeightForWidth(self.pushButton_undo.sizePolicy().hasHeightForWidth())
self.pushButton_undo.setSizePolicy(sizePolicy)
self.pushButton_undo.setMaximumSize(QtCore.QSize(16777215, 30))
self.pushButton_undo.setCheckable(False)
self.pushButton_undo.setObjectName("pushButton_undo")
self.horizontalLayout_4.addWidget(self.pushButton_undo)
self.verticalLayout_3.addLayout(self.horizontalLayout_4)
self.horizontalLayout_2.addLayout(self.verticalLayout_3)
self.line = QtGui.QFrame(postprocessing)
@ -153,6 +167,7 @@ class Ui_postprocessing(object):
self.label.setText(QtGui.QApplication.translate("postprocessing", "Selection", None, QtGui.QApplication.UnicodeUTF8))
self.pushButton_rect.setText(QtGui.QApplication.translate("postprocessing", "Rectangle", None, QtGui.QApplication.UnicodeUTF8))
self.pushButton_poly.setText(QtGui.QApplication.translate("postprocessing", "Polygon", None, QtGui.QApplication.UnicodeUTF8))
self.pushButton_undo.setText(QtGui.QApplication.translate("postprocessing", "Undo", None, QtGui.QApplication.UnicodeUTF8))
self.label_3.setText(QtGui.QApplication.translate("postprocessing", "Action", None, QtGui.QApplication.UnicodeUTF8))
self.pushButton_plot.setText(QtGui.QApplication.translate("postprocessing", "Plot", None, QtGui.QApplication.UnicodeUTF8))
self.pushButton_delete.setText(QtGui.QApplication.translate("postprocessing", "Delete", None, QtGui.QApplication.UnicodeUTF8))

View File

@ -2,7 +2,7 @@
# Form implementation generated from reading ui file 'vtk_tools_layout.ui'
#
# Created: Wed Aug 24 13:12:00 2016
# Created: Wed Aug 24 14:38:13 2016
# by: pyside-uic 0.2.15 running on PySide 1.2.2
#
# WARNING! All changes made in this file will be lost!

View File

@ -48,6 +48,35 @@ def getMaxCPU():
import multiprocessing
return multiprocessing.cpu_count()
def printDialogMessage(message):
qmb = QtGui.QMessageBox()
qmb.setText(message)
qmb.setStandardButtons(QtGui.QMessageBox.Ok)
qmb.setIcon(QtGui.QMessageBox.Warning)
qmb.exec_()
def continueDialogExists(name):
qmb = QtGui.QMessageBox()
qmb.setText('%s object already exists. Overwrite?'%name)
qmb.setStandardButtons(QtGui.QMessageBox.Ok | QtGui.QMessageBox.Cancel)
qmb.setIcon(QtGui.QMessageBox.Warning)
answer = qmb.exec_()
if answer == 1024:
return True
else:
return False
def continueDialogMessage(message):
qmb = QtGui.QMessageBox()
qmb.setText(message)
qmb.setStandardButtons(QtGui.QMessageBox.Ok | QtGui.QMessageBox.Cancel)
qmb.setIcon(QtGui.QMessageBox.Warning)
answer = qmb.exec_()
if answer == 1024:
return True
else:
return False
class Gen_SeisArray(object):
def __init__(self, mainwindow):
@ -606,6 +635,7 @@ class Postprocessing(object):
self.survey = survey
self.init_widget()
self.start_widget()
self.inkByVal = 'snrlog'
def init_widget(self):
qwidget = QtGui.QWidget()#
@ -642,11 +672,11 @@ class Postprocessing(object):
self.ax = ax
self.draw()
def refreshPlot(self, inkByVal = 'snrlog'):
def refreshPlot(self):
self.ax.clear()
ax = self.ax
ax, cbar, sc = self.survey.createPlot(self.dists, self.picks, self.inkDict[inkByVal],
inkByVal, ax = ax, cbar = self.cbar)
ax, cbar, sc = self.survey.createPlot(self.dists, self.picks, self.inkDict[self.inkByVal],
self.inkByVal, ax = ax, cbar = self.cbar)
#self.cbar = self.figure.colorbar(sc, fraction=0.05)
self.draw()
@ -663,6 +693,8 @@ class Postprocessing(object):
QtCore.QObject.connect(self.ui.pushButton_rect, QtCore.SIGNAL("clicked()"), self.chooseRect)
QtCore.QObject.connect(self.ui.pushButton_poly, QtCore.SIGNAL("clicked()"), self.choosePoly)
QtCore.QObject.connect(self.ui.pushButton_plot, QtCore.SIGNAL("clicked()"), self.plotPicks)
QtCore.QObject.connect(self.ui.pushButton_delete, QtCore.SIGNAL("clicked()"), self.deleteSelected)
QtCore.QObject.connect(self.ui.pushButton_undo, QtCore.SIGNAL("clicked()"), self.undoSelection)
QtCore.QObject.connect(self.ui.pushButton_snr, QtCore.SIGNAL("clicked()"), self.refrSNR)
QtCore.QObject.connect(self.ui.pushButton_pe, QtCore.SIGNAL("clicked()"), self.refrPE)
QtCore.QObject.connect(self.ui.pushButton_spe, QtCore.SIGNAL("clicked()"), self.refrSPE)
@ -673,15 +705,32 @@ class Postprocessing(object):
def choosePoly(self):
self.region.choosePolygon()
def disconnectRect(self):
self.region.disconnectRect()
def disconnectPoly(self):
self.region.disconnectPoly()
def plotPicks(self):
self.region.plotTracesInActiveRegions()
def deleteSelected(self):
self.region.setAllActiveRegionsForDeletion()
message = 'Are you sure you want to delete all marked picks?'
if continueDialogMessage(message):
self.region.deleteAllMarkedPicks()
else:
self.region.refreshFigure()
def undoSelection(self):
self.region.deselectLastSelection()
def refrSNR(self):
self.refreshPlot('snrlog')
self.region.refreshLog10SNR()
def refrPE(self):
self.refreshPlot('pe')
self.region.refreshPickerror()
def refrSPE(self):
self.refreshPlot('spe')
self.region.refreshSPE()

View File

@ -250,6 +250,7 @@ class regions(object):
return
key = max(self.shots_found.keys())
self.deselectSelection(key)
self.refreshFigure()
def deselectSelection(self, key, color='green', alpha=0.1):
if key not in self.shots_found.keys():
@ -498,14 +499,17 @@ class regions(object):
def refreshLog10SNR(self, event=None):
cbv = 'log10SNR'
self.cbv = cbv
self.refreshFigure(self, colorByVal=cbv)
def refreshPickerror(self, event=None):
cbv = 'pickerror'
self.cbv = cbv
self.refreshFigure(self, colorByVal=cbv)
def refreshSPE(self, event=None):
cbv = 'spe'
self.cbv = cbv
self.refreshFigure(self, colorByVal=cbv)
def refreshFigure(self, event=None, colorByVal=None):