From: Pascale Noyret Date: Fri, 17 Sep 2010 12:34:09 +0000 (+0000) Subject: *** empty log message *** X-Git-Tag: V2_0~1 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=97d44f552a33e132c24053084567925724c7744d;p=modules%2Feficas.git *** empty log message *** --- diff --git a/InterfaceQT4/configuration.py b/InterfaceQT4/configuration.py new file mode 100644 index 00000000..f3fa8096 --- /dev/null +++ b/InterfaceQT4/configuration.py @@ -0,0 +1,162 @@ +# -*- coding: utf-8 -*- +# CONFIGURATION MANAGEMENT OF EDF VERSION +# ====================================================================== +# COPYRIGHT (C) 1991 - 2002 EDF R&D WWW.CODE-ASTER.ORG +# THIS PROGRAM IS FREE SOFTWARE; YOU CAN REDISTRIBUTE IT AND/OR MODIFY +# IT UNDER THE TERMS OF THE GNU GENERAL PUBLIC LICENSE AS PUBLISHED BY +# THE FREE SOFTWARE FOUNDATION; EITHER VERSION 2 OF THE LICENSE, OR +# (AT YOUR OPTION) ANY LATER VERSION. +# +# THIS PROGRAM 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 +# GENERAL PUBLIC LICENSE FOR MORE DETAILS. +# +# YOU SHOULD HAVE RECEIVED A COPY OF THE GNU GENERAL PUBLIC LICENSE +# ALONG WITH THIS PROGRAM; IF NOT, WRITE TO EDF R&D CODE_ASTER, +# 1 AVENUE DU GENERAL DE GAULLE, 92141 CLAMART CEDEX, FRANCE. +# +# +# ====================================================================== +""" + Ce module sert pour charger les paramètres de configuration d'EFICAS +""" +# Modules Python +import os, sys, string, types, re +import traceback +from PyQt4.QtGui import * +from utils import read_file + +# Modules Eficas +from Editeur import utils + +class CONFIG_BASE: + + #-------------------------------------- + def __init__(self,appli,repIni,nomDir): + #-------------------------------------- + + # Classe de base permettant de lire, afficher + # et sauvegarder les fichiers utilisateurs + # On a deux directories : la directory generale (Repertoire d instal + Nom du code + # Par exemple : ~/Install_Eficas/EficasV1_14/Openturns_Wrapper + # et la directorie de l utilisateur + # HOME/.Eficas_Openturns + # Le fichier prefs.py va etre lu dans la directory generale puis surcharge eventuellement + # par celui de l utilisateur + # le fichier de catalogue va etre lu dans la directory de l utilisateur s il exite + # dans le fichier general sinon + self.appli = appli + self.code = appli.code + self.salome = appli.salome + self.repIni = repIni + self.REPINI = repIni + self.rep_user = os.path.join(os.environ['HOME'],nomDir) + + if self.appli: + self.parent=appli.top + self.appli.mode_nouv_commande='initial' + else: self.parent=None + + + + def setValeurs(self): + #--------------------- + + # Valeurs par defaut + if not os.path.isdir(self.rep_user) : os.mkdir(self.rep_user) + self.initialdir = self.rep_user + self.path_doc = self.rep_user + self.savedir = self.rep_user + self.exec_acrobat = self.rep_user + + #Lecture des fichiers utilisateurs + self.lecture_fichier_ini_standard() + self.lecture_fichier_ini_utilisateur() + self.lecture_catalogues() + + #-------------------------------------- + def lecture_fichier_ini_standard(self): + #-------------------------------------- + # Verifie l'existence du fichier "standard" + # appelle la lecture de ce fichier + import prefs + name='prefs_'+prefs.code + prefsCode=__import__(name) + self.prefsUser=name+".py" + for k in self.labels_eficas : + try : + valeur=getattr(prefsCode,k) + setattr(self,k,valeur) + except : + pass + if hasattr(self,'map_path') : + oldPath=self.map_path + + + #-------------------------------------- + def lecture_fichier_ini_utilisateur(self): + #-------------------------------------- + # Surcharge les paramètres standards par les paramètres utilisateur s'ils existent + self.fic_ini_utilisateur = os.path.join(self.rep_user,self.prefsUser) + if not os.path.isfile(self.fic_ini_utilisateur): return + + txt = utils.read_file(self.fic_ini_utilisateur) + from styles import style + d=locals() + try: + exec txt in d + except : + l=traceback.format_exception(sys.exc_info()[0],sys.exc_info()[1],sys.exc_info()[2]) + QMessageBox.critical( None, "Import du fichier de Configuration", + "Erreur à la lecture du fichier de configuration " + self.fic_ini_utilisateur ) + sys.exit(0) + for k in self.labels_user : + try : + setattr(self,k,d[k]) + except : + pass + + + #-------------------------------------- + def lecture_catalogues(self): + #-------------------------------------- + rep_mat=" " # Compatibilite Aster + if hasattr(self,"catalogues") : return + + fic_ini = os.path.join(self.repIni,self.cataFile) + if not os.path.isfile(fic_ini) : + QMessageBox.critical( None, "Erreur a l'import du fichier des Catalogues", + "Le fichier de configuration des catalogues "+fic_ini+" n a pas été trouvé" ) + sys.exit(0) + + txt = utils.read_file(fic_ini) + d=locals() + try: + exec txt in d + self.catalogues=d["catalogues"] + except : + l=traceback.format_exception(sys.exc_info()[0],sys.exc_info()[1],sys.exc_info()[2]) + QMessageBox.critical( None, "Import du fichier de Configuration", + "Erreur à la lecture du fichier de configuration " + fic_ini ) + sys.exit(0) + + + + #-------------------------------------- + def save_params(self): + #-------------------------------------- + # sauvegarde + # les nouveaux paramètres dans le fichier de configuration utilisateur + # + texte="" + for clef in self.labels_user : + if hasattr(self,clef): + valeur=getattr(self,clef) + texte= texte + clef+" = " + repr(valeur) +"\n" + f=open(self.fic_ini_utilisateur,'w+') + print self.fic_ini_utilisateur + f.write(texte) + f.close() +# + diff --git a/InterfaceQT4/editor.py b/InterfaceQT4/editor.py index 13081f49..e1351b90 100644 --- a/InterfaceQT4/editor.py +++ b/InterfaceQT4/editor.py @@ -529,19 +529,16 @@ class JDCEditor(QSplitter): else: return self.textePython - #-----------------------------# - def runYACS(self,execution="oui"): - #-----------------------------# + #------------------------------------------------# + def runYACS(self,execution="oui",nomFichier=None): + #------------------------------------------------# format=self.appliEficas.format_fichier - self.textePython="" if generator.plugins.has_key(format): # Le generateur existe on l'utilise self.generator=generator.plugins[format]() - self.textePython =self.generator.generRUNYACS(self.jdc,format='beautifie',config=self.appliEficas.CONFIGURATION) + self.generator.generRUNYACS(self.jdc,format='beautifie',config=self.appliEficas.CONFIGURATION,nomFichier=nomFichier) if execution=="oui" : print "il faut faire le run dans Salome" - else: - return self.textePython #-----------------------------# def saveRun(self): @@ -570,11 +567,10 @@ class JDCEditor(QSplitter): #-----------------------------# def saveYACS(self): #-----------------------------# - texte=self.runYACS(execution="non") path=self.CONFIGURATION.savedir fn = QFileDialog.getSaveFileName( self, self.trUtf8("sauvegarde"), path, - self.trUtf8("JDC (*.py);;" "All Files (*)"),None, + self.trUtf8("JDC (*.xml);;" "All Files (*)"),None, QFileDialog.DontConfirmOverwrite) if fn.isNull(): return ext = QFileInfo(fn).suffix() @@ -587,15 +583,16 @@ class JDCEditor(QSplitter): self.trUtf8("&Ecraser"), self.trUtf8("&Abandonner")) if abort == 1 : return - fn = unicode(QDir.convertSeparators(fn)) - self.writeFile( fn, txt = texte) + + texte=self.runYACS(execution="non",nomFichier=fn) + #self.writeFile( fn, txt = texte) - #-----------------------------------------#e + #-----------------------------------------# def cherche_Groupes(self): + #-----------------------------------------# listeMA,listeNO=self.get_text_JDC("GroupMA") return listeMA,listeNO - #-----------------------------------------# #-----------------------------------------# def saveFile(self, path = None, saveas= 0): @@ -662,38 +659,30 @@ class JDCEditor(QSplitter): self.tree.racine.item.getObject().nom=os.path.basename(newName) self.tree.racine.update_node_label() - try : - fileXML = fn[:fn.rfind(".")] + '.xml' - self.generator.writeOpenturnsXML( fileXML ) - except : - pass + if self.jdc.isvalid() != 0 : + try : + fileXML = fn[:fn.rfind(".")] + '.xml' + self.generator.writeOpenturnsXML( fileXML ) + except : + pass - try : - fileSTD = fn[:fn.rfind(".")] + '.py' - self.generator.writeOpenturnsSTD( fileSTD ) - except : - pass - - try: - self.generator.writeDefault(fn) - except: - pass - - try : - fileCuve2DG = fn[:fn.rfind(".")] + '.don' - self.generator.writeCuve2DG(fileCuve2DG) - except : - pass - - #try : - # self.tubePy=self.generator.getTubePy() - # fileTube = fn[:fn.rfind(".")] + '.py' - # if self.tubePy != '' : - # f=open(fileTube,'w') - # f.write(self.tubePy) - # f.close() - #except : - # pass + try : + fileSTD = fn[:fn.rfind(".")] + '.py' + self.generator.writeOpenturnsSTD( fileSTD ) + except : + pass + + try: + self.generator.writeDefault(fn) + except: + pass + + try : + fileCuve2DG = fn[:fn.rfind(".")] + '.don' + self.generator.writeCuve2DG(fileCuve2DG) + except : + pass + if self.salome : self.appliEficas.addJdcInSalome( self.fichier) diff --git a/InterfaceQT4/monChoixMap.py b/InterfaceQT4/monChoixMap.py index 701f06f1..c0d12fb5 100644 --- a/InterfaceQT4/monChoixMap.py +++ b/InterfaceQT4/monChoixMap.py @@ -73,13 +73,14 @@ class MonChoixMap(Ui_ChoixMap,QtGui.QDialog): à l'utilisateur de choisir une seule valeur parmi une liste de valeurs discrètes """ - def __init__(self, choixCata,name = None,fl = 0): - QtGui.QDialog.__init__(self) + def __init__(self, choixCata,parentQT=None,parentAppli=None): + QtGui.QDialog.__init__(self,parentQT) self.setMinimumSize(50, 50); self.setModal(True) self.setupUi(self) self.ajouteCeQuilFaut() self.choixCata=choixCata + self.parentAppli=parentAppli def ajouteCeQuilFaut(self) : @@ -121,6 +122,9 @@ class MonChoixMap(Ui_ChoixMap,QtGui.QDialog): schema=str(self.groupScheme.checkedButton().text()) self.choixCata.schema=schema nomCata= dico[self.module][schema] - self.choixCata.nom=nomCata + if self.parentAppli==None : + self.choixCata.nom=nomCata + else : + self.parentAppli.ssCode=nomCata self.close(); diff --git a/InterfaceQT4/monOptions_MAP.py b/InterfaceQT4/monOptions_MAP.py new file mode 100644 index 00000000..2dc9e49c --- /dev/null +++ b/InterfaceQT4/monOptions_MAP.py @@ -0,0 +1,259 @@ +# -*- coding: utf-8 -*- + +import os, re, sys + +from PyQt4.QtGui import * +from PyQt4.QtCore import * + +from OptionsMAP import Ui_desOptions + + +class desOptions(Ui_desOptions,QDialog): + def __init__(self,parent ,modal ) : + QDialog.__init__(self,parent) + self.setupUi(self) + self.setModal(modal) + +class Options(desOptions): + def __init__(self,parent = None,modal = 0,configuration=None): + desOptions.__init__(self,parent,modal) + self.configuration=configuration + self.viewMan=parent + self.dVersion={} + self.dRepCat={} + self.connecterSignaux() + self.initAll() + + def connecterSignaux(self) : + self.connect(self.CBVersions,SIGNAL("activated(int)"),self.VersionChoisie) + self.connect(self.Bdefaut,SIGNAL("clicked()"),self.BdefautChecked) + self.connect(self.LEVersionAjout,SIGNAL("returnPressed()"),self.AjoutVersion) + self.connect(self.PBajout,SIGNAL("clicked()"),self.AjoutVersion) + self.connect(self.LEVersionSup,SIGNAL("returnPressed()"),self.SupVersion) + self.connect(self.PBSup,SIGNAL("clicked()"),self.SupVersion) + self.connect(self.LERepDoc,SIGNAL("returnPressed()"),self.ChangePathDoc) + self.connect(self.LERepOT,SIGNAL("returnPressed()"),self.ChangePathOT) + self.connect(self.LERepMAP,SIGNAL("returnPressed()"),self.ChangePathMAP) + self.connect(self.LERepAster,SIGNAL("returnPressed()"),self.ChangePathAster) + self.connect(self.LERepCata,SIGNAL("returnPressed()"),self.BokClicked) + self.connect(self.LESaveDir,SIGNAL("returnPressed()"),self.ChangeSaveDir) + self.connect(self.Bok,SIGNAL("clicked()"),self.BokClicked) + self.connect(self.PBQuit,SIGNAL("clicked()"),self.close) + + + def initAll(self): + self.CBVersions.clear() + for item in self.configuration.catalogues : + (code,ssCode,cata,formatOut,formatIn)=item + self.dVersion[ssCode]=(item) + self.dRepCat[ssCode]=str(cata) + self.CBVersions.addItem(QString(ssCode)) + self.LERepCata.setText(self.dRepCat[str(self.CBVersions.currentText())]) + + if hasattr(self.configuration,"path_doc"): + self.LERepDoc.setText(self.configuration.path_doc) + if hasattr(self.configuration,"OpenTURNS_path"): + self.LERepOT.setText(self.configuration.OpenTURNS_path) + if hasattr(self.configuration,"savedir"): + self.LESaveDir.setText(self.configuration.savedir) + if hasattr(self.configuration,"PATH_MAP"): + self.LERepMAP.setText(self.configuration.PATH_MAP) + if hasattr(self.configuration,"PATH_ASTER"): + self.LERepAster.setText(self.configuration.PATH_ASTER) + + def ChangePathMAP(self): + if self.LERepMAP.text()=="" : return + if not os.path.isdir(self.LERepMAP.text()) : + res = QMessageBox.warning( None, + self.trUtf8("Repertoire MAP "), + self.trUtf8("Le Repertoire n existe pas."), + self.trUtf8("&Ok"), + self.trUtf8("&Abandonner")) + if res == 1 : + if hasattr(self.configuration,"PATH_MAP"): + self.LERepAster.setText(self.configuration.PATH_MAP) + return + self.configuration.PATH_MAP=str(self.LERepMAP.text()) + self.configuration.PATH_PYGMEE=self.configuration.PATH_MAP+"/components/pygmee_v1" + self.configuration.PATH_BENHUR=self.configuration.PATH_MAP+"/components/benhur" + self.configuration.PATH_FDVGRID=self.configuration.PATH_MAP+"components/fdvgrid/ther2d/bin" + self.configuration.PATH_MODULE=self.configuration.PATH_MODULE+"components/fdvgrid/ther2d/bin" + self.configuration.save_params() + + def VersionChoisie(self): + version=str(self.CBVersions.currentText()) + pass + + def ChangePathAster(self): + if self.LERepAster.text()=="" : return + if not os.path.isdir(self.LERepAster.text()) : + res = QMessageBox.warning( None, + self.trUtf8("Repertoire Aster "), + self.trUtf8("Le Repertoire n existe pas."), + self.trUtf8("&Ok"), + self.trUtf8("&Abandonner")) + if res == 1 : + if hasattr(self.configuration,"PATH_ASTER"): + self.LERepAster.setText(self.configuration.PATH_ASTER) + return + self.configuration.PATH_ASTER=str(self.LERepAster.text()) + self.configuration.save_params() + + def VersionChoisie(self): + version=str(self.CBVersions.currentText()) + if self.dRepCat.has_key(version): + self.LERepCata.setText(self.dRepCat[version]) + + def BokClicked(self): + version=str(self.CBVersions.currentText()) + if self.LERepCata.text() == "" : + QMessageBox.critical( self, "Champ non rempli","Le champ Catalogue doit etre rempli" ) + return + if not os.path.isfile(self.LERepCata.text()) : + res = QMessageBox.warning( None, + self.trUtf8("Fichier Catalogue "), + self.trUtf8("Le Fichier n existe pas. Voulez-vous supprimer cette version ?"), + self.trUtf8("&Oui"), + self.trUtf8("&Non")) + if res == 0 : + self.LEVersionSup.setText(version) + self.SupVersion() + return + + self.dRepCat[version]=str(self.LERepCata.text()) + if version in self.dVersion.keys(): + item=list(self.dVersion[version]) + item[2]=self.dRepCat[version] + self.dVersion[version]=tuple(item) + else : + import prefs + code=prefs.code + self.dVersion[version]=(code,version,self.dRepCat[version],code.lower()) + + lItem=[] + for version in self.dVersion.keys() : + lItem.append(self.dVersion[version]) + self.configuration.catalogues=lItem + self.configuration.save_params() + + def AjoutVersion(self): + version=self.LEVersionAjout.text() + if str(version) == "" : return + self.CBVersions.addItem(version) + self.LERepCata.setText("") + self.LEVersionAjout.setText("") + self.CBVersions.setCurrentIndex(self.CBVersions.count()-1) + + def SupVersion(self): + version=str(self.LEVersionSup.text()) + if version == "" : return + i =0 + while i < self.CBVersions.count() : + if self.CBVersions.itemText(i) == version : + self.CBVersions.removeItem(i) + break + i=i+1 + try : + del self.dVersion[version] + del self.dRepCat[version] + except : + self.LEVersionSup.setText("") + try : + self.CBVersions.setCurrentIndex(self.CBVersions.count()-1) + self.VersionChoisie() + except : + pass + return + codeSansPoint=re.sub("\.","",version) + chaine="rep_mat_"+codeSansPoint + if hasattr(self.configuration,chaine): + delattr(self.configuration,chaine) + self.LEVersionSup.setText("") + + lItem=[] + for version in self.dVersion.keys() : + lItem.append(self.dVersion[version]) + self.LERepCata.setText("") + self.configuration.catalogues=lItem + self.configuration.save_params() + self.CBVersions.setCurrentIndex(0) + self.VersionChoisie() + + + def BdefautChecked(self): + res = QMessageBox.warning( None, + self.trUtf8("Restauration des parametres par defaut "), + self.trUtf8("Votre fichier editeur sera ecrase."), + self.trUtf8("&Ok"), + self.trUtf8("&Abandonner")) + self.Bdefaut.setCheckState(Qt.Unchecked) + if res == 1 : return + + appli=self.configuration.appli + fic_ini_util=self.configuration.fic_ini_utilisateur + old_fic_ini_util=fic_ini_util+"_old" + commande="mv "+fic_ini_util+" "+old_fic_ini_util + os.system(commande) + import prefs + name='prefs_'+prefs.code + prefsCode=__import__(name) + repIni=prefsCode.REPINI + nameConf='configuration_'+prefs.code + configuration=__import__(nameConf) + + configNew=configuration.CONFIG(appli,repIni) + self.configuration=configNew + appli.CONFIGURATION=configNew + self.configuration.save_params() + self.dVersion={} + self.dRepCat={} + self.initAll() + + def ChangePathDoc(self): + if self.LERepDoc.text()=="" : return + if not os.path.isdir(self.LERepDoc.text()) : + res = QMessageBox.warning( None, + self.trUtf8("Repertoire de Documentation "), + self.trUtf8("Le Repertoire n existe pas."), + self.trUtf8("&Ok"), + self.trUtf8("&Abandonner")) + if res == 1 : + if hasattr(self.configuration,"path_doc"): + self.LERepDoc.setText(self.configuration.path_doc) + return + + self.configuration.path_doc=str(self.LERepDoc.text()) + self.configuration.save_params() + + def ChangePathOT(self): + if not os.path.isdir(self.LERepOT.text()) : + res = QMessageBox.warning( None, + self.trUtf8("Repertoire Open TURNS "), + self.trUtf8("Le Repertoire n existe pas."), + self.trUtf8("&Ok"), + self.trUtf8("&Abandonner")) + if res == 1 : + if hasattr(self.configuration,"OpenTURNS_path"): + self.LERepOT.setText(self.configuration.OpenTURNS_path) + return + + if hasattr(self.configuration,"OpenTURNS_path"): + sys.path.remove(self.configuration.OpenTURNS_path) + self.configuration.OpenTURNS_path=str(self.LERepOT.text()) + self.configuration.save_params() + if self.configuration.OpenTURNS_path == "" : return + sys.path[:0]=[self.configuration.OpenTURNS_path] + + def ChangeSaveDir(self): + if not os.path.isdir(self.LESaveDir.text()) : + res = QMessageBox.warning( None, + self.trUtf8("Repertoire Open TURNS "), + self.trUtf8("Le Repertoire n existe pas."), + self.trUtf8("&Ok"), + self.trUtf8("&Abandonner")) + if res == 1 : + if hasattr(self.configuration,"savedir"): + self.LESaveDir.setText(self.configuration.savedir) + self.configuration.savedir=str(self.LESaveDir.text()) + self.configuration.save_params() + diff --git a/InterfaceQT4/qtEficas.py b/InterfaceQT4/qtEficas.py index 2ff1ab16..e25b0626 100644 --- a/InterfaceQT4/qtEficas.py +++ b/InterfaceQT4/qtEficas.py @@ -31,7 +31,6 @@ class Appli(Ui_Eficas,QMainWindow): self.dict_reels={} import prefs - #print prefs prefs.code=code name='prefs_'+prefs.code prefsCode=__import__(name) diff --git a/InterfaceQT4/viewManager.py b/InterfaceQT4/viewManager.py index 9f1926a7..4ab1b299 100644 --- a/InterfaceQT4/viewManager.py +++ b/InterfaceQT4/viewManager.py @@ -153,6 +153,9 @@ class MyTabview: def saveCurrentEditor(self): index=self.myQtab.currentIndex() if index < 0 : return + print self + print index + print self.dict_editors editor=self.dict_editors[index] if editor in self.doubles.keys() : QMessageBox.warning( diff --git a/MAP/configuration_MAP.py b/MAP/configuration_MAP.py index eb6a0bdc..e7bba405 100644 --- a/MAP/configuration_MAP.py +++ b/MAP/configuration_MAP.py @@ -39,12 +39,12 @@ class CONFIG(configuration.CONFIG_BASE): self.labels_user=['exec_acrobat', 'catalogues','savedir','path_doc','map_path'] self.labels_user=self.labels_user+['PATH_PYGMEE','PATH_BENHUR','PATH_ASTER','PATH_MODULE'] - self.labels_user=self.labels_user+['PATH_STUDY','NAME_SCHEME','PATH_FDVGRID','PATH_MAP','OpenTURNS_path'] + self.labels_user=self.labels_user+['PATH_STUDY','NAME_SCHEME','PATH_FDVGRID','PATH_MAP','OpenTURNS_path','PATH_GMSH'] self.labels_eficas=["map_path","rep_user","INSTALLDIR","path_doc","exec_acrobat"] self.labels_eficas=self.labels_eficas+["rep_cata","initialdir","savedir","catalogues",'PATH_PYGMEE'] self.labels_eficas=self.labels_eficas+['PATH_BENHUR','PATH_ASTER','PATH_MODULE','PATH_STUDY'] - self.labels_eficas=self.labels_eficas+['NAME_SCHEME','PATH_FDVGRID','PATH_MAP','OpenTURNS_path'] + self.labels_eficas=self.labels_eficas+['NAME_SCHEME','PATH_FDVGRID','PATH_MAP','OpenTURNS_path','PATH_GMSH'] self.cataFile="catalogues_MAP.ini" self.setValeurs() diff --git a/MAP/prefs_MAP.py b/MAP/prefs_MAP.py index 87152687..f864b1ff 100644 --- a/MAP/prefs_MAP.py +++ b/MAP/prefs_MAP.py @@ -38,6 +38,7 @@ PATH_FDVGRID=PATH_MAP+"components/fdvgrid/ther2d/bin" PATH_MODULE=PATH_MAP+"/modules/polymers" PATH_STUDY=PATH_MAP+"/studies/demonstrateur_poly_st1" PATH_ASTER="/local/noyret/bin/Aster10/bin" +PATH_GMSH="/usr/bin" # Codage des strings qui accepte les accents (en remplacement de 'ascii') diff --git a/MAP/qtEficas_map.py b/MAP/qtEficas_map.py index f835ec33..debec22c 100755 --- a/MAP/qtEficas_map.py +++ b/MAP/qtEficas_map.py @@ -64,6 +64,5 @@ else : #MonChoixCata.nom=cata #permet de choisir le module -print MonChoixCata.nom eficas_go.lance_eficas(code=prefs.code,ssCode=MonChoixCata.nom) #eficas_go.lance_eficas(code=prefs.code,choix="non") diff --git a/MAP/s_poly_st_1_V1.py b/MAP/s_poly_st_1_V1.py index e11339dc..660d1c56 100644 --- a/MAP/s_poly_st_1_V1.py +++ b/MAP/s_poly_st_1_V1.py @@ -27,8 +27,13 @@ class Tuple: #CONTEXT.debug = 1 JdC = JDC_CATA ( code = 'MAP', execmodul = None, - regles=(AU_MOINS_UN('PYGMEE',),AU_MOINS_UN('BENHUR',), AVANT ('PYGMEE' , 'BENHUR'),), - )# Fin JDC_CATA + regles=(AU_MOINS_UN('PYGMEE',), + AU_MOINS_UN('BENHUR',), + AVANT ('PYGMEE' , 'BENHUR'), + AVANT('ASTER','GMSH'), + EXCLUS('ASTER','FDVGRID'), + ), + )# Fin JDC_CATA # PYGMEE= PROC(nom="PYGMEE",op=None, diff --git a/Openturns_Study/OpenTURNS_Cata_Study_V10.py b/Openturns_Study/OpenTURNS_Cata_Study_V10.py new file mode 100644 index 00000000..f53ee908 --- /dev/null +++ b/Openturns_Study/OpenTURNS_Cata_Study_V10.py @@ -0,0 +1,60 @@ +# -*- coding: utf-8 -*- + +# -------------------------------------------------- +# debut entete +# -------------------------------------------------- + +import Accas +from Accas import * + +class loi ( ASSD ) : pass +class variable ( ASSD ) : pass + + +#CONTEXT.debug = 1 +JdC = JDC_CATA ( code = 'OPENTURNS_STUDY', + execmodul = None, + regles = ( AU_MOINS_UN ( 'CRITERIA' ), ), + ) # Fin JDC_CATA + +# -------------------------------------------------- +# fin entete +# -------------------------------------------------- +#=============================== +# 5. Definition des parametres +#=============================== +VARI = OPER ( nom = "VARI", + sd_prod = variable, + op = None, + fr = "Definitions des lois marginales utilisees par les variables d'entree", + type=SIMP(statut='f',defaut="IN",into=("IN","OUT"), typ = "TXM",) + ) + +VARI1 = OPER ( nom = "VARI1", + sd_prod = variable, + op = None, + fr = "Definitions des lois marginales utilisees par les variables d'entree", + + POUTRE = FACT(statut= 'f',max= '**', + MAILLE = SIMP(statut= 'f',typ= 'TXM' ,validators= NoRepeat(),max= '**'), + GROUP_MA = SIMP(statut= 'f',typ= 'TXM' ,validators= NoRepeat(),max= '**'), + ), + POUTRE2 = FACT(statut= 'f',max= '**', + MAILLE2 = SIMP(statut= 'f',typ= 'TXM' ,validators= NoRepeat(),max= '**'), + GROUP_MA2 = SIMP(statut= 'f',typ= 'TXM' ,validators= NoRepeat(),max= '**'), + ), + FINAL =FACT(statut= 'f',max= '**', + type=SIMP(statut='f',min=1,max= '**', into=("POUTRE","POUTRE2"), + validators=[VerifExiste(2),NoRepeat()], typ="TXM",), + ), + ) + + +FICXML=MACRO(nom="FICXML", + op=None, + UIinfo={"groupes":("Gestion du travail",)}, + fr="Débranchement vers un fichier de commandes secondaires", + sd_prod=loi, + FICHIER = SIMP(statut='o',typ='TXM',), +); + diff --git a/generator/generator_map.py b/generator/generator_map.py index 3853ead3..9835fe77 100644 --- a/generator/generator_map.py +++ b/generator/generator_map.py @@ -85,7 +85,7 @@ class MapGenerator(PythonGenerator): return self.texteExecution - def generRUNYACS(self,obj,format='brut',config=None): + def generRUNYACS(self,obj,format='brut',config=None,nomFichier=None): self.initialise(config) text=PythonGenerator.gener(self,obj,format) import sys @@ -102,8 +102,7 @@ class MapGenerator(PythonGenerator): if hasattr(self.monSchema, codeYACS): fct=getattr(self.monSchema, codeYACS) fct(self.proc,dico) - self.monSchema.write_yacs_proc(self.proc,"/tmp/toto.xml") - return "/tmp/toto.xml" + self.monSchema.write_yacs_proc(self.proc,str(nomFichier)) def generePythonMap(self,execution) : ''' diff --git a/generator/generator_s_poly_st_1.py b/generator/generator_s_poly_st_1.py index 1c831626..81abff11 100644 --- a/generator/generator_s_poly_st_1.py +++ b/generator/generator_s_poly_st_1.py @@ -31,7 +31,7 @@ from generator_map import MapGenerator #____________________________________________________________________________________ # Liste des mots cles de config remplaces dans les fichiers à trous # -CONFIGliste=('NAME_SCHEME', 'PATH_ASTER', 'PATH_BENHUR', 'PATH_MODULE', 'PATH_PYGMEE', 'PATH_STUDY', 'repIni', 'PATH_FDVGRID') +CONFIGliste=('NAME_SCHEME', 'PATH_ASTER', 'PATH_BENHUR', 'PATH_MODULE', 'PATH_PYGMEE', 'PATH_STUDY', 'repIni', 'PATH_FDVGRID' ,'PATH_GMSH') #_____________________________________________________________________ # Attention les variables suivantes sont nécessaires entre les codes : @@ -170,6 +170,7 @@ class s_poly_st_1Generator(MapGenerator): monFichierCommOutput=self.nom_racine+"s_poly_st_1_aster.comm" monFichierExportOutput=self.nom_racine+"s_poly_st_1_aster.export" + self.monFichierMSH=self.nom_racine+"/"+self.config.NAME_SCHEME+"_aster.resu.msh" monFichierCommInput=self.config.INSTALLDIR+"/MAP/Templates/"+self.ssRepertoire+"/s_poly_st_1_aster_template.comm" monFichierExportInput=self.config.INSTALLDIR+"/MAP/Templates/"+self.ssRepertoire+"/s_poly_st_1_aster_template.export" @@ -196,7 +197,7 @@ class s_poly_st_1Generator(MapGenerator): if ('_ASTER_LANCEMENT' in dicoAster.keys()) and dicoAster['_ASTER_LANCEMENT'] == 'oui': commande="cd "+self.config.PATH_MODULE+";" - commande=commande + self.config.PATH_ASTER + "/as_run "+monFichierExportOutput + commande=commande + self.config.PATH_ASTER + "bin/as_run "+monFichierExportOutput +";\n" return commande else: return "" @@ -219,12 +220,10 @@ class s_poly_st_1Generator(MapGenerator): def GMSH(self,execution) : dicoGmsh=self.dictMCVal["GMSH"] if ('_GMSH_LANCEMENT' in dicoGmsh.keys()) and dicoGmsh['_GMSH_LANCEMENT'] == 'oui': - commande="cd "+self.config.PATH_MODULE+";" - commande=commande + "gmsh "+self.config.PATH_MODULE+"/"+self.config.NAME_SCHEME+"/"+self.config.NAME_SCHEME+"_aster.resu.msh" - print commande - os.system(commande) + commande=self.config.PATH_GMSH+"/gmsh " + commande=commande + self.monFichierMSH+";\n" + return commande else: return "" - diff --git a/generator/monCreateYacs.py b/generator/monCreateYacs.py new file mode 100755 index 00000000..2d495d7f --- /dev/null +++ b/generator/monCreateYacs.py @@ -0,0 +1,98 @@ +#!/usr/bin/env python + +import pilot +import SALOMERuntime +import loader +import logging +import traceback +import os + +class CreeSchemaYacs : + def __init__(self,config): + print "dans le init de CreeSchemaYacs " + self.config=config + self.ssCode=config.appli.ssCode + self.setUp() + self.addCatalog() + self.nodeAvant=None + + def setUp(self): + SALOMERuntime.RuntimeSALOME_setRuntime() + self.runtime = pilot.getRuntime() + self.loader = loader.YACSLoader() + self.loader.registerProcCataLoader() + + def addCatalog(self): + try: + monCataFile= os.environ["EFICAS_ROOT_DIR"] + monCataFile=monCataFile+"/share/salome/resources/eficas/cata" + monCataFile=monCataFile+self.ssCode+".xml" + print monCataFile + self.monCata = self.runtime.loadCatalog("proc",monCataFile) + except: + logging.fatal("Exception in loading MAP catalog") + traceback.print_exc() + sys.exit(1) + + def createProc(self): + proc = self.runtime.createProc("proc") + proc.setTypeCode("pyobj", self.runtime.getTypeCode("pyobj")) + t_pyobj = proc.getTypeCode("pyobj") + t_string = proc.getTypeCode("string") + return proc + + def write_yacs_proc(self,proc, yacs_schema_filename): + proc.saveSchema(yacs_schema_filename) + +class s_poly_st_1(CreeSchemaYacs) : + + def BENHURYACS(self,proc,dico): + monFichierInput=self.config.PATH_BENHUR+"/BHR_files.txt" + factoryNode = self.monCata._nodeMap["benhur"] + self.benhurNode = factoryNode.cloneNode("benhur") + self.benhurNode.getInputPort("fileInput").edInitPy(monFichierInput) + self.benhurNode.getInputPort("pathBenhur").edInitPy(self.config.PATH_BENHUR) + proc.edAddChild(self.benhurNode) + if self.nodeAvant != None : + proc.edAddCFLink(self.nodeAvant,self.benhurNode) + self.nodeAvant=self.benhurNode + + def PYGMEEYACS(self,proc,dico): + monFichierInput=self.config.PATH_STUDY+"/"+self.config.NAME_SCHEME+"/pygmee_input.txt" + factoryNode = self.monCata._nodeMap["pygmee"] + self.pygmeeNode = factoryNode.cloneNode("pygmee") + self.pygmeeNode.getInputPort("pathPygmee").edInitPy(self.config.PATH_PYGMEE) + self. pygmeeNode.getInputPort("fileInput").edInitPy(monFichierInput) + proc.edAddChild(self.pygmeeNode) + if self.nodeAvant != None : + proc.edAddCFLink(self.nodeAvant,self.pygmeeNode) + self.nodeAvant=self.pygmeeNode + + def ASTERYACS(self,proc,dico): + factoryNode = self.monCata._nodeMap["asterRun"] + self.asterNode = factoryNode.cloneNode("asterRun") + nom_racine=self.config.PATH_STUDY+"/"+self.config.NAME_SCHEME+"/" + monFichierExport=nom_racine+"s_poly_st_1_aster.export" + monFichierMed=nom_racine+"s_poly_st_1_aster.resu.med" + self.asterNode.getInputPort("pathAster").edInitPy(self.config.PATH_ASTER+"/bin") + self.asterNode.getInputPort("fileExport").edInitPy(monFichierExport) + self.asterNode.getInputPort("fileMed").edInitPy(monFichierMed) + + proc.edAddChild(self.asterNode) + if self.nodeAvant != None : + proc.edAddCFLink(self.nodeAvant,self.asterNode) + self.nodeAvant=self.asterNode + +dictKlass={'s_poly_st_1':s_poly_st_1} +def getSchema(config): + schema=config.appli.ssCode + return dictKlass[schema](config) + + +if __name__ == "__main__": + monCreator=getSchema('s_poly_st_1') + proc=monCreator.createProc() + monCreator.ajoutPygmee(proc) + monCreator.ajoutBenhur(proc) + monCreator.write_yacs_proc(proc,"/tmp/toto.xml") +