1 # -*- coding: iso-8859-1 -*-
2 # Copyright (C) 2007-2017 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=1,parent=None,ssCode=None,multi=False,langue='ang',ssIhm=False):
55 QMainWindow.__init__(self,parent)
56 Ui_Eficas.__init__(self)
60 version=getEficasVersion()
61 self.VERSION_EFICAS="Eficas QT5 Salome " + version
63 self.parentMainWindow=parent
66 self.top = self #(pour CONFIGURATION)
67 self.QWParent=None #(Pour lancement sans IHM)
76 self.ListePathCode=['Adao','ADAO','Carmel3D','Telemac','CF','MAP','ZCracks', 'SEP','SPECA','PSEN_Eficas','PSEN_N1']
77 self.listeCode=['Adao','ADAO','Carmel3D','Telemac','CF','MAP','ZCracks', 'SEP','SPECA','PSEN_Eficas','PSEN_N1']
78 self.repIcon=os.path.join( os.path.dirname(os.path.abspath(__file__)),'..','Editeur','icons')
80 if langue=='fr': self.langue=langue
81 else : self.langue="ang"
87 Accas.SalomeEntry = eficasSalome.SalomeEntry
89 print ('eficas hors salome')
92 self.demande=multi # specifique PSEN
95 if self.multi == False :
96 self.definitCode(code,ssCode)
101 if not self.salome and hasattr (self, 'CONFIGURATION') and hasattr(self.CONFIGURATION,'lang') : langue=self.CONFIGURATION.lang
104 self.suiteTelemac=False
105 if hasattr (self, 'CONFIGURATION') :
106 if self.CONFIGURATION.force_langue :
107 from .monChoixLangue import MonChoixLangue
108 widgetLangue = MonChoixLangue(self)
109 ret=widgetLangue.exec_()
110 self.suiteTelemac=self.CONFIGURATION.suiteTelemac
113 from Extensions import localisation
115 if hasattr (self, 'CONFIGURATION') : localisation.localise(None,self.langue,translatorFichier=self.CONFIGURATION.translatorFichier)
120 #if parent != None : self.parentCentralWidget = parent.centralWidget()
121 #else : self.parentCentralWidget = None
124 if hasattr (self, 'CONFIGURATION') and hasattr(self.CONFIGURATION,'taille') : self.taille=self.CONFIGURATION.taille
125 else : self.taille=1700
127 if self.code in ['MAP',] : self.resize(1440,self.height())
128 else : self.resize(self.taille,self.height())
131 icon = QIcon(self.repIcon+"/parametres.png")
132 self.actionParametres.setIcon(icon)
135 self.myQtab.removeTab(0)
136 self.blEntete= QBoxLayout(0,self.frameEntete)
137 self.blEntete.insertWidget(0,self.toolBar)
138 self.blEntete.insertWidget(0,self.menubar)
140 if hasattr (self, 'CONFIGURATION') and self.CONFIGURATION.closeEntete==True and self.salome: self.closeEntete()
142 eficas_root_dir = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
145 self.viewmanager = MyTabview(self)
146 self.recentMenu=QMenu(tr('&Recents'))
147 #self.menuFichier.insertMenu(self.actionOuvrir,self.recentMenu)
148 # actionARemplacer ne sert que pour l insert Menu
149 self.menuFichier.insertMenu(self.actionARemplacer ,self.recentMenu)
150 self.menuFichier.removeAction(self.actionARemplacer)
151 self.connecterSignaux()
152 self.toolBar.addSeparator()
153 if self.code != None : self.construitMenu()
155 self.setWindowTitle(self.VERSION_EFICAS)
159 #except EficasException, exc:
161 # print "je suis dans le except"
162 #if self.salome == 0 : exit()
166 def closeEntete(self):
167 self.menuBar().close()
169 self.frameEntete.close()
171 def definitCode(self,code,ssCode) :
176 from .monChoixCode import MonChoixCode
177 widgetChoix = MonChoixCode(self)
178 ret=widgetChoix.exec_()
180 if self.code == None:return # pour le cancel de la fenetre choix code
181 name='prefs_'+self.code
182 prefsCode=__import__(name)
184 self.repIni=prefsCode.repIni
186 self.format_fichier= ssCode #par defaut
187 prefsCode.NAME_SCHEME=ssCode
189 self.format_fichier="python" #par defaut
191 nameConf='configuration_'+self.code
192 configuration=__import__(nameConf)
193 self.CONFIGURATION = configuration.make_config(self,prefsCode.repIni)
194 self.CONFIGStyle = None
195 if hasattr(configuration,'make_config_style'):
196 self.CONFIGStyle = configuration.make_config_style(self,prefsCode.repIni)
197 from Extensions import localisation
199 if hasattr (self, 'CONFIGURATION') : localisation.localise(None,self.langue,translatorFichier=self.CONFIGURATION.translatorFichier)
200 #PN --> pb d exception qui font planter salome
201 # plus supporte en python 3
202 #if hasattr(prefsCode,'encoding'):
205 # sys.setdefaultencoding(prefsCode.encoding)
207 def construitMenu(self):
211 for intituleMenu in ("menuTraduction","menuOptions","menuMesh","menuExecution","menuN1"):
212 if hasattr(self,intituleMenu):
213 menu=getattr(self,intituleMenu)
214 menu.setAttribute(Qt.WA_DeleteOnClose)
216 delattr(self,intituleMenu)
217 for intituleAction in ("actionExecution","actionSaveRun"):
218 if hasattr(self,intituleAction):
219 action=getattr(self,intituleAction)
220 self.toolBar.removeAction(action)
221 if self.code.upper() in Appli.__dict__:
222 Appli.__dict__[self.code.upper()](self,)
223 if self.suiteTelemac : self.lookSuiteTelemac()
227 repAide=os.path.dirname(os.path.abspath(__file__))
228 fileName='index.html'
229 self.docPath=repAide+"/../Aide"
230 if hasattr(self,'CONFIGURATION') and hasattr(self.CONFIGURATION,'docPath') : self.docPath=self.CONFIGURATION.docPath
231 if hasattr(self,'CONFIGURATION') and hasattr(self.CONFIGURATION,'fileName'):fileName=self.CONFIGURATION.fileName
232 self.fileDoc=os.path.join(self.docPath,fileName)
233 self.actionCode.setText(tr("Aide specifique ")+str(self.code))
234 if not os.path.isfile(self.fileDoc) :
237 self.actionCode.setEnabled(False)
240 self.actionCode.setEnabled(True)
241 self.menuAide.addAction(self.actionCode)
247 dirCode=os.path.abspath(os.path.join(os.path.abspath(__file__),'../..',"ProcessOutputs_Eficas"))
248 sys.path.insert(0,dirCode)
250 self.definitCode(code,ssCode)
260 dirCode=os.path.abspath(os.path.join(os.path.abspath(__file__),'../..',code))
261 sys.path.insert(0,dirCode)
263 self.definitCode(code,ssCode)
269 self.menuN1 = self.menubar.addMenu(tr("Process Output"))
270 self.actionN1 = QAction(self)
271 self.actionN1.setText(tr("Process Output"))
272 self.menuN1.addAction(self.actionN1)
273 self.actionN1.triggered.connect(self.newN1)
276 if hasattr(self,'actionOpenProcess'):return
278 self.actionOpenProcess = QAction(self)
279 self.actionOpenProcess.setText(tr("Open Process_Output File"))
280 self.menuN1.addAction(self.actionOpenProcess)
281 self.actionOpenProcess.triggered.connect(self.openProcess)
283 def ajoutExecution(self):
284 self.menuExecution = self.menubar.addMenu(tr("&Run"))
285 self.actionExecution = QAction(self)
286 if sys.platform[0:5]=="linux":
287 icon6 = QIcon(self.repIcon+"/roue.png")
288 self.actionExecution.setIcon(icon6)
290 self.actionExecution.setText(tr("Run"))
291 self.actionExecution.setObjectName("actionExecution")
292 self.menuExecution.addAction(self.actionExecution)
293 if not(self.actionExecution in self.toolBar.actions()):
294 self.toolBar.addAction(self.actionExecution)
295 self.actionExecution.setText(tr("Run"))
296 self.actionExecution.triggered.connect(self.run)
298 def ajoutSauveExecution(self):
299 self.actionSaveRun = QAction(self)
300 icon7 = QIcon(self.repIcon+"/export_MAP.png")
301 self.actionSaveRun.setIcon(icon7)
302 self.actionSaveRun.setObjectName("actionSaveRun")
303 self.menuExecution.addAction(self.actionSaveRun)
304 if not(self.actionSaveRun in self.toolBar.actions()):
305 self.toolBar.addAction(self.actionSaveRun)
306 self.actionSaveRun.setText(tr("Save Run"))
307 self.actionSaveRun.triggered.connect(self.saveRun)
309 def griserActionsStructures(self):
310 self.actionCouper.setEnabled(False)
311 self.actionColler.setEnabled(False)
312 self.actionCopier.setEnabled(False)
313 self.actionSupprimer.setEnabled(False)
315 def enleverActionsStructures(self):
316 self.toolBar.removeAction(self.actionCopier)
317 self.toolBar.removeAction(self.actionColler)
318 self.toolBar.removeAction(self.actionCouper)
319 self.menuEdition.removeAction(self.actionCouper)
320 self.menuEdition.removeAction(self.actionCopier)
321 self.menuEdition.removeAction(self.actionColler)
324 def enleverParametres(self):
325 self.toolBar.removeAction(self.actionParametres)
326 self.menuJdC.removeAction(self.actionParametres)
328 def enleverSupprimer(self):
329 self.toolBar.removeAction(self.actionSupprimer)
331 def enleverNewInclude(self):
332 self.actionNouvel_Include.setVisible(False)
334 def enleverRechercherDsCatalogue(self):
335 self.actionRechercherDsCatalogue.setVisible(False)
337 def connectRechercherDsCatalogue(self):
338 if hasattr(self,'rechercherDejaLa') : return
339 self.rechercherDejaLa=True
340 self.actionRechercherDsCatalogue.triggered.connect(self.handleRechercherDsCatalogue)
342 def ajoutSortieLegere(self):
343 if hasattr(self,'actionSortieLegere') : return
344 self.actionSortieLegere = QAction(self)
345 self.actionSortieLegere.setText(tr("Sortie Legere"))
346 self.menuFichier.insertAction(self.actionEnregistrer_sous,self.actionSortieLegere)
347 self.actionSortieLegere.triggered.connect(self.handleSortieLegere)
351 self.enleverNewInclude()
352 self.toolBar.addSeparator()
353 self.ajoutExecution()
355 self.menuOptions = self.menubar.addMenu("menuOptions")
356 self.menuOptions.addAction(self.actionParametres_Eficas)
357 self.menuOptions.setTitle(tr("Options"))
360 self.enleverActionsStructures()
361 self.enleverNewInclude()
364 self.menuTraduction = self.menubar.addMenu("menuTraduction")
365 self.menuTraduction.addAction(self.actionTraduitV11V12)
366 self.menuTraduction.addAction(self.actionTraduitV10V11)
367 self.menuTraduction.addAction(self.actionTraduitV9V10)
368 self.menuTraduction.setTitle(tr("Traduction"))
370 self.menuFichier.addAction(self.actionSauveLigne)
372 self.menuOptions = self.menubar.addMenu("menuOptions")
373 self.menuOptions.addAction(self.actionParametres_Eficas)
374 self.menuOptions.addAction(self.actionLecteur_Pdf)
375 self.menuOptions.setTitle(tr("Options"))
378 #if self.salome == 0 : return
379 self.enleverNewInclude()
380 self.menuMesh = self.menubar.addMenu(tr("Gestion Maillage"))
381 self.menuMesh.setObjectName("Mesh")
382 self.menuMesh.addAction(self.actionChercheGrpMaille)
383 #self.griserActionsStructures()
386 self.enleverNewInclude()
387 self.enleverRechercherDsCatalogue()
388 self.ajoutExecution()
389 self.ajoutSauveExecution()
390 self.griserActionsStructures()
393 self.enleverNewInclude()
394 self.toolBar.addSeparator()
395 self.ajoutExecution()
396 self.ajoutSauveExecution()
397 self.menuOptions = self.menubar.addMenu("menuOptions")
398 self.menuOptions.addAction(self.actionParametres_Eficas)
399 self.menuOptions.setTitle(tr("Options"))
402 if self.first: self.first=0
403 try : self.action_Nouveau.triggered.disconnect(self.fileNew)
405 try : self.action_Nouveau.triggered.disconnect(self.newPSEN)
408 self.action_Nouveau.triggered.connect(self.newPSEN)
409 self.enleverActionsStructures()
410 self.enleverParametres()
411 self.enleverRechercherDsCatalogue()
412 self.enleverNewInclude()
413 self.ajoutExecution()
419 self.enleverActionsStructures()
420 self.enleverParametres()
421 self.enleverRechercherDsCatalogue()
422 self.enleverNewInclude()
423 self.ajoutExecution()
427 self.enleverActionsStructures()
428 self.enleverNewInclude()
429 self.connectRechercherDsCatalogue()
430 self.ajoutSortieLegere()
432 def lookSuiteTelemac(self):
433 self.enleverActionsStructures()
434 self.enleverNewInclude()
435 self.enleverParametres()
436 self.enleverSupprimer()
437 self.enleverRechercherDsCatalogue()
439 def ajoutHelpPSEN(self):
440 self.actionParametres_Eficas.setText('Help PSEN')
441 self.actionParametres_Eficas.triggered.connect(self.aidePSEN)
445 def ChercheGrpMesh(self):
446 Msg,listeGroup=self.ChercheGrpMeshInSalome()
448 self.viewmanager.handleAjoutGroup(listeGroup)
450 print ("il faut gerer les erreurs")
452 def ChercheGrpMaille(self):
453 # Normalement la variable self.salome permet de savoir si on est ou non dans Salome
455 Msg,listeGroup=self.ChercheGrpMailleInSalome() # recherche dans Salome
456 #Msg = None; listeGroup = None # recherche manuelle, i.e., sans Salome si ligne precedente commentee
458 raise ValueError('Salome non ouvert')
460 self.viewmanager.handleAjoutGroup(listeGroup)
462 print ("il faut gerer les erreurs")
465 def ChercheGrp(self):
466 #Msg,listeGroup=self.ChercheGrpMailleInSalome()
468 # self.viewmanager.handleAjoutGroup(listeGroup)
470 #print "il faut gerer "
474 def ajoutIcones(self) :
475 # Pour pallier les soucis de repertoire d icone
477 icon = QIcon(self.repIcon+"/new_file.png")
478 self.action_Nouveau.setIcon(icon)
479 icon1 = QIcon(self.repIcon+"/ouvrir.png")
480 self.actionOuvrir.setIcon(icon1)
481 icon2 = QIcon(self.repIcon+"/save.png")
482 self.actionEnregistrer.setIcon(icon2)
483 icon6 = QIcon(self.repIcon+"/delete.png")
484 self.actionSupprimer.setIcon(icon6)
485 icon7 = QIcon(self.repIcon+"/roue.png")
486 self.actionExecution.setIcon(icon7)
491 def connecterSignauxQT4(self) :
492 self.connect(self.recentMenu,SIGNAL('aboutToShow()'),self.handleShowRecentMenu)
494 self.connect(self.action_Nouveau,SIGNAL("triggered()"),self.fileNew)
495 self.connect(self.actionNouvel_Include,SIGNAL("triggered()"),self.NewInclude)
496 self.connect(self.actionOuvrir,SIGNAL("triggered()"),self.fileOpen)
497 self.connect(self.actionEnregistrer,SIGNAL("triggered()"),self.fileSave)
498 self.connect(self.actionEnregistrer_sous,SIGNAL("triggered()"),self.fileSaveAs)
499 self.connect(self.actionFermer,SIGNAL("triggered()"),self.fileClose)
500 self.connect(self.actionFermer_tout,SIGNAL("triggered()"),self.fileCloseAll)
501 self.connect(self.actionQuitter,SIGNAL("triggered()"),self.fileExit)
503 self.connect(self.actionEficas,SIGNAL("triggered()"),self.aidePPal)
504 self.connect(self.actionVersion,SIGNAL("triggered()"),self.version)
505 self.connect(self.actionParametres,SIGNAL("triggered()"),self.gestionParam)
507 self.connect(self.actionCouper,SIGNAL("triggered()"),self.editCut)
508 self.connect(self.actionCopier,SIGNAL("triggered()"),self.editCopy)
509 self.connect(self.actionColler,SIGNAL("triggered()"),self.editPaste)
510 self.connect(self.actionSupprimer,SIGNAL("triggered()"),self.supprimer)
511 self.connect(self.actionRechercher,SIGNAL("triggered()"),self.rechercher)
512 self.connect(self.actionDeplier_replier,SIGNAL("triggered()"),self.Deplier)
514 self.connect(self.actionRapport_de_Validation,SIGNAL("triggered()"),self.jdcRapport)
515 self.connect(self.actionRegles_du_JdC,SIGNAL("triggered()"),self.jdcRegles)
516 self.connect(self.actionFichier_Source,SIGNAL("triggered()"),self.jdcFichierSource)
517 self.connect(self.actionFichier_Resultat,SIGNAL("triggered()"),self.visuJdcPy)
523 self.actionTraduitV9V10 = QAction(self)
524 self.actionTraduitV9V10.setObjectName("actionTraduitV9V10")
525 self.actionTraduitV9V10.setText(tr("TraduitV9V10"))
526 self.actionTraduitV10V11 = QAction(self)
527 self.actionTraduitV10V11.setObjectName("actionTraduitV10V11")
528 self.actionTraduitV10V11.setText(tr("TraduitV10V11"))
529 self.actionTraduitV11V12 = QAction(self)
530 self.actionTraduitV11V12.setObjectName("actionTraduitV11V12")
531 self.actionTraduitV11V12.setText(tr("TraduitV11V12"))
532 self.actionSauveLigne = QAction(self)
533 self.actionSauveLigne.setText(tr("Sauve Format Ligne"))
535 #self.connect(self.actionParametres_Eficas,SIGNAL("triggered()"),self.optionEditeur)
536 self.connect(self.actionLecteur_Pdf,SIGNAL("triggered()"),self.optionPdf)
537 self.connect(self.actionTraduitV9V10,SIGNAL("triggered()"),self.traductionV9V10)
538 self.connect(self.actionTraduitV10V11,SIGNAL("triggered()"),self.traductionV10V11)
539 self.connect(self.actionTraduitV11V12,SIGNAL("triggered()"),self.traductionV11V12)
540 self.connect(self.actionSauveLigne,SIGNAL("triggered()"),self.sauveLigne)
544 self.actionChercheGrpMaille = QAction(self)
545 self.actionChercheGrpMaille.setText(tr("Acquiert groupe mailles"))
546 self.connect(self.actionChercheGrpMaille,SIGNAL("triggered()"),self.ChercheGrpMaille)
549 self.actionChercheGrp = QAction(self)
550 self.actionChercheGrp.setText(tr("Acquisition Groupe Maille"))
551 self.connect(self.actionChercheGrp,SIGNAL("triggered()"),self.ChercheGrp)
554 self.actionCode = QAction(self)
555 self.actionCode.setText(tr("Specificites Maille"))
556 self.connect(self.actionCode,SIGNAL("triggered()"),self.aideCode)
558 def connecterSignaux(self) :
560 self.recentMenu.aboutToShow.connect(self.handleShowRecentMenu)
561 self.action_Nouveau.triggered.connect(self.fileNew)
562 self.actionNouvel_Include.triggered.connect(self.NewInclude)
563 self.actionOuvrir.triggered.connect(self.fileOpen)
564 self.actionEnregistrer.triggered.connect(self.fileSave)
565 self.actionEnregistrer_sous.triggered.connect(self.fileSaveAs)
566 self.actionFermer.triggered.connect(self.fileClose)
567 self.actionFermer_tout.triggered.connect(self.fileCloseAll)
568 self.actionQuitter.triggered.connect(self.fileExit)
570 self.actionEficas.triggered.connect(self.aidePPal)
571 self.actionVersion.triggered.connect(self.version)
572 self.actionParametres.triggered.connect(self.gestionParam)
573 self.actionCommentaire.triggered.connect(self.ajoutCommentaire)
575 self.actionCouper.triggered.connect(self.editCut)
576 self.actionCopier.triggered.connect(self.editCopy)
577 self.actionColler.triggered.connect(self.editPaste)
578 self.actionSupprimer.triggered.connect(self.supprimer)
579 self.actionRechercher.triggered.connect(self.rechercher)
580 self.actionDeplier_replier.triggered.connect(self.Deplier)
582 self.actionRapport_de_Validation.triggered.connect(self.jdcRapport)
583 self.actionRegles_du_JdC.triggered.connect(self.jdcRegles)
584 self.actionFichier_Source.triggered.connect(self.jdcFichierSource)
585 self.actionFichier_Resultat.triggered.connect(self.visuJdcPy)
586 self.actionAfficher_l_Arbre.triggered.connect(self.ouvreArbre)
587 self.actionCacher_l_Arbre.triggered.connect(self.fermeArbre)
591 self.actionTraduitV9V10 = QAction(self)
592 self.actionTraduitV9V10.setObjectName("actionTraduitV9V10")
593 self.actionTraduitV9V10.setText(tr("TraduitV9V10"))
594 self.actionTraduitV10V11 = QAction(self)
595 self.actionTraduitV10V11.setObjectName("actionTraduitV10V11")
596 self.actionTraduitV10V11.setText(tr("TraduitV10V11"))
597 self.actionTraduitV11V12 = QAction(self)
598 self.actionTraduitV11V12.setObjectName("actionTraduitV11V12")
599 self.actionTraduitV11V12.setText(tr("TraduitV11V12"))
600 self.actionSauveLigne = QAction(self)
601 self.actionSauveLigne.setText(tr("Sauve Format Ligne"))
603 #self.actionParametres_Eficas.triggered.connect(self.optionEditeur)
604 self.actionTraduitV9V10.triggered.connect(self.traductionV9V10)
605 self.actionTraduitV10V11.triggered.connect(self.traductionV10V11)
606 self.actionTraduitV11V12.triggered.connect(self.traductionV11V12)
607 self.actionSauveLigne.triggered.connect(self.sauveLigne)
610 self.actionChercheGrpMaille = QAction(self)
611 self.actionChercheGrpMaille.setText(tr("Acquiert Groupe Maille"))
614 self.actionChercheGrp = QAction(self)
615 self.actionChercheGrp.setText(tr("Accquisition Groupe Maille"))
616 self.actionChercheGrp.triggered.connect(self.ChercheGrp)
619 self.actionCode = QAction(self)
620 self.actionCode.setText(tr("Specificites Maille"))
621 self.actionCode.triggered.connect(self.aideCode)
625 self.viewmanager.handleDeplier()
627 def ajoutCommentaire(self):
628 self.viewmanager.ajoutCommentaire()
630 def ouvreFichiers(self) :
631 # Ouverture des fichiers de commandes donnes sur la ligne de commande
634 for study in session.d_env.studies:
636 d=session.get_unit(study,self)
637 self.viewmanager.handleOpen(fichier=study["comm"],units=d)
640 def get_source(self,file):
641 # appele par Editeur/session.py
643 p=convert.plugins['python']()
645 texte=p.convert('execnoparseur')
648 def initPatrons(self) :
649 # Mise a jour du menu des fichiers recemment ouverts
650 from Editeur import listePatrons
651 if not(self.code in listePatrons.sous_menus) :
652 if hasattr(self,"menuPatrons"):
653 self.menuPatrons.setAttribute(Qt.WA_DeleteOnClose)
654 self.menuPatrons.close()
655 delattr(self,"menuPatrons")
657 if (not hasattr(self,"menuPatrons")):
658 self.menuPatrons = QMenu(self.menubar)
659 self.menuPatrons.setObjectName("menuPatrons")
660 self.menubar.addAction(self.menuPatrons.menuAction())
661 self.menuPatrons.setTitle(tr("Patrons"))
663 self.menuPatrons.clear()
664 self.listePatrons = listePatrons.listePatrons(self.code)
666 for nomSsMenu in self.listePatrons.liste:
667 ssmenu=self.menuPatrons.addMenu(nomSsMenu)
668 for fichier in self.listePatrons.liste[nomSsMenu]:
669 id = ssmenu.addAction(fichier)
670 self.ficPatrons[id]=fichier
671 self.id.triggered.connect(self.handleOpenPatrons)
672 # self.Patrons.setItemParameter(id,idx)
675 def initRecents(self):
678 if sys.platform[0:5]=="linux" :
679 rep=os.path.join(os.environ['HOME'],'.config/Eficas',self.code)
681 rep=os.path.join('C:/','.config/Eficas',self.code)
682 monFichier=rep+"/listefichiers_"+self.code
688 l=(ligne.split("\n"))[0]
689 self.recent.append(l)
697 def addToRecentList(self, fn):
698 while fn in self.recent: self.recent.remove(fn)
699 self.recent.insert(0,fn)
700 if len(self.recent) > 9:
701 self.recent = self.recent[:9]
704 def addToRecentListQT4(self, fn):
706 Public slot to add a filename to the list of recently opened files.
708 @param fn name of the file to be added
710 self.recent.removeAll(fn)
711 self.recent.prepend(fn)
712 if len(self.recent) > 9:
713 self.recent = self.recent[:9]
717 def sauveRecents(self) :
719 rep=self.CONFIGURATION.rep_user
720 monFichier=rep+"/listefichiers_"+self.code
724 f=open(monFichier,'w')
725 if len(self.recent) == 0 : return
727 while ( index < len(self.recent)):
728 ligne=str(self.recent[index])+"\n"
740 def traductionV11V12(self):
741 from .gereTraduction import traduction
742 traduction(self.CONFIGURATION.repIni,self.viewmanager,"V11V12")
744 def traductionV10V11(self):
745 from .gereTraduction import traduction
746 traduction(self.CONFIGURATION.repIni,self.viewmanager,"V10V11")
748 def traductionV9V10(self):
749 from .gereTraduction import traduction
750 traduction(self.CONFIGURATION.repIni,self.viewmanager,"V9V10")
753 from .monVisu import DVisu
754 titre = tr("version ")
755 monVisuDialg=DVisu(parent=self,fl=0)
756 monVisuDialg.setWindowTitle(titre)
757 monVisuDialg.TB.setText(self.VERSION_EFICAS +tr(" pour ") + self.code)
758 monVisuDialg.adjustSize()
762 repAide=os.path.dirname(os.path.abspath(__file__))
763 maD=os.path.join( repAide,'..','Doc')
765 indexAide=os.path.join(maD,'index.html')
766 if sys.platform[0:5]=="linux" : cmd="xdg-open "+indexAide
767 else : cmd="start "+indexAide
770 QMessageBox.warning( self,tr( "Aide Indisponible"),tr( "l'aide n est pas installee "))
773 repAide=os.path.dirname(os.path.abspath(__file__))
774 maD=os.path.join( repAide,'..','Doc')
776 indexAide=os.path.join(maD,'index.html')
777 if sys.platform[0:5]=="linux" : cmd="xdg-open "+indexAide
778 else : cmd="start "+indexAide
781 QMessageBox.warning( self,tr( "Aide Indisponible"),tr( "l'aide n est pas installee "))
784 if self.code==None : return
787 if sys.platform[0:5]=="linux" : cmd="xdg-open "+self.fileDoc
788 else : cmd="start "+self.fileDoc
792 QMessageBox.warning( self,tr( "Aide Indisponible"),tr( "l'aide n est pas installee "))
795 def optionEditeur(self) :
797 name='monOptions_'+self.code
799 QMessageBox.critical( self,tr( "Parametrage"),tr( "Veuillez d abord choisir un code"))
803 optionCode=__import__(name)
806 QMessageBox.critical( self, tr("Parametrage"), tr("Pas de possibilite de personnalisation de la configuration "))
808 monOption=optionCode.Options(parent=self,modal = 0 ,configuration=self.CONFIGURATION)
811 def optionPdf(self) :
812 from monOptionsPdf import OptionPdf
813 monOption=OptionPdf(parent=self,modal = 0 ,configuration=self.CONFIGURATION)
816 def handleSortieLegere(self):
817 return self.viewmanager.saveLegerCurrentEditor()
819 def handleShowRecentMenu(self):
821 Private method to set up recent files menu.
823 self.recentMenu.clear()
825 for rp in self.recent:
826 id = self.recentMenu.addAction(rp)
827 self.ficRecents[id]=rp
828 id.triggered.connect(self.handleOpenRecent)
829 self.recentMenu.addSeparator()
830 self.recentMenu.addAction(tr('&Effacer'), self.handleClearRecent)
832 def handleOpenPatrons(self):
834 fichier=self.repIni+"/../Editeur/Patrons/"+self.code+"/"+self.ficPatrons[idx]
835 self.viewmanager.handleOpen(fichier=fichier, patron = 1)
837 def handleOpenRecent(self):
839 fichier=self.ficRecents[idx]
840 self.viewmanager.handleOpen(fichier=fichier, patron =0 )
842 def handleClearRecent(self):
843 self.recent = QStringList()
846 def handleRechercherDsCatalogue(self):
847 if not self.viewmanager : return
848 self.viewmanager.handleRechercherDsCatalogue()
852 self.viewmanager.newEditor()
853 except EficasException as exc:
854 msg = six.text_type(exc)
855 if msg != "": QMessageBox.warning(self, tr(u"Erreur"), msg)
857 def openProcess(self):
861 dirCode=os.path.abspath(os.path.join(os.path.abspath(__file__),'../..',"ProcessOutputs_Eficas"))
862 sys.path.insert(0,dirCode)
864 self.definitCode(code,ssCode)
873 self.viewmanager.handleOpen()
874 except EficasException as exc:
875 msg = six.text_type(exc)
877 QMessageBox.warning(self, tr(u"Erreur"), msg)
879 def sauveLigne(self):
880 return self.viewmanager.sauveLigneCurrentEditor()
883 return self.viewmanager.saveCurrentEditor()
885 def fileSaveAs(self):
886 return self.viewmanager.saveAsCurrentEditor()
889 self.viewmanager.handleClose(texte='&Fermer')
891 def fileCloseAll(self):
892 self.viewmanager.handleCloseAll(texte='&Fermer')
895 # On peut sortir sur Abort
896 res=self.viewmanager.handleCloseAll()
902 self.viewmanager.handleEditCopy()
905 self.viewmanager.handleEditCut()
908 self.viewmanager.handleEditPaste()
910 def rechercher(self):
911 self.viewmanager.handleRechercher()
914 self.viewmanager.run()
917 self.viewmanager.saveRun()
921 self.viewmanager.handleSupprimer()
923 def jdcFichierSource(self):
924 self.viewmanager.handleViewJdcFichierSource()
926 def jdcRapport(self):
927 self.viewmanager.handleViewJdcRapport()
930 self.viewmanager.handleViewJdcRegles()
932 def gestionParam(self):
933 self.viewmanager.handlegestionParam()
936 self.viewmanager.handleViewJdcPy()
938 def ouvreArbre(self):
939 self.viewmanager.ouvreArbre()
941 def fermeArbre(self):
942 self.viewmanager.fermeArbre()
944 def NewInclude(self):
945 self.viewmanager.newIncludeEditor()
948 for pathCode in self.ListePathCode:
950 aEnlever=os.path.abspath(os.path.join(os.path.dirname(__file__),'..',pathCode))
951 sys.path.remove(aEnlever)
954 for pathCode in self.listeAEnlever:
956 sys.path.remove(aEnlever)
961 def closeEvent(self,event):
963 if res==2 : event.ignore()
966 if __name__=='__main__':
969 rep=os.path.abspath(os.path.join(os.path.dirname(os.path.abspath(__file__),'..','ASTER')))
971 from Aster import prefsCode
972 if hasattr(prefsCode,'encoding'):
973 # Hack pour changer le codage par defaut des strings
976 sys.setdefaultencoding(prefsCode.encoding)
977 del sys.setdefaultencoding
980 from Editeur import import_code
981 from Editeur import session
983 # Analyse des arguments de la ligne de commande
984 options=session.parse(sys.argv)
988 app = QApplication(sys.argv)
989 #app.setMainWidget(mw) (qt3)