From 73722f0e313d6d0572c3f482ab4e47fc8c6bf142 Mon Sep 17 00:00:00 2001 From: "pascale.noyret" Date: Wed, 13 Mar 2019 11:16:09 +0100 Subject: [PATCH] sauvegarde virtuel polymer avec calculation qui genere un .input --- InterfaceQT4/browser.py | 12 +- InterfaceQT4/compofact.py | 11 +- InterfaceQT4/compomclist.py | 5 + InterfaceQT4/configuration.py | 19 +-- InterfaceQT4/editor.py | 10 +- InterfaceQT4/editorSsIhm.py | 6 +- InterfaceQT4/groupe.py | 7 +- InterfaceQT4/monChoixCommande.py | 12 +- InterfaceQT4/monWidgetBloc.py | 1 + InterfaceQT4/monWidgetCommande.py | 5 + InterfaceQT4/monWidgetFact.py | 8 ++ InterfaceQT4/monWidgetInactif.py | 1 + InterfaceQT4/monWidgetNiveauFact.py | 1 + InterfaceQT4/monWidgetSimpBase.py | 4 +- InterfaceQT4/qtEficas.py | 2 +- InterfaceQT4/readercata.py | 5 +- InterfaceQT4/viewManager.py | 10 +- VirtualPolymer/VP_Cata.py | 72 +++++------ VirtualPolymer/prefs_VP.py | 18 ++- generator/generator_TELEMAC.py | 7 +- generator/generator_mapVP.py | 189 ++++++++++++++++++++++++++++ 21 files changed, 326 insertions(+), 79 deletions(-) create mode 100644 generator/generator_mapVP.py diff --git a/InterfaceQT4/browser.py b/InterfaceQT4/browser.py index 0718e9b9..169cc7a5 100644 --- a/InterfaceQT4/browser.py +++ b/InterfaceQT4/browser.py @@ -222,6 +222,7 @@ class JDCNode(QTreeWidgetItem,GereRegles): self.editor = self.treeParent.editor self.appliEficas = treeParent.appliEficas self.JESUISOFF=0 + self.firstAffiche = True self.childrenComplete=[] @@ -404,10 +405,13 @@ class JDCNode(QTreeWidgetItem,GereRegles): # ceinture et bretelle #print 'old fenetre = ',self.editor.fenetreCentraleAffichee if self.editor.fenetreCentraleAffichee != None : - self.editor.widgetCentraleLayout.removeWidget(self.editor.fenetreCentraleAffichee) - self.editor.fenetreCentraleAffichee.setParent(None) - self.editor.fenetreCentraleAffichee.close() - self.editor.fenetreCentraleAffichee.deleteLater() + try : + self.editor.widgetCentraleLayout.removeWidget(self.editor.fenetreCentraleAffichee) + self.editor.fenetreCentraleAffichee.setParent(None) + self.editor.fenetreCentraleAffichee.close() + self.editor.fenetreCentraleAffichee.deleteLater() + except : + pass self.editor.widgetCentraleLayout.addWidget(self.fenetre) #print ("j ajoute ", self.fenetre, self.fenetre.node.item.nom) diff --git a/InterfaceQT4/compofact.py b/InterfaceQT4/compofact.py index 93385943..26f8907a 100644 --- a/InterfaceQT4/compofact.py +++ b/InterfaceQT4/compofact.py @@ -31,20 +31,21 @@ import traceback class Node(browser.JDCNode,typeNode.PopUpMenuNodePartiel): def getPanelGroupe(self,parentQt,commande,insertIn=-1): + # est-ce que ce n est pas toujours le getPanelGroupe de compomclist qui est utilisee maDefinition=self.item.get_definition() monObjet=self.item.object monNom=self.item.nom maCommande=commande if hasattr(parentQt,'niveau'): self.niveau=parentQt.niveau+1 else : self.niveau=1 - #if hasattr(self,'plie') :print self.item.nom, self.plie - #if maDefinition.fenetreIhm == 'Tableau': - # from InterfaceQt4.monWidgetFact import MonWidgetFactTableau - # widget=MonWidgetFactTableau(self,self.editor,parentQt,maDefinition,monObjet,self.niveau,maCommande) - #elif hasattr(self,'plie') and self.plie==True : if hasattr(self,'plie') and self.plie==True : from InterfaceQT4.monWidgetFactPlie import MonWidgetFactPlie widget=MonWidgetFactPlie(self,self.editor,parentQt,maDefinition,monObjet,self.niveau,maCommande,insertIn) + elif self.editor.maConfiguration.afficheFirstPlies and self.firstAffiche: + self.firstAffiche = False + self.setPlie() + from InterfaceQT4.monWidgetFactPlie import MonWidgetFactPlie + widget=MonWidgetFactPlie(self,self.editor,parentQt,maDefinition,monObjet,self.niveau,maCommande,insertIn) else: from InterfaceQT4.monWidgetFact import MonWidgetFact widget=MonWidgetFact(self,self.editor,parentQt,maDefinition,monObjet,self.niveau,maCommande,insertIn) diff --git a/InterfaceQT4/compomclist.py b/InterfaceQT4/compomclist.py index 7035e14b..fca3168d 100644 --- a/InterfaceQT4/compomclist.py +++ b/InterfaceQT4/compomclist.py @@ -48,6 +48,11 @@ class Node(browser.JDCNode,typeNode.PopUpMenuNodeMinimal): if hasattr(self,'plie') and self.plie==True : from InterfaceQT4.monWidgetFactPlie import MonWidgetFactPlie widget=MonWidgetFactPlie(self,self.editor,parentQt,maDefinition,monObjet,self.niveau,maCommande,insertIn) + elif self.editor.maConfiguration.afficheFirstPlies and self.firstAffiche: + self.firstAffiche = False + self.setPlie() + from InterfaceQT4.monWidgetFactPlie import MonWidgetFactPlie + widget=MonWidgetFactPlie(self,self.editor,parentQt,maDefinition,monObjet,self.niveau,maCommande,insertIn) else: from InterfaceQT4.monWidgetFact import MonWidgetFact widget=MonWidgetFact(self,self.editor,parentQt,maDefinition,monObjet,self.niveau,maCommande,insertIn) diff --git a/InterfaceQT4/configuration.py b/InterfaceQT4/configuration.py index 334be9c2..f4ab1d9b 100644 --- a/InterfaceQT4/configuration.py +++ b/InterfaceQT4/configuration.py @@ -110,30 +110,35 @@ class configBase(object): self.closeFrameRechercheCommande = False self.closeEntete = False self.closeArbre = False - self.force_langue=False + self.demandeLangue=False self.suiteTelemac=False self.nombreDeBoutonParLigne=0 self.translatorFichier=None self.dicoImages= {} self.dicoIcones= {} self.afficheCommandesPliees = True - self.simpleClic= False + self.afficheFirstPlies = False + self.simpleClic = False self.afficheOptionnelVide=False self.afficheListesPliees=True self.boutonDsMenuBar=False self.ficIcones=None self.repIcones=None - self.differencieSiDefaut=False + self.differencieSiDefaut=True self.typeDeCata='Python' - self.dumpXSD=False - self.withXSD=False - self.afficheIhm=True self.closeParenthese=False + self.closeOptionnel=False self.enleverActionStructures=False + self.enleverPoubellePourCommande=False self.enleverParametres=False self.enleverSupprimer=False self.ajoutExecution=False - self.utilParExtensions=False + self.utilParExtensions=[] + self.rendVisiblesLesCaches=False + + self.dumpXSD=False + self.withXSD=False + self.afficheIhm=True diff --git a/InterfaceQT4/editor.py b/InterfaceQT4/editor.py index 5cad4b4c..a389926c 100755 --- a/InterfaceQT4/editor.py +++ b/InterfaceQT4/editor.py @@ -77,7 +77,6 @@ class JDCEditor(JDCEditorSsIhm,Ui_baseWidget,QWidget): self.fenetreCentraleAffichee=None self.dejaDansPlieTout=False self.listeDesListesOuvertes=set() - self.afficheListesPliees=True if appli!=None and hasattr(appli,"statusBar"): self.sb = appli.statusBar() else : self.sb = None self.QWParent=QWParent @@ -91,17 +90,17 @@ class JDCEditor(JDCEditorSsIhm,Ui_baseWidget,QWidget): # Particularites IHM : met la fenetre a jour self.initSplitterSizes() - if self.code == "ASTER" or self.code == "monCode" : self.afficheListesPliees =True - if self.code == 'PSEN_N1' : self.afficheListesPliees = False #self.affiche=self.appliEficas.maConfiguration.affiche + self.afficheListesPliees=self.maConfiguration.afficheListesPliees if self.code in ['MAP','CARMELCND','PSEN'] : self.maConfiguration.afficheCommandesPliees=False if self.code in ['MAP',]: self.fermeArbre() # self.widgetTree.close() # self.widgetTree=None - if self.maConfiguration.closeArbre: self.fermeArbre() + if self.maConfiguration.closeArbre : self.fermeArbre() + if self.maConfiguration.closeOptionnel : self.fermeOptionnel() if self.maConfiguration.boutonDsMenuBar : self.appliEficas.remplitIconesCommandes() self.version_code = session.d_env.cata @@ -849,8 +848,11 @@ class JDCEditor(JDCEditorSsIhm,Ui_baseWidget,QWidget): self.tree.racine.updateNodeLabel() print ('sortie du XML') + print('|',self.fichier,'|') if self.jdc.cata.modeleMetier : self.jdc.toXml(self.fichier) + print (self.generator) + print (hasattr(self.generator, "writeDefault")) if self.jdc.isValid() != 0 and hasattr(self.generator, "writeDefault"): #if hasattr(self.generator, "writeDefault"): self.generator.writeDefault(fn) diff --git a/InterfaceQT4/editorSsIhm.py b/InterfaceQT4/editorSsIhm.py index 3d251ae8..d842aab6 100755 --- a/InterfaceQT4/editorSsIhm.py +++ b/InterfaceQT4/editorSsIhm.py @@ -290,6 +290,7 @@ class JDCEditorSsIhm : cata_ord_dico=self.readercata.cata_ordonne_dico, rep_mat=self.maConfiguration.rep_mat, ) + jaux.editor=self jaux.analyse() J=JdC_aux( procedure="", @@ -299,6 +300,7 @@ class JDCEditorSsIhm : jdc_pere=jaux, rep_mat=self.maConfiguration.rep_mat, ) + J.editor=self J.analyse() if units is not None: J.recorded_units=units @@ -659,7 +661,7 @@ class JDCEditorSsIhm : ouChercher=etape if debug : print (ouChercher) for mot in listeAvant : - ouChercher=ouChercher.getChild(mot,restreint="oui", debug=1) + ouChercher=ouChercher.getChild(mot,restreint="oui") monMC=ouChercher.getChild(MCFils,restreint="oui") if monMC == None : monMC = ouChercher.addEntite(MCFils) monMC.valeur=valeurs @@ -678,7 +680,7 @@ class JDCEditorSsIhm : ouChercher=etape if debug : print (ouChercher) for mot in listeAvant : - ouChercher=ouChercher.getChild(mot,restreint="oui", debug=1) + ouChercher=ouChercher.getChild(mot,restreint="oui") # Attention si +sieursMCFACT ouChercher=ouChercher[0] if debug : print (ouChercher) diff --git a/InterfaceQT4/groupe.py b/InterfaceQT4/groupe.py index 55b66eec..7b8e0fe9 100644 --- a/InterfaceQT4/groupe.py +++ b/InterfaceQT4/groupe.py @@ -61,6 +61,7 @@ class Groupe(QWidget,FacultatifOuOptionnel): self.listeMCAAjouter=[] self.dictMCVenantDesBlocs={} if hasattr(self,'RBDeplie') : self.RBDeplie.clicked.connect(self.setDeplie) + if hasattr(self,'RBPlie') : self.RBPlie.clicked.connect( self.setPlie) self.setAcceptDrops(True) if hasattr (self, 'commandesLayout'): @@ -81,7 +82,7 @@ class Groupe(QWidget,FacultatifOuOptionnel): for node in self.node.children: # non return mais continue car il faut tenir compte des blocs if node.appartientAUnNoeudPlie==True : continue - #print "je suis apres le if pour ",node.item.nom + #print ("je suis apres le if pour ",node.item.nom) widget=node.getPanelGroupe(self,self.maCommande) #print ("widget pour ", node.item.nom, widget) self.listeFocus.append(node.fenetre) @@ -111,6 +112,7 @@ class Groupe(QWidget,FacultatifOuOptionnel): return def afficheOptionnel(self): + if self.editor.maConfiguration.closeOptionnel : return liste,liste_rouge=self.ajouteMCOptionnelDesBlocs() self.monOptionnel=self.editor.widgetOptionnel self.monOptionnel.afficheOptionnel(liste,liste_rouge,self) @@ -195,7 +197,8 @@ class Groupe(QWidget,FacultatifOuOptionnel): self.reaffiche(self.node) def setDeplie(self): - #print ('je passe ds setDeplie de groupe') + print ('je passe ds setDeplie de groupe', self.obj.nom) + self.node.firstDeplie = False self.node.setDeplie() self.reaffiche(self.node) diff --git a/InterfaceQT4/monChoixCommande.py b/InterfaceQT4/monChoixCommande.py index 5ebb70c4..7d41beec 100644 --- a/InterfaceQT4/monChoixCommande.py +++ b/InterfaceQT4/monChoixCommande.py @@ -159,11 +159,15 @@ class MonChoixCommande(Ui_ChoixCommandes,QWidget): def creeListeCommande(self,filtre): listeGroupes,dictGroupes=self.jdc.getGroups() sensibleALaCasse=self.RBCasse.isChecked() - if "CACHE" in dictGroupes: - aExclure=dictGroupes["CACHE"] - else: - aExclure=() + if "CACHE" in dictGroupes: aExclure=list(dictGroupes["CACHE"]) + else: aExclure=() listeACreer=[] + listeEtapesDejaPresentes=[] + if self.editor.maConfiguration.rendVisiblesLesCaches : + for e in self.jdc.etapes: + listeEtapesDejaPresentes.append(e.nom) + for c in aExclure : + if c not in listeEtapesDejaPresentes : aExclure.remove(c) for l in self.jdc.getListeCmd(): if l not in aExclure : if sensibleALaCasse and (filtre != None and not filtre in l) : continue diff --git a/InterfaceQT4/monWidgetBloc.py b/InterfaceQT4/monWidgetBloc.py index 1dc33526..6b970a96 100644 --- a/InterfaceQT4/monWidgetBloc.py +++ b/InterfaceQT4/monWidgetBloc.py @@ -31,6 +31,7 @@ class MonWidgetBloc(Ui_WidgetBloc,Groupe): def __init__(self,node,editor,parentQt,definition, obj, niveau,commande): #print ("bloc : ",node.item.nom) Groupe.__init__(self,node,editor,parentQt, definition,obj,niveau,commande) + #if self.editor.maConfiguration.afficheCommandesPliees ==True: self.node.plieToutEtReaffiche() self.parentQt.commandesLayout.insertWidget(-1,self,1) diff --git a/InterfaceQT4/monWidgetCommande.py b/InterfaceQT4/monWidgetCommande.py index 608d663f..64c208e7 100644 --- a/InterfaceQT4/monWidgetCommande.py +++ b/InterfaceQT4/monWidgetCommande.py @@ -108,6 +108,10 @@ class MonWidgetCommande(Ui_WidgetCommande,Groupe): self.RBPoubelle.close() # JDC Fige return # Pas de MC Optionnels pour Carmel + if self.editor.maConfiguration.enleverPoubellePourCommande : + self.RBPoubelle.close() # JDC Fige + return # Pas de MC Optionnels pour Carmel + from .monWidgetOptionnel import MonWidgetOptionnel if self.editor.widgetOptionnel!= None : self.monOptionnel=self.editor.widgetOptionnel @@ -232,6 +236,7 @@ class MonWidgetCommande(Ui_WidgetCommande,Groupe): def afficheOptionnel(self): # N a pas de parentQt. doit donc etre redefini + if self.editor.maConfiguration.closeOptionnel : self.editor.fermeOptionnel() liste,liste_rouge=self.ajouteMCOptionnelDesBlocs() #print "dans afficheOptionnel", self.monOptionnel # dans le cas ou l insertion n a pas eu leiu (souci d ordre par exemple) diff --git a/InterfaceQT4/monWidgetFact.py b/InterfaceQT4/monWidgetFact.py index d756cb28..d1086240 100644 --- a/InterfaceQT4/monWidgetFact.py +++ b/InterfaceQT4/monWidgetFact.py @@ -68,6 +68,14 @@ class MonWidgetFactCommun(Groupe): parentOuAjouter=parentOuAjouter.parentQt parentOuAjouter.ajoutMC(texteListeNom) +# def reaffiche(self, nodeAVoir=None): +# print ('ds reaffiche : ', self.obj.nom, self.node.firstDeplie) +# if self.node.editor.maConfiguration.afficheFirstPlies and self.node.firstDeplie: +# self.node.firstDeplie =False +# self.node.setPlie() +# Groupe.reaffiche(self,nodeAVoir) + + class MonWidgetFact(Ui_WidgetFact,MonWidgetFactCommun): def __init__(self,node,editor,parentQt,definition, obj, niveau,commande,insertIn=1): diff --git a/InterfaceQT4/monWidgetInactif.py b/InterfaceQT4/monWidgetInactif.py index ba8696db..db3657af 100644 --- a/InterfaceQT4/monWidgetInactif.py +++ b/InterfaceQT4/monWidgetInactif.py @@ -64,6 +64,7 @@ class MonWidgetInactif(QWidget,Ui_WidgetInactif): def afficheOptionnel(self): # N a pas de parentQt. doit donc etre redefini + if self.editor.maConfiguration.closeOptionnel : return liste=[] #print "dans afficheOptionnel", self.monOptionnel # dans le cas ou l insertion n a pas eu leiu (souci d ordre par exemple) diff --git a/InterfaceQT4/monWidgetNiveauFact.py b/InterfaceQT4/monWidgetNiveauFact.py index 236ab677..b3a7f27f 100644 --- a/InterfaceQT4/monWidgetNiveauFact.py +++ b/InterfaceQT4/monWidgetNiveauFact.py @@ -149,6 +149,7 @@ class MonWidgetNiveauFact(Ui_WidgetNiveauFact,Groupe): def afficheOptionnel(self): # N a pas de parentQt. doit donc etre redefini #print ('ds afficheOptionnel') + if self.editor.maConfiguration.closeOptionnel : return if self.editor.widgetOptionnel!= None : self.monOptionnel=self.editor.widgetOptionnel else : diff --git a/InterfaceQT4/monWidgetSimpBase.py b/InterfaceQT4/monWidgetSimpBase.py index ef4c5cea..9f2a20b9 100644 --- a/InterfaceQT4/monWidgetSimpBase.py +++ b/InterfaceQT4/monWidgetSimpBase.py @@ -42,7 +42,9 @@ class MonWidgetSimpBase (Ui_WidgetSimpBase,Feuille): Feuille.__init__(self,node,monSimpDef,nom,objSimp,parentQt,commande) self.parentQt.commandesLayout.insertWidget(-1,self,1) self.setFocusPolicy(Qt.StrongFocus) - self.lineEditVal.returnPressed.connect(self.LEvaleurPressed) + if monSimpDef.homo == 'constant' : self.lineEditVal.setReadOnly(True) + if monSimpDef.homo == 'constant' : self.lineEditVal.setStyleSheet("background:rgb(210,235,235);\n" "border:0px;") + else : self.lineEditVal.returnPressed.connect(self.LEvaleurPressed) self.AAfficher=self.lineEditVal self.maCommande.listeAffichageWidget.append(self.lineEditVal) self.lineEditVal.focusInEvent=self.monFocusInEvent diff --git a/InterfaceQT4/qtEficas.py b/InterfaceQT4/qtEficas.py index c5708cee..0feaff47 100755 --- a/InterfaceQT4/qtEficas.py +++ b/InterfaceQT4/qtEficas.py @@ -72,7 +72,7 @@ class Appli(AppliSsIhm,Ui_Eficas,QMainWindow): self.suiteTelemac=False if hasattr (self, 'maConfiguration') : - if self.maConfiguration.force_langue : + if self.maConfiguration.demandeLangue : from InterfaceQT4.monChoixLangue import MonChoixLangue widgetLangue = MonChoixLangue(self) ret=widgetLangue.exec_() diff --git a/InterfaceQT4/readercata.py b/InterfaceQT4/readercata.py index ede63e4e..272a1ef8 100644 --- a/InterfaceQT4/readercata.py +++ b/InterfaceQT4/readercata.py @@ -204,8 +204,9 @@ class ReaderCata (ReaderCataCommun): try : nomCataXsd = os.path.splitext(os.path.basename(self.fic_cata))[0]+'_genere' pathCata = os.path.dirname(self.fic_cata)+'/raw/'+nomCataXsd+'.py' - import imp - modeleMetier= imp.load_source(nomCataXsd,pathCata) + modeleMetier=__import__('raw.cata_DPD_genere',fromlist=['']) +# import imp +# modeleMetier= imp.load_source(nomCataXsd,pathCata) except : print ('______________ poum import cata_genere ') modeleMetier = None diff --git a/InterfaceQT4/viewManager.py b/InterfaceQT4/viewManager.py index 0050a294..de4499c0 100644 --- a/InterfaceQT4/viewManager.py +++ b/InterfaceQT4/viewManager.py @@ -85,16 +85,16 @@ class MyViewManager(object): if maPage : self.myQtab.setTabText(self.myQtab.indexOf(maPage),os.path.basename(fichier)) return result - def closeTab(self): - self.handleClose() + def closeTab(self,indexAFermer): + self.handleClose(indexAFermer = indexAFermer) - def handleClose(self,doitSauverRecent = 1,texte=tr('&Quitter')): + def handleClose(self,doitSauverRecent = 1,texte=tr('&Quitter'),indexAFermer=None): if doitSauverRecent : self.appliEficas.sauveRecents() - index=self.myQtab.currentIndex() + if indexAFermer == None :index=self.myQtab.currentIndex() + else : index = indexAFermer if index < 0 : return res=self.checkDirty(self.dict_editors[index],texte) if res == 2 : return 2 # l utilisateur a annule - index=self.myQtab.currentIndex() idx=index while idx < len(self.dict_editors) -1 : self.dict_editors[idx]=self.dict_editors[idx+1] diff --git a/VirtualPolymer/VP_Cata.py b/VirtualPolymer/VP_Cata.py index fa98b5c5..fed4a624 100644 --- a/VirtualPolymer/VP_Cata.py +++ b/VirtualPolymer/VP_Cata.py @@ -25,7 +25,6 @@ class Tuple: from for_eficace import filtre_calculation_mechanistic from for_eficace import filtre_calculation_analitic from for_eficace import filtre_data_model -#print filtre_calculation_analitic database = os.path.join(MAP_DIRECTORY,'share/map/tests/components/c_pre_polymer_data_management/local/') database="/home/A96028/MAPVp/my_map_installdir/share/map/tests/components/c_pre_polymer_data_management/local/" @@ -137,6 +136,7 @@ def blocPourCalculationForMechanisticSelonModeleTechnicalUse(technicalUse): condition = "TechnicalUse == '" + technicalUse + "'" ModelName = SIMP(statut='o',typ='TXM', into = dicoTechnicalUse[technicalUse].keys(),) SimulationName = SIMP(statut='o',typ='TXM') + OutPutFolder = SIMP(statut='o',typ = "Repertoire") for modeleName in dicoTechnicalUse[technicalUse].keys() : # modeleName est le modele par exmple radio_oxydation_PE_tetra_stabilization @@ -147,7 +147,7 @@ def blocPourCalculationForMechanisticSelonModeleTechnicalUse(technicalUse): dicoBloc['AgingParameters'] = calculAgingParameters() dicoBloc['InitialParameters'] = calculInitialParameters(technicalUse,modeleName) if dicoBloc != None : dicoArgs['b_ModelName_' + modeleName] = BLOC(**dicoBloc) - return BLOC(condition=condition, ModelName = ModelName,SimulationName=SimulationName,**dicoArgs) + return BLOC(condition=condition, ModelName = ModelName,SimulationName=SimulationName,OutPutFolder=OutPutFolder,**dicoArgs) @@ -206,7 +206,7 @@ def chercheConstantes(laClasse): def calculBlocAnalyticalEquationsForModification(): # PN refaire l algo -#print (dicoEquations['cable']['base']['initiation']) +# print (dicoEquations['cable']['base']['initiation']) #for technicalUse in dicoInfoGenerales['Modele_TechnicalUse']: #condition = "TechnicalUse == '" + technicalUse + "'" for technicalUse in ('cable',): @@ -247,6 +247,14 @@ def calculBlocAnalyticalEquationsForModification(): return FACT(statut = 'o',Equations = Equations, Constantes=Constantes) +def blocCreationEquation(): + ChemicalFormulation = SIMP(statut='o', typ='TXM', defaut = monMechanisticEquation.representation ) + Aging_Type = SIMP(statut= 'o',typ= 'TXM', min=1,max=1, into=('All', 'thermo', 'radio'), defaut = monMechanisticEquation.type_vieil[0]) + Reaction_Type = SIMP(statut= 'o',typ= 'TXM', min=1,max=1, into=dicoInfoGenerales['Type_D_Equation'], defaut = monMechanisticEquation.type_react) + print (Reaction_Type) + print (dicoEquationsParTechnicalUseParModelePartypeDEquation) + return FACT(statut = 'o', ChemicalFormulation=ChemicalFormulation, Aging_Type=Aging_Type, Reaction_Type=Reaction_Type) + # ------------------------------------------ @@ -261,43 +269,37 @@ Database = PROC (nom="Database", op=None, # toutes les valeurs sont par defaut class_data.Equation # generer le catalogue avec un fact # Aging_Type type_vieil, - Creation = FACT ( statut = 'o', - ChemicalFormulation = SIMP(statut='o', typ='TXM', defaut = monMechanisticEquation.representation ), - Aging_Type = SIMP(statut= 'o',typ= 'TXM', min=1,max=1, into=('All', 'thermo', 'radio'), defaut = monMechanisticEquation.type_vieil[0]), - Reaction_Type = SIMP(statut= 'o',typ= 'TXM', min=1,max=1, into=dicoInfoGenerales['Type_D_Equation'], defaut = monMechanisticEquation.type_react), - Constituants = chercheConstituant(monMechanisticEquation), - New = SIMP (statut = 'o', typ = bool, defaut=False), - b_new = BLOC(condition = " New == True" , - Constituant = FACT ( statut = 'o', min=1, max='**', - Name = SIMP(statut= 'o',typ= 'TXM'), - Differential_Equation = SIMP(statut= 'o',typ= 'TXM'), - ), - ), # b new - - Constantes = chercheConstantes(monMechanisticEquation), - New_Cst = SIMP (statut = 'o', typ = bool, defaut=False), - b_new_cst = BLOC(condition = " New_Cst == True" , - Constante = FACT ( statut = 'o', min=1, max='**', - Name = SIMP (statut = 'o', typ = 'TXM'), - ), # fin constante - ), #fin b_new - - Arrhenius = SIMP (statut = 'o', typ = bool, defaut=monMechanisticEquation.arrhenius), - Comment = SIMP(statut= 'o',typ= 'TXM', defaut = monMechanisticEquation.comment), - ), # fin creation mechanistic model + Creation_Equation = blocCreationEquation(), + #Creation_Equation = FACT ( statut = 'o', + # ChemicalFormulation = SIMP(statut='o', typ='TXM', defaut = monMechanisticEquation.representation ), + # Aging_Type = SIMP(statut= 'o',typ= 'TXM', min=1,max=1, into=('All', 'thermo', 'radio'), defaut = monMechanisticEquation.type_vieil[0]), + # blocCreationEquation = blocCreationEquation() +# Reaction_Type = SIMP(statut= 'o',typ= 'TXM', min=1,max=1, into=dicoInfoGenerales['Type_D_Equation'], defaut = monMechanisticEquation.type_react), +# Constituants = chercheConstituant(monMechanisticEquation), +# New = SIMP (statut = 'o', typ = bool, defaut=False), +# b_new = BLOC(condition = " New == True" , +# Constituant = FACT ( statut = 'o', min=1, max='**', +# Name = SIMP(statut= 'o',typ= 'TXM'), +# Differential_Equation = SIMP(statut= 'o',typ= 'TXM'), +# ), +# ), # b new +# +# Constantes = chercheConstantes(monMechanisticEquation), +# New_Cst = SIMP (statut = 'o', typ = bool, defaut=False), +# b_new_cst = BLOC(condition = " New_Cst == True" , +# Constante = FACT ( statut = 'o', min=1, max='**', +# Name = SIMP (statut = 'o', typ = 'TXM'), +# ), # fin constante +# ), #fin b_new +# +# Arrhenius = SIMP (statut = 'o', typ = bool, defaut=monMechanisticEquation.arrhenius), +# Comment = SIMP(statut= 'o',typ= 'TXM', defaut = monMechanisticEquation.comment), +# ), # fin creation mechanistic model ), # fin b_create_equation b_modify_equation = BLOC (condition = 'Type_chgt == "modify equation"', # les valeurs par defaut seront lues dans la base de données Filtre = calculBlocAnalyticalEquationsForModification(), - #Filtre = FACT (statut='o', - # #Reaction_Type=SIMP(statut= 'o',typ= 'TXM', min=1,into=dicoInfoGenerales['Type_D_Equation'], siValide=lienDB.remplitMechanisticModifyEquationListeEquation), - # Reaction_Type=SIMP(statut= 'o',typ= 'TXM', min=1,into=dicoInfoGenerales['Type_D_Equation'],),# siValide=lienDB.remplitMechanisticModifyEquationListeEquation), -# Filtre getMechanisticEquation(Reaction_Type) -# diictionnaire key : nom de l equation / valeur classe instancies liste de nom d'equation - # Equation_List=SIMP(statut= 'o',typ= 'TXM'), #siValide=lienDB.remplitModificationEquation), - # ), - # lorsque le choix est fait on peut recuperer les valeurs par defaut #ChemicalFormulation = SIMP(statut='o', typ='TXM', defaut = 'POOH -> 2P'), Modification = FACT (statut='o', diff --git a/VirtualPolymer/prefs_VP.py b/VirtualPolymer/prefs_VP.py index 869fc104..e5c54d9d 100644 --- a/VirtualPolymer/prefs_VP.py +++ b/VirtualPolymer/prefs_VP.py @@ -35,14 +35,24 @@ encoding='iso-8859-1' # catalogues=( -# ('VPCalcul','V1',os.path.join(repIni,'VP_Cata_simplifie.py'),'python','python'), - ('VPCalcul','VCalcul',os.path.join(repIni,'VP_Cata_Calculation.py'),'MAPVp','python'), - ('VPDabase','VDatabase',os.path.join(repIni,'VP_Cata_Database.py'),'python','python'), + #('VPCalcul','VCalcul',os.path.join(repIni,'VP_Cata_Calculation.py'),'MAPVp','python'), + ('VPCalcul','VCalcul',os.path.join(repIni,'VP_Cata.py'),'MAPVp','python'), +# ('VPDabase','VDatabase',os.path.join(repIni,'VP_Cata_Database.py'),'python','python'), ) nombreDeBoutonParLigne=2 closeFrameRechercheCommande = True closeEntete = True -#closeArbre = True +closeArbre = True +closeOptionnel=True afficheOptionnelVide=False +afficheListesPliees=True +afficheCommandesPliees=True +afficheFirstPlies = True +enleverActionStructures=True +enleverParametres=True +enleverSupprimer=True +enleverPoubellePourCommande=True +ajoutExecution=True + #### il faut afficher les listes pliees diff --git a/generator/generator_TELEMAC.py b/generator/generator_TELEMAC.py index ad25a7c1..3b52f688 100644 --- a/generator/generator_TELEMAC.py +++ b/generator/generator_TELEMAC.py @@ -59,7 +59,7 @@ class TELEMACGenerator(PythonGenerator): #---------------------------------------------------------------------------------------- def gener(self,obj,format='brut',config=None,appli=None,statut="Leger"): - + self.statut = statut self.langue = appli.langue try : self.TelemacdicoEn = appli.readercata.TelemacdicoEn @@ -136,8 +136,9 @@ class TELEMACGenerator(PythonGenerator): def writeDefault(self,fn) : self.texteDico+='&ETA\n' - if self.statut == 'Leger' : extension = ".Lcas" - else : extension = ".cas" + #if self.statut == 'Leger' : extension = ".Lcas" + #else : extension = ".cas" + extension=".cas" fileDico = fn[:fn.rfind(".")] + extension f = open( str(fileDico), 'w') f.write( self.texteDico ) diff --git a/generator/generator_mapVP.py b/generator/generator_mapVP.py new file mode 100644 index 00000000..bafbfbfe --- /dev/null +++ b/generator/generator_mapVP.py @@ -0,0 +1,189 @@ +# -*- coding: utf-8 -*- +# Copyright (C) 2007-2017 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. +# +# 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 +# +""" + Ce module contient le plugin generateur de fichier au format + CARMEL3D pour EFICAS. + +""" +from __future__ import print_function +from __future__ import absolute_import +try : + from builtins import str +except : pass + +import traceback +import types,re,os +import Accas + +from .generator_python import PythonGenerator + +listeCalParName = ('Time' , 'Temperature', 'DoseRate', 'Thickness') #'calculation_parameter_names' + + +def entryPoint(): + """ + Retourne les informations necessaires pour le chargeur de plugins + + Ces informations sont retournees dans un dictionnaire + """ + return { + # Le nom du plugin + 'name' : 'MAPVp', + # La factory pour creer une instance du plugin + 'factory' : MapGenerator, + } + + +class MapGenerator(PythonGenerator): + """ + Ce generateur parcourt un objet de type JDC et produit + un texte au format eficas et + un texte au format py + + """ + + def gener(self,obj,format='brut',config=None,appli=None): + self.initDico() + self.text=PythonGenerator.gener(self,obj,format) + if obj.isValid() :self.genereExeMap() + return self.text + + + def genereExeMap(self) : + ''' + Prepare le contenu du fichier de parametres python + peut ensuite etre obtenu au moyen de la fonction getTubePy(). + ''' + #nomSpec="spec_"+self.schema + #self.texteEXE="from map.spec import %s;\n"%nomSpec + #self.texteEXE+="node=%s.new();\n"%nomSpec + #self.texteEXE+="node.getInputData();\n" + #self.texteEXE+="node.setInputData(%s);\n"%self.dictValeur + #self.texteEXE+="node.execute();\n" + #self.texteEXE+="res=node.getOutputData();\n" + #self.texteEXE = "%s\n"%self.dictValeur + self.texteEXE = "" + self.txtEquations += ']\n' + self.texteEXE += self.genereCsv() + self.texteEXE += self.genereCalc() + self.texteEXE += self.txtNomCst + self.texteEXE += self.txtVal + self.texteEXE += self.txtValAct + self.texteEXE += self.txtNomCstNA + self.texteEXE += self.txtValNA + self.texteEXE += self.txtInitName + self.texteEXE += self.txtInitVal + self.texteEXE += self.txtEquations + + + + def genereCalc(self) : + txtNom = "calculation_parameter_names = [ " + txtVal = "calculation_parameters = [ " + for param in ('Time' , 'Temperature', 'DoseRate', 'Thickness') : + if param in self.dictValeur.keys() : + txtNom += "'"+param + "', " + txtVal += str(self.dictValeur[param]) + ", " + txtNom += "]\n" + txtVal += "]\n" + txt = txtNom + txtVal + return txt + + + def genereCsv(self) : + txt = 'study_name = ' +self.dictValeur['SimulationName'] + "\n" + txt += 'csv_output_file_name = ' + self.dictValeur['OutPutFolder'] + '/c_solver_stiff_ode_1d_' + self.dictValeur['SimulationName']+ '.csv\n' + return txt + + def initDico(self) : + if not hasattr(self,'schema') : self.schema="" + self.dictParam={} + self.dictValeur={} + self.txtEquations = "equation = [ " + + def writeDefault(self, fn): + fileEXE = fn[:fn.rfind(".")] + '.py' + f = open( str(fileEXE), 'wb') + f.write( self.texteEXE ) + f.close() + + def generMCList(self,obj): + s=PythonGenerator.generMCList(self,obj) + if obj.nom == 'ConstantesArrhenius' : + self.txtNomCst = "Arrhenius_Name = [ " + self.txtVal = "Arrhenius_A = [ " + self.txtValAct = "Arrhenius_Ea = [ " + for objFils in obj.data: + for mc in objFils.mcListe : + self.txtNomCst += "'" + mc.nom + "', " + self.txtVal += str(mc.valeur[0]) + ", " + self.txtValAct += str(mc.valeur[1]) + ", " + self.txtNomCst += ']\n' + self.txtVal += ']\n' + self.txtValAct += ']\n' + + if obj.nom == 'ConstantesNonArrhenius' : + self.txtNomCstNA = "non_Arrhenius_coefs_names = [ " + self.txtValNA = "non_Arrhenius_coefs = [ " + for objFils in obj.data: + for mc in objFils.mcListe : + self.txtNomCstNA += "'" + mc.nom + "', " + self.txtValNA += str(mc.valeur) + ", " + self.txtNomCstNA += ']\n' + self.txtValNA += ']\n' + + if obj.nom == 'InitialParameters' : + self.txtInitName = "initial_Value_names = [ " + self.txtInitVal = "initial_Values = [ " + for objFils in obj.data: + for mc in objFils.mcListe : + self.txtInitName += "'" + mc.nom + "', " + self.txtInitVal += str(mc.valeur) + ", " + self.txtInitName += ']\n' + self.txtInitVal += ']\n' + + if obj.nom in( 'initiation','propagation','termination','stabilization') : + for objFils in obj.data: + for mc in objFils.mcListe : + self.txtEquations += "'" + mc.nom + "', " + return s + + def generMCSIMP(self,obj) : + """ + Convertit un objet MCSIMP en texte python + Remplit le dictionnaire des MCSIMP + """ + s=PythonGenerator.generMCSIMP(self,obj) + if obj.nom=='Consigne' : return s + + if obj.getGenealogie()[0][-6:-1]=="_PARA": + self.dictParam[obj.nom]=obj.valeur + else : + self.dictValeur[obj.nom]=obj.valeur + return s + + + def generRUN(self,obj,schema): + if not(obj.isValid()) : + print ("TODO TODO TODO") + self.texteEXE="" + self.schema=schema + textComm=self.gener(obj) + return self.texteEXE -- 2.39.2