Salome HOME
reindent + copyright + merge manuel avec la V9_dev sauf repertoires metier
[tools/eficas.git] / Noyau / N_UserASSDMultiple.py
1 # coding=utf-8
2 # Copyright (C) 2007-2021   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 """
23
24 from __future__ import absolute_import
25 from __future__ import print_function
26 try :
27     from builtins import object
28 except : pass
29 import traceback
30 import sys
31
32 from .N_UserASSD import UserASSD
33 from .N_ASSD import ASSD
34
35 from collections import UserList
36 class UserASSDMultiple(UserASSD):
37     """
38        Classe de base pour definir des types de structures de donnees definie par
39        l utilisateur
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
43     """
44     def __init__(self,nom='sansNom'):
45         #print ('dans init de UserASSDMultiple ',nom)
46         UserASSD.__init__(self,nom)
47         self.peres=[]
48
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)
54
55     def renomme(self,nouveauNom):
56         print ('je passe dans renomme')
57         #import traceback
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):
63             mc.demandeRedessine()
64
65
66     def initialiseParent(self, pere):
67         # surcharge N_UserASSD  parent ici n a pas de sens
68         pass
69
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)
76
77
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()
84             while (pereWithId) :
85                 if pereWithId==monEtape :
86                     listeRetour.append(pereWithId)
87                     break
88                 if pereWithId.estIdentifiePar != None :
89                     listeRetour.append(pereWithId)
90                     break
91                 pereWithId=pereWithId.parent
92         return listeRetour
93
94     def getEtapes(self):
95         listeRetour= listUserASSD()
96         for pere in self.peres :
97             if pere.etape not in listeRetour : listeRetour.append(pere.etape)
98         return listeRetour
99
100
101 class listUserASSD(UserList):
102
103     def getListeMotsCles(self,nomMc):
104         if self.data == None : return []
105         listeRetour=[]
106         for concept in self.data:
107             listeRetour.append(concept.getChild(nomMc).val)
108         return listeRetour
109
110     def getListeNomsUserASSD(self,nomMc):
111         if self.data == None : return []
112         listeRetour=[]
113         for concept in self.data:
114             listeRetour.append(concept.getChild(nomMc).val.nom)
115         return listeRetour
116
117     def getListeUserASSD(self,nomMc):
118         if self.data == None : return []
119         listeRetour=[]
120         for concept in self.data:
121             if concept.getChild(nomMc) :
122                 if concept.getChild(nomMc).val :
123                     listeRetour.append(concept.getChild(nomMc).val)
124         return listeRetour