]> SALOME platform Git repositories - tools/eficas.git/blob - Noyau/N_SIMP.py
Salome HOME
Modifications liees a MT
[tools/eficas.git] / Noyau / N_SIMP.py
1 # coding=utf-8
2 # Copyright (C) 2007-2017   EDF R&D
3 #
4 # This library is free software; you can redistribute it and/or
5 # modify it under the terms of the GNU Lesser General Public
6 # License as published by the Free Software Foundation; either
7 # version 2.1 of the License.
8 #
9 # This library is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12 # Lesser General Public License for more details.
13 #
14 # You should have received a copy of the GNU Lesser General Public
15 # License along with this library; if not, write to the Free Software
16 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
17 #
18 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
19
20
21 """ Ce module contient la classe de definition SIMP
22     qui permet de spécifier les caractéristiques des mots clés simples
23 """
24
25 from __future__ import absolute_import
26 import types
27
28 from Noyau import N_ENTITE
29 from Noyau import N_MCSIMP
30
31
32 class SIMP(N_ENTITE.ENTITE):
33
34     """
35      Classe pour definir un mot cle simple
36
37      Cette classe a deux attributs de classe
38
39      - class_instance qui indique la classe qui devra etre utilisée
40              pour créer l'objet qui servira à controler la conformité d'un
41              mot-clé simple avec sa définition
42
43      - label qui indique la nature de l'objet de définition (ici, SIMP)
44
45     """
46     class_instance = N_MCSIMP.MCSIMP
47     label = 'SIMP'
48
49     def __init__(self, typ,ang="", fr="", statut='f', into=None, intoSug = None,siValide = None, defaut=None,
50                  min=1, max=1, homo=1, position='local',
51                  val_min=float('-inf'), val_max=float('inf'), docu="", validators=None,
52                  sug=None,fenetreIhm=None):
53         """
54             Un mot-clé simple est caractérisé par les attributs suivants :
55             - type : cet attribut est obligatoire et indique le type de valeur attendue
56             - fr : chaîne documentaire en français
57             - statut : obligatoire ou facultatif ou caché
58             - into : valeurs autorisées
59             - intoSug : valeurs possibles mais des valeurs autres du bon type peuvent etre entrees par l utilsateur
60             - defaut : valeur par défaut
61             - min : nombre minimal de valeurs
62             - max : nombre maximal de valeurs
63             - homo : un certatin nb de choses qui il faut redispacher ailleurs (information, constant)
64             - ang : doc
65             - position : si global, le mot-clé peut-être lu n'importe où dans la commande
66             - val_min : valeur minimale autorisée
67             - val_max : valeur maximale autorisée
68             - docu : clef sur de la documentation utilisateur
69             - sug : valeur suggere
70             - fenetreIhm=None 
71         """
72         #print (self)
73         #import traceback
74         #traceback.print_stack()
75         #print (self)
76         N_ENTITE.ENTITE.__init__(self, validators)
77         # Initialisation des attributs
78         if type(typ) == tuple:
79             self.type = typ
80         else:
81             self.type = (typ,)
82         self.fr = fr
83         self.statut = statut
84         self.into = into
85         self.intoSug = intoSug
86         self.siValide = siValide
87         self.defaut = defaut
88         self.min = min
89         self.max = max
90         self.homo = homo
91         self.position = position
92         self.val_min = val_min
93         self.val_max = val_max
94         self.docu = docu
95         self.sug = sug
96         self.ang=ang
97         if self.max     == '**' : self.max     = float('inf')
98         if self.val_max == '**' : self.val_max = float('inf')
99         if self.min     == '**' : self.min     = float('-inf')
100         if self.val_min == '**' : self.val_min = float('-inf')
101         self.fenetreIhm=fenetreIhm
102         #self.creeT_SIMP()
103
104     def verifCata(self):
105         """
106             Cette methode sert à valider les attributs de l'objet de définition
107             de la classe SIMP
108         """
109         self.checkMinMax()
110         self.checkFr()
111         self.checkStatut()
112         self.checkHomo()
113         self.checkInto()
114         self.checkPosition()
115         self.checkValidators()
116
117     def __call__(self, val, nom, parent=None, objPyxbDeConstruction = None):
118         """
119             Construit un objet mot cle simple (MCSIMP) a partir de sa definition (self)
120             de sa valeur (val), de son nom (nom) et de son parent dans l arboresence (parent)
121         """
122         return self.class_instance(nom=nom, definition=self, val=val, parent=parent, objPyxbDeConstruction=objPyxbDeConstruction)
123
124 #    def creeT_SIMP(self):
125 #        from Efi2Xsd.readerEfficas import monSIMP
126 #        from Efi2Xsd.mapDesTypes import dictSIMPEficasXML
127 #        self.objXML=monSIMP()
128 #        for nomEficasArg in dictSIMPEficasXML :
129 #           argu=getattr(self,nomEficasArg)
130 #           nomXMLarg=dictSIMPEficasXML[nomEficasArg]
131 #           if not isinstance(nomXMLarg, (list, tuple)) :
132 #              print(nomXMLarg, argu)
133               #if nomEficasArg  in listeParamDeTypeTypeAttendu:
134               #   typeAttendu = self.typ
135 #                 
136 #              setattr(self.objXML, nomXMLarg, argu)
137            
138
139
140 # for nomXMLArg in dir(self) :
141 #          if nomXMLArg in self.dictATraiter :
142 #              nomEficasArg=self.dictATraiter[nomXMLArg]
143 #              argu=getattr(self,nomXMLArg)
144 #              if argu==None : continue
145 #
146 #              if type(nomEficasArg) == types.DictionaryType:
147 #                 for nomXML in list(nomEficasArg.keys()):
148 #                      arguDecoupe=getattr(argu,nomXML)
149 #                      nomEficasDecoupe=nomEficasArg[nomXML]
150 #                      if arguDecoupe == None : continue
151 #                      self.dictArgsEficas[nomEficasDecoupe]=arguDecoupe
152 #              else :
153 #                self.dictArgsEficas[nomEficasArg] = argu
154 #
155
156 #        
157 #       
158 #