Salome HOME
Résolution du bug roundup n°32 (multi-études)
[modules/eficas.git] / src / EFICASGUI / eficasEtude.py
1 #=============================================================================
2 # File      : EficasEtude.py
3 # Created   : mar fév 25 09:48:34 CET 2003
4 # Author    : Pascale NOYRET, EDF
5 # Project   : SALOME
6 # Copyright : EDF 2003
7 #  $Header: /home/salome/PlateFormePAL/Bases_CVS_EDF/Modules_EDF/EFICAS_SRC/src/EFICASGUI/eficasEtude.py,v 1.3 2005/06/03 07:25:24 salome Exp $
8 #=============================================================================
9
10 import salome
11 import re
12 from tkFileDialog import asksaveasfilename
13
14 import salomedsgui
15 aGuiDS=salomedsgui.guiDS()
16
17 #--------------------------------------------------------------------------
18
19 class Eficas_In_Study:
20
21       def __init__(self,code,studyId=None):
22           print "#######################################################"
23           print "#######################################################"
24           print "#######################################################"
25           print "_CS_GBO_ : Eficas_In_Study:init: studyId = ", studyId
26           print "#######################################################"
27           print "#######################################################"        
28           import SMESH_utils
29           self.aGuiDS=salomedsgui.guiDS(studyId=studyId)
30           self.enregistre()
31           self.code=code
32           self.liste_deja_la=[]
33           
34       def  enregistre(self):
35            self.fatherId=self.aGuiDS.enregistre("Eficas")
36            salome.sg.updateObjBrowser(0)
37
38       def rangeInStudy(self,fichier, suf=""):
39            if fichier not in self.liste_deja_la :
40                 self.liste_deja_la.append(fichier)
41                 Nom=re.split("/",fichier)[-1]
42
43                 self.commId=self.aGuiDS.createItemInStudy(self.fatherId,Nom)
44                 if self.commId != None:
45                    self.aGuiDS.setExternalFileAttribute(self.commId,"FICHIER_EFICAS_"+self.code+suf,fichier)
46                    salome.sg.updateObjBrowser(0)
47
48       def creeConfigTxt(self,fichier,dico):
49            sauvegarde = asksaveasfilename(title="fichier config.txt",
50                                      defaultextension='.txt',
51                                      initialdir = fichier)
52            f=open(sauvegarde,'w+')
53            for unite in dico.keys():
54                 print unite
55                 type=dico[unite][0]
56                 fic=dico[unite][1:]
57                 ligne="fort."+str(unite)+" "+type+" "+fic
58                 f.write(ligne)
59            f.close()
60            self.rangeInStudy(sauvegarde)
61