Salome HOME
7.7 rc0
[tools/eficas.git] / generator / generator_vers3DSalome.py
index 298dd547d438ad112819c63d8d2817916a4931e9..dc5931cbb2b5226d5015e3cbfe07c9d2af3560ee 100644 (file)
@@ -1,23 +1,22 @@
 # -*- coding: utf-8 -*-
-#            CONFIGURATION MANAGEMENT OF EDF VERSION
-# ======================================================================
-# COPYRIGHT (C) 1991 - 2002  EDF R&D                  WWW.CODE-ASTER.ORG
-# THIS PROGRAM IS FREE SOFTWARE; YOU CAN REDISTRIBUTE IT AND/OR MODIFY
-# IT UNDER THE TERMS OF THE GNU GENERAL PUBLIC LICENSE AS PUBLISHED BY
-# THE FREE SOFTWARE FOUNDATION; EITHER VERSION 2 OF THE LICENSE, OR
-# (AT YOUR OPTION) ANY LATER VERSION.
+# Copyright (C) 2007-2013   EDF R&D
 #
-# THIS PROGRAM 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
-# GENERAL PUBLIC LICENSE FOR MORE DETAILS.
+# 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.
 #
-# YOU SHOULD HAVE RECEIVED A COPY OF THE GNU GENERAL PUBLIC LICENSE
-# ALONG WITH THIS PROGRAM; IF NOT, WRITE TO EDF R&D CODE_ASTER,
-#    1 AVENUE DU GENERAL DE GAULLE, 92141 CLAMART CEDEX, FRANCE.
+# 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 
     python pour EFICAS.
@@ -39,14 +38,14 @@ from generator_python import PythonGenerator
 
 def entryPoint():
    """
-       Retourne les informations nécessaires pour le chargeur de plugins
+       Retourne les informations nécessaires pour le chargeur de plugins
 
-       Ces informations sont retournées dans un dictionnaire
+       Ces informations sont retournées dans un dictionnaire
    """
    return {
         # Le nom du plugin
           'name' : 'vers3DSalome',
-        # La factory pour créer une instance du plugin
+        # La factory pour créer une instance du plugin
           'factory' : vers3DSalomeGenerator,
           }
 
@@ -67,9 +66,9 @@ class vers3DSalomeGenerator(PythonGenerator):
                             "BARRE", "CABLE", "CARA", "COQUE", "EPAIS", 
                             "EXCENTREMENT", "GROUP_MA", "ORIENTATION", 
                             "POUTRE", "SECTION", "VALE", "VARI_SECT",
-                            "GRILLE", "ANGL_REP",
+                            "GRILLE", "ANGL_REP", "VECTEUR",
                              "b_constant", "b_homothetique", 
-                            "b_rectangle", "b_affine", "b_cercle" )
+                            "b_rectangle", "b_affine", "b_cercle", "b_generale" )
       self.dict_deb_com={"POUTRE":"VisuPoutre", "CABLE" : "VisuCable",
                          "COQUE" : "VisuCoque", "GRILLE" : "VisuGrille",
                          "ORIENTATION" : "Orientation", "BARRE" : "VisuBarre"}
@@ -77,7 +76,7 @@ class vers3DSalomeGenerator(PythonGenerator):
       self.dict_suite_com={"RECTANGLE":"Rectangle","GENERALE":"Generale",
                            "CERCLE":"Cercle"}
 
-      self.dict_traduit={"VARI_SECT":"extrusion","EXCENTREMENT":"Excentre","EPAIS":"Epais"}
+      self.dict_traduit={"VARI_SECT":"extrusion","EXCENTREMENT":"Excentre","EPAIS":"Epais","VECTEUR":"Vecteur"}
 
       self.init_ligne() 
 
@@ -89,12 +88,13 @@ class vers3DSalomeGenerator(PythonGenerator):
       self.commande = ""
       self.dict_attributs = {} 
 
-   def gener(self,node):
+   def gener(self,node,config=None):
       """
       """
       self.node=node
       self.list_commandes=[];
       self.generator(self.node.object)
+      #print self.list_commandes
       return self.list_commandes
 
    def generator(self,obj):
@@ -119,7 +119,16 @@ class vers3DSalomeGenerator(PythonGenerator):
       """
       """
       if obj.isvalid() == 0 :
-         #showerror("Element non valide","Salome ne sait pas traiter les élements non valides")
+         #showerror("Element non valide","Salome ne sait pas traiter les elements non valides")
+         return
+      for v in obj.mc_liste:
+         liste=self.generator(v)
+
+   def generMACRO_ETAPE(self,obj):
+      """
+      """
+      if obj.isvalid() == 0 :
+         #showerror("Element non valide","Salome ne sait pas traiter les elements non valides")
          return
       for v in obj.mc_liste:
          liste=self.generator(v)
@@ -141,7 +150,7 @@ class vers3DSalomeGenerator(PythonGenerator):
 
    def generMCFACT(self,obj):
       """
-          Convertit un objet MCFACT en une liste de chaines de caractères à la
+          Convertit un objet MCFACT en une liste de chaines de caractères à la
           syntaxe python
       """
       self.init_ligne()
@@ -192,6 +201,8 @@ class vers3DSalomeGenerator(PythonGenerator):
        for k in range(len(atraiter)) :
            clef=self.clefs[k]
            val =atraiter[k] 
+           if isinstance(val, (types.TupleType, types.ListType)) and len(val) == 1:
+               val = val[0]
            if isinstance (val, Extensions.parametre.PARAMETRE):
               val=val.valeur
               print val.__class__
@@ -223,4 +234,3 @@ class vers3DSalomeGenerator(PythonGenerator):
       self.dict_attributs["axeX"]=alpha
       self.dict_attributs["axeY"]=beta
       self.dict_attributs["axeZ"]=gamma
-