1 # -*- coding: utf-8 -*-
2 # Copyright (C) 2007-2021 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
20 from __future__ import absolute_import
21 from Extensions.i18n import tr
22 from . import CONNECTOR
23 from . import I_MCCOMPO
26 class MCFACT(I_MCCOMPO.MCCOMPO):
27 def isRepetable(self):
29 Indique si l'objet est repetable.
30 Retourne 1 si le mot-cle facteur self peut etre repete
31 Retourne 0 dans le cas contraire
33 if self.definition.max > 1:
40 if self.definition.statut != 'o' : return 0
41 objet = self.parent.getChild(self.nom)
42 if len(objet) > 1 : return 0
47 Retourne les valeurs min et max admissibles pour la valeur de self
49 return self.definition.min,self.definition.max
51 def getNomDsXML(self):
52 # en xml on a une sequence si max est superieur a 1
54 objet = self.parent.getChild(self.nom, restreint='oui')
56 index = objet.getIndex(self)
57 nom = self.nom + "[" + str(index) + "]"
59 if self.definition.max == 1 : nom = self.nom
60 else : nom = self.nom+"[0]"
61 nomDsXML=self.parent.getNomDsXML()+"."+nom
65 def getLabelText(self):
67 Retourne le label de self suivant qu'il s'agit d'un MCFACT
68 isole ou d'un MCFACT appartenant a une MCList :
69 utilisee pour l'affichage dans l'arbre
71 objet = self.parent.getChild(self.nom, restreint='oui')
72 # objet peut-etre self ou une MCList qui contient self ...
73 if objet is None or objet is self:
74 return tr("Erreur - mclist inexistante : %s", self.nom)
78 index = objet.getIndex(self)+1 # + 1 a cause de la numerotation qui commence a 0
79 return tr(self.nom) +'_'+repr(index)+':'
83 return tr("Erreur - mot cle facteur de nom : %s", self.nom)
85 def getGenealogiePrecise(self):
86 nom=self.getLabelText()
87 if nom[-1]==':' : nom=nom[0:-1]
89 l=self.parent.getGenealogiePrecise()
98 Met l'etat de l'objet a modified et propage au parent
99 qui vaut None s'il n'existe pas
101 self.state = 'modified'
102 parent= hasattr(self,"alt_parent") and self.alt_parent or self.parent
108 Methode appelee apres qu'une modification a ete faite afin de declencher
109 d'eventuels traitements post-modification
111 #print "finModif",self
112 # pour les objets autres que les commandes, aucun traitement specifique
113 # on remonte l'info de fin de modif au parent
114 CONNECTOR.Emit(self,"valid")
115 parent= hasattr(self,"alt_parent") and self.alt_parent or self.parent
120 """ Retourne le MCFACT normalise. Pour un MCFACT isole, l'objet normalise
121 est une MCLIST de longueur 1 qui contient ce MCFACT
123 new_obj = self.definition.list_instance()
124 new_obj.init(nom=self.nom,parent=None)
130 Noyau.N_MCFACT.MCFACT.supprime(self)