From a38b958b273ded56f74a783859e0781aa49e8787 Mon Sep 17 00:00:00 2001 From: Christophe Bourcier Date: Mon, 14 Jan 2019 12:18:20 +0100 Subject: [PATCH] More fixes in Cleaner and SurfOpt: - fix decode error in case a GMF file is selected - fix save log error - fix wrong mesh used when changing from mesh object to mesh file. --- src/Tools/MGCleanerPlug/MGCleanerMonPlugDialog.py | 5 +++-- src/Tools/MGCleanerPlug/MGCleanerMonViewText.py | 15 +++++++-------- src/Tools/YamsPlug/monViewText.py | 8 ++++---- src/Tools/YamsPlug/monYamsPlugDialog.py | 7 ++++--- 4 files changed, 18 insertions(+), 17 deletions(-) diff --git a/src/Tools/MGCleanerPlug/MGCleanerMonPlugDialog.py b/src/Tools/MGCleanerPlug/MGCleanerMonPlugDialog.py index 19d1c41ef..0818f537c 100644 --- a/src/Tools/MGCleanerPlug/MGCleanerMonPlugDialog.py +++ b/src/Tools/MGCleanerPlug/MGCleanerMonPlugDialog.py @@ -449,16 +449,17 @@ class MGCleanerMonPlugDialog(Ui_MGCleanerPlugDialog,QWidget): if fd.exec_(): infile = fd.selectedFiles()[0] self.LE_MeshFile.setText(infile) - self.fichierIn=str(infile).encode("latin-1") + self.fichierIn=str(infile) self.MeshIn="" self.LE_MeshSmesh.setText("") + self.__selectedMesh=None def setParamsFileName(self): fd = QFileDialog(self, "select a file", self.LE_ParamsFile.text(), "dat Files (*.dat);;All Files (*)") if fd.exec_(): infile = fd.selectedFiles()[0] self.LE_ParamsFile.setText(infile) - self.paramsFile=str(infile).encode("latin-1") + self.paramsFile=str(infile) def meshFileNameChanged(self): self.fichierIn=str(self.LE_MeshFile.text()) diff --git a/src/Tools/MGCleanerPlug/MGCleanerMonViewText.py b/src/Tools/MGCleanerPlug/MGCleanerMonViewText.py index 393c9e209..f2647a3fb 100644 --- a/src/Tools/MGCleanerPlug/MGCleanerMonViewText.py +++ b/src/Tools/MGCleanerPlug/MGCleanerMonViewText.py @@ -106,17 +106,16 @@ class MGCleanerMonViewText(Ui_ViewExe, QDialog): def saveFile(self): #recuperation du nom du fichier savedir=os.environ['HOME'] - fn = QFileDialog.getSaveFileName(None, self.trUtf8("Save File"),savedir) - if fn.isNull() : return + fn, mask = QFileDialog.getSaveFileName(None,"Save File",savedir) + if not fn: return ulfile = os.path.abspath(str(fn)) try: - f = open(fn, 'wb') - f.write(str(self.TB_Exe.toPlainText())) - f.close() + f = open(fn, 'wb') + f.write(self.TB_Exe.toPlainText().encode("utf-8")) + f.close() except IOError as why: - QMessageBox.critical(self, self.trUtf8('Save File'), - self.trUtf8('The file %1 could not be saved.
Reason: %2') - .arg(str(fn)).arg(str(why))) + QMessageBox.critical(self, 'Save File', + 'The file %s could not be saved.
Reason: %s'%(str(fn), str(why))) def readFromStdErr(self): a=self.monExe.readAllStandardError() diff --git a/src/Tools/YamsPlug/monViewText.py b/src/Tools/YamsPlug/monViewText.py index 84d640e8e..9d92a0c55 100644 --- a/src/Tools/YamsPlug/monViewText.py +++ b/src/Tools/YamsPlug/monViewText.py @@ -94,16 +94,16 @@ class MonViewText(Ui_ViewExe, QDialog): def saveFile(self): #recuperation du nom du fichier savedir=os.environ['HOME'] - fn = QFileDialog.getSaveFileName(None,"Save File",savedir) - if fn.isNull() : return + fn, mask = QFileDialog.getSaveFileName(None,"Save File",savedir) + if not fn: return ulfile = os.path.abspath(str(fn)) try: f = open(fn, 'wb') - f.write(str(self.TB_Exe.toPlainText())) + f.write(self.TB_Exe.toPlainText().encode("utf-8")) f.close() except IOError as why: QMessageBox.critical(self, 'Save File', - 'The file %1 could not be saved.
Reason: %2'%(str(fn), str(why))) + 'The file %s could not be saved.
Reason: %s'%(str(fn), str(why))) def readFromStdErr(self): a=self.monExe.readAllStandardError() diff --git a/src/Tools/YamsPlug/monYamsPlugDialog.py b/src/Tools/YamsPlug/monYamsPlugDialog.py index 4aac5cf7c..54298c2ff 100644 --- a/src/Tools/YamsPlug/monYamsPlugDialog.py +++ b/src/Tools/YamsPlug/monYamsPlugDialog.py @@ -413,16 +413,17 @@ class MonYamsPlugDialog(Ui_YamsPlugDialog,QWidget): if fd.exec_(): infile = fd.selectedFiles()[0] self.LE_MeshFile.setText(infile) - self.fichierIn=str(infile).encode("latin-1") + self.fichierIn=str(infile) self.MeshIn="" self.LE_MeshSmesh.setText("") + self.__selectedMesh=None def setParamsFileName(self): fd = QFileDialog(self, "select a file", self.LE_ParamsFile.text(), "dat Files (*.dat);;All Files (*)") if fd.exec_(): infile = fd.selectedFiles()[0] self.LE_ParamsFile.setText(infile) - self.paramsFile=str(infile).encode("latin-1") + self.paramsFile=str(infile) def meshFileNameChanged(self): self.fichierIn=str(self.LE_MeshFile.text()) @@ -504,7 +505,7 @@ class MonYamsPlugDialog(Ui_YamsPlugDialog,QWidget): except: pass - style = str(self.style).encode("latin-1") + style = str(self.style) # Translation of old Yams options to new MG-SurfOpt options if style == "0" : self.commande+= " --optimisation only"