1 # -*- coding: utf-8 -*-
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
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.get_child(self.nom)
42 if len(objet) > 1 : return 0
45 def getlabeltext(self):
47 Retourne le label de self suivant qu'il s'agit d'un MCFACT
48 isole ou d'un MCFACT appartenant a une MCList :
49 utilisee pour l'affichage dans l'arbre
51 objet = self.parent.get_child(self.nom)
52 # objet peut-etre self ou une MCList qui contient self ...
53 if objet is None or objet is self:
54 return tr("Erreur - mclist inexistante : %s", self.nom)
58 index = objet.get_index(self)+1 # + 1 a cause de la numerotation qui commence a 0
59 return self.nom +'_'+repr(index)+':'
63 return tr("Erreur - mot cle facteur de nom : %s", self.nom)
65 def get_genealogie_precise(self):
66 nom=self.getlabeltext()
67 if nom[-1]==':' : nom=nom[0:-1]
69 l=self.parent.get_genealogie_precise()
78 Met l'etat de l'objet a modified et propage au parent
79 qui vaut None s'il n'existe pas
81 self.state = 'modified'
82 parent= hasattr(self,"alt_parent") and self.alt_parent or self.parent
88 Methode appelee apres qu'une modification a ete faite afin de declencher
89 d'eventuels traitements post-modification
91 #print "fin_modif",self
92 # pour les objets autres que les commandes, aucun traitement specifique
93 # on remonte l'info de fin de modif au parent
94 CONNECTOR.Emit(self,"valid")
95 parent= hasattr(self,"alt_parent") and self.alt_parent or self.parent
100 """ Retourne le MCFACT normalise. Pour un MCFACT isole, l'objet normalise
101 est une MCLIST de longueur 1 qui contient ce MCFACT
103 new_obj = self.definition.list_instance()
104 new_obj.init(nom=self.nom,parent=None)
110 Noyau.N_MCFACT.MCFACT.supprime(self)