self.editor = self.treeParent.editor
self.appliEficas = treeParent.appliEficas
self.JESUISOFF=0
+ self.firstAffiche = True
self.childrenComplete=[]
# 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)
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)
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)
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
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
# 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
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)
cata_ord_dico=self.readercata.cata_ordonne_dico,
rep_mat=self.maConfiguration.rep_mat,
)
+ jaux.editor=self
jaux.analyse()
J=JdC_aux( procedure="",
jdc_pere=jaux,
rep_mat=self.maConfiguration.rep_mat,
)
+ J.editor=self
J.analyse()
if units is not None:
J.recorded_units=units
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
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)
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'):
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)
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)
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)
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
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)
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
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)
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):
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)
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 :
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
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_()
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
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]
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/"
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
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)
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',):
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)
+
# ------------------------------------------
# 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',
#
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
#----------------------------------------------------------------------------------------
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
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 )
--- /dev/null
+# -*- 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