]> SALOME platform Git repositories - tools/eficas.git/blob - InterfaceQT4/compomacro.py
Salome HOME
c5c282e2b2b44f6909379f3c2bb539e17fb4f82b
[tools/eficas.git] / InterfaceQT4 / compomacro.py
1 # -*- coding: utf-8 -*-
2 # Copyright (C) 2007-2013   EDF R&D
3 #
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.
8 #
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.
13 #
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
17 #
18 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
19 #
20
21 # Modules Python
22 import os,sys,string
23 import types
24 import traceback
25
26 # Modules Eficas
27 from Editeur import Objecttreeitem
28 from Extensions.i18n import tr
29 import compooper
30 import browser
31 import typeNode
32 from PyQt4.QtGui import QAction
33 from PyQt4.QtCore import Qt, SIGNAL, QVariant
34
35
36 class MACRONode(browser.JDCNode,typeNode.PopUpMenuNode):         
37     def getPanel(self):
38       from   monMacroPanel import MonMacroPanel
39       return MonMacroPanel (self,parent=self.editor )
40     
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)
50            else:
51               self.ViewElt.setEnabled(0)
52
53     def view3D(self) :
54         from Editeur import TroisDPal
55         troisD=TroisDPal.TroisDPilote(self.item,self.editor.appliEficas)
56         troisD.envoievisu()
57
58         
59     #def doPaste(self,node_selected):
60     #    print 'je suis la'
61     #    objetACopier = self.item.get_copie_objet()
62     #    child=self.append_brother(objetACopier)
63     #    return child
64
65     
66 class MACROTreeItem(compooper.EtapeTreeItem):
67 #  """ Cette classe hérite d'une grande partie des comportements
68 #      de la classe compooper.EtapeTreeItem
69 #  """
70     itemNode=MACRONode
71
72 # ------------------------------------
73 #  Classes necessaires a INCLUDE
74 # ------------------------------------
75
76 class INCLUDETreeItemBase(MACROTreeItem):
77
78     def __init__(self,appli, labeltext, object, setfunction):    
79        MACROTreeItem.__init__(self,appli, labeltext, object, setfunction)
80
81     def iscopiable(self):
82        return 0
83
84
85 class INCLUDENode(browser.JDCNode,typeNode.PopUpMenuNode):    
86     def getPanel(self):
87       from   monIncludePanel import MonIncludePanel
88       return MonIncludePanel (self,parent=self.editor )
89
90     def createPopUpMenu(self):
91       typeNode.PopUpMenuNode.createPopUpMenu(self)
92       
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
98                 return
99     
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,"")
103     
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 )
106      
107
108 class INCLUDETreeItem(INCLUDETreeItemBase):
109     itemNode=INCLUDENode
110     
111
112 # ------------------------------------
113 #  Classes necessaires à POURSUITE
114 # ------------------------------------
115     
116 class POURSUITENode(browser.JDCNode, typeNode.PopUpMenuNode):    
117     def getPanel(self):
118       from   monPoursuitePanel import MonPoursuitePanel
119       return MonPoursuitePanel (self,parent=self.editor )
120
121     def createPopUpMenu(self):
122       typeNode.PopUpMenuNode.createPopUpMenu(self)
123
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
128                 return
129     
130         if not hasattr(self.item.object,"jdc_aux") or self.item.object.jdc_aux is None:
131             text="""DEBUT()
132                     FIN()"""
133             self.object.build_poursuite(None,text)
134     
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)
137     
138 class POURSUITETreeItem(INCLUDETreeItemBase):
139   itemNode=POURSUITENode
140
141
142 # ----------------------------------------
143 #  Classes necessaires a INCLUDE MATERIAU
144 # ----------------------------------------
145     
146
147 class MATERIAUNode(MACRONode):
148
149     def getPanel(self):
150       from   monMacroPanel import MonMacroPanel
151       return MonMacroPanel (self,parent=self.editor )
152
153     def createPopUpMenu(self):
154       typeNode.PopUpMenuNode.createPopUpMenu(self)
155
156     def makeView(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"))
159          return
160       f = open(self.item.object.fichier_ini, "rb")
161       texte = f.read()
162       f.close()
163       from desVisu import DVisu
164       monVisuDialg=DVisu(parent=self.editor.appliEficas,fl=0)
165       monVisuDialg.TB.setText(texte)
166       monVisuDialg.show()
167
168
169 class INCLUDE_MATERIAUTreeItem(INCLUDETreeItemBase):
170     itemNode=MATERIAUNode
171
172 # ------------------------------------
173 # TreeItem
174 # ------------------------------------
175     
176
177 def treeitem(appli, labeltext, object, setfunction=None):
178    """ Factory qui retourne l'item adapte au type de macro : 
179        INCLUDE, POURSUITE, MACRO
180    """
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)
187    else:
188       return MACROTreeItem(appli, labeltext, object, setfunction)
189
190 import Accas
191 objet=Accas.MACRO_ETAPE
192     
193