2 # -*- coding: iso-8859-1 -*-
3 # Copyright (C) 2007-2021 EDF R&D
5 # This library is free software; you can redistribute it and/or
6 # modify it under the terms of the GNU Lesser General Public
7 # License as published by the Free Software Foundation; either
8 # version 2.1 of the License.
10 # This library is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 # Lesser General Public License for more details.
15 # You should have received a copy of the GNU Lesser General Public
16 # License along with this library; if not, write to the Free Software
17 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
22 from __future__ import absolute_import
23 from __future__ import print_function
25 from builtins import str
31 from PyQt5.QtWidgets import QApplication, QMainWindow, QGridLayout, QBoxLayout, QMenu, QAction, QMessageBox
32 from PyQt5.QtGui import QIcon
33 from PyQt5.QtCore import Qt, QSize
36 from Editeur import session
37 from myMain import Ui_Eficas
38 from InterfaceQT4.viewManager import MyViewManager
39 from InterfaceQT4.qtEficasSsIhm import AppliSsIhm
41 from Extensions.i18n import tr
42 from Extensions.eficas_exception import EficasException
43 from Extensions import param2
46 class Appli(AppliSsIhm,Ui_Eficas,QMainWindow):
48 Class implementing the main user interface.
50 def __init__(self,code=None,salome=1,parent=None, multi=False,langue='en',ssIhm=False, labelCode=None):
55 print ('mauvaise utilisation de la classe Appli. Utiliser AppliSsIm SVP')
58 AppliSsIhm.__init__(self,code,salome,parent,multi=multi,langue=langue,ssIhm=True, labelCode=labelCode)
59 QMainWindow.__init__(self,parent)
60 Ui_Eficas.__init__(self)
64 self.demande=multi # voir PSEN
67 if self.multi == False :
68 self.definitCode(code,None)
69 if self.code==None: return
71 self.definitCode(code,None)
72 if self.code==None: return
74 self.suiteTelemac=False
75 if hasattr (self, 'maConfiguration') :
76 if self.maConfiguration.demandeLangue :
77 from InterfaceQT4.monChoixLangue import MonChoixLangue
78 widgetLangue = MonChoixLangue(self)
79 ret=widgetLangue.exec_()
80 self.suiteTelemac=self.maConfiguration.suiteTelemac
83 if not self.salome and hasattr (self, 'maConfiguration') and hasattr(self.maConfiguration,'lang') : self.langue=self.maConfiguration.lang
84 from Extensions import localisation
86 if hasattr (self, 'maConfiguration') : localisation.localise(None,self.langue,translatorFichier=self.maConfiguration.translatorFichier)
89 #if parent != None : self.parentCentralWidget = parent.centralWidget()
90 #else : self.parentCentralWidget = None
93 if hasattr (self, 'maConfiguration') and hasattr(self.maConfiguration,'taille') : self.taille=self.maConfiguration.taille
94 else : self.taille=1700
96 self.resize(self.taille,self.height())
99 icon = QIcon(self.repIcon+"/parametres.png")
100 self.actionParametres.setIcon(icon)
101 if hasattr (self, 'maConfiguration') and self.maConfiguration.boutonDsMenuBar :
102 self.frameEntete.setMaximumSize(QSize(16777215,100))
103 self.frameEntete.setMinimumSize(QSize(0,100))
104 if hasattr (self, 'maConfiguration') and self.maConfiguration.enleverActionStructures :
105 self.enleverActionsStructures()
106 if hasattr (self, 'maConfiguration') and self.maConfiguration.enleverParametres :
107 self.enleverParametres()
108 if hasattr (self, 'maConfiguration') and self.maConfiguration.enleverSupprimer :
109 self.enleverSupprimer()
112 self.myQtab.removeTab(0)
113 self.blEnteteGlob = QBoxLayout(2,self.frameEntete)
114 self.blEnteteGlob.setSpacing(0)
115 self.blEnteteGlob.setContentsMargins(0,0,0,0)
117 self.blEntete = QBoxLayout(0)
118 self.blEntete.insertWidget(0,self.toolBar)
119 self.blEntete.insertWidget(0,self.menubar)
120 self.blEnteteGlob.insertLayout(0,self.blEntete)
124 if hasattr (self, 'maConfiguration') and self.maConfiguration.boutonDsMenuBar :
125 self.blEnteteCommmande = QBoxLayout(0)
126 self.blEnteteCommmande.insertWidget(0,self.toolBarCommande)
127 self.toolBarCommande.setIconSize(QSize(96,96))
128 self.blEnteteGlob.insertLayout(-1,self.blEnteteCommmande)
130 self.toolBarCommande.close()
133 if hasattr (self, 'maConfiguration') and self.maConfiguration.closeEntete==True and self.salome: self.closeEntete()
135 eficas_root_dir = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
137 self.viewmanager = MyViewManager(self)
138 self.recentMenu=QMenu(tr('&Recents'))
139 #self.menuFichier.insertMenu(self.actionOuvrir,self.recentMenu)
141 # actionARemplacer ne sert que pour l insert Menu
142 self.menuFichier.insertMenu(self.actionARemplacer ,self.recentMenu)
143 self.menuFichier.removeAction(self.actionARemplacer)
144 self.connecterSignaux()
145 self.toolBar.addSeparator()
148 if self.code != None : self.construitMenu()
150 self.setWindowTitle(self.VERSION_EFICAS)
153 #print ('attention try devient if 1')
155 except EficasException as 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 InterfaceQT4.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 AppliSsIhm.definitCode(self,self.code,ssCode)
179 #PN --> pb d exception qui font planter salome
180 # plus supporte en python 3
182 #if hasattr(prefsCode,'encoding'):
185 # sys.setdefaultencoding(prefsCode.encoding)
187 def construitMenu(self):
191 for intituleMenu in ("menuTraduction","menuOptions","menuMesh","menuExecution","menuN1"):
192 if hasattr(self,intituleMenu):
193 menu=getattr(self,intituleMenu)
194 menu.setAttribute(Qt.WA_DeleteOnClose)
196 delattr(self,intituleMenu)
197 for intituleAction in ("actionExecution","actionSaveRun"):
198 if hasattr(self,intituleAction):
199 action=getattr(self,intituleAction)
200 self.toolBar.removeAction(action)
201 if self.code.upper() in Appli.__dict__:
202 Appli.__dict__[self.code.upper()](self,)
203 if self.suiteTelemac : self.lookSuiteTelemac()
204 self.metMenuAJourUtilisateurs()
205 if hasattr (self, 'maConfiguration') and self.maConfiguration.ajoutExecution :
206 self.ajoutExecution()
210 repAide=os.path.dirname(os.path.abspath(__file__))
211 fileName='index.html'
212 self.docPath=repAide+"/../Aide"
213 if hasattr(self,'maConfiguration') and hasattr(self.maConfiguration,'docPath') : self.docPath=self.maConfiguration.docPath
214 if hasattr(self,'maConfiguration') and hasattr(self.maConfiguration,'fileName'):fileName=self.maConfiguration.fileName
215 self.fileDoc=os.path.join(self.docPath,fileName)
216 self.actionCode.setText(tr("Aide specifique ")+str(self.code))
217 if not os.path.isfile(self.fileDoc) :
220 self.actionCode.setEnabled(False)
223 self.actionCode.setEnabled(True)
224 self.menuAide.addAction(self.actionCode)
230 dirCode=os.path.abspath(os.path.join(os.path.abspath(__file__),'../..',"ProcessOutputs_Eficas"))
231 sys.path.insert(0,dirCode)
233 self.definitCode(code,ssCode)
243 dirCode=os.path.abspath(os.path.join(os.path.abspath(__file__),'../..',code))
244 sys.path.insert(0,dirCode)
246 self.definitCode(code,ssCode)
253 self.menuN1 = self.menubar.addMenu(tr("Process Output"))
254 self.actionN1 = QAction(self)
255 self.actionN1.setText(tr("Process Output"))
256 self.menuN1.addAction(self.actionN1)
257 self.actionN1.triggered.connect(self.newN1)
260 if hasattr(self,'actionOpenProcess'):return
262 self.actionOpenProcess = QAction(self)
263 self.actionOpenProcess.setText(tr("Open Process_Output File"))
264 self.menuN1.addAction(self.actionOpenProcess)
265 self.actionOpenProcess.triggered.connect(self.openProcess)
267 def ajoutExecution(self):
268 self.menuExecution = self.menubar.addMenu(tr("&Run"))
269 self.actionExecution = QAction(self)
270 if sys.platform[0:5]=="linux":
271 icon6 = QIcon(self.repIcon+"/roue.png")
272 self.actionExecution.setIcon(icon6)
274 self.actionExecution.setText(tr("Run"))
275 self.actionExecution.setObjectName("actionExecution")
276 self.menuExecution.addAction(self.actionExecution)
277 if not(self.actionExecution in self.toolBar.actions()):
278 self.toolBar.addAction(self.actionExecution)
279 self.actionExecution.setText(tr("Run"))
280 self.actionExecution.triggered.connect(self.run)
282 def ajoutSauveExecution(self):
283 self.actionSaveRun = QAction(self)
284 icon7 = QIcon(self.repIcon+"/export_MAP.png")
285 self.actionSaveRun.setIcon(icon7)
286 self.actionSaveRun.setObjectName("actionSaveRun")
287 self.menuExecution.addAction(self.actionSaveRun)
288 if not(self.actionSaveRun in self.toolBar.actions()):
289 self.toolBar.addAction(self.actionSaveRun)
290 self.actionSaveRun.setText(tr("Save Run"))
291 self.actionSaveRun.triggered.connect(self.saveRun)
293 def griserActionsStructures(self):
294 self.actionCouper.setEnabled(False)
295 self.actionColler.setEnabled(False)
296 self.actionCopier.setEnabled(False)
297 self.actionSupprimer.setEnabled(False)
299 def enleverActionsStructures(self):
300 self.toolBar.removeAction(self.actionCopier)
301 self.toolBar.removeAction(self.actionColler)
302 self.toolBar.removeAction(self.actionCouper)
303 self.menuEdition.removeAction(self.actionCouper)
304 self.menuEdition.removeAction(self.actionCopier)
305 self.menuEdition.removeAction(self.actionColler)
308 def enleverParametres(self):
309 self.toolBar.removeAction(self.actionParametres)
310 self.menuJdC.removeAction(self.actionParametres)
312 def enleverSupprimer(self):
313 self.toolBar.removeAction(self.actionSupprimer)
315 def enlevernewInclude(self):
316 self.actionNouvel_Include.setVisible(False)
318 def enleverRechercherDsCatalogue(self):
319 self.actionRechercherDsCatalogue.setVisible(False)
321 def connectRechercherDsCatalogue(self):
322 if hasattr(self,'rechercherDejaLa') : return
323 self.rechercherDejaLa=True
324 self.actionRechercherDsCatalogue.triggered.connect(self.handleRechercherDsCatalogue)
326 def ajoutSortieComplete(self):
327 if hasattr(self,'actionSortieComplete') : return
328 self.actionSortieComplete = QAction(self)
329 self.actionSortieComplete.setText(tr("Sortie Complete"))
330 self.menuFichier.insertAction(self.actionEnregistrer_sous,self.actionSortieComplete)
331 self.actionSortieComplete.triggered.connect(self.handleSortieComplete)
335 self.enlevernewInclude()
336 self.toolBar.addSeparator()
340 self.enlevernewInclude()
341 self.toolBar.addSeparator()
342 self.ajoutExecution()
344 self.menuOptions = self.menubar.addMenu("menuOptions")
345 self.menuOptions.addAction(self.actionParametres_Eficas)
346 self.menuOptions.setTitle(tr("Options"))
349 self.enleverActionsStructures()
350 self.enlevernewInclude()
353 self.menuTraduction = self.menubar.addMenu("menuTraduction")
354 self.menuTraduction.addAction(self.actionTraduitV11V12)
355 self.menuTraduction.addAction(self.actionTraduitV10V11)
356 self.menuTraduction.addAction(self.actionTraduitV9V10)
357 self.menuTraduction.setTitle(tr("Traduction"))
359 self.menuFichier.addAction(self.actionSauveLigne)
361 self.menuOptions = self.menubar.addMenu("menuOptions")
362 self.menuOptions.addAction(self.actionParametres_Eficas)
363 self.menuOptions.addAction(self.actionLecteur_Pdf)
364 self.menuOptions.setTitle(tr("Options"))
367 #if self.salome == 0 : return
368 self.enlevernewInclude()
369 self.menuMesh = self.menubar.addMenu(tr("Gestion Maillage"))
370 self.menuMesh.setObjectName("Mesh")
371 self.menuMesh.addAction(self.actionChercheGrpMaille)
372 #self.griserActionsStructures()
375 self.enlevernewInclude()
376 self.enleverRechercherDsCatalogue()
377 self.ajoutExecution()
378 self.ajoutSauveExecution()
379 self.griserActionsStructures()
382 self.enlevernewInclude()
383 self.toolBar.addSeparator()
384 self.ajoutExecution()
385 self.ajoutSauveExecution()
386 self.menuOptions = self.menubar.addMenu("menuOptions")
387 self.menuOptions.addAction(self.actionParametres_Eficas)
388 self.menuOptions.setTitle(tr("Options"))
390 def MAPIDENTIFICATION(self):
391 self.enlevernewInclude()
392 self.enleverSupprimer()
393 #self.ajoutExecution()
394 self.enleverRechercherDsCatalogue()
395 self.enleverActionsStructures()
396 self.enleverParametres()
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.ajoutSortieComplete()
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.handleDeplier)
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.handleDeplier)
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)
620 def handleDeplier(self):
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.getUnit(study,self)
633 self.viewmanager.handleOpen(fichier=study["comm"],units=d)
636 def getSource(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 rep=os.path.join(os.path.expanduser("~"),'.config/Eficas',self.code)
675 monFichier=rep+"/listefichiers_"+self.code
681 l=(ligne.split("\n"))[0]
682 self.recent.append(l)
690 def addToRecentList(self, fn):
691 while fn in self.recent: self.recent.remove(fn)
692 self.recent.insert(0,fn)
693 if len(self.recent) > 9:
694 self.recent = self.recent[:9]
697 def addToRecentListQT4(self, fn):
699 Public slot to add a filename to the list of recently opened files.
701 @param fn name of the file to be added
703 self.recent.removeAll(fn)
704 self.recent.prepend(fn)
705 if len(self.recent) > 9:
706 self.recent = self.recent[:9]
710 def sauveRecents(self) :
712 rep=self.maConfiguration.rep_user
713 monFichier=rep+"/listefichiers_"+self.code
717 f=open(monFichier,'w')
718 if len(self.recent) == 0 : return
720 while ( index < len(self.recent)):
721 ligne=str(self.recent[index])+"\n"
733 def traductionV11V12(self):
734 from .gereTraduction import traduction
735 traduction(self.maConfiguration.repIni,self.viewmanager,"V11V12")
737 def traductionV10V11(self):
738 from .gereTraduction import traduction
739 traduction(self.maConfiguration.repIni,self.viewmanager,"V10V11")
741 def traductionV9V10(self):
742 from .gereTraduction import traduction
743 traduction(self.maConfiguration.repIni,self.viewmanager,"V9V10")
746 from .monVisu import DVisu
747 titre = tr("version ")
748 monVisuDialg=DVisu(parent=self,fl=0)
749 monVisuDialg.setWindowTitle(titre)
750 if self.code != None : monVisuDialg.TB.setText(self.VERSION_EFICAS +tr(" pour ") + self.code)
751 else : monVisuDialg.TB.setText(self.VERSION_EFICAS )
752 monVisuDialg.adjustSize()
756 repAide=os.path.dirname(os.path.abspath(__file__))
757 maD=os.path.join( repAide,'..','Doc')
759 indexAide=os.path.join(maD,'index.html')
760 if sys.platform[0:5]=="linux" : cmd="xdg-open "+indexAide
761 else : cmd="start "+indexAide
764 QMessageBox.warning( self,tr( "Aide Indisponible"),tr( "l'aide n est pas installee "))
767 repAide=os.path.dirname(os.path.abspath(__file__))
768 maD=os.path.join( repAide,'..','Doc')
770 indexAide=os.path.join(maD,'index.html')
771 if sys.platform[0:5]=="linux" : cmd="xdg-open "+indexAide
772 else : cmd="start "+indexAide
775 QMessageBox.warning( self,tr( "Aide Indisponible"),tr( "l'aide n est pas installee "))
778 if self.code==None : return
781 if sys.platform[0:5]=="linux" : cmd="xdg-open "+self.fileDoc
782 else : cmd="start "+self.fileDoc
786 QMessageBox.warning( self,tr( "Aide Indisponible"),tr( "l'aide n est pas installee "))
789 def optionEditeur(self) :
791 name='monOptions_'+self.code
793 QMessageBox.critical( self,tr( "Parametrage"),tr( "Veuillez d abord choisir un code"))
797 optionCode=__import__(name)
800 QMessageBox.critical( self, tr("Parametrage"), tr("Pas de possibilite de personnalisation de la configuration "))
802 monOption=optionCode.Options(parent=self,modal = 0 ,configuration=self.maConfiguration)
805 def optionPdf(self) :
806 from monOptionsPdf import OptionPdf
807 monOption=OptionPdf(parent=self,modal = 0 ,configuration=self.maConfiguration)
810 def handleSortieComplete(self):
811 return self.viewmanager.saveCompleteCurrentEditor()
813 def handleShowRecentMenu(self):
815 Private method to set up recent files menu.
817 self.recentMenu.clear()
819 for rp in self.recent:
820 id = self.recentMenu.addAction(rp)
821 self.ficRecents[id]=rp
822 id.triggered.connect(self.handleOpenRecent)
823 self.recentMenu.addSeparator()
824 self.recentMenu.addAction(tr('&Effacer'), self.handleClearRecent)
826 def handleOpenPatrons(self):
828 fichier=self.repIni+"/../Editeur/Patrons/"+self.code+"/"+self.ficPatrons[idx]
829 self.viewmanager.handleOpen(fichier=fichier, patron = 1)
831 def handleOpenRecent(self):
833 fichier=self.ficRecents[idx]
834 self.viewmanager.handleOpen(fichier=fichier, patron =0 )
836 def handleClearRecent(self):
840 def handleRechercherDsCatalogue(self):
841 if not self.viewmanager : return
842 self.viewmanager.handleRechercherDsCatalogue()
846 self.viewmanager.newEditor()
847 except EficasException as exc:
849 if msg != "": QMessageBox.warning(self, tr(u"Erreur"), msg)
851 def openProcess(self):
855 dirCode=os.path.abspath(os.path.join(os.path.abspath(__file__),'../..',"ProcessOutputs_Eficas"))
856 sys.path.insert(0,dirCode)
858 self.definitCode(code,ssCode)
867 self.viewmanager.handleOpen()
868 except EficasException as exc:
871 QMessageBox.warning(self, tr(u"Erreur"), msg)
873 def sauveLigne(self):
874 return self.viewmanager.sauveLigneCurrentEditor()
877 return self.viewmanager.saveCurrentEditor()
879 def fileSaveAs(self):
880 return self.viewmanager.saveAsCurrentEditor()
883 self.viewmanager.handleClose(texte='&Fermer')
885 def fileCloseAll(self):
886 self.viewmanager.handleCloseAll(texte='&Fermer')
889 # On peut sortir sur Abort
890 res=self.viewmanager.handleCloseAll()
896 self.viewmanager.handleEditCopy()
899 self.viewmanager.handleEditCut()
902 self.viewmanager.handleEditPaste()
904 def rechercher(self):
905 self.viewmanager.handleRechercher()
908 self.viewmanager.run()
911 self.viewmanager.saveRun()
915 self.viewmanager.handleSupprimer()
917 def jdcFichierSource(self):
918 self.viewmanager.handleViewJdcFichierSource()
920 def jdcRapport(self):
921 self.viewmanager.handleViewJdcRapport()
924 self.viewmanager.handleViewJdcRegles()
926 def gestionParam(self):
927 self.viewmanager.handleGestionParam()
930 self.viewmanager.handleViewJdcPy()
932 def ouvreArbre(self):
933 self.viewmanager.ouvreArbre()
935 def fermeArbre(self):
936 self.viewmanager.fermeArbre()
938 def newInclude(self):
939 self.viewmanager.newIncludeEditor()
942 for pathCode in self.ListePathCode:
944 aEnlever=os.path.abspath(os.path.join(os.path.dirname(__file__),'..',pathCode))
945 sys.path.remove(aEnlever)
948 for pathCode in self.listeAEnlever:
950 sys.path.remove(aEnlever)
955 def closeEvent(self,event):
957 if res==2 : event.ignore()
960 def remplitIconesCommandes(self):
961 if self.maConfiguration.boutonDsMenuBar == False : return
962 if not hasattr(self, 'readercata') : return
963 from monLayoutBouton import MonLayoutBouton
964 if hasattr(self,'monLayoutBoutonRempli') : return
965 self.monLayoutBoutonRempli=MonLayoutBouton(self)
967 def handleAjoutEtape(self,nomEtape):
968 self.viewmanager.handleAjoutEtape(nomEtape)
970 def metMenuAJourUtilisateurs(self):
971 self.lesFonctionsUtilisateurs={}
972 if self.code not in self.mesScripts : return
973 if not hasattr(self.mesScripts[self.code],'dict_menu') : return
974 for monMenu in iter(self.mesScripts[self.code].dict_menu.items()) :
975 titre,lesFonctions= monMenu
976 self.menuOptions = self.menubar.addMenu("menuOptions")
977 self.menuOptions.setTitle(tr(titre))
978 for elt in lesFonctions :
979 laFonctionUtilisateur, label, lesArguments = elt
980 action = QAction(self)
981 action.setText(label)
982 #action.triggered.connect(self.appelleFonctionUtilisateur)
983 self.menuOptions.addAction(action)
984 self.lesFonctionsUtilisateurs[action]=(laFonctionUtilisateur, lesArguments)
985 self.menuOptions.triggered.connect(self.handleFonctionUtilisateur)
988 def handleFonctionUtilisateur(self,action) :
989 (laFonctionUtilisateur, lesArguments)=self.lesFonctionsUtilisateurs[action]
990 self.viewmanager.handleFonctionUtilisateur(laFonctionUtilisateur, lesArguments)
992 if __name__=='__main__':
995 rep=os.path.abspath(os.path.join(os.path.dirname(os.path.abspath(__file__),'..','Adao')))
997 from Adao import prefs
998 from Adao import prefs_Adao
1000 from Editeur import import_code
1001 from Editeur import session
1003 # Analyse des arguments de la ligne de commande
1004 options=session.parse(sys.argv)
1008 app = QApplication(sys.argv)
1009 #app.setMainWidget(mw) (qt3)