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):
39 from monWidgetCommande import MonWidgetCommande
40 return MonWidgetCommande (self,self.editor ,self.item.object)
43 def createPopUpMenu(self):
44 typeNode.PopUpMenuNode.createPopUpMenu(self)
45 if ("AFFE_CARA_ELEM" in self.item.get_genealogie()) and self.editor.salome:
46 self.ViewElt = QAction(tr('View3D'),self.tree)
47 self.tree.connect(self.ViewElt,SIGNAL("triggered()"),self.view3D)
48 self.ViewElt.setStatusTip(tr("affiche dans Geom les elements de structure"))
49 self.menu.addAction(self.ViewElt)
50 if self.item.isvalid() :
51 self.ViewElt.setEnabled(1)
53 self.ViewElt.setEnabled(0)
56 from Editeur import TroisDPal
57 troisD=TroisDPal.TroisDPilote(self.item,self.editor.appliEficas)
63 class MACROTreeItem(compooper.EtapeTreeItem):
64 # """ Cette classe hérite d'une grande partie des comportements
65 # de la classe compooper.EtapeTreeItem
69 # ------------------------------------
70 # Classes necessaires a INCLUDE
71 # ------------------------------------
73 class INCLUDETreeItemBase(MACROTreeItem):
75 def __init__(self,appli, labeltext, object, setfunction):
76 MACROTreeItem.__init__(self,appli, labeltext, object, setfunction)
82 class INCLUDENode(browser.JDCNode,typeNode.PopUpMenuNode):
85 from monWidgetCommande import MonWidgetCommande
86 return MonWidgetCommande (self,self.editor ,self.item.object)
88 def createPopUpMenu(self):
89 typeNode.PopUpMenuNode.createPopUpMenu(self)
91 def makeEdit(self): #,appli,node
92 if self.item.object.text_converted == 0:
93 # Le texte du fichier inclus n'a pas pu etre converti par le module convert
94 msg=tr("Le fichier de commande n'a pas pu etre converti pour etre editable par Eficas\n\n")
95 msg=msg+self.item.object.text_error
98 if not hasattr(self.item.object,"jdc_aux") or self.item.object.jdc_aux is None:
99 #L'include n'est pas initialise
100 self.item.object.build_include(None,"")
102 # On cree un nouvel onglet dans le bureau
103 self.editor.vm.displayJDC( self.item.object.jdc_aux , self.item.object.jdc_aux.nom )
106 class INCLUDETreeItem(INCLUDETreeItemBase):
110 # ------------------------------------
111 # Classes necessaires à POURSUITE
112 # ------------------------------------
114 class POURSUITENode(browser.JDCNode, typeNode.PopUpMenuNode):
117 from monWidgetCommande import MonWidgetCommande
118 return MonWidgetCommande (self,self.editor ,self.item.object)
120 def createPopUpMenu(self):
121 typeNode.PopUpMenuNode.createPopUpMenu(self)
123 def makeEdit(self): #,appli,node
124 if self.item.object.text_converted == 0:
125 msg=tr("Le fichier de commande n'a pas pu etre converti pour etre editable par Eficas\n\n")
126 msg=msg+self.item.object.text_error
129 if not hasattr(self.item.object,"jdc_aux") or self.item.object.jdc_aux is None:
132 self.object.build_poursuite(None,text)
134 # On cree un nouvel onglet dans le bureau
135 self.editor.vm.displayJDC( self.item.object.jdc_aux , self.item.object.jdc_aux.nom)
137 class POURSUITETreeItem(INCLUDETreeItemBase):
138 itemNode=POURSUITENode
141 # ----------------------------------------
142 # Classes necessaires a INCLUDE MATERIAU
143 # ----------------------------------------
146 class MATERIAUNode(MACRONode):
149 from monWidgetCommande import MonWidgetCommande
150 return MonWidgetCommande (self,self.editor ,self.item.object)
152 def createPopUpMenu(self):
153 typeNode.PopUpMenuNode.createPopUpMenu(self)
156 if hasattr(self.item.object,'fichier_ini') and self.item.object.fichier_ini==None:
157 QMessageBox.information( self,tr("Include vide"),tr("L'include doit etre correctement initialise pour etre visualise"))
159 f = open(self.item.object.fichier_ini, "rb")
162 from desVisu import DVisu
163 monVisuDialg=DVisu(parent=self.editor.appliEficas,fl=0)
164 monVisuDialg.TB.setText(texte)
168 class INCLUDE_MATERIAUTreeItem(INCLUDETreeItemBase):
169 itemNode=MATERIAUNode
171 # ------------------------------------
173 # ------------------------------------
176 def treeitem(appli, labeltext, object, setfunction=None):
177 """ Factory qui retourne l'item adapte au type de macro :
178 INCLUDE, POURSUITE, MACRO
180 if object.nom == "INCLUDE_MATERIAU":
181 return INCLUDE_MATERIAUTreeItem(appli, labeltext, object, setfunction)
182 elif object.nom == "INCLUDE" or object.nom== "DICTDATA":
183 return INCLUDETreeItem(appli, labeltext, object, setfunction)
184 elif object.nom == "POURSUITE":
185 return POURSUITETreeItem(appli, labeltext, object, setfunction)
187 return MACROTreeItem(appli, labeltext, object, setfunction)
190 objet=Accas.MACRO_ETAPE