X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FTools%2FZCracksPlug%2Fmain.py;h=9fb40199c69da9a84bb210b96f3f1f7cc45dea58;hb=HEAD;hp=e4b3e526dfdb5e20f075e7a1414d1005abf6f59b;hpb=1746a461949c030eb46ccb860e586ade2e5de5e3;p=modules%2Fsmesh.git diff --git a/src/Tools/ZCracksPlug/main.py b/src/Tools/ZCracksPlug/main.py index e4b3e526d..9fb40199c 100644 --- a/src/Tools/ZCracksPlug/main.py +++ b/src/Tools/ZCracksPlug/main.py @@ -1,19 +1,34 @@ +# Copyright (C) 2016-2024 EDF +# +# 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, 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 +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# +# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +# + import sys, pickle, tempfile, shutil from os import path, getpid, environ, remove, system -try: - from PyQt5.QtCore import * - from PyQt5.QtGui import * - from PyQt5.QtWidgets import * -except: - from PyQt4.QtCore import * - from PyQt4.QtGui import * +from PyQt5.QtCore import * +from PyQt5.QtGui import * +from PyQt5.QtWidgets import * -import utilityFunctions as uF -import genereCrack, Zset, output, zcracks_ui +from . import utilityFunctions as uF +from . import genereCrack, Zset, output, zcracks_ui -from output import message, init -from zcracks_ui import Ui_Zui +from .output import message, init +from .zcracks_ui import Ui_Zui # --------------------- @@ -21,13 +36,11 @@ from zcracks_ui import Ui_Zui # --------------------- -uF.removeFromSessionPath('LD_LIBRARY_PATH', 'Meshgems-2111') - def stringToFloat(string, typ=float): if str(string).replace(' ','')=='': out=[] else: - out=map(typ, str(string).split()) + out=list(map(typ, str(string).split())) return(out) def addExtension(string, extension): @@ -78,25 +91,6 @@ class ShipHolderApplication(QGroupBox): self.verbose=1 - #self.connect(self.ui.CBQuad, SIGNAL("toggled(bool)"),self.pressQuad) - #self.connect(self.ui.btReset, SIGNAL("clicked()"),self.pressReset) - #self.connect(self.ui.btCancel, SIGNAL("clicked()"),self.pressCancel) - #self.connect(self.ui.btApply, SIGNAL("clicked()"),self.pressApply) - #self.connect(self.ui.btApplyClose, SIGNAL("clicked()"),self.pressApplyClose) - #self.connect(self.ui.btLoad, SIGNAL("clicked()"),self.pressCharger) - #self.connect(self.ui.btSave, SIGNAL("clicked()"),self.pressSauver) - #self.connect(self.ui.btLoadCracked, SIGNAL("clicked()"),self.pressLoadCracked) - #self.connect(self.ui.btLoadSane, SIGNAL("clicked()"),self.pressLoadSane) - - #self.connect(self.ui.btGrVol, SIGNAL("clicked()"),self.pressLoadGroupVOL) - #self.connect(self.ui.btGrFace, SIGNAL("clicked()"),self.pressLoadGroupFACE) - #self.connect(self.ui.btGrEdge, SIGNAL("clicked()"),self.pressLoadGroupEDGE) - #self.connect(self.ui.btGrNode, SIGNAL("clicked()"),self.pressLoadGroupNODE) - #self.connect(self.ui.btGrAll, SIGNAL("clicked()"),self.pressLoadGroupALL) - #self.connect(self.ui.btVisu, SIGNAL("clicked()"),self.pressVisu) - - #self.connect(self.ui.CBAdvanced, SIGNAL("toggled(bool)"),self.pressAdvanced) - self.ui.CBQuad.toggled.connect(self.pressQuad) self.ui.btReset.clicked.connect(self.pressReset) self.ui.btCancel.clicked.connect(self.pressCancel) @@ -144,9 +138,9 @@ class ShipHolderApplication(QGroupBox): def pressQuad(self): if self.ui.CBQuad.isChecked(): self.ui.CBBarsoum.setEnabled(True) - self.ui.valGradation.setText(QString('2.3')) + self.ui.valGradation.setText('2.3') else: - self.ui.valGradation.setText(QString('1.3')) + self.ui.valGradation.setText('1.3') self.ui.CBBarsoum.setChecked(False) self.ui.CBBarsoum.setEnabled(False) @@ -162,10 +156,10 @@ class ShipHolderApplication(QGroupBox): tab=onglet.findChildren(QTableWidget)[0] for irow in range(tab.rowCount()): if tab.item(irow,0) != None: - tab.item(irow,0).setText(QString('')) - self.ui.valGradation.setText(QString('1.3')) - self.ui.valLayers.setText(QString('5')) - self.ui.valIterations.setText(QString('2')) + tab.item(irow,0).setText('') + self.ui.valGradation.setText('1.3') + self.ui.valLayers.setText('6') + self.ui.valIterations.setText('2') self.ui.CBIs2D.setChecked(False) self.ui.CBRefine.setChecked(False) @@ -257,7 +251,7 @@ class ShipHolderApplication(QGroupBox): fileNames = fileDiag.selectedFiles() filedef = fileNames[0] filedef = addExtension(str(filedef), 'med') - self.ui.valCrackedName.setText(QString(filedef)) + self.ui.valCrackedName.setText(filedef) def pressLoadSane(self): @@ -268,7 +262,7 @@ class ShipHolderApplication(QGroupBox): if fileDiag.exec_() : fileNames = fileDiag.selectedFiles() filedef = fileNames[0] - self.ui.valSaneName.setText(QString(filedef)) + self.ui.valSaneName.setText(filedef) def pressCharger(self): @@ -287,23 +281,15 @@ class ShipHolderApplication(QGroupBox): for cont, obj in enumerate(self.lineEditObjects): if self.lineEditTypes[cont] in [float, int]: - obj.setText(QString(self.data['TXT'+self.lineEditNames[cont]])) + obj.setText(self.data['TXT'+self.lineEditNames[cont]]) else: - obj.setText(QString(self.data[self.lineEditNames[cont]])) - - self.ui.CBQuad.setChecked(True if 'quad' in self.data.keys() and self.data['quad'] else False) - self.ui.CBBarsoum.setChecked(True if 'barsoum' in self.data.keys() and self.data['barsoum'] else False) - self.ui.CBIs2D.setChecked(True if 'is2D' in self.data.keys() and self.data['is2D'] else False) - self.ui.CBRefine.setChecked(True if 'refine' in self.data.keys() and self.data['refine'] else False) + obj.setText(self.data[self.lineEditNames[cont]]) + self.ui.CBQuad.setChecked(True if 'quad' in list(self.data.keys()) and self.data['quad'] else False) + self.ui.CBBarsoum.setChecked(True if 'barsoum' in list(self.data.keys()) and self.data['barsoum'] else False) + self.ui.CBIs2D.setChecked(True if 'is2D' in list(self.data.keys()) and self.data['is2D'] else False) + self.ui.CBRefine.setChecked(True if 'refine' in list(self.data.keys()) and self.data['refine'] else False) - - - - #if self.data['quad']: self.ui.CBQuad.setChecked(True) - #if self.data['barsoum']: self.ui.CBBarsoum.setChecked(True) - #if self.data['is2D']: self.ui.CBIs2D.setChecked(True) - #if self.data['refine']: self.ui.CBRefine.setChecked(True) self.setTableParameters() @@ -370,10 +356,10 @@ class ShipHolderApplication(QGroupBox): if not test2: message('A','No mesh file to visualize') else: - print medit+' %s' %meshFile2 + print(medit+' %s' %meshFile2) system(medit+' %s' %meshFile2) else: - print medit+' %s' %meshFile1 + print(medit+' %s' %meshFile1) system(medit+' %s' %meshFile1) return() @@ -451,7 +437,7 @@ class ShipHolderApplication(QGroupBox): if tab.item(irow,0) == None: item = QTableWidgetItem() tab.setItem(irow, 0, item) - tab.item(irow,0).setText(QString(self.data['TXTcrack'][str(self.ui.tabWidget.tabText(iongl))][str(label)])) + tab.item(irow,0).setText(self.data['TXTcrack'][str(self.ui.tabWidget.tabText(iongl))][str(label)]) if str(self.ui.tabWidget.tabText(iongl)) == self.data['TXTcrack']['actif']: self.ui.tabWidget.setCurrentWidget(onglet) @@ -464,9 +450,8 @@ class ShipHolderApplication(QGroupBox): else: import SMESH, salome #salome.salome_init() - theStudy = salome.myStudy from salome.smesh import smeshBuilder - smesh = smeshBuilder.New(theStudy) + smesh = smeshBuilder.New() ([objetSain], status) = smesh.CreateMeshesFromMED(saneFile) @@ -475,19 +460,19 @@ class ShipHolderApplication(QGroupBox): for group in objetSain.GetGroups(): if (self.GroupToLoad in ['VOL','ALL']) and (group.GetType()==SMESH.VOLUME): - groupsVOL+=group.GetName().replace(' ','')+" " + groupsVOL+=self.cleanGroupName(group) nGr+=1 if (self.GroupToLoad in ['FACE','ALL']) and (group.GetType()==SMESH.FACE): - groupsFAC+=group.GetName().replace(' ','')+" " + groupsFAC+=self.cleanGroupName(group) nGr+=1 if (self.GroupToLoad in ['EDGE','ALL']) and (group.GetType()==SMESH.EDGE): - groupsEDG+=group.GetName().replace(' ','')+" " + groupsEDG+=self.cleanGroupName(group) nGr+=1 if (self.GroupToLoad in ['NODE','ALL']) and (group.GetType()==SMESH.NODE): - groupsNOD+=group.GetName().replace(' ','')+" " + groupsNOD+=self.cleanGroupName(group) nGr+=1 if groupsVOL!='': self.ui.valGrVol.setText(groupsVOL) @@ -503,6 +488,24 @@ class ShipHolderApplication(QGroupBox): remove(f) except: pass + + def cleanGroupName(self, group): + name=group.GetName() + while name.endswith(' '): name=name[:-1] + if ' ' in name: + message('A','%s group has a space in its name --> ignored' %name) + return('') + else: + return(name+" ") + + def checkNamesSpaces(self, names): + if type(names) is str: names=[names] + ok=True + for n in names: + if ' ' in n: + message('E','%s has a space in its name, please remove it' %n, goOn=True) + ok=False + return(ok) # ---------------------------------