1 # -*- coding: utf-8 -*-
2 # CONFIGURATION MANAGEMENT OF EDF VERSION
3 # ======================================================================
4 # COPYRIGHT (C) 1991 - 2002 EDF R&D WWW.CODE-ASTER.ORG
5 # THIS PROGRAM IS FREE SOFTWARE; YOU CAN REDISTRIBUTE IT AND/OR MODIFY
6 # IT UNDER THE TERMS OF THE GNU GENERAL PUBLIC LICENSE AS PUBLISHED BY
7 # THE FREE SOFTWARE FOUNDATION; EITHER VERSION 2 OF THE LICENSE, OR
8 # (AT YOUR OPTION) ANY LATER VERSION.
10 # THIS PROGRAM IS DISTRIBUTED IN THE HOPE THAT IT WILL BE USEFUL, BUT
11 # WITHOUT ANY WARRANTY; WITHOUT EVEN THE IMPLIED WARRANTY OF
12 # MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. SEE THE GNU
13 # GENERAL PUBLIC LICENSE FOR MORE DETAILS.
15 # YOU SHOULD HAVE RECEIVED A COPY OF THE GNU GENERAL PUBLIC LICENSE
16 # ALONG WITH THIS PROGRAM; IF NOT, WRITE TO EDF R&D CODE_ASTER,
17 # 1 AVENUE DU GENERAL DE GAULLE, 92141 CLAMART CEDEX, FRANCE.
20 # ======================================================================
22 Ce module contient le plugin generateur de fichier au format
28 import types,string,re
30 from Noyau import N_CR
31 from Noyau.N_utils import repr_float
34 from Extensions.parametre import ITEM_PARAMETRE
35 from Formatage import Formatage
36 from generator_python import PythonGenerator
37 from Editeur.widgets import showerror
41 Retourne les informations nécessaires pour le chargeur de plugins
43 Ces informations sont retournées dans un dictionnaire
47 'name' : 'vers3DSalome',
48 # La factory pour créer une instance du plugin
49 'factory' : vers3DSalomeGenerator,
53 class vers3DSalomeGenerator(PythonGenerator):
55 Ce generateur parcourt un objet AFFE-CARA_ELEM
56 et produit un fichier au format texte contenant
57 les instructions idl pour PAL
60 def __init__(self,cr=None):
61 self.list_commandes=[];
65 self.liste_motetat = ("AFFE_CARA_ELEM", "ORIG_AXE", "AXE" ,
66 "BARRE", "CABLE", "CARA", "COQUE", "EPAIS",
67 "EXCENTREMENT", "GROUP_MA", "ORIENTATION",
68 "POUTRE", "SECTION", "VALE", "VARI_SECT",
70 "b_constant", "b_homothetique",
71 "b_rectangle", "b_affine", "b_cercle" )
72 self.dict_deb_com={"POUTRE":"VisuPoutre", "CABLE" : "VisuCable",
73 "COQUE" : "VisuCoque", "GRILLE" : "VisuGrille",
74 "ORIENTATION" : "Orientation", "BARRE" : "VisuBarre"}
76 self.dict_suite_com={"RECTANGLE":"Rectangle","GENERALE":"Generale",
79 self.dict_traduit={"VARI_SECT":"extrusion","EXCENTREMENT":"Excentre","EPAIS":"Epais"}
83 def init_jdc(self,jdc) :
86 def init_ligne (self) :
89 self.dict_attributs = {}
95 self.list_commandes=[];
96 self.generator(self.node.object)
97 return self.list_commandes
99 def generator(self,obj):
100 if (obj.nom in self.liste_motetat) and (self.calcule_ouinon(obj)):
101 PythonGenerator.generator(self,obj)
103 f1=PythonGenerator.generator(self,obj)
108 def calcule_ouinon(self,obj):
110 for l in obj.get_genealogie() :
111 if not l in self.liste_motetat :
117 def generETAPE(self,obj):
120 if obj.isvalid() == 0 :
121 showerror("Element non valide","Salome ne sait pas traiter les élements non valides")
123 for v in obj.mc_liste:
124 liste=self.generator(v)
127 def generMCSIMP(self,obj) :
130 #print "MCSIMP : ", obj.nom
131 if obj.nom in dir(self) :
132 suite = self.__class__.__dict__[obj.nom](self,obj)
134 clef=self.dict_traduit[obj.nom]
135 self.dict_attributs[clef]=obj.val
137 def generMCFACT(self,obj):
139 Convertit un objet MCFACT en une liste de chaines de caractères à la
143 self.commande=self.dict_deb_com[obj.nom]
145 for v in obj.mc_liste:
148 #print self.dict_attributs
149 if self.boolGpMa == 1:
150 self.list_commandes.append((self.commande,self.dict_attributs))
152 showerror("Elements ne portant pas sur un Groupe de Maille","Salome ne sait pas montrer ce type d' element")
154 def generMCList(self,obj):
157 for mcfact in obj.data:
158 self.generator(mcfact)
160 def generMCBLOC(self,obj):
163 for v in obj.mc_liste:
166 def GROUP_MA(self,obj):
168 self.dict_attributs["Group_Maille"]=obj.val
170 def SECTION(self,obj):
171 assert (self.commande != "" )
172 if self.commande == "VisuCable" :
173 self.dict_attributs["R"]=obj.val
174 elif (self.commande !="VisuGrille") :
175 self.commande=self.commande+self.dict_suite_com[obj.valeur]
179 if type(self.clefs) == types.StringType :
180 self.clefs=(obj.val,)
184 if len(self.clefs) > 1 :
185 assert (len(atraiter) == len(self.clefs))
188 for k in range(len(atraiter)) :
191 if isinstance (val, Extensions.parametre.PARAMETRE):
195 if type(val) == type("aaa") :
196 for p in self.jdc.params:
197 context[p.nom]=eval(p.val,self.jdc.const_context, context)
199 res=eval(val,self.jdc.const_context, context)
201 self.dict_attributs[clef]=val
203 def ANGL_REP(self,obj) :
204 assert (len(obj.val) == 2)
206 self.dict_attributs["angleAlpha"]=alpha
207 self.dict_attributs["angleBeta"]=beta
209 def ORIG_AXE(self,obj) :
210 assert (len(obj.val) == 3)
211 alpha,beta,gamma=obj.val
212 self.dict_attributs["origAxeX"]=alpha
213 self.dict_attributs["origAxeY"]=beta
214 self.dict_attributs["origAxeZ"]=gamma
217 assert (len(obj.val) == 3)
218 alpha,beta,gamma=obj.val
219 self.dict_attributs["axeX"]=alpha
220 self.dict_attributs["axeY"]=beta
221 self.dict_attributs["axeZ"]=gamma