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
24 from __future__ import absolute_import
25 from __future__ import print_function
27 from builtins import object
32 from .N_UserASSD import UserASSD
33 from .N_ASSD import ASSD
35 from collections import UserList
36 class UserASSDMultiple(UserASSD):
38 Classe de base pour definir des types de structures de donnees definie par
40 equivalent d un concept ASSD pour un SIMP ou un FACT
41 mais pouvant referencer 2 objets par exemple les groupes de mailles qui peuvent porter
42 le meme nom dans 2 maillages differents
44 def __init__(self,nom='sansNom'):
45 #print ('dans init de UserASSDMultiple ',nom)
46 UserASSD.__init__(self,nom)
49 def ajouteUnPere(self,pere):
50 #print ('dans ajouteUnPere', self.peres, self.nom, pere)
51 if pere not in self.peres : self.peres.append(pere)
52 etape = pere.getEtape()
53 if self not in etape.userASSDCrees : etape.userASSDCrees.append(self)
55 def renomme(self,nouveauNom):
56 print ('je passe dans renomme')
58 #traceback.print_stack()
59 self.jdc.delConcept(self.nom)
60 self.jdc.sdsDict[nouveauNom] = self
61 self.setName(nouveauNom)
62 for mc in (self.utilisePar):
66 def initialiseParent(self, pere):
67 # surcharge N_UserASSD parent ici n a pas de sens
70 def deleteReference(self,mcCreateur):
71 print ('je passe dans deleteReference', mcCreateur.nom)
72 if not(mcCreateur in self.peres) : return
73 self.peres.pop(self.peres.index(mcCreateur))
74 if len(self.peres)==0 :
75 UserASSD.deleteReference(self)
78 def getParentsWithId(self):
79 #print ('je suis dans getParentsWithId ')
80 listeRetour= listUserASSD()
81 for pere in self.peres :
82 pereWithId = pere.parent
83 monEtape = pere.getEtape()
85 if pereWithId==monEtape :
86 listeRetour.append(pereWithId)
88 if pereWithId.estIdentifiePar != None :
89 listeRetour.append(pereWithId)
91 pereWithId=pereWithId.parent
95 listeRetour= listUserASSD()
96 for pere in self.peres :
97 if pere.etape not in listeRetour : listeRetour.append(pere.etape)
101 class listUserASSD(UserList):
103 def getListeMotsCles(self,nomMc):
104 if self.data == None : return []
106 for concept in self.data:
107 listeRetour.append(concept.getChild(nomMc).val)
110 def getListeNomsUserASSD(self,nomMc):
111 if self.data == None : return []
113 for concept in self.data:
114 listeRetour.append(concept.getChild(nomMc).val.nom)
117 def getListeUserASSD(self,nomMc):
118 if self.data == None : return []
120 for concept in self.data:
121 if concept.getChild(nomMc) :
122 if concept.getChild(nomMc).val :
123 listeRetour.append(concept.getChild(nomMc).val)