activating vtk_tools widget, bugfix on merging rays.dat (too many linebreaks)

This commit is contained in:
Marcel Paffrath 2016-07-06 11:40:08 +02:00
parent 0be69de6f7
commit 5293bb6ec7
9 changed files with 100 additions and 23 deletions

View File

@ -271,7 +271,10 @@ class gui_control(object):
self.vtk_tools_ui = ui self.vtk_tools_ui = ui
self.connectButtons_vtk_tools() self.connectButtons_vtk_tools()
#self.getFMTOMOparameters(ui, fmtomo_parameters) self.openVTKdialog(ui, vtk_tools)
def openVTKdialog(self, ui, vtk_tools):
vtk_tools.exec_()
def getFMTOMOparameters(self, ui, fmtomo_parameters): def getFMTOMOparameters(self, ui, fmtomo_parameters):
if fmtomo_parameters.exec_(): if fmtomo_parameters.exec_():
@ -313,34 +316,77 @@ class gui_control(object):
QtCore.QObject.connect(self.vtk_tools_ui.pushButton_vgref, QtCore.SIGNAL("clicked()"), self.chooseVgridref) QtCore.QObject.connect(self.vtk_tools_ui.pushButton_vgref, QtCore.SIGNAL("clicked()"), self.chooseVgridref)
QtCore.QObject.connect(self.vtk_tools_ui.pushButton_rays, QtCore.SIGNAL("clicked()"), self.chooseRaysIn) QtCore.QObject.connect(self.vtk_tools_ui.pushButton_rays, QtCore.SIGNAL("clicked()"), self.chooseRaysIn)
QtCore.QObject.connect(self.vtk_tools_ui.pushButton_raysout, QtCore.SIGNAL("clicked()"), self.chooseRaysOutDir) QtCore.QObject.connect(self.vtk_tools_ui.pushButton_raysout, QtCore.SIGNAL("clicked()"), self.chooseRaysOutDir)
QtCore.QObject.connect(self.vtk_tools_ui.pushButton_parav, QtCore.SIGNAL("clicked()"), self.openFileParaview)
QtCore.QObject.connect(self.vtk_tools_ui.start_vg, QtCore.SIGNAL("clicked()"), self.startvgvtk) QtCore.QObject.connect(self.vtk_tools_ui.start_vg, QtCore.SIGNAL("clicked()"), self.startvgvtk)
QtCore.QObject.connect(self.vtk_tools_ui.start_rays, QtCore.SIGNAL("clicked()"), self.startraysvtk) QtCore.QObject.connect(self.vtk_tools_ui.start_rays, QtCore.SIGNAL("clicked()"), self.startraysvtk)
QtCore.QObject.connect(self.vtk_tools_ui.radioButton_rel, QtCore.SIGNAL("clicked()"), self.activateVgref)
QtCore.QObject.connect(self.vtk_tools_ui.radioButton_abs, QtCore.SIGNAL("clicked()"), self.deactivateVgref)
def openFileParaview(self):
os.system('paraview %s &'%self.vtk_tools_ui.lineEdit_vgout.text())
def activateVgref(self):
self.vtk_tools_ui.lineEdit_vgref.setEnabled(True)
self.vtk_tools_ui.pushButton_vgref.setEnabled(True)
def deactivateVgref(self):
self.vtk_tools_ui.lineEdit_vgref.setEnabled(False)
self.vtk_tools_ui.pushButton_vgref.setEnabled(False)
def checkVgStartButton(self):
ui = self.vtk_tools_ui
if ui.radioButton_rel.isChecked():
if ui.lineEdit_vg.text() != '' and ui.lineEdit_vgref.text() != '':
ui.start_vg.setEnabled(True)
else:
ui.start_vg.setEnabled(False)
if ui.radioButton_abs.isChecked():
if ui.lineEdit_vg.text() != '':
ui.start_vg.setEnabled(True)
else:
ui.start_vg.setEnabled(False)
def checkRaysStartButton(self):
ui = self.vtk_tools_ui
if ui.lineEdit_rays.text() != '' and ui.lineEdit_raysout.text() != '':
ui.start_rays.setEnabled(True)
else:
ui.start_rays.setEnabled(False)
def chooseVgrid(self): def chooseVgrid(self):
self.vtk_tools_ui.lineEdit_vg.setText(self.openFile()) self.vtk_tools_ui.lineEdit_vg.setText(self.openFile())
self.checkVgStartButton()
def chooseVgridref(self): def chooseVgridref(self):
self.vtk_tools_ui.lineEdit_vgref.setText(self.openFile()) self.vtk_tools_ui.lineEdit_vgref.setText(self.openFile())
self.checkVgStartButton()
def chooseRaysIn(self): def chooseRaysIn(self):
self.vtk_tools_ui.lineEdit_rays.setText(self.openFile()) self.vtk_tools_ui.lineEdit_rays.setText(self.openFile())
self.checkRaysStartButton()
def chooseRaysOutDir(self): def chooseRaysOutDir(self):
self.vtk_tools_ui.lineEdit_raysout.setText(self.browseDir()) self.vtk_tools_ui.lineEdit_raysout.setText(self.browseDir())
self.checkRaysStartButton()
def startvgvtk(self): def startvgvtk(self):
if self.vtk_tools_ui.radioButton_abs.isChecked(): ui = self.vtk_tools_ui
fmtomoUtils.vgrids2VTK(inputfile = self.vtk_tools_ui.lineEdit_vg.text(), if ui.lineEdit_vgout.text() == '':
outputfile = 'vgrids_rel.vtk', if not self.printDialogMessage('Please specify output filename.'):
return
if ui.radioButton_abs.isChecked():
fmtomoUtils.vgrids2VTK(inputfile = ui.lineEdit_vg.text(),
outputfile = ui.lineEdit_vgout.text(),
absOrRel='abs') absOrRel='abs')
elif self.vtk_tools_ui.radioButton_rel.isChecked(): elif ui.radioButton_rel.isChecked():
fmtomoUtils.vgrids2VTK(inputfile = self.vtk_tools_ui.lineEdit_vg.text(), fmtomoUtils.vgrids2VTK(inputfile = ui.lineEdit_vg.text(),
outputfile = 'vgrids_rel.vtk', outputfile = ui.lineEdit_vgout.text(),
absOrRel='rel', absOrRel='rel',
inputfileref = self.vtk_tools_ui.lineEdit_vgref.text()) inputfileref = ui.lineEdit_vgref.text())
def startraysvtk(self): def startraysvtk(self):
fmtomoUtils.rays2VTK() ui = self.vtk_tools_ui
fmtomoUtils.rays2VTK(ui.lineEdit_rays.text(), ui.lineEdit_raysout.text())
def chooseFMTOMOdir(self): def chooseFMTOMOdir(self):
self.fmtomo_parameters_ui.fmtomo_dir.setText(self.browseDir()) self.fmtomo_parameters_ui.fmtomo_dir.setText(self.browseDir())

