From: Gilles DAVID Date: Tue, 18 Apr 2017 13:43:53 +0000 (+0200) Subject: Merge remote-tracking branch 'origin/V8_3_BR' into ngr/python3_dev X-Git-Tag: V9_0_0~6^2~11 X-Git-Url: http://git.salome-platform.org/gitweb/?p=modules%2Fsmesh.git;a=commitdiff_plain;h=e8173b4ff130ddb26d165c92403ef847fdfb8be2;hp=-c Merge remote-tracking branch 'origin/V8_3_BR' into ngr/python3_dev Conflicts: src/Tools/ZCracksPlug/casTests/launchCas.py src/Tools/padder/spadderpy/gui/inputdialog.py src/Tools/padder/spadderpy/gui/plugindialog.py src/Tools/padder/unittests/usecase_meshJobManager.py --- e8173b4ff130ddb26d165c92403ef847fdfb8be2 diff --combined src/Tools/ZCracksPlug/__init__.py index b06743239,4ae994c94..967dc97cf --- a/src/Tools/ZCracksPlug/__init__.py +++ b/src/Tools/ZCracksPlug/__init__.py @@@ -1,16 -1,21 +1,21 @@@ import sys, os, shutil, pickle, tempfile -import main, genereCrack, Zset -import utilityFunctions as uF +from Zcracks import main, genereCrack, Zset +from Zcracks import utilityFunctions as uF + os.environ['QT_QPA_PLATFORM_PLUGIN_PATH']=os.path.join(os.environ['QTDIR'],'plugins','platforms') + + if 'MESHGEMSHOME' in os.environ: + meshgemsdir=os.environ['MESHGEMSHOME'] + if len(meshgemsdir) > 0: + meshgems=meshgemsdir.split(os.sep)[-1] + uF.removeFromSessionPath('LD_LIBRARY_PATH', meshgems) + #commande="/bin/bash -c ""source $HOME/zebulon/Z8.6.6_NEW/do_config_bash""" #os.system(commande) def IHM(): - try: - from PyQt5.QtWidgets import QApplication - except: - from PyQt4.QtGui import QApplication + from PyQt5.QtWidgets import QApplication app = QApplication(sys.argv) myapp = main.ShipHolderApplication() @@@ -20,19 -25,18 +25,18 @@@ def SCRIPT(dataFile=None, data=None, dim=3, names=None): if dim!=3 and dim!=2: - print 'ERROR' + print('ERROR') return(False) if dataFile==None and data==None: - print 'One of dataFile or data is mandatory' + print('One of dataFile or data is mandatory') return(False) if data==None: data=pickle.load(open(dataFile,'r')) - print data + print(data) - tmpdir=tempfile.mkdtemp() - uF.removeFromSessionPath('LD_LIBRARY_PATH', 'Meshgems-2111') + tmpdir=tempfile.mkdtemp(prefix='tmpZcracks') if names==None: names={'saneGeoName':'salome_sane', 'crackGeoName':'salome_crack', 'crackedGeoName':'salome_cracked'} @@@ -47,7 -51,7 +51,7 @@@ for f in [crackMed, crackedMed, saneGeo, crackGeo, crackedGeo]: if os.path.isfile(f): os.remove(f) - print crackMed + print(crackMed) genereCrack.main(data, crackMed) goOn=os.path.isfile(crackMed) diff --combined src/Tools/ZCracksPlug/casTests/launchCas.py index 3522ee67e,4672776ec..592305cce --- a/src/Tools/ZCracksPlug/casTests/launchCas.py +++ b/src/Tools/ZCracksPlug/casTests/launchCas.py @@@ -1,7 -1,7 +1,7 @@@ from Zcracks import genereCrack, Zset from Zcracks import utilityFunctions as uF -import genereCube +from . import genereCube from math import sqrt @@@ -18,16 -18,16 +18,16 @@@ import strin #tmpdir = "/local00/home/B27118/projets/Zcracks/Zcracks/casTests/tmpdir" #if not os.path.isdir(tmpdir): os.mkdir(tmpdir) - tmpdir=tempfile.mktemp(prefix='tmpZcracks') + tmpdir=tempfile.mkdtemp(prefix='tmpZcracks') -print "tmpdir=", tmpdir +print("tmpdir=", tmpdir) - meshgemsdir=os.environ('MESHGEMSHOME') - if len(meshgemsdir) > 0: - meshgems=string.split(meshgemsdir,os.sep)[-1] - uF.removeFromSessionPath('LD_LIBRARY_PATH', meshgems) + #meshgemsdir=os.environ('MESHGEMSHOME') + #if len(meshgemsdir) > 0: + #meshgems=string.split(meshgemsdir,os.sep)[-1] + #uF.removeFromSessionPath('LD_LIBRARY_PATH', meshgems) def LAUNCH(listCas=[]): - if type(listCas)!=list: listCas=[listCas] + if not isinstance(listCas, list): listCas=[listCas] N=20 L=1. @@@ -194,18 -194,18 +194,18 @@@ OK=[] NOOK=[] - for s in list(synthese.keys()): - for s in synthese.keys(): ++ for s in synthese: if synthese[s]: OK.append(s) else: NOOK.append(s) - print 'OK:' - print OK - print ' ' - print 'NOOK:' - print NOOK - print ' ' + print('OK:') + print(OK) + print(' ') + print('NOOK:') + print(NOOK) + print(' ') return(synthese) diff --combined src/Tools/ZCracksPlug/main.py index 347c7c0ad,4d3384de0..fb75c82e1 --- a/src/Tools/ZCracksPlug/main.py +++ b/src/Tools/ZCracksPlug/main.py @@@ -1,19 -1,15 +1,15 @@@ 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 -17,11 +17,11 @@@ # --------------------- - 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 -72,6 +72,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 -119,9 +119,9 @@@ 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 -137,10 +137,10 @@@ 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 -232,7 +232,7 @@@ 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 -243,7 +243,7 @@@ 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 -262,15 +262,15 @@@ 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]])) + obj.setText(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) + 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 -337,10 +337,10 @@@ 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 -418,7 +418,7 @@@ 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) @@@ -475,19 -442,19 +442,19 @@@ 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 -470,24 +470,24 @@@ 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) # --------------------------------- diff --combined src/Tools/ZCracksPlug/utilityFunctions.py index 34e46f857,9571fd8d9..997f02f7c --- a/src/Tools/ZCracksPlug/utilityFunctions.py +++ b/src/Tools/ZCracksPlug/utilityFunctions.py @@@ -3,7 -3,7 +3,7 @@@ import numpy, subprocess, sys from os import remove, getpid, path, environ -from output import message +from .output import message def calcCoordVectors(normalIN, directionIN): V3TEMP=numpy.cross(normalIN,directionIN) @@@ -17,11 -17,11 +17,11 @@@ def testStrictRange(x, inf=0.0, sup=False): test=False - c1=(type(x)==list) + c1=(isinstance(x, list)) if c1: c2=(len(x)==1) if c2: - c3=(type(x[0])==type(inf)) + c3=(isinstance(x[0], type(inf))) if c3: c4=(x[0]>inf) c5=True @@@ -33,24 -33,24 +33,24 @@@ def test3dVector(x): test=False - c1=(type(x)==list) + c1=(isinstance(x, list)) if c1: c2=(len(x)==3) if c2: - c3=(type(x[0])==float) - c4=(type(x[1])==float) - c5=(type(x[2])==float) + c3=(isinstance(x[0], float)) + c4=(isinstance(x[1], float)) + c5=(isinstance(x[2], float)) if c3 and c4 and c5: test=True return(test) def testRange(x, inf=0.0, sup=False): test=False - c1=(type(x)==list) + c1=(isinstance(x, list)) if c1: c2=(len(x)==1) if c2: - c3=(type(x[0])==type(inf)) + c3=(isinstance(x[0], type(inf))) if c3: c4=(x[0]>=inf) c5=True @@@ -178,7 -178,13 +178,13 @@@ def extendElsets(meshFile, outFile=None smesh = smeshBuilder.New(theStudy) ([mesh], status) = smesh.CreateMeshesFromMED(meshFile) - + + if mesh.NbVolumes()>0: + case2D=False + mesh.Reorient2DBy3D( [ mesh ], mesh, 1 ) + else: + case2D=True + mesh=cleanGroups(mesh) # Node color status @@@ -260,8 -266,8 +266,8 @@@ while ifChanged : ifChanged=False for elemId in elemList[0]: - minColor=sys.maxint - maxColor=-sys.maxint + minColor=sys.maxsize + maxColor=-sys.maxsize for elemNodeId in mesh.GetElemNodes(elemId) : nodeColor=colorList[elemNodeId-1] if nodeColormaxColor : maxColor=nodeColor - #if minColor!=maxColor : - #ifChanged = True - #for elemNodeId in mesh.GetElemNodes(elemId) : - #colorList[elemNodeId-1]=maxColor - - #velem0 = [] - #velem1 = [] - #for elemId in volElemList: - #elemNodesId=mesh.GetElemNodes(elemId) - #elemColor=colorList[elemNodesId[0]-1] - #if(elemColor==1) : velem0.append(elemId) - #if(elemColor==2) : velem1.append(elemId) - - #mesh.MakeGroupByIds('SIDE_co',SMESH.VOLUME,velem0) - #mesh.MakeGroupByIds('SIDE_ext',SMESH.VOLUME,velem1) - - #surfElemList=mesh.GetElementsByType(SMESH.FACE) - #selem0 = [] - #selem1 = [] - #nbelem0=0 - #nbelem1=0 - - #for elemId in surfElemList: - #elemNodesId=mesh.GetElemNodes(elemId) - #elemColor=colorList[elemNodesId[0]-1] - #if(elemColor==1) : selem0.append(elemId) - #if(elemColor==2) : selem1.append(elemId) - - #mesh.MakeGroupByIds('SIDE_co',SMESH.FACE,selem0) - #mesh.MakeGroupByIds('SIDE_ext',SMESH.FACE,selem1) - - #maxAR=0. - #for elem in volElemList: - #maxAR=max(mesh.GetAspectRatio(elem),maxAR) - #for elem in surfElemList: - #maxAR=max(mesh.GetAspectRatio(elem),maxAR) - - #mesh.ExportMED(meshFile, 0, SMESH.MED_V2_2, 1, None ,1) - #return(maxAR) def removeFromSessionPath(envVar, patern): - if type(patern) is not list: patern=[patern] - if type(envVar) is not list: envVar=[envVar] + if not isinstance(patern, list): patern=[patern] + if not isinstance(envVar, list): envVar=[envVar] for env in envVar: path=environ[env] diff --combined src/Tools/padder/spadderpy/gui/inputdialog.py index a5e08488c,a05007792..6620020b7 --- a/src/Tools/padder/spadderpy/gui/inputdialog.py +++ b/src/Tools/padder/spadderpy/gui/inputdialog.py @@@ -32,12 -32,20 +32,20 @@@ from omniORB import CORB from qtsalome import QIcon, QStandardItemModel, QStandardItem, QMessageBox, pyqtSignal -from inputframe_ui import Ui_InputFrame -from inputdata import InputData +from salome.smesh.spadder.gui.inputframe_ui import Ui_InputFrame +from salome.smesh.spadder.gui.inputdata import InputData DEBUG_MODE=True GROUPNAME_MAXLENGTH=8 + INPUTDATA_KEY_FILES="meshfiles" + INPUTDATA_KEY_PARAM="parameters" + + PARAM_KEY_NBITER = "NbIteration" + PARAM_KEY_RMAXRMIN = "RmaxRmin" + PARAM_NBITER_DEFAULT_VALUE = 10 + PARAM_RMAXRMIN_DEFAULT_VALUE = 3 + class InputDialog(GenericDialog): TBL_HEADER_LABEL=["Input Mesh", "Output group name"] @@@ -116,7 -124,8 +124,8 @@@ # name item. # Setup default values for numerical parameters - self.__ui.txtParamNbIter.setValue(3) + self.__ui.txtParamNbIter.setValue(PARAM_NBITER_DEFAULT_VALUE) + self.__ui.txtParamRmaxRmin.setValue(PARAM_RMAXRMIN_DEFAULT_VALUE) # Note that PADDER does not support group name longer than 8 # characters. We apply then this limit in the gui field. @@@ -138,7 -147,7 +147,7 @@@ self.__ui.txtSmeshObject.setEnabled(False) self.__ui.btnAddInput.setEnabled(False) self.__selectedMesh = None - self.__dictInputData = {} + self.__dictInputFiles = {} self.__nbConcreteMesh = 0 self.__nbSteelbarMesh = 0 @@@ -231,7 -240,7 +240,7 @@@ """ # if the entry already exists, we remove it to replace by a # new one - if meshName in self.__dictInputData: - if self.__dictInputFiles.has_key(meshName): ++ if meshName in self.__dictInputFiles: self.__delInputFromMap(meshName) inputData = InputData() @@@ -240,16 -249,16 +249,16 @@@ inputData.meshType = meshType inputData.groupName = groupName # The key of the map is the mesh name - self.__dictInputData[meshName] = inputData + self.__dictInputFiles[meshName] = inputData if inputData.meshType == InputData.MESHTYPES.CONCRETE: self.__nbConcreteMesh += 1 else: self.__nbSteelbarMesh += 1 - print inputData - print "meshType = ",inputData.meshType - print "nb concrete mesh ",self.__nbConcreteMesh - print "nb steelbar mesh ",self.__nbSteelbarMesh + print(inputData) + print("meshType = ",inputData.meshType) + print("nb concrete mesh ",self.__nbConcreteMesh) + print("nb steelbar mesh ",self.__nbSteelbarMesh) def onDeleteInput(self): @@@ -272,44 -281,62 +281,62 @@@ This function removes the specified entry from the internal map (for data management purpose) """ - inputData = self.__dictInputData.pop(meshName) + inputData = self.__dictInputFiles.pop(meshName) if inputData.meshType == InputData.MESHTYPES.CONCRETE: self.__nbConcreteMesh -= 1 else: self.__nbSteelbarMesh -= 1 - print inputData - print "nb concrete mesh ",self.__nbConcreteMesh - print "nb steelbar mesh ",self.__nbSteelbarMesh + print(inputData) + print("nb concrete mesh ",self.__nbConcreteMesh) + print("nb steelbar mesh ",self.__nbSteelbarMesh) - def setData(self, listInputData=[]): + def setData(self, dictInputData={}): """ This function fills the dialog widgets with values provided by the specified data list. """ self.clear() - for inputData in listInputData: - if dictInputData.has_key(INPUTDATA_KEY_FILES): ++ if INPUTDATA_KEY_FILES in dictInputData: + listInputData = dictInputData["meshfiles"] + for inputData in listInputData: - meshName = inputData.meshName - meshObject = inputData.meshObject - meshType = inputData.meshType - groupName = inputData.groupName - meshName = inputData.meshName ++ meshName = inputData.meshName + meshObject = inputData.meshObject - meshType = inputData.meshType - groupName = inputData.groupName ++ meshType = inputData.meshType ++ groupName = inputData.groupName - self.__addInputInGui(meshName, meshObject, meshType, groupName) - self.__addInputInMap(meshName, meshObject, meshType, groupName) + self.__addInputInGui(meshName, meshObject, meshType, groupName) + self.__addInputInMap(meshName, meshObject, meshType, groupName) - if not DEBUG_MODE: - self.onSelectSmeshObject() + if not DEBUG_MODE: + self.onSelectSmeshObject() + - if dictInputData.has_key(INPUTDATA_KEY_PARAM): - dictInputParameters = dictInputData[INPUTDATA_KEY_PARAM] - if dictInputParameters.has_key(PARAM_KEY_NBITER): ++ if INPUTDATA_KEY_PARAM in dictInputData: ++ dictInputParameters = dictInputData[INPUTDATA_KEY_PARAM] ++ if PARAM_KEY_NBITER in dictInputParameters: + self.__ui.txtParamNbIter.setValue(dictInputParameters[PARAM_KEY_NBITER]) - if dictInputParameters.has_key(PARAM_KEY_RMAXRMIN): ++ if PARAM_KEY_RMAXRMIN in dictInputParameters: + self.__ui.txtParamRminRmax.setValue(dictInputParameters[PARAM_KEY_RMAXRMIN]) def getData(self): """ This function returns a list of InputData that corresponds to the data in the dialog widgets of the current dialog. """ + # Get the list of mesh files # Note that the values() function returns a copy of the list # of values. - return list(self.__dictInputData.values()) + dictInputData={} + dictInputData[INPUTDATA_KEY_FILES] = self.__dictInputFiles.values() + + # Get the list of additionnal parameters + dictInputParameters = {} + dictInputParameters[PARAM_KEY_NBITER] = self.__ui.txtParamNbIter.value() + dictInputParameters[PARAM_KEY_RMAXRMIN] = self.__ui.txtParamRmaxRmin.value() + dictInputData[INPUTDATA_KEY_PARAM] = dictInputParameters + return dictInputData def checkData(self): """ @@@ -328,7 -355,6 +355,6 @@@ return True - #def setParameters(self, # ============================================================================== # Basic use case @@@ -343,7 -369,7 +369,7 @@@ def TEST_InputDialog() dlg=InputDialog() dlg.displayAndWait() if dlg.wasOk(): - print "OK has been pressed" + print("OK has been pressed") def TEST_InputDialog_setData(): import sys @@@ -353,7 -379,7 +379,7 @@@ dlg=InputDialog() - from inputdata import InputData + from .inputdata import InputData inputData = InputData() inputData.meshName = "myMesh" inputData.meshObject = None @@@ -366,9 -392,9 +392,9 @@@ dlg.displayAndWait() if dlg.wasOk(): - print "OK has been pressed" + print("OK has been pressed") outputListInputData = dlg.getData2() - print outputListInputData + print(outputListInputData) if __name__ == "__main__": diff --combined src/Tools/padder/spadderpy/gui/plugindialog.py index c3f30e55b,4fec4e8d3..ba00df765 --- a/src/Tools/padder/spadderpy/gui/plugindialog.py +++ b/src/Tools/padder/spadderpy/gui/plugindialog.py @@@ -22,9 -22,10 +22,10 @@@ from qtsalome import QDialog, QIcon, Qt -from plugindialog_ui import Ui_PluginDialog -from inputdialog import InputDialog, INPUTDATA_KEY_FILES, INPUTDATA_KEY_PARAM -from inputdialog import PARAM_KEY_NBITER, PARAM_KEY_RMAXRMIN -from inputdata import InputData +from salome.smesh.spadder.gui.plugindialog_ui import Ui_PluginDialog - from salome.smesh.spadder.gui.inputdialog import InputDialog ++from salome.smesh.spadder.gui.inputdialog import InputDialog, INPUTDATA_KEY_FILES, INPUTDATA_KEY_PARAM ++from salome.smesh.spadder.gui.inputdialog import PARAM_KEY_NBITER, PARAM_KEY_RMAXRMIN +from salome.smesh.spadder.gui.inputdata import InputData # __GBO__: uncomment this line and comment the previous one to use the # demo input dialog instead of the real one. #from demoinputdialog import InputDialog @@@ -86,7 -87,7 +87,7 @@@ class PluginDialog(QDialog) self.__ui.btnClear.setIcon(icon) # Then, we can connect the slot to there associated button event - self.__ui.btnInput.clicked.connect( self.onInput ) + self.__ui.btnInput.clicked.connect( self.onInput ) self.__ui.btnCompute.clicked.connect( self.onCompute ) self.__ui.btnRefresh.clicked.connect( self.onRefresh ) self.__ui.btnPublish.clicked.connect( self.onPublish ) @@@ -139,7 -140,7 +140,7 @@@ self.__inputDialog.windowFlags() | Qt.WindowStaysOnTopHint) # The signal inputValidated emitted from inputDialog is # connected to the slot function onProcessInput: - self.__inputDialog.inputValidated.connect( self.onProcessInput ) + self.__inputDialog.inputValidated.connect( self.onProcessInput ) else: self.__ui.frameInput.setVisible(True) @@@ -178,7 -179,7 +179,7 @@@ servant. Note that the component is loaded on first demand, and then the reference is recycled. """ - if self.__dict__.has_key("__jobManager") and self.__jobManager is not None: + if "__jobManager" in self.__dict__ and self.__jobManager is not None: return self.__jobManager # WARN: we first have to update the SALOME components catalog @@@ -218,6 -219,7 +219,7 @@@ This function clears the log area and the states of the buttons """ self.__listInputData = [] + self.__dictInputParameters = {} self.__ui.txtLog.clear() self.__setGuiState(["CAN_SELECT"]) self.__isRunning = False @@@ -241,7 -243,10 +243,10 @@@ windows to process the validation event (see the slot onProcessInput which is connected to this event). ''' - self.__inputDialog.setData(self.__listInputData) + dictInputData = {} + dictInputData[INPUTDATA_KEY_FILES] = self.__listInputData + dictInputData[INPUTDATA_KEY_PARAM] = self.__dictInputParameters + self.__inputDialog.setData(dictInputData) self.__inputDialog.open() def onProcessInput(self): @@@ -252,7 -257,10 +257,10 @@@ """ # The processing simply consists in requesting the input data # from the dialog window. - self.__listInputData = self.__inputDialog.getData() + dictInputData = self.__inputDialog.getData() + self.__listInputData = dictInputData[INPUTDATA_KEY_FILES] + self.__dictInputParameters = dictInputData[INPUTDATA_KEY_PARAM] + self.__ui.lblStatusBar.setText("Input data OK") self.__log("INF: Press \"Compute\" to start the job") self.__setGuiState(["CAN_SELECT", "CAN_COMPUTE"]) @@@ -283,8 -291,16 +291,16 @@@ group_name = inputData.groupName) meshJobFileList.append(parameter) + # And to create a list of the additional parameters. + # WARN: the CORBA interface requires string values. + meshJobParameterList=[] - for inputParameterKey in self.__dictInputParameters.keys(): ++ for inputParameterKey in self.__dictInputParameters: + value = self.__dictInputParameters[inputParameterKey] + parameter = MESHJOB.MeshJobParameter(name=inputParameterKey,value=str(value)) + meshJobParameterList.append(parameter) + jobManager = self.__getJobManager() - self.__jobid = jobManager.initialize(meshJobFileList, self.__configId) + self.__jobid = jobManager.initialize(meshJobFileList, meshJobParameterList, self.__configId) if self.__jobid < 0: self.__log("ERR: the job can't be initialized") self.__log("ERR: %s"%jobManager.getLastErrorMessage()) @@@ -401,3 -417,6 +417,3 @@@ def TEST_PluginDialog() if __name__ == "__main__": TEST_PluginDialog() - - - diff --combined src/Tools/padder/unittests/usecase_meshJobManager.py index 393840239,3f705458f..4fe3da6d9 --- a/src/Tools/padder/unittests/usecase_meshJobManager.py +++ b/src/Tools/padder/unittests/usecase_meshJobManager.py @@@ -83,7 -83,7 +83,7 @@@ PADDERTESTDIR = getPadderTestDir(defaul # padder.cfg). # def test00_parameters(): - """Test using a concrete mesh and a single steelbar mesh""" + """Test using a concrete mesh and a single steelbar mesh""" file_concrete=os.path.join(spadder.getTestDataDir(),"concrete.med") file_steelbar=os.path.join(spadder.getTestDataDir(),"ferraill.med") @@@ -109,7 -109,7 +109,7 @@@ def test01_parameters() file_type=MESHJOB.MED_CONCRETE, group_name="concrete") meshJobFileList.append(param) - + medfile = os.path.join(datadir,"ferraill.med") param = MESHJOB.MeshJobFile(file_name=medfile, file_type=MESHJOB.MED_STEELBAR, @@@ -121,7 -121,7 +121,7 @@@ file_type=MESHJOB.MED_STEELBAR, group_name="ferrtran") meshJobFileList.append(param) - + return meshJobFileList def test02_parameters(): @@@ -161,7 -161,7 +161,7 @@@ def test03_parameters() meshJobFileList = test03_parameters() meshJobParameterList = [] - param = MESHJOB.MeshJobParameter(name="RminRmax",value="1.5") + param = MESHJOB.MeshJobParameter(name="RmaxRmin",value="1.5") meshJobParameterList.append(param) param = MESHJOB.MeshJobParameter(name="NbIteration",value="3") meshJobParameterList.append(param) @@@ -172,14 -172,14 +172,14 @@@ jobid = component.initialize(meshJobFileList, meshJobParameterList, configId) if jobid<0: msg = component.getLastErrorMessage() - print "ERR: %s"%msg + print("ERR: %s"%msg) sys.exit(1) - + created = False nbiter = 0 while not created: state = component.getState(jobid) - print "MeshJobManager ["+str(nbiter)+"] : state = "+str(state) + print("MeshJobManager ["+str(nbiter)+"] : state = "+str(state)) if state == "CREATED": created = True time.sleep(0.5) @@@ -196,10 -196,10 +196,10 @@@ ok=component.start(jobid) if not ok: msg = component.getLastErrorMessage() - print "ERR: %s"%msg + print("ERR: %s"%msg) sys.exit(1) -print "job started: %s"%ok +print("job started: %s"%ok) # # This part illustrates how you can follow the execution of the job. @@@ -212,20 -212,20 +212,20 @@@ ended = Fals nbiter = 0 while not ended: state = component.getState(jobid) - print "MeshJobManager ["+str(nbiter)+"] : state = "+str(state) + print("MeshJobManager ["+str(nbiter)+"] : state = "+str(state)) if state not in run_states: ended=True time.sleep(0.5) nbiter+=1 - + if state not in end_states: - print "ERR: jobid = "+str(jobid)+" ended abnormally with state="+str(state) + print("ERR: jobid = "+str(jobid)+" ended abnormally with state="+str(state)) msg = component.getLastErrorMessage() - print("ERR: %s"%msg) - print "ERR: %s"%msg ++ print("ERR: %s"%msg) else: - print "OK: jobid = "+str(jobid)+" ended with state="+str(state) + print("OK: jobid = "+str(jobid)+" ended with state="+str(state)) meshJobResults = component.finalize(jobid) - print meshJobResults + print(meshJobResults) if meshJobResults.status is not True: - print "ERR: the results are not OK: %s"%component.getLastErrorMessage() - print "ERR: see log files in %s"%meshJobResults.results_dirname + print("ERR: the results are not OK: %s"%component.getLastErrorMessage()) + print("ERR: see log files in %s"%meshJobResults.results_dirname)