]> SALOME platform Git repositories - tools/eficas.git/blob - Noyau/N_MCFACT.py
Salome HOME
chgt Copyrigth
[tools/eficas.git] / Noyau / N_MCFACT.py
1 # coding=utf-8
2 # Copyright (C) 2007-2021   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 """
22     Ce module contient la classe MCFACT qui sert à controler la valeur
23     d'un mot-clé facteur par rapport à sa définition portée par un objet
24     de type ENTITE
25 """
26
27 from __future__ import absolute_import
28 from . import N_MCCOMPO
29
30
31 class MCFACT(N_MCCOMPO.MCCOMPO):
32
33     """
34     """
35     nature = "MCFACT"
36
37     def __init__(self, val, definition, nom, parent,dicoPyxbDeConstruction):
38         """
39            Attributs :
40             - val : valeur du mot clé simple
41             - definition
42             - nom
43             - parent
44         """
45         print ('MCFACT', self, val, definition, nom, parent, dicoPyxbDeConstruction)
46         #import traceback
47         #traceback.print_stack()
48         self.dicoPyxbDeConstruction=dicoPyxbDeConstruction
49         if self.dicoPyxbDeConstruction :
50            self.objPyxbDeConstruction=self.dicoPyxbDeConstruction['objEnPyxb']
51            del self.dicoPyxbDeConstruction['objEnPyxb']
52         else :
53            self.objPyxbDeConstruction=None
54         self.definition = definition
55         self.nom = nom
56         self.val = val
57         self.parent = parent
58         self.valeur = self.getValeurEffective(self.val)
59         if parent:
60             self.jdc = self.parent.jdc
61             self.niveau = self.parent.niveau
62             self.etape = self.parent.etape
63         else:
64             # Le mot cle a été créé sans parent
65             self.jdc = None
66             self.niveau = None
67             self.etape = None
68         self.mcListe = self.buildMc()
69
70     def getValeurEffective(self, val):
71         """
72             Retourne la valeur effective du mot-clé en fonction
73             de la valeur donnée. Defaut si val == None
74         """
75         if (val is None and hasattr(self.definition, 'defaut')):
76             return self.definition.defaut
77         else:
78             return val
79
80     def getValeur(self):
81         """
82             Retourne la "valeur" d'un mot-clé facteur qui est l'objet lui-meme.
83             Cette valeur est utilisée lors de la création d'un contexte
84             d'évaluation d'expressions à l'aide d'un interpréteur Python
85         """
86         return self
87
88     def getVal(self):
89         """
90             Une autre méthode qui retourne une "autre" valeur du mot clé facteur.
91             Elle est utilisée par la méthode getMocle
92         """
93         return [self]
94
95     def __getitem__(self, key):
96         """
97             Dans le cas d un mot cle facteur unique on simule une liste de
98             longueur 1
99         """
100         if key == 0:
101             return self
102         return self.getMocle(key)
103
104     def accept(self, visitor):
105         """
106            Cette methode permet de parcourir l'arborescence des objets
107            en utilisant le pattern VISITEUR
108         """
109         visitor.visitMCFACT(self)
110
111     def makeobjet(self):
112         return self.definition.class_instance(val=None, nom=self.nom,
113                                               definition=self.definition, parent=self.parent)