View File

@ -2,7 +2,7 @@
# Form implementation generated from reading ui file 'asp3d_layout.ui' # Form implementation generated from reading ui file 'asp3d_layout.ui'
# #
# Created: Tue Jul 5 13:55:55 2016 # Created: Wed Jul 6 11:39:58 2016
# by: pyside-uic 0.2.15 running on PySide 1.2.2 # by: pyside-uic 0.2.15 running on PySide 1.2.2
# #
# WARNING! All changes made in this file will be lost! # WARNING! All changes made in this file will be lost!

View File

@ -498,7 +498,7 @@ class Tomo3d(object):
raypoints = [] raypoints = []
for j in range(int(npoints)): for j in range(int(npoints)):
raypoints.append(raysfile.readline() + '\n') raypoints.append(raysfile.readline())
raysecs[sec] = {'npoints': npoints, raysecs[sec] = {'npoints': npoints,
'region': region, 'region': region,
@ -739,10 +739,12 @@ def rays2VTK(fnin, fdirout='./vtk_files/', nthPoint=50):
while True: while True:
raynumber += 1 raynumber += 1
firstline = infile.readline() firstline = infile.readline()
if firstline == '': break # break at EOF if firstline == '':
raynumber = int(firstline.split()[0]) break # break at EOF
shotnumber = int(firstline.split()[1]) fl_list = firstline.split()
rayValid = int(firstline.split()[4]) # is zero if the ray is invalid raynumber = int(fl_list[0])
shotnumber = int(fl_list[1])
rayValid = int(fl_list[4]) # is zero if the ray is invalid
if rayValid == 0: if rayValid == 0:
print('Invalid ray number %d for shot number %d' % (raynumber, shotnumber)) print('Invalid ray number %d for shot number %d' % (raynumber, shotnumber))
continue continue

View File

@ -2,7 +2,7 @@
# Form implementation generated from reading ui file 'fmtomo_parameters_layout.ui' # Form implementation generated from reading ui file 'fmtomo_parameters_layout.ui'
# #
# Created: Tue Jul 5 13:55:55 2016 # Created: Wed Jul 6 11:39:58 2016
# by: pyside-uic 0.2.15 running on PySide 1.2.2 # by: pyside-uic 0.2.15 running on PySide 1.2.2
# #
# WARNING! All changes made in this file will be lost! # 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' # Form implementation generated from reading ui file 'generate_seisarray_layout.ui'
# #
# Created: Tue Jul 5 13:55:55 2016 # Created: Wed Jul 6 11:39:58 2016
# by: pyside-uic 0.2.15 running on PySide 1.2.2 # by: pyside-uic 0.2.15 running on PySide 1.2.2
# #
# WARNING! All changes made in this file will be lost! # 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' # Form implementation generated from reading ui file 'generate_survey_layout.ui'
# #
# Created: Tue Jul 5 13:55:56 2016 # Created: Wed Jul 6 11:39:58 2016
# by: pyside-uic 0.2.15 running on PySide 1.2.2 # by: pyside-uic 0.2.15 running on PySide 1.2.2
# #
# WARNING! All changes made in this file will be lost! # 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' # Form implementation generated from reading ui file 'generate_survey_layout_minimal.ui'
# #
# Created: Tue Jul 5 13:55:56 2016 # Created: Wed Jul 6 11:39:58 2016
# by: pyside-uic 0.2.15 running on PySide 1.2.2 # by: pyside-uic 0.2.15 running on PySide 1.2.2
# #
# WARNING! All changes made in this file will be lost! # 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' # Form implementation generated from reading ui file 'picking_parameters_layout.ui'
# #
# Created: Tue Jul 5 13:55:56 2016 # Created: Wed Jul 6 11:39:58 2016
# by: pyside-uic 0.2.15 running on PySide 1.2.2 # by: pyside-uic 0.2.15 running on PySide 1.2.2
# #
# WARNING! All changes made in this file will be lost! # WARNING! All changes made in this file will be lost!

View File

@ -2,7 +2,7 @@
# Form implementation generated from reading ui file 'vtk_tools_layout.ui' # Form implementation generated from reading ui file 'vtk_tools_layout.ui'
# #
# Created: Tue Jul 5 13:55:56 2016 # Created: Wed Jul 6 11:39:58 2016
# by: pyside-uic 0.2.15 running on PySide 1.2.2 # by: pyside-uic 0.2.15 running on PySide 1.2.2
# #
# WARNING! All changes made in this file will be lost! # WARNING! All changes made in this file will be lost!
@ -12,7 +12,7 @@ from PySide import QtCore, QtGui
class Ui_vtk_tools(object): class Ui_vtk_tools(object):
def setupUi(self, vtk_tools): def setupUi(self, vtk_tools):
vtk_tools.setObjectName("vtk_tools") vtk_tools.setObjectName("vtk_tools")
vtk_tools.resize(406, 407) vtk_tools.resize(362, 432)
self.verticalLayout_8 = QtGui.QVBoxLayout(vtk_tools) self.verticalLayout_8 = QtGui.QVBoxLayout(vtk_tools)
self.verticalLayout_8.setObjectName("verticalLayout_8") self.verticalLayout_8.setObjectName("verticalLayout_8")
self.verticalLayout = QtGui.QVBoxLayout() self.verticalLayout = QtGui.QVBoxLayout()
@ -27,6 +27,10 @@ class Ui_vtk_tools(object):
sizePolicy.setVerticalStretch(0) sizePolicy.setVerticalStretch(0)
sizePolicy.setHeightForWidth(self.label_rec.sizePolicy().hasHeightForWidth()) sizePolicy.setHeightForWidth(self.label_rec.sizePolicy().hasHeightForWidth())
self.label_rec.setSizePolicy(sizePolicy) self.label_rec.setSizePolicy(sizePolicy)
font = QtGui.QFont()
font.setWeight(75)
font.setBold(True)
self.label_rec.setFont(font)
self.label_rec.setToolTip("") self.label_rec.setToolTip("")
self.label_rec.setObjectName("label_rec") self.label_rec.setObjectName("label_rec")
self.horizontalLayout.addWidget(self.label_rec) self.horizontalLayout.addWidget(self.label_rec)
@ -71,6 +75,19 @@ class Ui_vtk_tools(object):
self.pushButton_vgref.setObjectName("pushButton_vgref") self.pushButton_vgref.setObjectName("pushButton_vgref")
self.horizontalLayout_4.addWidget(self.pushButton_vgref) self.horizontalLayout_4.addWidget(self.pushButton_vgref)
self.verticalLayout_7.addLayout(self.horizontalLayout_4) self.verticalLayout_7.addLayout(self.horizontalLayout_4)
self.horizontalLayout_3 = QtGui.QHBoxLayout()
self.horizontalLayout_3.setObjectName("horizontalLayout_3")
self.label_5 = QtGui.QLabel(vtk_tools)
self.label_5.setObjectName("label_5")
self.horizontalLayout_3.addWidget(self.label_5)
self.lineEdit_vgout = QtGui.QLineEdit(vtk_tools)
self.lineEdit_vgout.setAlignment(QtCore.Qt.AlignRight|QtCore.Qt.AlignTrailing|QtCore.Qt.AlignVCenter)
self.lineEdit_vgout.setObjectName("lineEdit_vgout")
self.horizontalLayout_3.addWidget(self.lineEdit_vgout)
self.pushButton_parav = QtGui.QPushButton(vtk_tools)
self.pushButton_parav.setObjectName("pushButton_parav")
self.horizontalLayout_3.addWidget(self.pushButton_parav)
self.verticalLayout_7.addLayout(self.horizontalLayout_3)
self.start_vg = QtGui.QPushButton(vtk_tools) self.start_vg = QtGui.QPushButton(vtk_tools)
self.start_vg.setEnabled(False) self.start_vg.setEnabled(False)
self.start_vg.setObjectName("start_vg") self.start_vg.setObjectName("start_vg")
@ -90,6 +107,10 @@ class Ui_vtk_tools(object):
sizePolicy.setVerticalStretch(0) sizePolicy.setVerticalStretch(0)
sizePolicy.setHeightForWidth(self.label_src.sizePolicy().hasHeightForWidth()) sizePolicy.setHeightForWidth(self.label_src.sizePolicy().hasHeightForWidth())
self.label_src.setSizePolicy(sizePolicy) self.label_src.setSizePolicy(sizePolicy)
font = QtGui.QFont()
font.setWeight(75)
font.setBold(True)
self.label_src.setFont(font)
self.label_src.setObjectName("label_src") self.label_src.setObjectName("label_src")
self.verticalLayout_2.addWidget(self.label_src) self.verticalLayout_2.addWidget(self.label_src)
self.verticalLayout_3 = QtGui.QVBoxLayout() self.verticalLayout_3 = QtGui.QVBoxLayout()
@ -130,7 +151,7 @@ class Ui_vtk_tools(object):
self.verticalLayout_8.addLayout(self.verticalLayout) self.verticalLayout_8.addLayout(self.verticalLayout)
self.buttonBox = QtGui.QDialogButtonBox(vtk_tools) self.buttonBox = QtGui.QDialogButtonBox(vtk_tools)
self.buttonBox.setOrientation(QtCore.Qt.Horizontal) self.buttonBox.setOrientation(QtCore.Qt.Horizontal)
self.buttonBox.setStandardButtons(QtGui.QDialogButtonBox.Cancel|QtGui.QDialogButtonBox.Ok) self.buttonBox.setStandardButtons(QtGui.QDialogButtonBox.Ok)
self.buttonBox.setObjectName("buttonBox") self.buttonBox.setObjectName("buttonBox")
self.verticalLayout_8.addWidget(self.buttonBox) self.verticalLayout_8.addWidget(self.buttonBox)
@ -176,6 +197,14 @@ class Ui_vtk_tools(object):
self.pushButton_vg.setText(QtGui.QApplication.translate("vtk_tools", "Browse", None, QtGui.QApplication.UnicodeUTF8)) self.pushButton_vg.setText(QtGui.QApplication.translate("vtk_tools", "Browse", None, QtGui.QApplication.UnicodeUTF8))
self.label_4.setText(QtGui.QApplication.translate("vtk_tools", "Browse for reference velocity grid file (\'vgridsref.in\'):", None, QtGui.QApplication.UnicodeUTF8)) self.label_4.setText(QtGui.QApplication.translate("vtk_tools", "Browse for reference velocity grid file (\'vgridsref.in\'):", None, QtGui.QApplication.UnicodeUTF8))
self.pushButton_vgref.setText(QtGui.QApplication.translate("vtk_tools", "Browse", None, QtGui.QApplication.UnicodeUTF8)) self.pushButton_vgref.setText(QtGui.QApplication.translate("vtk_tools", "Browse", None, QtGui.QApplication.UnicodeUTF8))
self.label_5.setText(QtGui.QApplication.translate("vtk_tools", "Output Filename", None, QtGui.QApplication.UnicodeUTF8))
self.lineEdit_vgout.setText(QtGui.QApplication.translate("vtk_tools", "vgrids.vtk", None, QtGui.QApplication.UnicodeUTF8))
self.pushButton_parav.setToolTip(QtGui.QApplication.translate("vtk_tools", "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0//EN\" \"http://www.w3.org/TR/REC-html40/strict.dtd\">\n"
"<html><head><meta name=\"qrichtext\" content=\"1\" /><style type=\"text/css\">\n"
"p, li { white-space: pre-wrap; }\n"
"</style></head><body style=\" font-family:\'Sans\'; font-size:10pt; font-weight:400; font-style:normal;\">\n"
"<p style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\">Call Paraview (Shell command: <span style=\" font-style:italic;\">paraview</span>) for the specified output filename in the current directory.</p></body></html>", None, QtGui.QApplication.UnicodeUTF8))
self.pushButton_parav.setText(QtGui.QApplication.translate("vtk_tools", "<- Paraview", None, QtGui.QApplication.UnicodeUTF8))
self.start_vg.setText(QtGui.QApplication.translate("vtk_tools", "Start", None, QtGui.QApplication.UnicodeUTF8)) self.start_vg.setText(QtGui.QApplication.translate("vtk_tools", "Start", None, QtGui.QApplication.UnicodeUTF8))
self.label_src.setToolTip(QtGui.QApplication.translate("vtk_tools", "Create VTK files from the FMTOMO output file \'rays.dat\'.\n" self.label_src.setToolTip(QtGui.QApplication.translate("vtk_tools", "Create VTK files from the FMTOMO output file \'rays.dat\'.\n"
"This will generate one file of ray paths for each individual source.", None, QtGui.QApplication.UnicodeUTF8)) "This will generate one file of ray paths for each individual source.", None, QtGui.QApplication.UnicodeUTF8))