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
21 from __future__ import absolute_import
22 from InterfaceQT4 import browser
23 from InterfaceQT4 import typeNode
24 from Extensions.i18n import tr
27 from Editeur import Objecttreeitem
31 class Node(browser.JDCNode,typeNode.PopUpMenuNodePartiel):
33 def getPanelGroupe(self,parentQt,commande):
34 # ----------------------------------------
35 maDefinition=self.item.get_definition()
36 monObjet=self.item.object
39 if hasattr(parentQt,'niveau'): self.niveau=parentQt.niveau+1
41 if hasattr(self,'plie') and self.plie==True :
42 from InterfaceQT4.monWidgetFactPlie import MonWidgetFactPlie
43 widget=MonWidgetFactPlie(self,self.editor,parentQt,maDefinition,monObjet,self.niveau,maCommande)
44 elif self.editor.maConfiguration.afficheFirstPlies and self.firstAffiche:
45 self.firstAffiche = False
47 from InterfaceQT4.monWidgetFactPlie import MonWidgetFactPlie
48 widget=MonWidgetFactPlie(self,self.editor,parentQt,maDefinition,monObjet,self.niveau,maCommande)
50 from InterfaceQT4.monWidgetFact import MonWidgetFact
51 widget=MonWidgetFact(self,self.editor,parentQt,maDefinition,monObjet,self.niveau,maCommande)
55 def createPopUpMenu(self):
56 # ------------------------
57 typeNode.PopUpMenuNodeMinimal.createPopUpMenu(self)
60 class FACTTreeItem(Objecttreeitem.ObjectTreeItem):
63 def isExpandable(self):
64 # ----------------------
71 def getLabelText(self):
72 # ----------------------
73 """ Retourne 3 valeurs :
74 - le texte à afficher dans le noeud representant l'item
75 - la fonte dans laquelle afficher ce texte
78 # None --> fonte et couleur par defaut
79 if not(hasattr(self.object,'getLabelText')): return self.object.nom,None,None
80 return self.object.getLabelText(),None,None
84 return self.object.isValid()
90 def getIconName(self):
92 if self.object.isValid() : return "ast-green-los"
93 elif self.object.isOblig(): return "ast-red-los"
94 else : return "ast-yel-los"
98 # keys=self.object.mc_dict
101 def getSubList(self):
104 Reactualise la liste des items fils stockes dans self.sublist
106 liste=self.object.mcListe
107 sublist=[None]*len(liste)
108 # suppression des items lies aux objets disparus
109 for item in self.sublist:
110 old_obj=item.getObject()
112 pos=liste.index(old_obj)
115 pass # objets supprimes ignores
116 # ajout des items lies aux nouveaux objets
119 if sublist[pos] is None:
120 # nouvel objet : on cree un nouvel item
121 def setFunction(value, object=obj):
123 item = self.makeObjecttreeitem(self.appliEficas, obj.nom + " : ", obj, setFunction)
130 def addItem(self,name,pos):
131 objet = self.object.addEntite(name,pos)
134 def suppItem(self,item) :
136 Cette methode a pour fonction de supprimer l'item passee en argument
137 des fils de l'item FACT qui est son pere
138 - item = item du MOCLE a supprimer du MOCLE pere
139 - item.getObject() = MCSIMP ou MCBLOC
141 itemobject=item.getObject()
142 if itemobject.isOblig() :
143 return (0, tr('Impossible de supprimer un mot-cle obligatoire '))
145 if self.object.suppEntite(itemobject):
146 message = tr("Mot-cle %s supprime")+ itemobject.nom
149 return (0,tr('Pb interne : impossible de supprimer ce mot-cle'))
153 treeitem = FACTTreeItem