From 8847a378fe84b50f118459deae72fc0164beb9ec Mon Sep 17 00:00:00 2001 From: "pascale.noyret" Date: Fri, 9 Jun 2017 10:54:31 +0200 Subject: [PATCH] pourTelemac --- Editeur/{utils.py => Eficas_utils.py} | 0 InterfaceQT4/configuration.py | 3 +- InterfaceQT4/editor.py | 5 +-- InterfaceQT4/qtEficas.py | 17 +++++----- InterfaceQT4/viewManager.py | 1 + convert/convert_TELEMAC.py | 4 +-- generator/generator_TELEMAC.py | 46 ++++++++++++++++----------- 7 files changed, 43 insertions(+), 33 deletions(-) rename Editeur/{utils.py => Eficas_utils.py} (100%) diff --git a/Editeur/utils.py b/Editeur/Eficas_utils.py similarity index 100% rename from Editeur/utils.py rename to Editeur/Eficas_utils.py diff --git a/InterfaceQT4/configuration.py b/InterfaceQT4/configuration.py index 8b7bb7d5..ebdbdf94 100644 --- a/InterfaceQT4/configuration.py +++ b/InterfaceQT4/configuration.py @@ -31,9 +31,10 @@ except : pass import os, sys, types, re import traceback from PyQt5.QtWidgets import QMessageBox -from Editeur.utils import read_file +from Editeur.Eficas_utils import read_file from Extensions.i18n import tr + class CONFIG_BASE(object): #------------------------------- diff --git a/InterfaceQT4/editor.py b/InterfaceQT4/editor.py index 5ca8a375..134549a5 100755 --- a/InterfaceQT4/editor.py +++ b/InterfaceQT4/editor.py @@ -52,7 +52,7 @@ from monWidgetCreeParam import MonWidgetCreeParam from . import browser from . import readercata -DictExtensions= {"MAP" : ".map", "TELEMAC" : '.comm'} +DictExtensions= {"MAP" : ".map", "TELEMAC" : '.cas'} @@ -194,6 +194,7 @@ class JDCEditor(Ui_baseWidget,QWidget): if jdc==None : try : self.jdc = self.readFile(self.fichier) + if self.salome : self.appliEficas.addJdcInSalome( self.fichier) except : print ("mauvaise lecture") else : @@ -1076,7 +1077,7 @@ class JDCEditor(Ui_baseWidget,QWidget): def determineNomFichier(self,path,extension): #-----------------------------------------------------# if self.appli.code in DictExtensions: - chaine1="JDC (*"+DictExtensions[self.appli.code]+");;" + chaine1=DictExtensions[self.appli.code]+" (*."+DictExtensions[self.appli.code]+");;" extensions= tr(chaine1+ "All Files (*)") else : extensions= tr("JDC (*.comm);;" "All Files (*)") diff --git a/InterfaceQT4/qtEficas.py b/InterfaceQT4/qtEficas.py index 21b86ef9..3d6263b6 100755 --- a/InterfaceQT4/qtEficas.py +++ b/InterfaceQT4/qtEficas.py @@ -48,7 +48,7 @@ class Appli(Ui_Eficas,QMainWindow): """ Class implementing the main user interface. """ - def __init__(self,code=None,salome=1,parent=None,ssCode=None,multi=False,langue='ang',ssIhm=False): + def __init__(self,code=None,salome=1,parent=None,ssCode=None,multi=False,langue='fr',ssIhm=False): """ Constructor """ @@ -77,8 +77,6 @@ class Appli(Ui_Eficas,QMainWindow): self.listeCode=['Adao','ADAO','Carmel3D','Telemac','CF','MAP','ZCracks', 'SEP','SPECA','PSEN_Eficas','PSEN_N1'] self.repIcon=os.path.join( os.path.dirname(os.path.abspath(__file__)),'..','Editeur','icons') - if langue=='fr': self.langue=langue - else : self.langue="ang" if self.salome: import Accas @@ -91,6 +89,8 @@ class Appli(Ui_Eficas,QMainWindow): self.multi=multi self.demande=multi # specifique PSEN + if langue=='fr': self.langue=langue + else : self.langue="ang" if self.multi == False : self.definitCode(code,ssCode) @@ -98,7 +98,6 @@ class Appli(Ui_Eficas,QMainWindow): - if not self.salome and hasattr (self, 'CONFIGURATION') and hasattr(self.CONFIGURATION,'lang') : langue=self.CONFIGURATION.lang self.suiteTelemac=False @@ -110,12 +109,11 @@ class Appli(Ui_Eficas,QMainWindow): self.suiteTelemac=self.CONFIGURATION.suiteTelemac + if not self.salome and hasattr (self, 'CONFIGURATION') and hasattr(self.CONFIGURATION,'lang') : self.langue=self.CONFIGURATION.lang from Extensions import localisation app=QApplication if hasattr (self, 'CONFIGURATION') : localisation.localise(None,self.langue,translatorFichier=self.CONFIGURATION.translatorFichier) - - self.setupUi(self) #if parent != None : self.parentCentralWidget = parent.centralWidget() #else : self.parentCentralWidget = None @@ -194,9 +192,10 @@ class Appli(Ui_Eficas,QMainWindow): self.CONFIGStyle = None if hasattr(configuration,'make_config_style'): self.CONFIGStyle = configuration.make_config_style(self,prefsCode.repIni) - from Extensions import localisation - app=QApplication - if hasattr (self, 'CONFIGURATION') : localisation.localise(None,self.langue,translatorFichier=self.CONFIGURATION.translatorFichier) + # + #from Extensions import localisation + #app=QApplication + #if hasattr (self, 'CONFIGURATION') : localisation.localise(None,self.langue,translatorFichier=self.CONFIGURATION.translatorFichier) #PN --> pb d exception qui font planter salome # plus supporte en python 3 #if hasattr(prefsCode,'encoding'): diff --git a/InterfaceQT4/viewManager.py b/InterfaceQT4/viewManager.py index e75c8a9b..85459d8c 100644 --- a/InterfaceQT4/viewManager.py +++ b/InterfaceQT4/viewManager.py @@ -67,6 +67,7 @@ class MyTabview(object): if self.appliEficas.code in DictExtensions: chaine="JDC (*"+DictExtensions[self.appliEficas.code]+");;" extensions=tr(chaine+ "All Files (*)") + elif self.appliEficas.code== "TELEMAC" : extensions=tr('CAS (*.cas);;All Files (*)') else : extensions=tr('Fichiers JDC (*.comm);;''Tous les Fichiers (*)') diff --git a/convert/convert_TELEMAC.py b/convert/convert_TELEMAC.py index ac524184..b5330f4b 100644 --- a/convert/convert_TELEMAC.py +++ b/convert/convert_TELEMAC.py @@ -102,7 +102,7 @@ class TELEMACParser(PythonParser): self.Ordre_Des_Commandes=appli.readercata.Ordre_Des_Commandes if appli.langue=='fr' : - from enum_Telemac2d_into import DicoEnumCasFrToEnumCasEn + from enum_Telemac2d_auto import DicoEnumCasFrToEnumCasEn for k in DicoEnumCasFrToEnumCasEn : TelemacdicoEn[k]=DicoEnumCasFrToEnumCasEn[k] @@ -333,7 +333,7 @@ class TELEMACParser(PythonParser): print (nom) def convertSIMP(self,obj,nom,valeur): - #print 'in convertSIMP', nom,valeur + #print ('in convertSIMP', nom,valeur) #if nom in ("PRESCRIBED_FLOWRATES", "PRESCRIBED_VELOCITIES", "PRESCRIBED_ELEVATIONS" ): return if obj.max==1 : if hasattr(obj.type[0],'ntuple') : diff --git a/generator/generator_TELEMAC.py b/generator/generator_TELEMAC.py index 2ad9f845..b5758f5d 100644 --- a/generator/generator_TELEMAC.py +++ b/generator/generator_TELEMAC.py @@ -32,19 +32,6 @@ from Extensions.i18n import tr from .generator_python import PythonGenerator extensions=('.comm',) -#if 1: -try : - from enum_Telemac2d_auto import TelemacdicoEn - DicoEnumCasEnInverse={} - for motClef in TelemacdicoEn: - d={} - for valTelemac in TelemacdicoEn[motClef]: - valEficas= TelemacdicoEn[motClef][valTelemac] - d[valEficas]=valTelemac - DicoEnumCasEnInverse[motClef]=d - -except : - pass @@ -75,6 +62,27 @@ class TELEMACGenerator(PythonGenerator): self.statut=statut self.langue=appli.langue + if self.langue == 'fr' : + from enum_Telemac2d_auto import DicoEnumCasFrToEnumCasEn + self.DicoEnumCasEnInverse={} + for motClef in DicoEnumCasFrToEnumCasEn: + d={} + for valTelemac in DicoEnumCasFrToEnumCasEn[motClef]: + valEficas= DicoEnumCasFrToEnumCasEn[motClef][valTelemac] + d[valEficas]=valTelemac + self.DicoEnumCasEnInverse[motClef]=d + else : + try : + from enum_Telemac2d_auto import TelemacdicoEn + self.DicoEnumCasEnInverse={} + for motClef in TelemacdicoEn: + d={} + for valTelemac in TelemacdicoEn[motClef]: + valEficas= TelemacdicoEn[motClef][valTelemac] + d[valEficas]=valTelemac + self.DicoEnumCasEnInverse[motClef]=d + except : + pass self.initDico() # Pour Simplifier les verifs d ecriture if hasattr(appli,'listeTelemac') : self.listeTelemac=appli.listeTelemac @@ -175,17 +183,17 @@ class TELEMACGenerator(PythonGenerator): sTelemac=s[0:-1] if not( type(obj.valeur) in (tuple,list) ): - if obj.nom in DicoEnumCasEnInverse: - try : sTelemac=str(DicoEnumCasEnInverse[obj.nom][obj.valeur]) + if obj.nom in self.DicoEnumCasEnInverse: + try : sTelemac=str(self.DicoEnumCasEnInverse[obj.nom][obj.valeur]) except : if obj.valeur==None : sTelemac=obj.valeur else : print(("generMCSIMP Pb valeur avec ", obj.nom, obj.valeur)) if type(obj.valeur) in (tuple,list) : - if obj.nom in DicoEnumCasEnInverse: + if obj.nom in self.DicoEnumCasEnInverse: #sT = "'" sT='' for v in obj.valeur: - try : sT +=str(DicoEnumCasEnInverse[obj.nom][v]) +";" + try : sT +=str(self.DicoEnumCasEnInverse[obj.nom][v]) +";" except : if obj.definition.intoSug != [] : sT +=str(v) + ";" else : print(("generMCSIMP Pb Tuple avec ", obj.nom, v, obj.valeur)) @@ -328,11 +336,11 @@ class TELEMACGenerator(PythonGenerator): if c.nom[0:18] == 'Type_Of_Advection_' and c.valeur!=None: suf=c.nom[18:] index=dicoSuf[suf] - listeAdvection[index]=DicoEnumCasEnInverse['Type_Of_Advection'][c.valeur] + listeAdvection[index]=self.DicoEnumCasEnInverse['Type_Of_Advection'][c.valeur] if c.nom[0:13] == 'Supg_Option_' and c.valeur!=None: suf=c.nom[13:] index=dicoSuf[suf] - listeAdvection[index]=DicoEnumCasEnInverse['Supg_Option'][c.valeur] + listeAdvection[index]=self.DicoEnumCasEnInverse['Supg_Option'][c.valeur] if c.nom[0:23] == 'Upwind_Coefficients_Of_' and c.valeur!=None: suf=c.nom[23:] index=dicoSuf[suf] -- 2.39.2