2 # Copyright (C) 2007-2013 EDF R&D
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.
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.
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
18 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 """ Ce module contient la classe de definition SIMP
22 qui permet de spécifier les caractéristiques des mots clés simples
25 from __future__ import absolute_import
28 from . import N_ENTITE
29 from . import N_MCSIMP
32 class SIMP(N_ENTITE.ENTITE):
35 Classe pour definir un mot cle simple
37 Cette classe a deux attributs de classe
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
43 - label qui indique la nature de l'objet de définition (ici, SIMP)
46 class_instance = N_MCSIMP.MCSIMP
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,
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
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
71 N_ENTITE.ENTITE.__init__(self, validators)
72 # Initialisation des attributs
73 if type(typ) == tuple:
80 self.intoSug = intoSug
81 self.siValide = siValide
86 self.position = position
87 self.val_min = val_min
88 self.val_max = val_max
92 if self.max == '**' : self.max = float('inf')
93 if self.val_max == '**' : self.val_max = float('inf')
94 if self.min == '**' : self.min = float('-inf')
95 if self.val_min == '**' : self.val_min = float('-inf')
99 Cette methode sert à valider les attributs de l'objet de définition
107 self.check_position()
108 self.check_validators()
110 def __call__(self, val, nom, parent=None):
112 Construit un objet mot cle simple (MCSIMP) a partir de sa definition (self)
113 de sa valeur (val), de son nom (nom) et de son parent dans l arboresence (parent)
115 return self.class_instance(nom=nom, definition=self, val=val, parent=parent)