Salome HOME
gitignore V1
[tools/eficas.git] / InterfaceQT4 / qtEficas.py
1 # -*- coding: iso-8859-1 -*-
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 import os, sys
22
23 from PyQt4.QtGui  import *
24 from PyQt4.QtCore import *
25 from myMain import Ui_Eficas
26 from viewManager import MyTabview
27 from getVersion import getEficasVersion
28
29 from Extensions.i18n import tr
30 from Extensions.eficas_exception import EficasException
31
32 from Editeur import session
33
34
35 class Appli(Ui_Eficas,QMainWindow):
36     """
37     Class implementing the main user interface.
38     """
39     def __init__(self,code=None,salome=0,parent=None,ssCode=None,multi=False,langue='fr',ssIhm=False):
40         """
41         Constructor
42         """
43         QMainWindow.__init__(self,parent)
44         Ui_Eficas.__init__(self)
45         self.setupUi(self)
46         self.myQtab.removeTab(0)
47         self.blEntete= QBoxLayout(0,self.frameEntete)
48         self.blEntete.insertWidget(0,self.toolBar)
49         self.blEntete.insertWidget(0,self.menubar)
50
51
52         version=getEficasVersion()
53         self.VERSION_EFICAS="Eficas QT4 "+version
54         self.salome=salome
55         self.ihm="QT"
56         self.ssIhm=ssIhm
57         self.top = self    #(pour CONFIGURATION)
58         self.QWParent=None #(Pour lancement sans IHM)
59         self.code=code
60         self.indice=0
61         self.dict_reels={}
62         self.recent =  QStringList()
63         self.ficRecents={}
64         self.listeAEnlever=[]
65         self.ListeCode=['Aster','Carmel3D','Cuve2dg','Openturns_Study','Openturns_Wrapper','MAP','ZCracks', 'CarmelCND','MT']
66         self.repIcon=os.path.join( os.path.dirname(os.path.abspath(__file__)),'../Editeur/icons')
67
68         if self.salome:
69           import Accas
70           import eficasSalome
71           Accas.SalomeEntry = eficasSalome.SalomeEntry
72
73         #self.ajoutIcones()
74         self.multi=multi
75         if langue=='fr': self.langue=langue
76         else           : self.langue="ang"
77         if self.multi == False :
78              self.definitCode(code,ssCode)
79              if code==None: return
80
81         eficas_root_dir = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
82
83         self.viewmanager = MyTabview(self)
84         self.recentMenu=self.menuFichier.addMenu(tr('&Recents'))
85         self.connecterSignaux()
86         self.toolBar.addSeparator()
87         if self.code != None : self.construitMenu()
88
89
90         self.setWindowTitle(self.VERSION_EFICAS)
91         self.ouvreFichiers()
92
93
94     #def eventFilter(QObject watched, QEvent e) :
95     #def eventFilter(watched, e) :
96     #    print "hhhhhhhhhhhhhhhhhhhhhh"
97     #    return QMainWindow.eventFilter(watched, e)
98
99    
100
101     def definitCode(self,code,ssCode) :
102         self.code=code
103         self.ssCode=ssCode
104         if self.code==None :
105            self.cleanPath()
106            from monChoixCode import MonChoixCode
107            widgetChoix = MonChoixCode(self)
108            ret=widgetChoix.exec_()
109         import sys
110         if self.code == None:return # pour le cancel de la fenetre choix code
111         name='prefs_'+self.code
112         prefsCode=__import__(name)
113
114         self.repIni=prefsCode.repIni
115         if ssCode != None :
116            self.format_fichier= ssCode  #par defaut
117            prefsCode.NAME_SCHEME=ssCode
118         else :
119            self.format_fichier="python" #par defaut
120
121         nameConf='configuration_'+self.code
122         configuration=__import__(nameConf)
123         self.CONFIGURATION = configuration.make_config(self,prefsCode.repIni)
124         self.CONFIGStyle = None
125         if hasattr(configuration,'make_config_style'):
126            self.CONFIGStyle = configuration.make_config_style(self,prefsCode.repIni)
127         if hasattr(prefsCode,'encoding'):
128            import sys
129            reload(sys)
130            sys.setdefaultencoding(prefsCode.encoding)
131
132     def construitMenu(self):
133         self.initPatrons()
134         self.initRecents()
135         self.initAides()
136         for intituleMenu in ("menuTraduction","menuOptions","menuMesh","menuExecution"):
137               if hasattr(self,intituleMenu):
138                  menu=getattr(self,intituleMenu)
139                  menu.setAttribute(Qt.WA_DeleteOnClose)
140                  menu.close()
141                  delattr(self,intituleMenu)
142         for intituleAction in ("actionExecution","actionSaveRun",):
143             if hasattr(self,intituleAction):
144               action=getattr(self,intituleAction)
145               self.toolBar.removeAction(action)
146         if self.code in Appli.__dict__.keys():
147           listeTexte=apply(Appli.__dict__[self.code],(self,))
148
149     def initAides(self):
150         #print "je passe la"
151         repAide=os.path.dirname(os.path.abspath(__file__))
152         fileName='index.html'
153         self.docPath=repAide+"/../Aide"
154         if hasattr(self,'CONFIGURATION') and hasattr(self.CONFIGURATION,'docPath') : self.docPath=self.CONFIGURATION.docPath
155         if hasattr(self,'CONFIGURATION') and hasattr(self.CONFIGURATION,'fileName'):fileName=self.CONFIGURATION.fileName
156         self.fileDoc=os.path.join(self.docPath,fileName)
157         self.actionCode.setText(tr("Aide specifique ")+str(self.code))
158         if not os.path.isfile(self.fileDoc) :
159                self.fileDoc=""
160                self.docPath=""
161                self.actionCode.setEnabled(False)
162                return
163
164         self.actionCode.setEnabled(True)
165         self.menuAide.addAction(self.actionCode)
166
167     def MAP(self):
168         self.menuExecution = self.menubar.addMenu(QApplication.translate("Eficas", "Execution", None, QApplication.UnicodeUTF8))
169         self.actionExecution = QAction(self)
170         icon6 = QIcon(self.repIcon+"/roue.png")
171         self.actionExecution.setIcon(icon6)
172         self.actionExecution.setObjectName("actionExecution")
173         self.menuExecution.addAction(self.actionExecution)
174         if not(self.actionExecution in self.toolBar.actions()):
175            self.toolBar.addAction(self.actionExecution)
176         self.actionExecution.setText(QApplication.translate("Eficas", "Execution ", None, QApplication.UnicodeUTF8))
177         self.connect(self.actionExecution,SIGNAL("activated()"),self.run)
178
179         self.actionSaveRun = QAction(self)
180         icon7 = QIcon(self.repIcon+"/export_MAP.png")
181         #icon7 = QIcon(self.repIcon+"/saveRun.png")
182         self.actionSaveRun.setIcon(icon7)
183         self.actionSaveRun.setObjectName("actionSaveRun")
184         self.menuExecution.addAction(self.actionSaveRun)
185         if not(self.actionSaveRun in self.toolBar.actions()):
186            self.toolBar.addAction(self.actionSaveRun)
187         self.actionSaveRun.setText(QApplication.translate("Eficas", "Save Run", None, QApplication.UnicodeUTF8))
188         self.connect(self.actionSaveRun,SIGNAL("activated()"),self.saveRun)
189
190         self.menuOptions = self.menubar.addMenu("menuOptions")
191         self.menuOptions.addAction(self.actionParametres_Eficas)
192         self.menuOptions.setTitle(tr("Options"))
193
194     def ZCRACKS(self):
195         self.toolBar.addSeparator()
196         self.menuExecution = self.menubar.addMenu(QApplication.translate("Eficas", "Execution", None, QApplication.UnicodeUTF8))
197         self.actionExecution = QAction(self)
198         icon6 = QIcon(self.repIcon+"/compute.png")
199         self.actionExecution.setIcon(icon6)
200         self.actionExecution.setObjectName("actionExecution")
201         self.menuExecution.addAction(self.actionExecution)
202         if not(self.actionExecution in self.toolBar.actions()):
203            self.toolBar.addAction(self.actionExecution)
204         self.actionExecution.setText(QApplication.translate("Eficas", "Execution ", None, QApplication.UnicodeUTF8))
205         self.connect(self.actionExecution,SIGNAL("activated()"),self.run)
206
207         self.menuOptions = self.menubar.addMenu("menuOptions")
208         self.menuOptions.addAction(self.actionParametres_Eficas)
209         self.menuOptions.setTitle(tr("Options"))
210
211
212     def ASTER(self) :
213         self.menuTraduction = self.menubar.addMenu("menuTraduction")
214         self.menuTraduction.addAction(self.actionTraduitV7V8)
215         self.menuTraduction.addAction(self.actionTraduitV8V9)
216         self.menuTraduction.addAction(self.actionTraduitV9V10)
217         self.menuTraduction.setTitle(tr("Traduction"))
218
219         self.menuOptions = self.menubar.addMenu("menuOptions")
220         self.menuOptions.addAction(self.actionParametres_Eficas)
221         self.menuOptions.addAction(self.actionLecteur_Pdf)
222         self.menuOptions.setTitle(tr("Options"))
223
224     def CARMEL3D(self):
225         #if self.salome == 0 : return
226         self.menuMesh = self.menubar.addMenu("menuMesh")
227         self.menuMesh.setObjectName("Mesh")
228         self.menuMesh.addAction(self.actionChercheGrpMaille)
229
230     def CARMELCND(self):
231         self.menuMesh = self.menubar.addMenu("Maillage")
232         self.menuMesh.setObjectName("Mesh")
233         self.menuMesh.addAction(self.actionChercheGrp)
234         self.menuExecution = self.menubar.addMenu(QApplication.translate("Eficas", "Execution", None, QApplication.UnicodeUTF8))
235         self.actionExecution = QAction(self)
236         icon6 = QIcon(self.repIcon+"/compute.png")
237         self.actionExecution.setIcon(icon6)
238         self.actionExecution.setObjectName("actionExecution")
239         self.menuExecution.addAction(self.actionExecution)
240         if not(self.actionExecution in self.toolBar.actions()):
241            self.toolBar.addAction(self.actionExecution)
242         self.actionExecution.setText(QApplication.translate("Eficas", "Execution ", None, QApplication.UnicodeUTF8))
243         self.connect(self.actionExecution,SIGNAL("activated()"),self.run)
244
245
246     def ChercheGrpMesh(self):
247         Msg,listeGroup=self.ChercheGrpMeshInSalome()
248         if Msg == None :
249            self.viewmanager.handleAjoutGroup(listeGroup)
250         else :
251            print "il faut gerer les erreurs"
252
253     def ChercheGrpMaille(self):
254         Msg,listeGroup=self.ChercheGrpMailleInSalome()
255         if Msg == None :
256            self.viewmanager.handleAjoutGroup(listeGroup)
257         else :
258            print "il faut gerer les erreurs"
259
260     def ChercheGrp(self):
261         #Msg,listeGroup=self.ChercheGrpMailleInSalome()
262         #if Msg == None :
263         #   self.viewmanager.handleAjoutGroup(listeGroup)
264         #else :
265         print "il faut gerer "
266
267
268     def ajoutIcones(self) :
269         # Pour pallier les soucis de repertoire d icone
270         icon = QIcon(self.repIcon+"/New24.png")
271         self.action_Nouveau.setIcon(icon)
272         icon1 = QIcon(self.repIcon+"/Open24.png")
273         self.action_Ouvrir.setIcon(icon1)
274         icon2 = QIcon(self.repIcon+"/Save24.png")
275         self.actionEnregistrer.setIcon(icon2)
276         icon3 = QIcon(self.repIcon+"/Cut24.png")
277         self.actionCouper.setIcon(icon3)
278         icon4 = QIcon(self.repIcon+"/Copy24.png")
279         self.actionCopier.setIcon(icon4)
280         icon5 = QIcon(self.repIcon+"/Paste24.png")
281         self.actionColler.setIcon(icon5)
282         icon6 = QIcon(self.repIcon+"/Delete24.png")
283         self.actionSupprimer.setIcon(icon6)
284
285
286
287     def connecterSignaux(self) :
288         self.connect(self.recentMenu,SIGNAL('aboutToShow()'),self.handleShowRecentMenu)
289
290         self.connect(self.action_Nouveau,SIGNAL("activated()"),self.fileNew)
291         self.connect(self.actionNouvel_Include,SIGNAL("activated()"),self.NewInclude)
292         self.connect(self.action_Ouvrir,SIGNAL("activated()"),self.fileOpen)
293         self.connect(self.actionEnregistrer,SIGNAL("activated()"),self.fileSave)
294         self.connect(self.actionEnregistrer_sous,SIGNAL("activated()"),self.fileSaveAs)
295         self.connect(self.actionFermer,SIGNAL("activated()"),self.fileClose)
296         self.connect(self.actionFermer_tout,SIGNAL("activated()"),self.fileCloseAll)
297         self.connect(self.actionQuitter,SIGNAL("activated()"),self.fileExit)
298
299         self.connect(self.actionEficas,SIGNAL("activated()"),self.aidePPal)
300         self.connect(self.actionVersion,SIGNAL("activated()"),self.version)
301
302         self.connect(self.actionCouper,SIGNAL("activated()"),self.editCut)
303         self.connect(self.actionCopier,SIGNAL("activated()"),self.editCopy)
304         self.connect(self.actionColler,SIGNAL("activated()"),self.editPaste)
305         self.connect(self.actionSupprimer,SIGNAL("activated()"),self.supprimer)
306         self.connect(self.actionRechercher,SIGNAL("activated()"),self.rechercher)
307         self.connect(self.actionDeplier_replier,SIGNAL("activated()"),self.Deplier)
308
309         self.connect(self.actionRapport_de_Validation,SIGNAL("activated()"),self.jdcRapport)
310         self.connect(self.actionFichier_Source,SIGNAL("activated()"),self.jdcFichierSource)
311         self.connect(self.actionFichier_Resultat,SIGNAL("activated()"),self.visuJdcPy)
312
313
314         #self.connect(self.helpIndexAction,SIGNAL("activated()"),self.helpIndex)
315         #self.connect(self.helpContentsAction,SIGNAL("activated()"),self.helpContents)
316
317         # Pour Aster
318         self.actionTraduitV7V8 = QAction(self)
319         self.actionTraduitV7V8.setObjectName("actionTraduitV7V8")
320         self.actionTraduitV8V9 = QAction(self)
321         self.actionTraduitV8V9.setObjectName("actionTraduitV8V9")
322         self.actionTraduitV9V10 = QAction(self)
323         self.actionTraduitV9V10.setObjectName("actionTraduitV9V10")
324         self.actionTraduitV7V8.setText(tr("TraduitV7V8"))
325         self.actionTraduitV8V9.setText(tr("TraduitV8V9"))
326         self.actionTraduitV9V10.setText(tr("TraduitV9V10"))
327         self.connect(self.actionParametres_Eficas,SIGNAL("activated()"),self.optionEditeur)
328         self.connect(self.actionLecteur_Pdf,SIGNAL("activated()"),self.optionPdf)
329         self.connect(self.actionTraduitV7V8,SIGNAL("activated()"),self.traductionV7V8)
330         self.connect(self.actionTraduitV8V9,SIGNAL("activated()"),self.traductionV8V9)
331         self.connect(self.actionTraduitV9V10,SIGNAL("activated()"),self.traductionV9V10)
332
333         # Pour Carmel
334         self.actionChercheGrpMaille = QAction(self)
335         self.actionChercheGrpMaille.setText(tr("Acquiert Groupe Maille"))
336         self.connect(self.actionChercheGrpMaille,SIGNAL("activated()"),self.ChercheGrpMaille)
337
338         # Pour CarmelCND
339         self.actionChercheGrp = QAction(self)
340         self.actionChercheGrp.setText(tr("Accquisition Groupe Maille"))
341         self.connect(self.actionChercheGrp,SIGNAL("activated()"),self.ChercheGrp)
342
343         # Pour Aide
344         self.actionCode = QAction(self)
345         self.actionCode.setText(tr("Specificites Maille"))
346         self.connect(self.actionCode,SIGNAL("activated()"),self.aideCode)
347
348     def Deplier(self):
349         self.viewmanager.handleDeplier()
350
351     def ouvreFichiers(self) :
352     # Ouverture des fichiers de commandes donnes sur la ligne de commande
353         cwd=os.getcwd()
354         self.dir=cwd
355         for study in session.d_env.studies:
356             os.chdir(cwd)
357             d=session.get_unit(study,self)
358             self.viewmanager.handleOpen(fichier=study["comm"],units=d)
359
360
361     def  get_source(self,file):
362     # appele par Editeur/session.py
363         import convert
364         p=convert.plugins['python']()
365         p.readfile(file)
366         texte=p.convert('execnoparseur')
367         return texte
368
369     def initPatrons(self) :
370     # Mise a jour du menu des fichiers recemment ouverts
371         from Editeur import listePatrons
372         if not(self.code in listePatrons.sous_menus.keys()) :
373            if hasattr(self,"menuPatrons"):
374               self.menuPatrons.setAttribute(Qt.WA_DeleteOnClose)
375               self.menuPatrons.close()
376               delattr(self,"menuPatrons")
377            return
378         if (not hasattr(self,"menuPatrons")):
379            self.menuPatrons = QMenu(self.menubar)
380            self.menuPatrons.setObjectName("menuPatrons")
381            self.menubar.addAction(self.menuPatrons.menuAction())
382            self.menuPatrons.setTitle(QApplication.translate("Eficas", "Patrons", None, QApplication.UnicodeUTF8))
383         else :
384            self.menuPatrons.clear()
385         self.listePatrons = listePatrons.listePatrons(self.code)
386         idx = 0
387         for nomSsMenu in self.listePatrons.liste.keys():
388             ssmenu=self.menuPatrons.addMenu(nomSsMenu)
389             for fichier in self.listePatrons.liste[nomSsMenu]:
390                id = ssmenu.addAction(fichier)
391                self.ficPatrons[id]=fichier
392                self.connect(id, SIGNAL('triggered()'),self.handleOpenPatrons)
393             #   self.Patrons.setItemParameter(id,idx)
394                idx=idx+1
395
396     def initRecents(self):
397        self.recent =  QStringList()
398        try :
399        #if 1 :
400            rep=os.path.join(os.environ['HOME'],'.config/Eficas',self.code)
401            monFichier=rep+"/listefichiers_"+self.code
402            index=0
403            f=open(monFichier)
404            while ( index < 9) :
405               ligne=f.readline()
406               if ligne != "" :
407                  l=(ligne.split("\n"))[0]
408                  self.recent.append(l)
409               index=index+1
410        except :
411        #else :
412            pass
413
414        try    : f.close()
415        except : pass
416
417     def addToRecentList(self, fn):
418         """
419         Public slot to add a filename to the list of recently opened files.
420
421         @param fn name of the file to be added
422         """
423         self.recent.removeAll(fn)
424         self.recent.prepend(fn)
425         if len(self.recent) > 9:
426             self.recent = self.recent[:9]
427
428     def sauveRecents(self) :
429        try :
430          rep=self.CONFIGURATION.rep_user
431          monFichier=rep+"/listefichiers_"+self.code
432        except :
433          return
434        try :
435             f=open(monFichier,'w')
436             if len(self.recent) == 0 : return
437             index=0
438             while ( index <  len(self.recent)):
439               ligne=str(self.recent[index])+"\n"
440               f.write(ligne)
441               index=index+1
442        except :
443             pass
444        try :
445             f.close()
446        except :
447             pass
448
449
450
451     def traductionV7V8(self):
452         from gereTraduction import traduction
453         traduction(self.CONFIGURATION.repIni,self.viewmanager,"V7V8")
454
455     def traductionV8V9(self):
456         from gereTraduction import traduction
457         traduction(self.CONFIGURATION.repIni,self.viewmanager,"V8V9")
458
459     def traductionV9V10(self):
460         from gereTraduction import traduction
461         traduction(self.CONFIGURATION.repIni,self.viewmanager,"V9V10")
462
463     def version(self) :
464         from monVisu import DVisu
465         titre = tr("version ")
466         monVisuDialg=DVisu(parent=self,fl=0)
467         monVisuDialg.setWindowTitle(titre)
468         monVisuDialg.TB.setText(self.VERSION_EFICAS +tr(" pour ") + self.code)
469         monVisuDialg.adjustSize()
470         monVisuDialg.show()
471
472     def aidePPal(self) :
473         if self.code==None : return
474         repAide=os.path.dirname(os.path.abspath(__file__))
475         maD=repAide+"/../Aide"
476         try :
477           indexAide=maD+"/fichiers_EFICAS/index.html"
478           cmd="xdg-open "+indexAide
479           os.system(cmd)
480         except:
481           QMessageBox.warning( self,tr( "Aide Indisponible"),tr( "l'aide n est pas installee "))
482
483
484     def aideCode(self) :
485         if self.code==None : return
486         try :
487         #if 1 :
488           cmd="xdg-open "+self.fileDoc
489           os.system(cmd)
490         except:
491         #else:
492           QMessageBox.warning( self,tr( "Aide Indisponible"),tr( "l'aide n est pas installee "))
493
494
495     def optionEditeur(self) :
496         try :
497            name='monOptions_'+self.code
498         except :
499            QMessageBox.critical( self,tr( "Parametrage"),tr( "Veuillez d abord choisir un code"))
500            return
501         try :
502         #if 1:
503            optionCode=__import__(name)
504         except :
505         #else :
506            QMessageBox.critical( self, tr("Parametrage"), tr("Pas de possibilite de personnalisation de la configuration "))
507            return
508         monOption=optionCode.Options(parent=self,modal = 0 ,configuration=self.CONFIGURATION)
509         monOption.show()
510
511     def optionPdf(self) :
512         from monOptionsPdf import OptionPdf
513         monOption=OptionPdf(parent=self,modal = 0 ,configuration=self.CONFIGURATION)
514         monOption.show()
515
516     def handleShowRecentMenu(self):
517         """
518         Private method to set up recent files menu.
519         """
520         self.recentMenu.clear()
521
522         for rp in self.recent:
523             id = self.recentMenu.addAction(rp)
524             self.ficRecents[id]=rp
525             self.connect(id, SIGNAL('triggered()'),self.handleOpenRecent)
526         self.recentMenu.addSeparator()
527         self.recentMenu.addAction(tr('&Effacer'), self.handleClearRecent)
528
529     def handleOpenPatrons(self):
530         idx=self.sender()
531         fichier=self.repIni+"/../Editeur/Patrons/"+self.code+"/"+self.ficPatrons[idx]
532         self.viewmanager.handleOpen(fichier=fichier, patron = 1)
533
534     def handleOpenRecent(self):
535         idx=self.sender()
536         fichier=self.ficRecents[idx]
537         self.viewmanager.handleOpen(fichier=fichier, patron =0 )
538
539     def handleClearRecent(self):
540         self.recent = QStringList()
541         self.sauveRecents()
542
543     def fileNew(self):
544         try:
545             self.viewmanager.newEditor()
546         except EficasException, exc:
547             msg = unicode(exc)
548             if msg != "":
549                 QMessageBox.warning(self, tr(u"Erreur"), msg)
550
551     def fileOpen(self):
552         try:
553             self.viewmanager.handleOpen()
554         except EficasException, exc:
555             msg = unicode(exc)
556             if msg != "":
557                 QMessageBox.warning(self, tr(u"Erreur"), msg)
558
559     def fileSave(self):
560         return self.viewmanager.saveCurrentEditor()
561
562     def fileSaveAs(self):
563         return self.viewmanager.saveAsCurrentEditor()
564
565     def fileClose(self):
566         self.viewmanager.handleClose(texte='&Fermer')
567
568     def fileCloseAll(self):
569         self.viewmanager.handleCloseAll(texte='&Fermer')
570
571     def fileExit(self):
572         # On peut sortir sur Abort
573         res=self.viewmanager.handleCloseAll()
574         if (res != 2) :
575             self.close()
576         return res
577
578     def editCopy(self):
579         self.viewmanager.handleEditCopy()
580
581     def editCut(self):
582         self.viewmanager.handleEditCut()
583
584     def editPaste(self):
585         self.viewmanager.handleEditPaste()
586
587     def rechercher(self):
588         self.viewmanager.handleRechercher()
589
590     def run(self):
591         self.viewmanager.run()
592
593     def saveRun(self):
594         self.viewmanager.saveRun()
595
596
597     def supprimer(self):
598         self.viewmanager.handleSupprimer()
599
600     def jdcFichierSource(self):
601         self.viewmanager.handleViewJdcFichierSource()
602
603     def jdcRapport(self):
604         self.viewmanager.handleViewJdcRapport()
605
606     def visuJdcPy(self):
607         self.viewmanager.handleViewJdcPy()
608
609
610     def NewInclude(self):
611         self.viewmanager.newIncludeEditor()
612
613     def cleanPath(self):
614         for pathCode in self.ListeCode:
615             try:
616               aEnlever=os.path.abspath(os.path.join(os.path.dirname(__file__),'..',pathCode))
617               sys.path.remove(aEnlever)
618             except :
619               pass
620         for pathCode in self.listeAEnlever:
621             try:
622               sys.path.remove(aEnlever)
623             except :
624               pass
625
626
627     def closeEvent(self,event):
628       res=self.fileExit()
629       if res==2 : event.ignore()
630
631 if __name__=='__main__':
632
633     # Modules Eficas
634     rep=os.path.abspath(os.path.join(os.path.dirname(os.path.abspath(__file__),'..','ASTER')))
635     sys.path.append(rep)
636     from Aster import prefsCode
637     if hasattr(prefsCode,'encoding'):
638        # Hack pour changer le codage par defaut des strings
639        import sys
640        reload(sys)
641        sys.setdefaultencoding(prefsCode.encoding)
642        del sys.setdefaultencoding
643        # Fin hack
644
645     from Editeur import import_code
646     from Editeur import session
647
648     # Analyse des arguments de la ligne de commande
649     options=session.parse(sys.argv)
650     code=options.code
651
652
653     app = QApplication(sys.argv)
654     #app.setMainWidget(mw) (qt3)
655     Eficas=Appli()
656     Eficas.show()
657
658     #app.connect(app, SIGNAL("lastWindowClosed()"), app, SLOT("quit()"))
659     #mw.ouvreFichiers()
660     #mw.show()
661
662     res=app.exec_()
663     sys.exit(res)