1 # -*- coding: utf-8 -*-
2 # Copyright (C) 2007-2013 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
27 from Editeur import Objecttreeitem
28 from Extensions.i18n import tr
32 from PyQt4.QtGui import QAction
33 from PyQt4.QtCore import Qt, SIGNAL, QVariant
36 class MACRONode(browser.JDCNode,typeNode.PopUpMenuNode):
38 from monMacroPanel import MonMacroPanel
39 return MonMacroPanel (self,parent=self.editor )
41 def createPopUpMenu(self):
42 typeNode.PopUpMenuNode.createPopUpMenu(self)
43 if ("AFFE_CARA_ELEM" in self.item.get_genealogie()) and self.editor.salome:
44 self.ViewElt = QAction(tr('View3D'),self.tree)
45 self.tree.connect(self.ViewElt,SIGNAL("activated()"),self.view3D)
46 self.ViewElt.setStatusTip(tr("affiche dans Geom les elements de structure"))
47 self.menu.addAction(self.ViewElt)
48 if self.item.isvalid() :
49 self.ViewElt.setEnabled(1)
51 self.ViewElt.setEnabled(0)
54 from Editeur import TroisDPal
55 troisD=TroisDPal.TroisDPilote(self.item,self.editor.appliEficas)
59 #def doPaste(self,node_selected):
61 # objetACopier = self.item.get_copie_objet()
62 # child=self.append_brother(objetACopier)
66 class MACROTreeItem(compooper.EtapeTreeItem):
67 # """ Cette classe hérite d'une grande partie des comportements
68 # de la classe compooper.EtapeTreeItem
72 # ------------------------------------
73 # Classes necessaires a INCLUDE
74 # ------------------------------------
76 class INCLUDETreeItemBase(MACROTreeItem):
78 def __init__(self,appli, labeltext, object, setfunction):
79 MACROTreeItem.__init__(self,appli, labeltext, object, setfunction)
85 class INCLUDENode(browser.JDCNode,typeNode.PopUpMenuNode):
87 from monIncludePanel import MonIncludePanel
88 return MonIncludePanel (self,parent=self.editor )
90 def createPopUpMenu(self):
91 typeNode.PopUpMenuNode.createPopUpMenu(self)
93 def makeEdit(self): #,appli,node
94 if self.item.object.text_converted == 0:
95 # Le texte du fichier inclus n'a pas pu etre converti par le module convert
96 msg=tr("Le fichier de commande n'a pas pu etre converti pour etre editable par Eficas\n\n")
97 msg=msg+self.item.object.text_error
100 if not hasattr(self.item.object,"jdc_aux") or self.item.object.jdc_aux is None:
101 #L'include n'est pas initialise
102 self.item.object.build_include(None,"")
104 # On cree un nouvel onglet dans le bureau
105 self.editor.vm.displayJDC( self.item.object.jdc_aux , self.item.object.jdc_aux.nom )
108 class INCLUDETreeItem(INCLUDETreeItemBase):
112 # ------------------------------------
113 # Classes necessaires à POURSUITE
114 # ------------------------------------
116 class POURSUITENode(browser.JDCNode, typeNode.PopUpMenuNode):
118 from monPoursuitePanel import MonPoursuitePanel
119 return MonPoursuitePanel (self,parent=self.editor )
121 def createPopUpMenu(self):
122 typeNode.PopUpMenuNode.createPopUpMenu(self)
124 def makeEdit(self): #,appli,node
125 if self.item.object.text_converted == 0:
126 msg=tr("Le fichier de commande n'a pas pu etre converti pour etre editable par Eficas\n\n")
127 msg=msg+self.item.object.text_error
130 if not hasattr(self.item.object,"jdc_aux") or self.item.object.jdc_aux is None:
133 self.object.build_poursuite(None,text)
135 # On cree un nouvel onglet dans le bureau
136 self.editor.vm.displayJDC( self.item.object.jdc_aux , self.item.object.jdc_aux.nom)
138 class POURSUITETreeItem(INCLUDETreeItemBase):
139 itemNode=POURSUITENode
142 # ----------------------------------------
143 # Classes necessaires a INCLUDE MATERIAU
144 # ----------------------------------------
147 class MATERIAUNode(MACRONode):
150 from monMacroPanel import MonMacroPanel
151 return MonMacroPanel (self,parent=self.editor )
153 def createPopUpMenu(self):
154 typeNode.PopUpMenuNode.createPopUpMenu(self)
157 if hasattr(self.item.object,'fichier_ini') and self.item.object.fichier_ini==None:
158 QMessageBox.information( self,tr("Include vide"),tr("L'include doit etre correctement initialise pour etre visualise"))
160 f = open(self.item.object.fichier_ini, "rb")
163 from desVisu import DVisu
164 monVisuDialg=DVisu(parent=self.editor.appliEficas,fl=0)
165 monVisuDialg.TB.setText(texte)
169 class INCLUDE_MATERIAUTreeItem(INCLUDETreeItemBase):
170 itemNode=MATERIAUNode
172 # ------------------------------------
174 # ------------------------------------
177 def treeitem(appli, labeltext, object, setfunction=None):
178 """ Factory qui retourne l'item adapte au type de macro :
179 INCLUDE, POURSUITE, MACRO
181 if object.nom == "INCLUDE_MATERIAU":
182 return INCLUDE_MATERIAUTreeItem(appli, labeltext, object, setfunction)
183 elif object.nom == "INCLUDE" or object.nom== "DICTDATA":
184 return INCLUDETreeItem(appli, labeltext, object, setfunction)
185 elif object.nom == "POURSUITE":
186 return POURSUITETreeItem(appli, labeltext, object, setfunction)
188 return MACROTreeItem(appli, labeltext, object, setfunction)
191 objet=Accas.MACRO_ETAPE