X-Git-Url: http://git.salome-platform.org/gitweb/?p=modules%2Fsmesh.git;a=blobdiff_plain;f=src%2FTools%2FMeshCut%2Fmeshcut_plugin.py;h=7a4f5dfdd303907a738101172e02bb5db177263e;hp=271b4b1517789d3162d44647e6ae0ed73c552dcc;hb=0fc0831670e27a5611b941c52dc152fd63964515;hpb=bd8f1aee7c78f7d2eb82bd4fec5e08c9e3d280ce diff --git a/src/Tools/MeshCut/meshcut_plugin.py b/src/Tools/MeshCut/meshcut_plugin.py index 271b4b151..7a4f5dfdd 100644 --- a/src/Tools/MeshCut/meshcut_plugin.py +++ b/src/Tools/MeshCut/meshcut_plugin.py @@ -1,9 +1,9 @@ -# Copyright (C) 2006-2013 EDF R&D +# Copyright (C) 2006-2020 EDF R&D # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public # License as published by the Free Software Foundation; either -# version 2.1 of the License. +# version 2.1 of the License, or (at your option) any later version. # # This library is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -20,35 +20,30 @@ # if you already have plugins defined in a salome_plugins.py file, add this file at the end. # if not, copy this file as ${HOME}/Plugins/smesh_plugins.py or ${APPLI}/Plugins/smesh_plugins.py +import sys + def MeshCut(context): - # get context study, studyId, salomeGui + # get context study, salomeGui study = context.study - studyId = context.studyId sg = context.sg import os import subprocess import tempfile - from PyQt4 import QtCore - from PyQt4 import QtGui - from PyQt4.QtGui import QFileDialog - from PyQt4.QtGui import QMessageBox - from MeshCutDialog import Ui_Dialog + from qtsalome import QFileDialog, QMessageBox, QDialog + from MeshCutDialog_ui import Ui_Dialog - class CutDialog(QtGui.QDialog): + class CutDialog(QDialog): def __init__(self): - QtGui.QDialog.__init__(self) + QDialog.__init__(self) # Set up the user interface from Designer. self.ui = Ui_Dialog() self.ui.setupUi(self) # Connect up the buttons. - self.connect(self.ui.pb_origMeshFile, QtCore.SIGNAL("clicked()"), - self.setInputFile) - self.connect(self.ui.pb_cutMeshFile, QtCore.SIGNAL("clicked()"), - self.setOutputFile) - self.connect(self.ui.pb_help, QtCore.SIGNAL("clicked()"), - self.helpMessage) + self.ui.pb_origMeshFile.clicked.connect(self.setInputFile) + self.ui.pb_cutMeshFile.clicked.connect(self.setOutputFile) + self.ui.pb_help.clicked.connect(self.helpMessage) pass def setInputFile(self): @@ -56,9 +51,9 @@ def MeshCut(context): if fd.exec_(): infile = fd.selectedFiles()[0] self.ui.le_origMeshFile.setText(infile) - insplit = os.path.splitext(infile.toLocal8Bit().data()) - outfile = insplit[0] + '_cut' + insplit[1] - self.ui.le_cutMeshFile.setText(outfile) + insplit = os.path.splitext(str(infile).encode()) + outfile = insplit[0] + '_cut'.encode() + insplit[1] + self.ui.le_cutMeshFile.setText(outfile.decode()) pass def setOutputFile(self): @@ -103,11 +98,18 @@ and T the tolerance. if result: # dialog accepted args = ['MeshCut'] - args += [window.ui.le_origMeshFile.text().toLocal8Bit().data()] - args += [window.ui.le_cutMeshFile.text().toLocal8Bit().data()] - args += [window.ui.le_outMeshName.text().toLocal8Bit().data()] - args += [window.ui.le_groupAbove.text().toLocal8Bit().data()] - args += [window.ui.le_groupBelow.text().toLocal8Bit().data()] + if sys.platform == "win32": + args += [str(window.ui.le_origMeshFile.text())] + args += [str(window.ui.le_cutMeshFile.text())] + args += [str(window.ui.le_outMeshName.text())] + args += [str(window.ui.le_groupAbove.text())] + args += [str(window.ui.le_groupBelow.text())] + else: + args += [str(window.ui.le_origMeshFile.text()).encode()] + args += [str(window.ui.le_cutMeshFile.text()).encode()] + args += [str(window.ui.le_outMeshName.text()).encode()] + args += [str(window.ui.le_groupAbove.text()).encode()] + args += [str(window.ui.le_groupBelow.text()).encode()] args += [str(window.ui.dsb_normX.value())] args += [str(window.ui.dsb_normY.value())] args += [str(window.ui.dsb_normZ.value())]