Salome HOME
chgt date copyright
[tools/eficas.git] / Ihm / I_OBJECT.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 """
22 from __future__ import absolute_import
23 import Noyau
24
25 from . import CONNECTOR
26
27 class OBJECT:
28   from Noyau.N_CO import CO
29   from Noyau.N_ASSD import assd
30
31   def isMCList(self):
32     """ 
33         Retourne 1 si self est une MCList (liste de mots-cles), 0 sinon (defaut) 
34     """
35     return 0
36
37   def get_regles(self):
38     """ 
39        Retourne les regles de self 
40     """
41     if hasattr(self,'definition'):
42       return self.definition.regles
43     elif hasattr(self,'regles'):
44       return self.regles
45     else :
46       return []
47
48   def init_modif(self):
49     """
50        Met l'etat de l'objet a modified et propage au parent
51        qui vaut None s'il n'existe pas
52     """
53     self.state = 'modified'
54     if self.parent:
55       self.parent.init_modif()
56
57   def fin_modif(self):
58       """
59       Methode appelee apres qu'une modification a ete faite afin de declencher
60       d'eventuels traitements post-modification
61       """
62       #print "fin_modif",self
63       # pour les objets autres que les commandes, aucun traitement specifique 
64       # on remonte l'info de fin de modif au parent
65       CONNECTOR.Emit(self,"valid")
66       if self.parent:
67         self.parent.fin_modif()
68
69   def isrepetable(self):
70     """
71          Indique si l'objet est repetable
72     """
73     return 0
74
75   def liste_mc_presents(self):
76     """
77          Retourne la liste des noms des mots cles presents
78     """
79     return []
80
81   def get_docu(self):
82     return self.definition.get_docu()
83
84   def get_liste_mc_inconnus(self):
85      """
86      Retourne la liste des mots-cles inconnus dans self
87      """
88      return []
89
90   def verif_condition_regles(self,liste_presents):
91     """ 
92         Retourne la liste des mots-cles a rajouter pour satisfaire les regles
93         en fonction de la liste des mots-cles presents 
94     """
95     liste=[]
96     for regle in self.definition.regles:
97         liste=regle.verif_condition_regle(liste,liste_presents)
98     return liste
99
100   def verif_condition_bloc(self):
101     """ 
102         Evalue les conditions de tous les blocs fils possibles 
103         (en fonction du catalogue donc de la definition) de self et
104         retourne deux listes :
105           - la premiere contient les noms des blocs a rajouter
106           - la seconde contient les noms des blocs a supprimer
107     """
108     return [],[]
109
110   def get_genealogie_precise(self):
111     if self.parent:
112        l=self.parent.get_genealogie_precise()
113        l.append(self.nom.strip())
114        return l
115     else:
116        return [self.nom.strip()]
117
118   def get_genealogie(self):
119     """ 
120         Retourne la liste des noms des ascendants (noms de MCSIMP,MCFACT,MCBLOC
121         ou ETAPE) de self jusqu'au premier objet etape rencontre
122     """
123     if self.parent:
124        l=self.parent.get_genealogie()
125        l.append(self.nom.strip())
126        return l
127     else:
128        return [self.nom.strip()]
129
130   def get_fr(self):
131      """
132          Retourne la chaine d'aide contenue dans le catalogue
133          en tenant compte de la langue
134      """
135      try:
136      #if 1 :
137         c=getattr(self.definition,self.jdc.lang)
138         return c
139      except:
140      #else:
141         try :
142             c=getattr(self.definition,"fr")
143             return c
144         except :
145             return ''
146
147   def update_concept(self,sd):
148      pass
149
150   def normalize(self):
151      """ Retourne l'objet normalise. En general self sauf si
152          pour etre insere dans l'objet pere il doit etre 
153          wrappe dans un autre objet (voir mot cle facteur).
154      """
155      return self
156
157   def delete_mc_global(self):
158      return
159
160   def update_mc_global(self):
161      return
162
163   #def __del__(self):
164   #   print "__del__",self
165
166 class ErrorObj(OBJECT):pass
167