]> SALOME platform Git repositories - tools/eficas.git/blob - InterfaceQT4/compofact.py
Salome HOME
chgt Copyrigth
[tools/eficas.git] / InterfaceQT4 / compofact.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 from __future__ import absolute_import
22 from InterfaceQT4 import browser
23 from InterfaceQT4 import typeNode
24 from Extensions.i18n import tr
25
26
27 from Editeur import Objecttreeitem
28 import traceback
29
30
31 class Node(browser.JDCNode,typeNode.PopUpMenuNodePartiel):
32
33     def getPanelGroupe(self,parentQt,commande):
34     # ----------------------------------------
35         maDefinition=self.item.get_definition()
36         monObjet=self.item.object
37         monNom=self.item.nom
38         maCommande=commande
39         if hasattr(parentQt,'niveau'): self.niveau=parentQt.niveau+1
40         else : self.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
46            self.setPlie()
47            from InterfaceQT4.monWidgetFactPlie import MonWidgetFactPlie
48            widget=MonWidgetFactPlie(self,self.editor,parentQt,maDefinition,monObjet,self.niveau,maCommande)
49         else:
50            from InterfaceQT4.monWidgetFact import MonWidgetFact
51            widget=MonWidgetFact(self,self.editor,parentQt,maDefinition,monObjet,self.niveau,maCommande)
52         return widget
53
54
55     def createPopUpMenu(self):
56     # ------------------------
57         typeNode.PopUpMenuNodeMinimal.createPopUpMenu(self)
58
59
60 class FACTTreeItem(Objecttreeitem.ObjectTreeItem):
61   itemNode=Node
62   
63   def isExpandable(self):
64   # ----------------------
65     return 1
66
67   def getText(self):
68   # ----------------
69       return  ''
70
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
76         - la couleur du texte
77       """
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
81
82   def isValid(self):
83   # ----------------
84     return self.object.isValid()
85
86   def isCopiable(self):
87   # ----------------
88     return 1
89
90   def getIconName(self):
91   # ----------------
92     if self.object.isValid()  : return "ast-green-los"
93     elif self.object.isOblig(): return "ast-red-los"
94     else                      : return "ast-yel-los"
95
96   #PNPN ????
97   #def keys(self):
98   #  keys=self.object.mc_dict
99   #  return keys
100
101   def getSubList(self):
102   # ----------------
103       """
104          Reactualise la liste des items fils stockes dans self.sublist
105       """
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()
111          if old_obj in liste:
112             pos=liste.index(old_obj)
113             sublist[pos]=item
114          else:
115             pass # objets supprimes ignores
116       # ajout des items lies aux nouveaux objets
117       pos=0
118       for obj in liste:
119          if sublist[pos] is None:
120             # nouvel objet : on cree un nouvel item
121             def setFunction(value, object=obj):
122                 object.setval(value)
123             item = self.makeObjecttreeitem(self.appliEficas, obj.nom + " : ", obj, setFunction)
124             sublist[pos]=item
125          pos=pos+1
126
127       self.sublist=sublist
128       return self.sublist
129
130   def addItem(self,name,pos):
131     objet = self.object.addEntite(name,pos)
132     return objet
133
134   def suppItem(self,item) :
135       """ 
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 
140       """
141       itemobject=item.getObject()
142       if itemobject.isOblig() :
143          return (0, tr('Impossible de supprimer un mot-cle obligatoire '))
144
145       if self.object.suppEntite(itemobject):
146          message = tr("Mot-cle %s supprime")+ itemobject.nom
147          return (1, message)
148       else:
149          return (0,tr('Pb interne : impossible de supprimer ce mot-cle'))
150
151 import Accas
152 objet = Accas.MCFACT
153 treeitem = FACTTreeItem