1 # -*- coding: iso-8859-1 -*-
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
21 from __future__ import absolute_import
22 from __future__ import print_function
24 from builtins import str
31 from PyQt5.QtWidgets import QApplication, QMainWindow, QBoxLayout, QMenu, QAction, QMessageBox
32 from PyQt5.QtGui import QIcon
33 from PyQt5.QtCore import Qt
35 from Extensions.i18n import tr
36 from Extensions.eficas_exception import EficasException
37 from Extensions import param2
40 from myMain import Ui_Eficas
41 from .viewManager import MyTabview
42 from .getVersion import getEficasVersion
43 from Editeur import session
47 class Appli(Ui_Eficas,QMainWindow):
49 Class implementing the main user interface.
51 def __init__(self,code=None,salome=0,parent=None,ssCode=None,multi=False,langue='ang',ssIhm=False):
55 QMainWindow.__init__(self,parent)
56 Ui_Eficas.__init__(self)
59 version=getEficasVersion()
60 self.VERSION_EFICAS="Eficas QT5 Salome " + version
62 self.parentMainWindow=parent
65 self.top = self #(pour CONFIGURATION)
66 self.QWParent=None #(Pour lancement sans IHM)
75 self.ListePathCode=['Adao','ADAO','Carmel3D','Telemac','CF','MAP','ZCracks', 'SEP','SPECA','PSEN_Eficas','PSEN_N1']
76 self.listeCode=['Adao','ADAO','Carmel3D','Telemac','CF','MAP','ZCracks', 'SEP','SPECA','PSEN_Eficas','PSEN_N1']
77 self.repIcon=os.path.join( os.path.dirname(os.path.abspath(__file__)),'..','Editeur','icons')
79 if langue=='fr': self.langue=langue
80 else : self.langue="ang"
85 Accas.SalomeEntry = eficasSalome.SalomeEntry
88 self.demande=multi # specifique PSEN
91 if self.multi == False :
92 self.definitCode(code,ssCode)
97 if not self.salome and hasattr (self, 'CONFIGURATION') and hasattr(self.CONFIGURATION,'lang') : langue=self.CONFIGURATION.lang
100 self.suiteTelemac=False
101 if hasattr (self, 'CONFIGURATION') :
102 if self.CONFIGURATION.force_langue :
103 from .monChoixLangue import MonChoixLangue
104 widgetLangue = MonChoixLangue(self)
105 ret=widgetLangue.exec_()
106 self.suiteTelemac=self.CONFIGURATION.suiteTelemac
109 from Extensions import localisation
111 if hasattr (self, 'CONFIGURATION') : localisation.localise(None,self.langue,translatorFichier=self.CONFIGURATION.translatorFichier)
116 #if parent != None : self.parentCentralWidget = parent.centralWidget()
117 #else : self.parentCentralWidget = None
120 if hasattr (self, 'CONFIGURATION') and hasattr(self.CONFIGURATION,'taille') : self.taille=self.CONFIGURATION.taille
121 else : self.taille=1700
123 if self.code in ['MAP',] : self.resize(1440,self.height())
124 else : self.resize(self.taille,self.height())
127 icon = QIcon(self.repIcon+"/parametres.png")
128 self.actionParametres.setIcon(icon)
131 self.myQtab.removeTab(0)
132 self.blEntete= QBoxLayout(0,self.frameEntete)
133 self.blEntete.insertWidget(0,self.toolBar)
134 self.blEntete.insertWidget(0,self.menubar)
136 if hasattr (self, 'CONFIGURATION') and self.CONFIGURATION.closeEntete==True and self.salome: self.closeEntete()
138 eficas_root_dir = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
141 self.viewmanager = MyTabview(self)
142 self.recentMenu=QMenu(tr('&Recents'))
143 #self.menuFichier.insertMenu(self.actionOuvrir,self.recentMenu)
144 # actionARemplacer ne sert que pour l insert Menu
145 self.menuFichier.insertMenu(self.actionARemplacer ,self.recentMenu)
146 self.menuFichier.removeAction(self.actionARemplacer)
147 self.connecterSignaux()
148 self.toolBar.addSeparator()
149 if self.code != None : self.construitMenu()
151 self.setWindowTitle(self.VERSION_EFICAS)
155 #except EficasException, exc:
157 # print "je suis dans le except"
158 #if self.salome == 0 : exit()
162 def closeEntete(self):
163 self.menuBar().close()
165 self.frameEntete.close()
167 def definitCode(self,code,ssCode) :
172 from .monChoixCode import MonChoixCode
173 widgetChoix = MonChoixCode(self)
174 ret=widgetChoix.exec_()
176 if self.code == None:return # pour le cancel de la fenetre choix code
177 name='prefs_'+self.code
178 prefsCode=__import__(name)
180 self.repIni=prefsCode.repIni
182 self.format_fichier= ssCode #par defaut
183 prefsCode.NAME_SCHEME=ssCode
185 self.format_fichier="python" #par defaut
187 nameConf='configuration_'+self.code
188 configuration=__import__(nameConf)
189 self.CONFIGURATION = configuration.make_config(self,prefsCode.repIni)
190 self.CONFIGStyle = None
191 if hasattr(configuration,'make_config_style'):
192 self.CONFIGStyle = configuration.make_config_style(self,prefsCode.repIni)
193 from Extensions import localisation
195 if hasattr (self, 'CONFIGURATION') : localisation.localise(None,self.langue,translatorFichier=self.CONFIGURATION.translatorFichier)
196 #PN --> pb d exception qui font planter salome
197 # plus supporte en python 3
198 #if hasattr(prefsCode,'encoding'):
201 # sys.setdefaultencoding(prefsCode.encoding)
203 def construitMenu(self):
207 for intituleMenu in ("menuTraduction","menuOptions","menuMesh","menuExecution","menuN1"):
208 if hasattr(self,intituleMenu):
209 menu=getattr(self,intituleMenu)
210 menu.setAttribute(Qt.WA_DeleteOnClose)
212 delattr(self,intituleMenu)
213 for intituleAction in ("actionExecution","actionSaveRun"):
214 if hasattr(self,intituleAction):
215 action=getattr(self,intituleAction)
216 self.toolBar.removeAction(action)
217 if self.code.upper() in Appli.__dict__:
218 Appli.__dict__[self.code.upper()](self,)
219 if self.suiteTelemac : self.lookSuiteTelemac()
223 repAide=os.path.dirname(os.path.abspath(__file__))
224 fileName='index.html'
225 self.docPath=repAide+"/../Aide"
226 if hasattr(self,'CONFIGURATION') and hasattr(self.CONFIGURATION,'docPath') : self.docPath=self.CONFIGURATION.docPath
227 if hasattr(self,'CONFIGURATION') and hasattr(self.CONFIGURATION,'fileName'):fileName=self.CONFIGURATION.fileName
228 self.fileDoc=os.path.join(self.docPath,fileName)
229 self.actionCode.setText(tr("Aide specifique ")+str(self.code))
230 if not os.path.isfile(self.fileDoc) :
233 self.actionCode.setEnabled(False)
236 self.actionCode.setEnabled(True)
237 self.menuAide.addAction(self.actionCode)
243 dirCode=os.path.abspath(os.path.join(os.path.abspath(__file__),'../..',"ProcessOutputs_Eficas"))
244 sys.path.insert(0,dirCode)
246 self.definitCode(code,ssCode)
256 dirCode=os.path.abspath(os.path.join(os.path.abspath(__file__),'../..',code))
257 sys.path.insert(0,dirCode)
259 self.definitCode(code,ssCode)
265 self.menuN1 = self.menubar.addMenu(tr("Process Output"))
266 self.actionN1 = QAction(self)
267 self.actionN1.setText(tr("Process Output"))
268 self.menuN1.addAction(self.actionN1)
269 self.actionN1.triggered.connect(self.newN1)
272 if hasattr(self,'actionOpenProcess'):return
274 self.actionOpenProcess = QAction(self)
275 self.actionOpenProcess.setText(tr("Open Process_Output File"))
276 self.menuN1.addAction(self.actionOpenProcess)
277 self.actionOpenProcess.triggered.connect(self.openProcess)
279 def ajoutExecution(self):
280 self.menuExecution = self.menubar.addMenu(tr("&Run"))
281 self.actionExecution = QAction(self)
282 if sys.platform[0:5]=="linux":
283 icon6 = QIcon(self.repIcon+"/roue.png")
284 self.actionExecution.setIcon(icon6)
286 self.actionExecution.setText(tr("Run"))
287 self.actionExecution.setObjectName("actionExecution")
288 self.menuExecution.addAction(self.actionExecution)
289 if not(self.actionExecution in self.toolBar.actions()):
290 self.toolBar.addAction(self.actionExecution)
291 self.actionExecution.setText(tr("Run"))
292 self.actionExecution.triggered.connect(self.run)
294 def ajoutSauveExecution(self):
295 self.actionSaveRun = QAction(self)
296 icon7 = QIcon(self.repIcon+"/export_MAP.png")
297 self.actionSaveRun.setIcon(icon7)
298 self.actionSaveRun.setObjectName("actionSaveRun")
299 self.menuExecution.addAction(self.actionSaveRun)
300 if not(self.actionSaveRun in self.toolBar.actions()):
301 self.toolBar.addAction(self.actionSaveRun)
302 self.actionSaveRun.setText(tr("Save Run"))
303 self.actionSaveRun.triggered.connect(self.saveRun)
305 def griserActionsStructures(self):
306 self.actionCouper.setEnabled(False)
307 self.actionColler.setEnabled(False)
308 self.actionCopier.setEnabled(False)
309 self.actionSupprimer.setEnabled(False)
311 def enleverActionsStructures(self):
312 self.toolBar.removeAction(self.actionCopier)
313 self.toolBar.removeAction(self.actionColler)
314 self.toolBar.removeAction(self.actionCouper)
315 self.menuEdition.removeAction(self.actionCouper)
316 self.menuEdition.removeAction(self.actionCopier)
317 self.menuEdition.removeAction(self.actionColler)
320 def enleverParametres(self):
321 self.toolBar.removeAction(self.actionParametres)
322 self.menuJdC.removeAction(self.actionParametres)
324 def enleverSupprimer(self):
325 self.toolBar.removeAction(self.actionSupprimer)
327 def enleverNewInclude(self):
328 self.actionNouvel_Include.setVisible(False)
330 def enleverRechercherDsCatalogue(self):
331 self.actionRechercherDsCatalogue.setVisible(False)
333 def connectRechercherDsCatalogue(self):
334 if hasattr(self,'rechercherDejaLa') : return
335 self.rechercherDejaLa=True
336 self.actionRechercherDsCatalogue.triggered.connect(self.handleRechercherDsCatalogue)
338 def ajoutSortieLegere(self):
339 if hasattr(self,'actionSortieLegere') : return
340 self.actionSortieLegere = QAction(self)
341 self.actionSortieLegere.setText(tr("Sortie Legere"))
342 self.menuFichier.insertAction(self.actionEnregistrer_sous,self.actionSortieLegere)
343 self.actionSortieLegere.triggered.connect(self.handleSortieLegere)
347 self.enleverNewInclude()
348 self.toolBar.addSeparator()
349 self.ajoutExecution()
351 self.menuOptions = self.menubar.addMenu("menuOptions")
352 self.menuOptions.addAction(self.actionParametres_Eficas)
353 self.menuOptions.setTitle(tr("Options"))
356 self.enleverActionsStructures()
357 self.enleverNewInclude()
360 self.menuTraduction = self.menubar.addMenu("menuTraduction")
361 self.menuTraduction.addAction(self.actionTraduitV11V12)
362 self.menuTraduction.addAction(self.actionTraduitV10V11)
363 self.menuTraduction.addAction(self.actionTraduitV9V10)
364 self.menuTraduction.setTitle(tr("Traduction"))
366 self.menuFichier.addAction(self.actionSauveLigne)
368 self.menuOptions = self.menubar.addMenu("menuOptions")
369 self.menuOptions.addAction(self.actionParametres_Eficas)
370 self.menuOptions.addAction(self.actionLecteur_Pdf)
371 self.menuOptions.setTitle(tr("Options"))
374 #if self.salome == 0 : return
375 self.enleverNewInclude()
376 self.menuMesh = self.menubar.addMenu(tr("Gestion Maillage"))
377 self.menuMesh.setObjectName("Mesh")
378 self.menuMesh.addAction(self.actionChercheGrpMaille)
379 #self.griserActionsStructures()
382 self.enleverNewInclude()
383 self.enleverRechercherDsCatalogue()
384 self.ajoutExecution()
385 self.ajoutSauveExecution()
386 self.griserActionsStructures()
389 self.enleverNewInclude()
390 self.toolBar.addSeparator()
391 self.ajoutExecution()
392 self.ajoutSauveExecution()
393 self.menuOptions = self.menubar.addMenu("menuOptions")
394 self.menuOptions.addAction(self.actionParametres_Eficas)
395 self.menuOptions.setTitle(tr("Options"))
398 if self.first: self.first=0
399 try : self.action_Nouveau.triggered.disconnect(self.fileNew)
401 try : self.action_Nouveau.triggered.disconnect(self.newPSEN)
404 self.action_Nouveau.triggered.connect(self.newPSEN)
405 self.enleverActionsStructures()
406 self.enleverParametres()
407 self.enleverRechercherDsCatalogue()
408 self.enleverNewInclude()
409 self.ajoutExecution()
415 self.enleverActionsStructures()
416 self.enleverParametres()
417 self.enleverRechercherDsCatalogue()
418 self.enleverNewInclude()
419 self.ajoutExecution()
423 self.enleverActionsStructures()
424 self.enleverNewInclude()
425 self.connectRechercherDsCatalogue()
426 self.ajoutSortieLegere()
428 def lookSuiteTelemac(self):
429 self.enleverActionsStructures()
430 self.enleverNewInclude()
431 self.enleverParametres()
432 self.enleverSupprimer()
433 self.enleverRechercherDsCatalogue()
435 def ajoutHelpPSEN(self):
436 self.actionParametres_Eficas.setText('Help PSEN')
437 self.actionParametres_Eficas.triggered.connect(self.aidePSEN)
441 def ChercheGrpMesh(self):
442 Msg,listeGroup=self.ChercheGrpMeshInSalome()
444 self.viewmanager.handleAjoutGroup(listeGroup)
446 print ("il faut gerer les erreurs")
448 def ChercheGrpMaille(self):
449 # Normalement la variable self.salome permet de savoir si on est ou non dans Salome
451 Msg,listeGroup=self.ChercheGrpMailleInSalome() # recherche dans Salome
452 #Msg = None; listeGroup = None # recherche manuelle, i.e., sans Salome si ligne precedente commentee
454 raise ValueError('Salome non ouvert')
456 self.viewmanager.handleAjoutGroup(listeGroup)
458 print ("il faut gerer les erreurs")
461 def ChercheGrp(self):
462 #Msg,listeGroup=self.ChercheGrpMailleInSalome()
464 # self.viewmanager.handleAjoutGroup(listeGroup)
466 #print "il faut gerer "
470 def ajoutIcones(self) :
471 # Pour pallier les soucis de repertoire d icone
473 icon = QIcon(self.repIcon+"/new_file.png")
474 self.action_Nouveau.setIcon(icon)
475 icon1 = QIcon(self.repIcon+"/ouvrir.png")
476 self.actionOuvrir.setIcon(icon1)
477 icon2 = QIcon(self.repIcon+"/save.png")
478 self.actionEnregistrer.setIcon(icon2)
479 icon6 = QIcon(self.repIcon+"/delete.png")
480 self.actionSupprimer.setIcon(icon6)
481 icon7 = QIcon(self.repIcon+"/roue.png")
482 self.actionExecution.setIcon(icon7)
487 def connecterSignauxQT4(self) :
488 self.connect(self.recentMenu,SIGNAL('aboutToShow()'),self.handleShowRecentMenu)
490 self.connect(self.action_Nouveau,SIGNAL("triggered()"),self.fileNew)
491 self.connect(self.actionNouvel_Include,SIGNAL("triggered()"),self.NewInclude)
492 self.connect(self.actionOuvrir,SIGNAL("triggered()"),self.fileOpen)
493 self.connect(self.actionEnregistrer,SIGNAL("triggered()"),self.fileSave)
494 self.connect(self.actionEnregistrer_sous,SIGNAL("triggered()"),self.fileSaveAs)
495 self.connect(self.actionFermer,SIGNAL("triggered()"),self.fileClose)
496 self.connect(self.actionFermer_tout,SIGNAL("triggered()"),self.fileCloseAll)
497 self.connect(self.actionQuitter,SIGNAL("triggered()"),self.fileExit)
499 self.connect(self.actionEficas,SIGNAL("triggered()"),self.aidePPal)
500 self.connect(self.actionVersion,SIGNAL("triggered()"),self.version)
501 self.connect(self.actionParametres,SIGNAL("triggered()"),self.gestionParam)
503 self.connect(self.actionCouper,SIGNAL("triggered()"),self.editCut)
504 self.connect(self.actionCopier,SIGNAL("triggered()"),self.editCopy)
505 self.connect(self.actionColler,SIGNAL("triggered()"),self.editPaste)
506 self.connect(self.actionSupprimer,SIGNAL("triggered()"),self.supprimer)
507 self.connect(self.actionRechercher,SIGNAL("triggered()"),self.rechercher)
508 self.connect(self.actionDeplier_replier,SIGNAL("triggered()"),self.Deplier)
510 self.connect(self.actionRapport_de_Validation,SIGNAL("triggered()"),self.jdcRapport)
511 self.connect(self.actionRegles_du_JdC,SIGNAL("triggered()"),self.jdcRegles)
512 self.connect(self.actionFichier_Source,SIGNAL("triggered()"),self.jdcFichierSource)
513 self.connect(self.actionFichier_Resultat,SIGNAL("triggered()"),self.visuJdcPy)
519 self.actionTraduitV9V10 = QAction(self)
520 self.actionTraduitV9V10.setObjectName("actionTraduitV9V10")
521 self.actionTraduitV9V10.setText(tr("TraduitV9V10"))
522 self.actionTraduitV10V11 = QAction(self)
523 self.actionTraduitV10V11.setObjectName("actionTraduitV10V11")
524 self.actionTraduitV10V11.setText(tr("TraduitV10V11"))
525 self.actionTraduitV11V12 = QAction(self)
526 self.actionTraduitV11V12.setObjectName("actionTraduitV11V12")
527 self.actionTraduitV11V12.setText(tr("TraduitV11V12"))
528 self.actionSauveLigne = QAction(self)
529 self.actionSauveLigne.setText(tr("Sauve Format Ligne"))
531 #self.connect(self.actionParametres_Eficas,SIGNAL("triggered()"),self.optionEditeur)
532 self.connect(self.actionLecteur_Pdf,SIGNAL("triggered()"),self.optionPdf)
533 self.connect(self.actionTraduitV9V10,SIGNAL("triggered()"),self.traductionV9V10)
534 self.connect(self.actionTraduitV10V11,SIGNAL("triggered()"),self.traductionV10V11)
535 self.connect(self.actionTraduitV11V12,SIGNAL("triggered()"),self.traductionV11V12)
536 self.connect(self.actionSauveLigne,SIGNAL("triggered()"),self.sauveLigne)
540 self.actionChercheGrpMaille = QAction(self)
541 self.actionChercheGrpMaille.setText(tr("Acquiert groupe mailles"))
542 self.connect(self.actionChercheGrpMaille,SIGNAL("triggered()"),self.ChercheGrpMaille)
545 self.actionChercheGrp = QAction(self)
546 self.actionChercheGrp.setText(tr("Acquisition Groupe Maille"))
547 self.connect(self.actionChercheGrp,SIGNAL("triggered()"),self.ChercheGrp)
550 self.actionCode = QAction(self)
551 self.actionCode.setText(tr("Specificites Maille"))
552 self.connect(self.actionCode,SIGNAL("triggered()"),self.aideCode)
554 def connecterSignaux(self) :
556 self.recentMenu.aboutToShow.connect(self.handleShowRecentMenu)
557 self.action_Nouveau.triggered.connect(self.fileNew)
558 self.actionNouvel_Include.triggered.connect(self.NewInclude)
559 self.actionOuvrir.triggered.connect(self.fileOpen)
560 self.actionEnregistrer.triggered.connect(self.fileSave)
561 self.actionEnregistrer_sous.triggered.connect(self.fileSaveAs)
562 self.actionFermer.triggered.connect(self.fileClose)
563 self.actionFermer_tout.triggered.connect(self.fileCloseAll)
564 self.actionQuitter.triggered.connect(self.fileExit)
566 self.actionEficas.triggered.connect(self.aidePPal)
567 self.actionVersion.triggered.connect(self.version)
568 self.actionParametres.triggered.connect(self.gestionParam)
569 self.actionCommentaire.triggered.connect(self.ajoutCommentaire)
571 self.actionCouper.triggered.connect(self.editCut)
572 self.actionCopier.triggered.connect(self.editCopy)
573 self.actionColler.triggered.connect(self.editPaste)
574 self.actionSupprimer.triggered.connect(self.supprimer)
575 self.actionRechercher.triggered.connect(self.rechercher)
576 self.actionDeplier_replier.triggered.connect(self.Deplier)
578 self.actionRapport_de_Validation.triggered.connect(self.jdcRapport)
579 self.actionRegles_du_JdC.triggered.connect(self.jdcRegles)
580 self.actionFichier_Source.triggered.connect(self.jdcFichierSource)
581 self.actionFichier_Resultat.triggered.connect(self.visuJdcPy)
582 self.actionAfficher_l_Arbre.triggered.connect(self.ouvreArbre)
583 self.actionCacher_l_Arbre.triggered.connect(self.fermeArbre)
587 self.actionTraduitV9V10 = QAction(self)
588 self.actionTraduitV9V10.setObjectName("actionTraduitV9V10")
589 self.actionTraduitV9V10.setText(tr("TraduitV9V10"))
590 self.actionTraduitV10V11 = QAction(self)
591 self.actionTraduitV10V11.setObjectName("actionTraduitV10V11")
592 self.actionTraduitV10V11.setText(tr("TraduitV10V11"))
593 self.actionTraduitV11V12 = QAction(self)
594 self.actionTraduitV11V12.setObjectName("actionTraduitV11V12")
595 self.actionTraduitV11V12.setText(tr("TraduitV11V12"))
596 self.actionSauveLigne = QAction(self)
597 self.actionSauveLigne.setText(tr("Sauve Format Ligne"))
599 #self.actionParametres_Eficas.triggered.connect(self.optionEditeur)
600 self.actionTraduitV9V10.triggered.connect(self.traductionV9V10)
601 self.actionTraduitV10V11.triggered.connect(self.traductionV10V11)
602 self.actionTraduitV11V12.triggered.connect(self.traductionV11V12)
603 self.actionSauveLigne.triggered.connect(self.sauveLigne)
606 self.actionChercheGrpMaille = QAction(self)
607 self.actionChercheGrpMaille.setText(tr("Acquiert Groupe Maille"))
610 self.actionChercheGrp = QAction(self)
611 self.actionChercheGrp.setText(tr("Accquisition Groupe Maille"))
612 self.actionChercheGrp.triggered.connect(self.ChercheGrp)
615 self.actionCode = QAction(self)
616 self.actionCode.setText(tr("Specificites Maille"))
617 self.actionCode.triggered.connect(self.aideCode)
621 self.viewmanager.handleDeplier()
623 def ajoutCommentaire(self):
624 self.viewmanager.ajoutCommentaire()
626 def ouvreFichiers(self) :
627 # Ouverture des fichiers de commandes donnes sur la ligne de commande
630 for study in session.d_env.studies:
632 d=session.get_unit(study,self)
633 self.viewmanager.handleOpen(fichier=study["comm"],units=d)
636 def get_source(self,file):
637 # appele par Editeur/session.py
639 p=convert.plugins['python']()
641 texte=p.convert('execnoparseur')
644 def initPatrons(self) :
645 # Mise a jour du menu des fichiers recemment ouverts
646 from Editeur import listePatrons
647 if not(self.code in listePatrons.sous_menus) :
648 if hasattr(self,"menuPatrons"):
649 self.menuPatrons.setAttribute(Qt.WA_DeleteOnClose)
650 self.menuPatrons.close()
651 delattr(self,"menuPatrons")
653 if (not hasattr(self,"menuPatrons")):
654 self.menuPatrons = QMenu(self.menubar)
655 self.menuPatrons.setObjectName("menuPatrons")
656 self.menubar.addAction(self.menuPatrons.menuAction())
657 self.menuPatrons.setTitle(tr("Patrons"))
659 self.menuPatrons.clear()
660 self.listePatrons = listePatrons.listePatrons(self.code)
662 for nomSsMenu in self.listePatrons.liste:
663 ssmenu=self.menuPatrons.addMenu(nomSsMenu)
664 for fichier in self.listePatrons.liste[nomSsMenu]:
665 id = ssmenu.addAction(fichier)
666 self.ficPatrons[id]=fichier
667 self.id.triggered.connect(self.handleOpenPatrons)
668 # self.Patrons.setItemParameter(id,idx)
671 def initRecents(self):
674 if sys.platform[0:5]=="linux" :
675 rep=os.path.join(os.environ['HOME'],'.config/Eficas',self.code)
677 rep=os.path.join('C:/','.config/Eficas',self.code)
678 monFichier=rep+"/listefichiers_"+self.code
684 l=(ligne.split("\n"))[0]
685 self.recent.append(l)
693 def addToRecentList(self, fn):
694 while fn in self.recent: self.recent.remove(fn)
695 self.recent.insert(0,fn)
696 if len(self.recent) > 9:
697 self.recent = self.recent[:9]
700 def addToRecentListQT4(self, fn):
702 Public slot to add a filename to the list of recently opened files.
704 @param fn name of the file to be added
706 self.recent.removeAll(fn)
707 self.recent.prepend(fn)
708 if len(self.recent) > 9:
709 self.recent = self.recent[:9]
713 def sauveRecents(self) :
715 rep=self.CONFIGURATION.rep_user
716 monFichier=rep+"/listefichiers_"+self.code
720 f=open(monFichier,'w')
721 if len(self.recent) == 0 : return
723 while ( index < len(self.recent)):
724 ligne=str(self.recent[index])+"\n"
736 def traductionV11V12(self):
737 from .gereTraduction import traduction
738 traduction(self.CONFIGURATION.repIni,self.viewmanager,"V11V12")
740 def traductionV10V11(self):
741 from .gereTraduction import traduction
742 traduction(self.CONFIGURATION.repIni,self.viewmanager,"V10V11")
744 def traductionV9V10(self):
745 from .gereTraduction import traduction
746 traduction(self.CONFIGURATION.repIni,self.viewmanager,"V9V10")
749 from .monVisu import DVisu
750 titre = tr("version ")
751 monVisuDialg=DVisu(parent=self,fl=0)
752 monVisuDialg.setWindowTitle(titre)
753 monVisuDialg.TB.setText(self.VERSION_EFICAS +tr(" pour ") + self.code)
754 monVisuDialg.adjustSize()
758 repAide=os.path.dirname(os.path.abspath(__file__))
759 maD=os.path.join( repAide,'..','Doc','html')
761 indexAide=os.path.join(maD,'index.html')
762 if sys.platform[0:5]=="linux" : cmd="xdg-open "+indexAide
763 else : cmd="start "+indexAide
766 QMessageBox.warning( self,tr( "Aide Indisponible"),tr( "l'aide n est pas installee "))
769 repAide=os.path.dirname(os.path.abspath(__file__))
770 maD=os.path.join( repAide,'..','Doc','html')
772 indexAide=os.path.join(maD,'index.html')
773 if sys.platform[0:5]=="linux" : cmd="xdg-open "+indexAide
774 else : cmd="start "+indexAide
777 QMessageBox.warning( self,tr( "Aide Indisponible"),tr( "l'aide n est pas installee "))
780 if self.code==None : return
783 if sys.platform[0:5]=="linux" : cmd="xdg-open "+self.fileDoc
784 else : cmd="start "+self.fileDoc
788 QMessageBox.warning( self,tr( "Aide Indisponible"),tr( "l'aide n est pas installee "))
791 def optionEditeur(self) :
793 name='monOptions_'+self.code
795 QMessageBox.critical( self,tr( "Parametrage"),tr( "Veuillez d abord choisir un code"))
799 optionCode=__import__(name)
802 QMessageBox.critical( self, tr("Parametrage"), tr("Pas de possibilite de personnalisation de la configuration "))
804 monOption=optionCode.Options(parent=self,modal = 0 ,configuration=self.CONFIGURATION)
807 def optionPdf(self) :
808 from monOptionsPdf import OptionPdf
809 monOption=OptionPdf(parent=self,modal = 0 ,configuration=self.CONFIGURATION)
812 def handleSortieLegere(self):
813 return self.viewmanager.saveLegerCurrentEditor()
815 def handleShowRecentMenu(self):
817 Private method to set up recent files menu.
819 self.recentMenu.clear()
821 for rp in self.recent:
822 id = self.recentMenu.addAction(rp)
823 self.ficRecents[id]=rp
824 id.triggered.connect(self.handleOpenRecent)
825 self.recentMenu.addSeparator()
826 self.recentMenu.addAction(tr('&Effacer'), self.handleClearRecent)
828 def handleOpenPatrons(self):
830 fichier=self.repIni+"/../Editeur/Patrons/"+self.code+"/"+self.ficPatrons[idx]
831 self.viewmanager.handleOpen(fichier=fichier, patron = 1)
833 def handleOpenRecent(self):
835 fichier=self.ficRecents[idx]
836 self.viewmanager.handleOpen(fichier=fichier, patron =0 )
838 def handleClearRecent(self):
839 self.recent = QStringList()
842 def handleRechercherDsCatalogue(self):
843 if not self.viewmanager : return
844 self.viewmanager.handleRechercherDsCatalogue()
848 self.viewmanager.newEditor()
849 except EficasException as exc:
850 msg = six.text_type(exc)
851 if msg != "": QMessageBox.warning(self, tr(u"Erreur"), msg)
853 def openProcess(self):
857 dirCode=os.path.abspath(os.path.join(os.path.abspath(__file__),'../..',"ProcessOutputs_Eficas"))
858 sys.path.insert(0,dirCode)
860 self.definitCode(code,ssCode)
869 self.viewmanager.handleOpen()
870 except EficasException as exc:
871 msg = six.text_type(exc)
873 QMessageBox.warning(self, tr(u"Erreur"), msg)
875 def sauveLigne(self):
876 return self.viewmanager.sauveLigneCurrentEditor()
879 return self.viewmanager.saveCurrentEditor()
881 def fileSaveAs(self):
882 return self.viewmanager.saveAsCurrentEditor()
885 self.viewmanager.handleClose(texte='&Fermer')
887 def fileCloseAll(self):
888 self.viewmanager.handleCloseAll(texte='&Fermer')
891 # On peut sortir sur Abort
892 res=self.viewmanager.handleCloseAll()
898 self.viewmanager.handleEditCopy()
901 self.viewmanager.handleEditCut()
904 self.viewmanager.handleEditPaste()
906 def rechercher(self):
907 self.viewmanager.handleRechercher()
910 self.viewmanager.run()
913 self.viewmanager.saveRun()
917 self.viewmanager.handleSupprimer()
919 def jdcFichierSource(self):
920 self.viewmanager.handleViewJdcFichierSource()
922 def jdcRapport(self):
923 self.viewmanager.handleViewJdcRapport()
926 self.viewmanager.handleViewJdcRegles()
928 def gestionParam(self):
929 self.viewmanager.handlegestionParam()
932 self.viewmanager.handleViewJdcPy()
934 def ouvreArbre(self):
935 self.viewmanager.ouvreArbre()
937 def fermeArbre(self):
938 self.viewmanager.fermeArbre()
940 def NewInclude(self):
941 self.viewmanager.newIncludeEditor()
944 for pathCode in self.ListePathCode:
946 aEnlever=os.path.abspath(os.path.join(os.path.dirname(__file__),'..',pathCode))
947 sys.path.remove(aEnlever)
950 for pathCode in self.listeAEnlever:
952 sys.path.remove(aEnlever)
957 def closeEvent(self,event):
959 if res==2 : event.ignore()
962 if __name__=='__main__':
965 rep=os.path.abspath(os.path.join(os.path.dirname(os.path.abspath(__file__),'..','ASTER')))
967 from Aster import prefsCode
968 if hasattr(prefsCode,'encoding'):
969 # Hack pour changer le codage par defaut des strings
972 sys.setdefaultencoding(prefsCode.encoding)
973 del sys.setdefaultencoding
976 from Editeur import import_code
977 from Editeur import session
979 # Analyse des arguments de la ligne de commande
980 options=session.parse(sys.argv)
984 app = QApplication(sys.argv)
985 #app.setMainWidget(mw) (qt3)