]> SALOME platform Git repositories - tools/eficas.git/blob - Aster/Cata/cataSTA10/Macro/calc_essai_ops.py
Salome HOME
Modif V6_4_°
[tools/eficas.git] / Aster / Cata / cataSTA10 / Macro / calc_essai_ops.py
1 #@ MODIF calc_essai_ops Macro  DATE 14/12/2010   AUTEUR PELLET J.PELLET 
2 # -*- coding: iso-8859-1 -*-
3 #            CONFIGURATION MANAGEMENT OF EDF VERSION
4 # ======================================================================
5 # COPYRIGHT (C) 1991 - 2010  EDF R&D                  WWW.CODE-ASTER.ORG
6 # THIS PROGRAM IS FREE SOFTWARE; YOU CAN REDISTRIBUTE IT AND/OR MODIFY  
7 # IT UNDER THE TERMS OF THE GNU GENERAL PUBLIC LICENSE AS PUBLISHED BY  
8 # THE FREE SOFTWARE FOUNDATION; EITHER VERSION 2 OF THE LICENSE, OR     
9 # (AT YOUR OPTION) ANY LATER VERSION.                                                  
10 #                                                                       
11 # THIS PROGRAM IS DISTRIBUTED IN THE HOPE THAT IT WILL BE USEFUL, BUT   
12 # WITHOUT ANY WARRANTY; WITHOUT EVEN THE IMPLIED WARRANTY OF            
13 # MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. SEE THE GNU      
14 # GENERAL PUBLIC LICENSE FOR MORE DETAILS.                              
15 #                                                                       
16 # YOU SHOULD HAVE RECEIVED A COPY OF THE GNU GENERAL PUBLIC LICENSE     
17 # ALONG WITH THIS PROGRAM; IF NOT, WRITE TO EDF R&D CODE_ASTER,         
18 #    1 AVENUE DU GENERAL DE GAULLE, 92141 CLAMART CEDEX, FRANCE.        
19 # ======================================================================
20
21 ## \package calc_essai_ops Implémentation de la macro CALC_ESSAI
22 #
23 # Ce module contient la partie controle de la macro CALC_ESSAI
24 # les autres fichiers sources sont situes dans ../Calc_essai
25
26
27 def calc_essai_ops( self,
28                     INTERACTIF          = None,
29                     UNITE_RESU          = None,
30                     EXPANSION           = None,
31                     IDENTIFICATION      = None,
32                     MODIFSTRUCT         = None,
33                     TRAITEMENTSIG       = None,
34                     GROUP_NO_CAPTEURS   = None,
35                     GROUP_NO_EXTERIEUR  = None,
36                     RESU_IDENTIFICATION = None,
37                     RESU_MODIFSTRU      = None,
38                     **args):
39
40     from Calc_essai.cata_ce import CalcEssaiObjects
41     import aster
42     ier = 0
43     
44     # La macro compte pour 1 dans la numerotation des commandes
45     self.set_icmd(1)
46
47     prev = aster.onFatalError()
48     
49     # gestion des concepts sortants de la macro, declares a priori
50     table = []
51     table_fonction = []
52     mode_mec = []
53
54
55     if not RESU_MODIFSTRU:
56         out_modifstru = {}
57     else:
58         out_modifstru = RESU_MODIFSTRU[0] # max=1 dans le capy
59
60
61     if not RESU_IDENTIFICATION:
62         RESU_IDENTIFICATION = []
63     else:
64         for res in RESU_IDENTIFICATION:
65             table_fonction.append(res['TABLE'])
66     out_identification = {"DeclareOut" : self.DeclareOut,
67                           "TypeTables" : 'TABLE_FONCTION',
68                           "ComptTable" : 0,
69                           "TablesOut"  : table_fonction}
70
71     
72     # Mode interactif : ouverture d'une fenetre Tk
73     if INTERACTIF == "OUI":
74         aster.onFatalError('EXCEPTION')
75
76         create_interactive_window(self,
77                                   out_identification,
78                                   out_modifstru,
79                                   )
80     else:
81         from Calc_essai.ce_test import MessageBox
82         from Calc_essai.ce_test import TestCalcEssai
83         mess = MessageBox(UNITE_RESU)
84         mess.disp_mess("Mode non intéractif")
85         
86         objects = CalcEssaiObjects(self, mess)
87
88         # importation des concepts aster existants de la memoire jeveux
89         TestCalcEssai(self,
90                       mess,
91                       out_identification,
92                       out_modifstru,
93                       objects,
94                       EXPANSION,
95                       IDENTIFICATION,
96                       MODIFSTRUCT,
97                       GROUP_NO_CAPTEURS,
98                       GROUP_NO_EXTERIEUR              
99                       )
100
101         mess.close_file()
102     aster.onFatalError(prev)
103     return ier
104
105
106
107 def create_tab_mess_widgets(tk,tabskeys):
108     """Construits les objects table et boîte à messages."""
109     try:
110         from Pmw import PanedWidget
111     except ImportError:
112         PanedWidget = None
113     
114     from Calc_essai.outils_ihm import MessageBoxInteractif, TabbedWindow
115     
116     tabsw = tk
117     msgw = tk
118     tk.rowconfigure(0, weight=2)
119     tk.rowconfigure(1, weight=1)
120
121     tabs = TabbedWindow(tabsw, tabskeys)
122
123     tabs.grid(row=0, column=0, sticky='nsew')
124     # pack(side='top',expand=1,fill='both')
125     
126     # ecriture des message dans un fichier message
127     mess = MessageBoxInteractif(msgw)
128     mess.grid(row=1, column=0, sticky='nsew')
129     
130     return tabs, mess
131
132
133 class FermetureCallback:
134     """Opérations à appliquer lors de la fermeture de la
135     fenêtre Tk.
136     """
137
138     def __init__(self, main_tk, turbulent):
139         self.main_tk = main_tk
140         self.turbulent = turbulent
141
142     def apply(self):
143         """Enlève les fichiers temporaires de Xmgrace"""
144         if self.turbulent.param_visu.logiciel_courbes is not None:
145             self.turbulent.param_visu.logiciel_courbes.fermer()
146         self.main_tk.quit()
147
148
149 def create_interactive_window(macro,
150                               out_identification,
151                               out_modifstru,
152                               ):
153     """Construit la fenêtre interactive comprenant une table pour 
154     les 4 domaines de CALC_ESSAI."""
155     from Tkinter import Tk
156     
157     from Calc_essai.cata_ce import CalcEssaiObjects
158     from Calc_essai.ce_ihm_expansion import InterfaceCorrelation
159     from Calc_essai.ce_ihm_modifstruct import InterfaceModifStruct
160     from Calc_essai.ce_ihm_identification import InterfaceIdentification
161     from Calc_essai.ce_ihm_parametres import InterfaceParametres
162     from Calc_essai.ce_calc_spec import InterfaceCalcSpec
163     
164     # fenetre principale
165     tk = Tk()
166     tk.title("CALC_ESSAI")
167     tk.rowconfigure(0,weight=1)
168     tk.rowconfigure(1,weight=20)
169     tk.rowconfigure(2,weight=1)
170
171     tabskeys = ["Expansion de modeles",
172                 "Modification structurale",
173                 "Identification de chargement",
174                 "Traitement du signal",
175                 "Parametres de visualisation" ]
176     
177     tabs, mess = create_tab_mess_widgets(tk, tabskeys)
178     main = tabs.root()
179     
180     # importation des concepts aster de la memoire jeveux    
181     objects = CalcEssaiObjects(macro, mess)
182     tabs.set_objects(objects)
183     
184     param_visu = InterfaceParametres(main, mess)
185     
186     iface = InterfaceCorrelation(main, objects, macro, mess,param_visu)
187     imodifstruct = InterfaceModifStruct(main, objects, macro,mess, out_modifstru, param_visu)
188     identification = InterfaceIdentification(main, objects, mess, out_identification, param_visu)
189     calc_spec= InterfaceCalcSpec(main,objects,mess,param_visu)
190
191     tabs.set_tab(tabskeys[0], iface.main)
192     tabs.set_tab(tabskeys[1], imodifstruct.main)
193     tabs.set_tab(tabskeys[2], identification)
194     tabs.set_tab(tabskeys[3], calc_spec)
195     tabs.set_tab(tabskeys[4], param_visu)    
196     
197     tabs.set_current_tab(tabskeys[4])
198
199     tk.protocol("WM_DELETE_WINDOW", FermetureCallback(tk, identification).apply)
200     
201     try:
202         tk.mainloop()
203     except :
204         print "CALC_ESSAI : *ERREUR*"
205
206