]> SALOME platform Git repositories - tools/eficas.git/blob - Ihm/I_MCFACT.py
Salome HOME
348341f1ef40892790a09eed73d5cb74b390a3d1
[tools/eficas.git] / Ihm / I_MCFACT.py
1 # -*- coding: utf-8 -*-
2 # Copyright (C) 2007-2013   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 from Extensions.i18n import tr
21 import CONNECTOR
22 import I_MCCOMPO
23 import Noyau
24 import string
25
26 class MCFACT(I_MCCOMPO.MCCOMPO):
27   def isrepetable(self):
28      """ 
29          Indique si l'objet est répétable.
30          Retourne 1 si le mot-clé facteur self peut être répété
31          Retourne 0 dans le cas contraire
32      """
33      if self.definition.max > 1:
34        # marche avec '**'
35        return 1
36      else :
37        return 0
38
39   def isoblig(self):
40     return self.definition.statut=='o'
41
42   def getlabeltext(self):
43     """
44        Retourne le label de self suivant qu'il s'agit d'un MCFACT
45        isole ou d'un MCFACT appartenant a une MCList :
46        utilisee pour l'affichage dans l'arbre
47     """
48     objet = self.parent.get_child(self.nom)
49     # objet peut-etre self ou une MCList qui contient self ...
50     if objet is None or objet is self:
51      return tr("Erreur - mclist inexistante : %s", self.nom)
52
53     try:
54       if len(objet) > 1 :
55         index = objet.get_index(self)+1 # + 1 à cause de la numérotation qui commence à 0
56         return self.nom +'_'+`index`+':'
57       else:
58         return self.nom
59     except:
60       return tr("Erreur - mot cle facteur de nom : %s", self.nom)
61
62   def get_genealogie_precise(self):
63     nom=self.getlabeltext() 
64     if nom[-1]==':' : nom=nom[0:-1]
65     if self.parent:
66        l=self.parent.get_genealogie_precise()
67        l.append(string.strip(nom))
68        return l
69     else:
70        return [string.strip(nom)]
71
72
73   def init_modif(self):
74     """
75        Met l'état de l'objet à modified et propage au parent
76        qui vaut None s'il n'existe pas
77     """
78     self.state = 'modified'
79     parent= hasattr(self,"alt_parent") and self.alt_parent or self.parent
80     if parent:
81        parent.init_modif()
82
83   def fin_modif(self):
84     """
85       Méthode appelée après qu'une modification a été faite afin de déclencher
86       d'éventuels traitements post-modification
87     """
88     #print "fin_modif",self
89     # pour les objets autres que les commandes, aucun traitement spécifique
90     # on remonte l'info de fin de modif au parent
91     CONNECTOR.Emit(self,"valid")
92     parent= hasattr(self,"alt_parent") and self.alt_parent or self.parent
93     if parent:
94        parent.fin_modif()
95
96   def normalize(self):
97     """ Retourne le MCFACT normalisé. Pour un MCFACT isolé, l'objet normalisé
98         est une MCLIST de longueur 1 qui contient ce MCFACT
99     """
100     new_obj = self.definition.list_instance()
101     new_obj.init(nom=self.nom,parent=None)
102     new_obj.append(self)
103     return new_obj
104
105   def supprime(self):
106     self.alt_parent=None
107     Noyau.N_MCFACT.MCFACT.supprime(self)