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
22 from __future__ import absolute_import
28 from Editeur import Objecttreeitem
29 from Extensions.i18n import tr
30 from . import compooper
32 from . import typeNode
33 from PyQt5.QtWidgets import QAction
34 from PyQt5.QtCore import Qt
38 class MACRONode(browser.JDCNode,typeNode.PopUpMenuNode):
41 from .monWidgetCommande import MonWidgetCommande
42 return MonWidgetCommande (self,self.editor ,self.item.object)
45 def createPopUpMenu(self):
46 typeNode.PopUpMenuNode.createPopUpMenu(self)
47 if ("AFFE_CARA_ELEM" in self.item.get_genealogie()) and self.editor.salome:
48 self.ViewElt = QAction(tr('View3D'),self.tree)
49 self.ViewElt.triggered.connect(self.view3D)
50 self.ViewElt.setStatusTip(tr("affiche dans Geom les elements de structure"))
51 self.menu.addAction(self.ViewElt)
52 if self.item.isvalid() :
53 self.ViewElt.setEnabled(1)
55 self.ViewElt.setEnabled(0)
58 from Editeur import TroisDPal
59 troisD=TroisDPal.TroisDPilote(self.item,self.editor.appliEficas)
64 class MACROTreeItem(compooper.EtapeTreeItem):
65 # """ Cette classe herite d'une grande partie des comportements
66 # de la classe compooper.EtapeTreeItem
70 # ------------------------------------
71 # Classes necessaires a INCLUDE
72 # ------------------------------------
74 class INCLUDETreeItemBase(MACROTreeItem):
76 def __init__(self,appli, labeltext, object, setfunction):
77 MACROTreeItem.__init__(self,appli, labeltext, object, setfunction)
83 class INCLUDENode(browser.JDCNode,typeNode.PopUpMenuNode):
86 from .monWidgetCommande import MonWidgetCommande
87 return MonWidgetCommande (self,self.editor ,self.item.object)
89 def createPopUpMenu(self):
90 typeNode.PopUpMenuNode.createPopUpMenu(self)
92 def makeEdit(self): #,appli,node
93 if self.item.object.text_converted == 0:
94 # Le texte du fichier inclus n'a pas pu etre converti par le module convert
95 msg=tr("Le fichier de commande n'a pas pu etre converti pour etre editable par Eficas\n\n")
96 msg=msg+self.item.object.text_error
99 if not hasattr(self.item.object,"jdc_aux") or self.item.object.jdc_aux is None:
100 #L'include n'est pas initialise
101 self.item.object.build_include(None,"")
103 # On cree un nouvel onglet dans le bureau
104 self.editor.vm.displayJDC( self.item.object.jdc_aux , self.item.object.jdc_aux.nom )
107 class INCLUDETreeItem(INCLUDETreeItemBase):
111 # ------------------------------------
112 # Classes necessaires a POURSUITE
113 # ------------------------------------
115 class POURSUITENode(browser.JDCNode, typeNode.PopUpMenuNode):
118 from .monWidgetCommande import MonWidgetCommande
119 return MonWidgetCommande (self,self.editor ,self.item.object)
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 .monWidgetCommande import MonWidgetCommande
151 return MonWidgetCommande (self,self.editor ,self.item.object)
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