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 determine import monEnvQT5
34 from PyQt5.QtWidgets import QAction
35 from PyQt5.QtCore import Qt
37 from PyQt4.QtGui import *
38 from PyQt4.QtCore import *
42 class MACRONode(browser.JDCNode,typeNode.PopUpMenuNode):
45 from monWidgetCommande import MonWidgetCommande
46 return MonWidgetCommande (self,self.editor ,self.item.object)
49 def createPopUpMenu(self):
50 typeNode.PopUpMenuNode.createPopUpMenu(self)
51 if ("AFFE_CARA_ELEM" in self.item.get_genealogie()) and self.editor.salome:
52 self.ViewElt = QAction(tr('View3D'),self.tree)
54 self.ViewElt.triggered.connect(self.view3D)
56 self.tree.connect(self.ViewElt,SIGNAL("triggered()"),self.view3D)
57 self.ViewElt.setStatusTip(tr("affiche dans Geom les elements de structure"))
58 self.menu.addAction(self.ViewElt)
59 if self.item.isvalid() :
60 self.ViewElt.setEnabled(1)
62 self.ViewElt.setEnabled(0)
65 from Editeur import TroisDPal
66 troisD=TroisDPal.TroisDPilote(self.item,self.editor.appliEficas)
71 class MACROTreeItem(compooper.EtapeTreeItem):
72 # """ Cette classe hérite d'une grande partie des comportements
73 # de la classe compooper.EtapeTreeItem
77 # ------------------------------------
78 # Classes necessaires a INCLUDE
79 # ------------------------------------
81 class INCLUDETreeItemBase(MACROTreeItem):
83 def __init__(self,appli, labeltext, object, setfunction):
84 MACROTreeItem.__init__(self,appli, labeltext, object, setfunction)
90 class INCLUDENode(browser.JDCNode,typeNode.PopUpMenuNode):
93 from monWidgetCommande import MonWidgetCommande
94 return MonWidgetCommande (self,self.editor ,self.item.object)
96 def createPopUpMenu(self):
97 typeNode.PopUpMenuNode.createPopUpMenu(self)
99 def makeEdit(self): #,appli,node
100 if self.item.object.text_converted == 0:
101 # Le texte du fichier inclus n'a pas pu etre converti par le module convert
102 msg=tr("Le fichier de commande n'a pas pu etre converti pour etre editable par Eficas\n\n")
103 msg=msg+self.item.object.text_error
106 if not hasattr(self.item.object,"jdc_aux") or self.item.object.jdc_aux is None:
107 #L'include n'est pas initialise
108 self.item.object.build_include(None,"")
110 # On cree un nouvel onglet dans le bureau
111 self.editor.vm.displayJDC( self.item.object.jdc_aux , self.item.object.jdc_aux.nom )
114 class INCLUDETreeItem(INCLUDETreeItemBase):
118 # ------------------------------------
119 # Classes necessaires à POURSUITE
120 # ------------------------------------
122 class POURSUITENode(browser.JDCNode, typeNode.PopUpMenuNode):
125 from monWidgetCommande import MonWidgetCommande
126 return MonWidgetCommande (self,self.editor ,self.item.object)
128 def createPopUpMenu(self):
129 typeNode.PopUpMenuNode.createPopUpMenu(self)
131 def makeEdit(self): #,appli,node
132 if self.item.object.text_converted == 0:
133 msg=tr("Le fichier de commande n'a pas pu etre converti pour etre editable par Eficas\n\n")
134 msg=msg+self.item.object.text_error
137 if not hasattr(self.item.object,"jdc_aux") or self.item.object.jdc_aux is None:
140 self.object.build_poursuite(None,text)
142 # On cree un nouvel onglet dans le bureau
143 self.editor.vm.displayJDC( self.item.object.jdc_aux , self.item.object.jdc_aux.nom)
145 class POURSUITETreeItem(INCLUDETreeItemBase):
146 itemNode=POURSUITENode
149 # ----------------------------------------
150 # Classes necessaires a INCLUDE MATERIAU
151 # ----------------------------------------
154 class MATERIAUNode(MACRONode):
157 from monWidgetCommande import MonWidgetCommande
158 return MonWidgetCommande (self,self.editor ,self.item.object)
160 def createPopUpMenu(self):
161 typeNode.PopUpMenuNode.createPopUpMenu(self)
164 if hasattr(self.item.object,'fichier_ini') and self.item.object.fichier_ini==None:
165 QMessageBox.information( self,tr("Include vide"),tr("L'include doit etre correctement initialise pour etre visualise"))
167 f = open(self.item.object.fichier_ini, "rb")
170 from desVisu import DVisu
171 monVisuDialg=DVisu(parent=self.editor.appliEficas,fl=0)
172 monVisuDialg.TB.setText(texte)
176 class INCLUDE_MATERIAUTreeItem(INCLUDETreeItemBase):
177 itemNode=MATERIAUNode
179 # ------------------------------------
181 # ------------------------------------
184 def treeitem(appli, labeltext, object, setfunction=None):
185 """ Factory qui retourne l'item adapte au type de macro :
186 INCLUDE, POURSUITE, MACRO
188 if object.nom == "INCLUDE_MATERIAU":
189 return INCLUDE_MATERIAUTreeItem(appli, labeltext, object, setfunction)
190 elif object.nom == "INCLUDE" or object.nom== "DICTDATA":
191 return INCLUDETreeItem(appli, labeltext, object, setfunction)
192 elif object.nom == "POURSUITE":
193 return POURSUITETreeItem(appli, labeltext, object, setfunction)
195 return MACROTreeItem(appli, labeltext, object, setfunction)
198 objet=Accas.MACRO_ETAPE