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
32 from PyQt5.QtWidgets import QApplication, QMainWindow, QGridLayout, QBoxLayout, QMenu, QAction, QMessageBox
33 from PyQt5.QtGui import QIcon
34 from PyQt5.QtCore import Qt, QSize
37 from Editeur import session
38 from myMain import Ui_Eficas
39 from InterfaceQT4.viewManager import MyViewManager
40 from InterfaceQT4.qtEficasSsIhm import AppliSsIhm
42 from Extensions.i18n import tr
43 from Extensions.eficas_exception import EficasException
44 from Extensions import param2
47 class Appli(AppliSsIhm,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='fr',ssIhm=False,versionCode=None):
56 print ('mauvaise utilisation de la classe Appli. Utiliser AppliSsIm SVP')
59 AppliSsIhm.__init__(self,code,salome,parent,ssCode,multi,langue,ssIhm=True,versionCode=None)
60 QMainWindow.__init__(self,parent)
61 Ui_Eficas.__init__(self)
65 self.demande=multi # voir PSEN
67 if self.multi == False :
68 self.definitCode(code,ssCode)
71 print ('a programmer')
73 self.suiteTelemac=False
74 if hasattr (self, 'maConfiguration') :
75 if self.maConfiguration.force_langue :
76 from InterfaceQT4.monChoixLangue import MonChoixLangue
77 widgetLangue = MonChoixLangue(self)
78 ret=widgetLangue.exec_()
79 self.suiteTelemac=self.maConfiguration.suiteTelemac
82 if not self.salome and hasattr (self, 'maConfiguration') and hasattr(self.maConfiguration,'lang') : self.langue=self.maConfiguration.lang
83 from Extensions import localisation
85 if hasattr (self, 'maConfiguration') : localisation.localise(None,self.langue,translatorFichier=self.maConfiguration.translatorFichier)
88 #if parent != None : self.parentCentralWidget = parent.centralWidget()
89 #else : self.parentCentralWidget = None
92 if hasattr (self, 'maConfiguration') and hasattr(self.maConfiguration,'taille') : self.taille=self.maConfiguration.taille
93 else : self.taille=1700
95 #if self.code in ['MAP',] : self.resize(1440,self.height())
96 #else : self.resize(self.taille,self.height())
97 self.resize(self.taille,self.height())
100 icon = QIcon(self.repIcon+"/parametres.png")
101 self.actionParametres.setIcon(icon)
102 if hasattr (self, 'maConfiguration') and self.maConfiguration.boutonDsMenuBar :
103 self.frameEntete.setMaximumSize(QSize(16777215,100))
104 self.frameEntete.setMinimumSize(QSize(0,100))
105 if hasattr (self, 'maConfiguration') and self.maConfiguration.enleverActionStructures :
106 self.enleverActionsStructures()
107 if hasattr (self, 'maConfiguration') and self.maConfiguration.enleverParametres :
108 self.enleverParametres()
109 if hasattr (self, 'maConfiguration') and self.maConfiguration.enleverSupprimer :
110 self.enleverSupprimer()
113 self.myQtab.removeTab(0)
114 self.blEnteteGlob = QBoxLayout(2,self.frameEntete)
115 self.blEnteteGlob.setSpacing(0)
116 self.blEnteteGlob.setContentsMargins(0,0,0,0)
118 self.blEntete = QBoxLayout(0)
119 self.blEntete.insertWidget(0,self.toolBar)
120 self.blEntete.insertWidget(0,self.menubar)
121 self.blEnteteGlob.insertLayout(0,self.blEntete)
125 if hasattr (self, 'maConfiguration') and self.maConfiguration.boutonDsMenuBar :
126 self.blEnteteCommmande = QBoxLayout(0)
127 self.blEnteteCommmande.insertWidget(0,self.toolBarCommande)
128 self.toolBarCommande.setIconSize(QSize(96,96))
129 self.blEnteteGlob.insertLayout(-1,self.blEnteteCommmande)
131 self.toolBarCommande.close()
134 if hasattr (self, 'maConfiguration') and self.maConfiguration.closeEntete==True and self.salome: self.closeEntete()
136 eficas_root_dir = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
138 self.viewmanager = MyViewManager(self)
139 self.recentMenu=QMenu(tr('&Recents'))
140 #self.menuFichier.insertMenu(self.actionOuvrir,self.recentMenu)
142 # actionARemplacer ne sert que pour l insert Menu
143 self.menuFichier.insertMenu(self.actionARemplacer ,self.recentMenu)
144 self.menuFichier.removeAction(self.actionARemplacer)
145 self.connecterSignaux()
146 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 if self.first: self.first=0
400 try : self.action_Nouveau.triggered.disconnect(self.fileNew)
402 try : self.action_Nouveau.triggered.disconnect(self.newPSEN)
405 self.action_Nouveau.triggered.connect(self.newPSEN)
406 self.enleverActionsStructures()
407 self.enleverParametres()
408 self.enleverRechercherDsCatalogue()
409 self.enlevernewInclude()
410 self.ajoutExecution()
416 self.enleverActionsStructures()
417 self.enleverParametres()
418 self.enleverRechercherDsCatalogue()
419 self.enlevernewInclude()
420 self.ajoutExecution()
424 self.enleverActionsStructures()
425 self.enlevernewInclude()
426 self.connectRechercherDsCatalogue()
427 self.ajoutSortieComplete()
429 def lookSuiteTelemac(self):
430 self.enleverActionsStructures()
431 self.enlevernewInclude()
432 self.enleverParametres()
433 self.enleverSupprimer()
434 self.enleverRechercherDsCatalogue()
436 def ajoutHelpPSEN(self):
437 self.actionParametres_Eficas.setText('Help PSEN')
438 self.actionParametres_Eficas.triggered.connect(self.aidePSEN)
442 def ChercheGrpMesh(self):
443 Msg,listeGroup=self.ChercheGrpMeshInSalome()
445 self.viewmanager.handleAjoutGroup(listeGroup)
447 print ("il faut gerer les erreurs")
449 def ChercheGrpMaille(self):
450 # Normalement la variable self.salome permet de savoir si on est ou non dans Salome
452 Msg,listeGroup=self.ChercheGrpMailleInSalome() # recherche dans Salome
453 #Msg = None; listeGroup = None # recherche manuelle, i.e., sans Salome si ligne precedente commentee
455 raise ValueError('Salome non ouvert')
457 self.viewmanager.handleAjoutGroup(listeGroup)
459 print ("il faut gerer les erreurs")
462 def ChercheGrp(self):
463 #Msg,listeGroup=self.ChercheGrpMailleInSalome()
465 # self.viewmanager.handleAjoutGroup(listeGroup)
467 #print "il faut gerer "
471 def ajoutIcones(self) :
472 # Pour pallier les soucis de repertoire d icone
474 icon = QIcon(self.repIcon+"/new_file.png")
475 self.action_Nouveau.setIcon(icon)
476 icon1 = QIcon(self.repIcon+"/ouvrir.png")
477 self.actionOuvrir.setIcon(icon1)
478 icon2 = QIcon(self.repIcon+"/save.png")
479 self.actionEnregistrer.setIcon(icon2)
480 icon6 = QIcon(self.repIcon+"/delete.png")
481 self.actionSupprimer.setIcon(icon6)
482 icon7 = QIcon(self.repIcon+"/roue.png")
483 self.actionExecution.setIcon(icon7)
488 def connecterSignauxQT4(self) :
489 self.connect(self.recentMenu,SIGNAL('aboutToShow()'),self.handleShowRecentMenu)
491 self.connect(self.action_Nouveau,SIGNAL("triggered()"),self.fileNew)
492 self.connect(self.actionNouvel_Include,SIGNAL("triggered()"),self.newInclude)
493 self.connect(self.actionOuvrir,SIGNAL("triggered()"),self.fileOpen)
494 self.connect(self.actionEnregistrer,SIGNAL("triggered()"),self.fileSave)
495 self.connect(self.actionEnregistrer_sous,SIGNAL("triggered()"),self.fileSaveAs)
496 self.connect(self.actionFermer,SIGNAL("triggered()"),self.fileClose)
497 self.connect(self.actionFermer_tout,SIGNAL("triggered()"),self.fileCloseAll)
498 self.connect(self.actionQuitter,SIGNAL("triggered()"),self.fileExit)
500 self.connect(self.actionEficas,SIGNAL("triggered()"),self.aidePPal)
501 self.connect(self.actionVersion,SIGNAL("triggered()"),self.version)
502 self.connect(self.actionParametres,SIGNAL("triggered()"),self.gestionParam)
504 self.connect(self.actionCouper,SIGNAL("triggered()"),self.editCut)
505 self.connect(self.actionCopier,SIGNAL("triggered()"),self.editCopy)
506 self.connect(self.actionColler,SIGNAL("triggered()"),self.editPaste)
507 self.connect(self.actionSupprimer,SIGNAL("triggered()"),self.supprimer)
508 self.connect(self.actionRechercher,SIGNAL("triggered()"),self.rechercher)
509 self.connect(self.actionDeplier_replier,SIGNAL("triggered()"),self.handleDeplier)
511 self.connect(self.actionRapport_de_Validation,SIGNAL("triggered()"),self.jdcRapport)
512 self.connect(self.actionRegles_du_JdC,SIGNAL("triggered()"),self.jdcRegles)
513 self.connect(self.actionFichier_Source,SIGNAL("triggered()"),self.jdcFichierSource)
514 self.connect(self.actionFichier_Resultat,SIGNAL("triggered()"),self.visuJdcPy)
520 self.actionTraduitV9V10 = QAction(self)
521 self.actionTraduitV9V10.setObjectName("actionTraduitV9V10")
522 self.actionTraduitV9V10.setText(tr("TraduitV9V10"))
523 self.actionTraduitV10V11 = QAction(self)
524 self.actionTraduitV10V11.setObjectName("actionTraduitV10V11")
525 self.actionTraduitV10V11.setText(tr("TraduitV10V11"))
526 self.actionTraduitV11V12 = QAction(self)
527 self.actionTraduitV11V12.setObjectName("actionTraduitV11V12")
528 self.actionTraduitV11V12.setText(tr("TraduitV11V12"))
529 self.actionSauveLigne = QAction(self)
530 self.actionSauveLigne.setText(tr("Sauve Format Ligne"))
532 #self.connect(self.actionParametres_Eficas,SIGNAL("triggered()"),self.optionEditeur)
533 self.connect(self.actionLecteur_Pdf,SIGNAL("triggered()"),self.optionPdf)
534 self.connect(self.actionTraduitV9V10,SIGNAL("triggered()"),self.traductionV9V10)
535 self.connect(self.actionTraduitV10V11,SIGNAL("triggered()"),self.traductionV10V11)
536 self.connect(self.actionTraduitV11V12,SIGNAL("triggered()"),self.traductionV11V12)
537 self.connect(self.actionSauveLigne,SIGNAL("triggered()"),self.sauveLigne)
541 self.actionChercheGrpMaille = QAction(self)
542 self.actionChercheGrpMaille.setText(tr("Acquiert groupe mailles"))
543 self.connect(self.actionChercheGrpMaille,SIGNAL("triggered()"),self.ChercheGrpMaille)
546 self.actionChercheGrp = QAction(self)
547 self.actionChercheGrp.setText(tr("Acquisition Groupe Maille"))
548 self.connect(self.actionChercheGrp,SIGNAL("triggered()"),self.ChercheGrp)
551 self.actionCode = QAction(self)
552 self.actionCode.setText(tr("Specificites Maille"))
553 self.connect(self.actionCode,SIGNAL("triggered()"),self.aideCode)
555 def connecterSignaux(self) :
557 self.recentMenu.aboutToShow.connect(self.handleShowRecentMenu)
558 self.action_Nouveau.triggered.connect(self.fileNew)
559 self.actionNouvel_Include.triggered.connect(self.newInclude)
560 self.actionOuvrir.triggered.connect(self.fileOpen)
561 self.actionEnregistrer.triggered.connect(self.fileSave)
562 self.actionEnregistrer_sous.triggered.connect(self.fileSaveAs)
563 self.actionFermer.triggered.connect(self.fileClose)
564 self.actionFermer_tout.triggered.connect(self.fileCloseAll)
565 self.actionQuitter.triggered.connect(self.fileExit)
567 self.actionEficas.triggered.connect(self.aidePPal)
568 self.actionVersion.triggered.connect(self.version)
569 self.actionParametres.triggered.connect(self.gestionParam)
570 self.actionCommentaire.triggered.connect(self.ajoutCommentaire)
572 self.actionCouper.triggered.connect(self.editCut)
573 self.actionCopier.triggered.connect(self.editCopy)
574 self.actionColler.triggered.connect(self.editPaste)
575 self.actionSupprimer.triggered.connect(self.supprimer)
576 self.actionRechercher.triggered.connect(self.rechercher)
577 self.actionDeplier_replier.triggered.connect(self.handleDeplier)
579 self.actionRapport_de_Validation.triggered.connect(self.jdcRapport)
580 self.actionRegles_du_JdC.triggered.connect(self.jdcRegles)
581 self.actionFichier_Source.triggered.connect(self.jdcFichierSource)
582 self.actionFichier_Resultat.triggered.connect(self.visuJdcPy)
583 self.actionAfficher_l_Arbre.triggered.connect(self.ouvreArbre)
584 self.actionCacher_l_Arbre.triggered.connect(self.fermeArbre)
588 self.actionTraduitV9V10 = QAction(self)
589 self.actionTraduitV9V10.setObjectName("actionTraduitV9V10")
590 self.actionTraduitV9V10.setText(tr("TraduitV9V10"))
591 self.actionTraduitV10V11 = QAction(self)
592 self.actionTraduitV10V11.setObjectName("actionTraduitV10V11")
593 self.actionTraduitV10V11.setText(tr("TraduitV10V11"))
594 self.actionTraduitV11V12 = QAction(self)
595 self.actionTraduitV11V12.setObjectName("actionTraduitV11V12")
596 self.actionTraduitV11V12.setText(tr("TraduitV11V12"))
597 self.actionSauveLigne = QAction(self)
598 self.actionSauveLigne.setText(tr("Sauve Format Ligne"))
600 #self.actionParametres_Eficas.triggered.connect(self.optionEditeur)
601 self.actionTraduitV9V10.triggered.connect(self.traductionV9V10)
602 self.actionTraduitV10V11.triggered.connect(self.traductionV10V11)
603 self.actionTraduitV11V12.triggered.connect(self.traductionV11V12)
604 self.actionSauveLigne.triggered.connect(self.sauveLigne)
607 self.actionChercheGrpMaille = QAction(self)
608 self.actionChercheGrpMaille.setText(tr("Acquiert Groupe Maille"))
611 self.actionChercheGrp = QAction(self)
612 self.actionChercheGrp.setText(tr("Accquisition Groupe Maille"))
613 self.actionChercheGrp.triggered.connect(self.ChercheGrp)
616 self.actionCode = QAction(self)
617 self.actionCode.setText(tr("Specificites Maille"))
618 self.actionCode.triggered.connect(self.aideCode)
621 def handleDeplier(self):
622 self.viewmanager.handleDeplier()
624 def ajoutCommentaire(self):
625 self.viewmanager.ajoutCommentaire()
627 def ouvreFichiers(self) :
628 # Ouverture des fichiers de commandes donnes sur la ligne de commande
631 for study in session.d_env.studies:
633 d=session.getUnit(study,self)
634 self.viewmanager.handleOpen(fichier=study["comm"],units=d)
637 def getSource(self,file):
638 # appele par Editeur/session.py
640 p=convert.plugins['python']()
642 texte=p.convert('execnoparseur')
645 def initPatrons(self) :
646 # Mise a jour du menu des fichiers recemment ouverts
647 from Editeur import listePatrons
648 if not(self.code in listePatrons.sous_menus) :
649 if hasattr(self,"menuPatrons"):
650 self.menuPatrons.setAttribute(Qt.WA_DeleteOnClose)
651 self.menuPatrons.close()
652 delattr(self,"menuPatrons")
654 if (not hasattr(self,"menuPatrons")):
655 self.menuPatrons = QMenu(self.menubar)
656 self.menuPatrons.setObjectName("menuPatrons")
657 self.menubar.addAction(self.menuPatrons.menuAction())
658 self.menuPatrons.setTitle(tr("Patrons"))
660 self.menuPatrons.clear()
661 self.listePatrons = listePatrons.listePatrons(self.code)
663 for nomSsMenu in self.listePatrons.liste:
664 ssmenu=self.menuPatrons.addMenu(nomSsMenu)
665 for fichier in self.listePatrons.liste[nomSsMenu]:
666 id = ssmenu.addAction(fichier)
667 self.ficPatrons[id]=fichier
668 self.id.triggered.connect(self.handleOpenPatrons)
669 # self.Patrons.setItemParameter(id,idx)
672 def initRecents(self):
675 rep=os.path.join(os.path.expanduser("~"),'.config/Eficas',self.code)
676 #if sys.platform[0:5]=="linux" :
677 #rep=os.path.join(os.environ['HOME'],'.config/Eficas',self.code)
679 # rep=os.path.join('C:/','.config/Eficas',self.code)
680 monFichier=rep+"/listefichiers_"+self.code
686 l=(ligne.split("\n"))[0]
687 self.recent.append(l)
695 def addToRecentList(self, fn):
696 while fn in self.recent: self.recent.remove(fn)
697 self.recent.insert(0,fn)
698 if len(self.recent) > 9:
699 self.recent = self.recent[:9]
702 def addToRecentListQT4(self, fn):
704 Public slot to add a filename to the list of recently opened files.
706 @param fn name of the file to be added
708 self.recent.removeAll(fn)
709 self.recent.prepend(fn)
710 if len(self.recent) > 9:
711 self.recent = self.recent[:9]
715 def sauveRecents(self) :
717 rep=self.maConfiguration.rep_user
718 monFichier=rep+"/listefichiers_"+self.code
722 f=open(monFichier,'w')
723 if len(self.recent) == 0 : return
725 while ( index < len(self.recent)):
726 ligne=str(self.recent[index])+"\n"
738 def traductionV11V12(self):
739 from .gereTraduction import traduction
740 traduction(self.maConfiguration.repIni,self.viewmanager,"V11V12")
742 def traductionV10V11(self):
743 from .gereTraduction import traduction
744 traduction(self.maConfiguration.repIni,self.viewmanager,"V10V11")
746 def traductionV9V10(self):
747 from .gereTraduction import traduction
748 traduction(self.maConfiguration.repIni,self.viewmanager,"V9V10")
751 from .monVisu import DVisu
752 titre = tr("version ")
753 monVisuDialg=DVisu(parent=self,fl=0)
754 monVisuDialg.setWindowTitle(titre)
755 if self.code != None : monVisuDialg.TB.setText(self.VERSION_EFICAS +tr(" pour ") + self.code)
756 else : monVisuDialg.TB.setText(self.VERSION_EFICAS )
757 monVisuDialg.adjustSize()
761 repAide=os.path.dirname(os.path.abspath(__file__))
762 maD=os.path.join( repAide,'..','Doc')
764 indexAide=os.path.join(maD,'index.html')
765 if sys.platform[0:5]=="linux" : cmd="xdg-open "+indexAide
766 else : cmd="start "+indexAide
769 QMessageBox.warning( self,tr( "Aide Indisponible"),tr( "l'aide n est pas installee "))
772 repAide=os.path.dirname(os.path.abspath(__file__))
773 maD=os.path.join( repAide,'..','Doc')
775 indexAide=os.path.join(maD,'index.html')
776 if sys.platform[0:5]=="linux" : cmd="xdg-open "+indexAide
777 else : cmd="start "+indexAide
780 QMessageBox.warning( self,tr( "Aide Indisponible"),tr( "l'aide n est pas installee "))
783 if self.code==None : return
786 if sys.platform[0:5]=="linux" : cmd="xdg-open "+self.fileDoc
787 else : cmd="start "+self.fileDoc
791 QMessageBox.warning( self,tr( "Aide Indisponible"),tr( "l'aide n est pas installee "))
794 def optionEditeur(self) :
796 name='monOptions_'+self.code
798 QMessageBox.critical( self,tr( "Parametrage"),tr( "Veuillez d abord choisir un code"))
802 optionCode=__import__(name)
805 QMessageBox.critical( self, tr("Parametrage"), tr("Pas de possibilite de personnalisation de la configuration "))
807 monOption=optionCode.Options(parent=self,modal = 0 ,configuration=self.maConfiguration)
810 def optionPdf(self) :
811 from monOptionsPdf import OptionPdf
812 monOption=OptionPdf(parent=self,modal = 0 ,configuration=self.maConfiguration)
815 def handleSortieComplete(self):
816 return self.viewmanager.saveCompleteCurrentEditor()
818 def handleShowRecentMenu(self):
820 Private method to set up recent files menu.
822 self.recentMenu.clear()
824 for rp in self.recent:
825 id = self.recentMenu.addAction(rp)
826 self.ficRecents[id]=rp
827 id.triggered.connect(self.handleOpenRecent)
828 self.recentMenu.addSeparator()
829 self.recentMenu.addAction(tr('&Effacer'), self.handleClearRecent)
831 def handleOpenPatrons(self):
833 fichier=self.repIni+"/../Editeur/Patrons/"+self.code+"/"+self.ficPatrons[idx]
834 self.viewmanager.handleOpen(fichier=fichier, patron = 1)
836 def handleOpenRecent(self):
838 fichier=self.ficRecents[idx]
839 self.viewmanager.handleOpen(fichier=fichier, patron =0 )
841 def handleClearRecent(self):
842 self.recent = QStringList()
845 def handleRechercherDsCatalogue(self):
846 if not self.viewmanager : return
847 self.viewmanager.handleRechercherDsCatalogue()
851 self.viewmanager.newEditor()
852 except EficasException as exc:
853 msg = six.text_type(exc)
854 if msg != "": QMessageBox.warning(self, tr(u"Erreur"), msg)
856 def openProcess(self):
860 dirCode=os.path.abspath(os.path.join(os.path.abspath(__file__),'../..',"ProcessOutputs_Eficas"))
861 sys.path.insert(0,dirCode)
863 self.definitCode(code,ssCode)
872 self.viewmanager.handleOpen()
873 except EficasException as exc:
874 msg = six.text_type(exc)
876 QMessageBox.warning(self, tr(u"Erreur"), msg)
878 def sauveLigne(self):
879 return self.viewmanager.sauveLigneCurrentEditor()
882 return self.viewmanager.saveCurrentEditor()
884 def fileSaveAs(self):
885 return self.viewmanager.saveAsCurrentEditor()
888 self.viewmanager.handleClose(texte='&Fermer')
890 def fileCloseAll(self):
891 self.viewmanager.handleCloseAll(texte='&Fermer')
894 # On peut sortir sur Abort
895 res=self.viewmanager.handleCloseAll()
901 self.viewmanager.handleEditCopy()
904 self.viewmanager.handleEditCut()
907 self.viewmanager.handleEditPaste()
909 def rechercher(self):
910 self.viewmanager.handleRechercher()
913 self.viewmanager.run()
916 self.viewmanager.saveRun()
920 self.viewmanager.handleSupprimer()
922 def jdcFichierSource(self):
923 self.viewmanager.handleViewJdcFichierSource()
925 def jdcRapport(self):
926 self.viewmanager.handleViewJdcRapport()
929 self.viewmanager.handleViewJdcRegles()
931 def gestionParam(self):
932 self.viewmanager.handleGestionParam()
935 self.viewmanager.handleViewJdcPy()
937 def ouvreArbre(self):
938 self.viewmanager.ouvreArbre()
940 def fermeArbre(self):
941 self.viewmanager.fermeArbre()
943 def newInclude(self):
944 self.viewmanager.newIncludeEditor()
947 for pathCode in self.ListePathCode:
949 aEnlever=os.path.abspath(os.path.join(os.path.dirname(__file__),'..',pathCode))
950 sys.path.remove(aEnlever)
953 for pathCode in self.listeAEnlever:
955 sys.path.remove(aEnlever)
960 def closeEvent(self,event):
962 if res==2 : event.ignore()
965 def remplitIconesCommandes(self):
966 if self.maConfiguration.boutonDsMenuBar == False : return
967 if not hasattr(self, 'readercata') : return
968 from monLayoutBouton import MonLayoutBouton
969 if hasattr(self,'monLayoutBoutonRempli') : return
970 self.monLayoutBoutonRempli=MonLayoutBouton(self)
972 def handleAjoutEtape(self,nomEtape):
973 self.viewmanager.handleAjoutEtape(nomEtape)
975 def metMenuAJourUtilisateurs(self):
976 self.lesFonctionsUtilisateurs={}
977 if self.code not in self.mesScripts : return
978 if not hasattr(self.mesScripts[self.code],'dict_menu') : return
979 for monMenu in iter(self.mesScripts[self.code].dict_menu.items()) :
980 titre,lesFonctions= monMenu
981 self.menuOptions = self.menubar.addMenu("menuOptions")
982 self.menuOptions.setTitle(tr(titre))
983 for elt in lesFonctions :
984 laFonctionUtilisateur, label, lesArguments = elt
985 action = QAction(self)
986 action.setText(label)
987 #action.triggered.connect(self.appelleFonctionUtilisateur)
988 self.menuOptions.addAction(action)
989 self.lesFonctionsUtilisateurs[action]=(laFonctionUtilisateur, lesArguments)
990 self.menuOptions.triggered.connect(self.handleFonctionUtilisateur)
992 def handleFonctionUtilisateur(self,action) :
993 (laFonctionUtilisateur, lesArguments)=self.lesFonctionsUtilisateurs[action]
994 self.viewmanager.handleFonctionUtilisateur(laFonctionUtilisateur, lesArguments)
996 if __name__=='__main__':
999 rep=os.path.abspath(os.path.join(os.path.dirname(os.path.abspath(__file__),'..','Adao')))
1000 sys.path.append(rep)
1001 from Adao import prefs
1002 from Adao import prefs_Adao
1003 #if hasattr(prefsCode,'encoding'):
1004 # Hack pour changer le codage par defaut des strings
1007 #sys.setdefaultencoding(prefsCode.encoding)
1008 #del sys.setdefaultencoding
1011 from Editeur import import_code
1012 from Editeur import session
1014 # Analyse des arguments de la ligne de commande
1015 options=session.parse(sys.argv)
1019 app = QApplication(sys.argv)
1020 #app.setMainWidget(mw) (qt3)