Salome HOME
Pour V1 Carmel
[tools/eficas.git] / InterfaceQT4 / compojdc.py
1 # -*- coding: utf-8 -*-
2 # Copyright (C) 2007-2013   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 Editeur import Objecttreeitem
22 import browser
23 import typeNode
24 from Extensions.i18n import tr
25
26
27 class Node(browser.JDCNode,typeNode.PopUpMenuRacine):
28     def getPanel(self):
29         """
30         """
31         #if self.affichage_onglet==1 :
32         #   from monRacinePanel_onglet import MonRacinePanel
33         #   return MonRacinePanel(self,parent=self.editor)
34         from monRacinePanel import MonRacinePanel
35         return MonRacinePanel(self,parent=self.editor)
36
37     def getPanel2(self):
38         from monChoixCommande import MonChoixCommande
39         return MonChoixCommande(self,self.item, self.editor)
40         
41
42     def createPopUpMenu(self):
43         typeNode.PopUpMenuRacine.createPopUpMenu(self)
44
45     def addParameters(self,apres):
46         self.append_child("PARAMETRE",pos=0)
47
48
49 class JDCTreeItem(Objecttreeitem.ObjectTreeItem):
50   itemNode=Node
51   
52   def IsExpandable(self):
53     return 1
54
55   def GetText(self):
56       return  "    "
57
58   def GetLabelText(self):
59       # None --> fonte et couleur par defaut
60       return tr(self.object.nom),None,None
61
62   def get_jdc(self):
63     """
64     Retourne l'objet pointe par self
65     """
66     return self.object
67   
68   def GetIconName(self):
69     if self.object.isvalid():
70       return "ast-green-square"
71     else:
72       return "ast-red-square"
73
74   def keys(self):
75       if self.object.etapes_niveaux != []:
76           return range(len(self.object.etapes_niveaux))
77       else:
78           return range(len(self.object.etapes))
79
80   def additem(self,name,pos):
81       cmd = self._object.addentite(name,pos)
82       return cmd
83
84   def suppitem(self,item) :
85     # item             = item de l'ETAPE a supprimer du JDC
86     # item.getObject() = ETAPE ou COMMENTAIRE
87     # self.object      = JDC
88
89     itemobject=item.getObject()
90     if self.object.suppentite(itemobject):
91        if itemobject.nature == "COMMENTAIRE" :
92           message = tr("Commentaire supprime")
93        else :
94           message = tr("Commande %s supprimee",itemobject.nom)
95        self.appli.affiche_infos(message)
96        return 1
97     else:
98        self.appli.affiche_infos(tr("Pb interne : impossible de supprimer cet objet"),Qt.red)
99        return 0
100
101   def GetSubList(self):
102     """
103        Retourne la liste des items fils de l'item jdc.
104        Cette liste est conservee et mise a jour a chaque appel
105     """
106     if self.object.etapes_niveaux != []:
107         liste = self.object.etapes_niveaux
108     else:
109         liste = self.object.etapes
110     sublist=[None]*len(liste)
111     # suppression des items lies aux objets disparus
112     for item in self.sublist:
113        old_obj=item.getObject()
114        if old_obj in liste:
115           pos=liste.index(old_obj)
116           sublist[pos]=item
117        else:
118           pass # objets supprimes ignores
119     # ajout des items lies aux nouveaux objets
120     pos=0
121     for obj in liste:
122        if sublist[pos] is None:
123           # nouvel objet : on cree un nouvel item
124           item = self.make_objecttreeitem(self.appli, obj.nom + " : ", obj)
125           sublist[pos]=item
126        pos=pos+1
127
128     self.sublist=sublist
129     return self.sublist
130
131   def get_l_noms_etapes(self):
132       """ Retourne la liste des noms des etapes de self.object"""
133       return self.object.get_l_noms_etapes()
134
135   def get_liste_cmd(self):
136       listeCmd = self.object.niveau.definition.get_liste_cmd()
137       return listeCmd
138
139 import Accas
140 treeitem =JDCTreeItem
141 objet = Accas.JDC