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 )
42 from monWidgetCommande import MonWidgetCommande
43 return MonWidgetCommande (self,self.editor ,self.item.object)
46 def createPopUpMenu(self):
47 typeNode.PopUpMenuNode.createPopUpMenu(self)
48 if ("AFFE_CARA_ELEM" in self.item.get_genealogie()) and self.editor.salome:
49 self.ViewElt = QAction(tr('View3D'),self.tree)
50 self.tree.connect(self.ViewElt,SIGNAL("triggered()"),self.view3D)
51 self.ViewElt.setStatusTip(tr("affiche dans Geom les elements de structure"))
52 self.menu.addAction(self.ViewElt)
53 if self.item.isvalid() :
54 self.ViewElt.setEnabled(1)
56 self.ViewElt.setEnabled(0)
59 from Editeur import TroisDPal
60 troisD=TroisDPal.TroisDPilote(self.item,self.editor.appliEficas)
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 )
91 from monWidgetCommande import MonWidgetCommande
92 return MonWidgetCommande (self,self.editor ,self.item.object)
94 def createPopUpMenu(self):
95 typeNode.PopUpMenuNode.createPopUpMenu(self)
97 def makeEdit(self): #,appli,node
98 if self.item.object.text_converted == 0:
99 # Le texte du fichier inclus n'a pas pu etre converti par le module convert
100 msg=tr("Le fichier de commande n'a pas pu etre converti pour etre editable par Eficas\n\n")
101 msg=msg+self.item.object.text_error
104 if not hasattr(self.item.object,"jdc_aux") or self.item.object.jdc_aux is None:
105 #L'include n'est pas initialise
106 self.item.object.build_include(None,"")
108 # On cree un nouvel onglet dans le bureau
109 self.editor.vm.displayJDC( self.item.object.jdc_aux , self.item.object.jdc_aux.nom )
112 class INCLUDETreeItem(INCLUDETreeItemBase):
116 # ------------------------------------
117 # Classes necessaires à POURSUITE
118 # ------------------------------------
120 class POURSUITENode(browser.JDCNode, typeNode.PopUpMenuNode):
122 from monPoursuitePanel import MonPoursuitePanel
123 return MonPoursuitePanel (self,parent=self.editor )
126 from monWidgetCommande import MonWidgetCommande
127 return MonWidgetCommande (self,self.editor ,self.item.object)
129 def createPopUpMenu(self):
130 typeNode.PopUpMenuNode.createPopUpMenu(self)
132 def makeEdit(self): #,appli,node
133 if self.item.object.text_converted == 0:
134 msg=tr("Le fichier de commande n'a pas pu etre converti pour etre editable par Eficas\n\n")
135 msg=msg+self.item.object.text_error
138 if not hasattr(self.item.object,"jdc_aux") or self.item.object.jdc_aux is None:
141 self.object.build_poursuite(None,text)
143 # On cree un nouvel onglet dans le bureau
144 self.editor.vm.displayJDC( self.item.object.jdc_aux , self.item.object.jdc_aux.nom)
146 class POURSUITETreeItem(INCLUDETreeItemBase):
147 itemNode=POURSUITENode
150 # ----------------------------------------
151 # Classes necessaires a INCLUDE MATERIAU
152 # ----------------------------------------
155 class MATERIAUNode(MACRONode):
158 from monMacroPanel import MonMacroPanel
159 return MonMacroPanel (self,parent=self.editor )
161 def createPopUpMenu(self):
162 typeNode.PopUpMenuNode.createPopUpMenu(self)
165 if hasattr(self.item.object,'fichier_ini') and self.item.object.fichier_ini==None:
166 QMessageBox.information( self,tr("Include vide"),tr("L'include doit etre correctement initialise pour etre visualise"))
168 f = open(self.item.object.fichier_ini, "rb")
171 from desVisu import DVisu
172 monVisuDialg=DVisu(parent=self.editor.appliEficas,fl=0)
173 monVisuDialg.TB.setText(texte)
177 class INCLUDE_MATERIAUTreeItem(INCLUDETreeItemBase):
178 itemNode=MATERIAUNode
180 # ------------------------------------
182 # ------------------------------------
185 def treeitem(appli, labeltext, object, setfunction=None):
186 """ Factory qui retourne l'item adapte au type de macro :
187 INCLUDE, POURSUITE, MACRO
189 if object.nom == "INCLUDE_MATERIAU":
190 return INCLUDE_MATERIAUTreeItem(appli, labeltext, object, setfunction)
191 elif object.nom == "INCLUDE" or object.nom== "DICTDATA":
192 return INCLUDETreeItem(appli, labeltext, object, setfunction)
193 elif object.nom == "POURSUITE":
194 return POURSUITETreeItem(appli, labeltext, object, setfunction)
196 return MACROTreeItem(appli, labeltext, object, setfunction)
199 objet=Accas.MACRO_ETAPE