2 # -*- coding: iso-8859-1 -*-
3 # Copyright (C) 2007-2017 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 if sys.platform[0:5]=="linux" :
676 rep=os.path.join(os.environ['HOME'],'.config/Eficas',self.code)
678 rep=os.path.join('C:/','.config/Eficas',self.code)
679 monFichier=rep+"/listefichiers_"+self.code
685 l=(ligne.split("\n"))[0]
686 self.recent.append(l)
694 def addToRecentList(self, fn):
695 while fn in self.recent: self.recent.remove(fn)
696 self.recent.insert(0,fn)
697 if len(self.recent) > 9:
698 self.recent = self.recent[:9]
701 def addToRecentListQT4(self, fn):
703 Public slot to add a filename to the list of recently opened files.
705 @param fn name of the file to be added
707 self.recent.removeAll(fn)
708 self.recent.prepend(fn)
709 if len(self.recent) > 9:
710 self.recent = self.recent[:9]
714 def sauveRecents(self) :
716 rep=self.maConfiguration.rep_user
717 monFichier=rep+"/listefichiers_"+self.code
721 f=open(monFichier,'w')
722 if len(self.recent) == 0 : return
724 while ( index < len(self.recent)):
725 ligne=str(self.recent[index])+"\n"
737 def traductionV11V12(self):
738 from .gereTraduction import traduction
739 traduction(self.maConfiguration.repIni,self.viewmanager,"V11V12")
741 def traductionV10V11(self):
742 from .gereTraduction import traduction
743 traduction(self.maConfiguration.repIni,self.viewmanager,"V10V11")
745 def traductionV9V10(self):
746 from .gereTraduction import traduction
747 traduction(self.maConfiguration.repIni,self.viewmanager,"V9V10")
750 from .monVisu import DVisu
751 titre = tr("version ")
752 monVisuDialg=DVisu(parent=self,fl=0)
753 monVisuDialg.setWindowTitle(titre)
754 monVisuDialg.TB.setText(self.VERSION_EFICAS +tr(" pour ") + self.code)
755 monVisuDialg.adjustSize()
759 repAide=os.path.dirname(os.path.abspath(__file__))
760 maD=os.path.join( repAide,'..','Doc')
762 indexAide=os.path.join(maD,'index.html')
763 if sys.platform[0:5]=="linux" : cmd="xdg-open "+indexAide
764 else : cmd="start "+indexAide
767 QMessageBox.warning( self,tr( "Aide Indisponible"),tr( "l'aide n est pas installee "))
770 repAide=os.path.dirname(os.path.abspath(__file__))
771 maD=os.path.join( repAide,'..','Doc')
773 indexAide=os.path.join(maD,'index.html')
774 if sys.platform[0:5]=="linux" : cmd="xdg-open "+indexAide
775 else : cmd="start "+indexAide
778 QMessageBox.warning( self,tr( "Aide Indisponible"),tr( "l'aide n est pas installee "))
781 if self.code==None : return
784 if sys.platform[0:5]=="linux" : cmd="xdg-open "+self.fileDoc
785 else : cmd="start "+self.fileDoc
789 QMessageBox.warning( self,tr( "Aide Indisponible"),tr( "l'aide n est pas installee "))
792 def optionEditeur(self) :
794 name='monOptions_'+self.code
796 QMessageBox.critical( self,tr( "Parametrage"),tr( "Veuillez d abord choisir un code"))
800 optionCode=__import__(name)
803 QMessageBox.critical( self, tr("Parametrage"), tr("Pas de possibilite de personnalisation de la configuration "))
805 monOption=optionCode.Options(parent=self,modal = 0 ,configuration=self.maConfiguration)
808 def optionPdf(self) :
809 from monOptionsPdf import OptionPdf
810 monOption=OptionPdf(parent=self,modal = 0 ,configuration=self.maConfiguration)
813 def handleSortieComplete(self):
814 return self.viewmanager.saveCompleteCurrentEditor()
816 def handleShowRecentMenu(self):
818 Private method to set up recent files menu.
820 self.recentMenu.clear()
822 for rp in self.recent:
823 id = self.recentMenu.addAction(rp)
824 self.ficRecents[id]=rp
825 id.triggered.connect(self.handleOpenRecent)
826 self.recentMenu.addSeparator()
827 self.recentMenu.addAction(tr('&Effacer'), self.handleClearRecent)
829 def handleOpenPatrons(self):
831 fichier=self.repIni+"/../Editeur/Patrons/"+self.code+"/"+self.ficPatrons[idx]
832 self.viewmanager.handleOpen(fichier=fichier, patron = 1)
834 def handleOpenRecent(self):
836 fichier=self.ficRecents[idx]
837 self.viewmanager.handleOpen(fichier=fichier, patron =0 )
839 def handleClearRecent(self):
840 self.recent = QStringList()
843 def handleRechercherDsCatalogue(self):
844 if not self.viewmanager : return
845 self.viewmanager.handleRechercherDsCatalogue()
849 self.viewmanager.newEditor()
850 except EficasException as exc:
851 msg = six.text_type(exc)
852 if msg != "": QMessageBox.warning(self, tr(u"Erreur"), msg)
854 def openProcess(self):
858 dirCode=os.path.abspath(os.path.join(os.path.abspath(__file__),'../..',"ProcessOutputs_Eficas"))
859 sys.path.insert(0,dirCode)
861 self.definitCode(code,ssCode)
870 self.viewmanager.handleOpen()
871 except EficasException as exc:
872 msg = six.text_type(exc)
874 QMessageBox.warning(self, tr(u"Erreur"), msg)
876 def sauveLigne(self):
877 return self.viewmanager.sauveLigneCurrentEditor()
880 return self.viewmanager.saveCurrentEditor()
882 def fileSaveAs(self):
883 return self.viewmanager.saveAsCurrentEditor()
886 self.viewmanager.handleClose(texte='&Fermer')
888 def fileCloseAll(self):
889 self.viewmanager.handleCloseAll(texte='&Fermer')
892 # On peut sortir sur Abort
893 res=self.viewmanager.handleCloseAll()
899 self.viewmanager.handleEditCopy()
902 self.viewmanager.handleEditCut()
905 self.viewmanager.handleEditPaste()
907 def rechercher(self):
908 self.viewmanager.handleRechercher()
911 self.viewmanager.run()
914 self.viewmanager.saveRun()
918 self.viewmanager.handleSupprimer()
920 def jdcFichierSource(self):
921 self.viewmanager.handleViewJdcFichierSource()
923 def jdcRapport(self):
924 self.viewmanager.handleViewJdcRapport()
927 self.viewmanager.handleViewJdcRegles()
929 def gestionParam(self):
930 self.viewmanager.handleGestionParam()
933 self.viewmanager.handleViewJdcPy()
935 def ouvreArbre(self):
936 self.viewmanager.ouvreArbre()
938 def fermeArbre(self):
939 self.viewmanager.fermeArbre()
941 def newInclude(self):
942 self.viewmanager.newIncludeEditor()
945 for pathCode in self.ListePathCode:
947 aEnlever=os.path.abspath(os.path.join(os.path.dirname(__file__),'..',pathCode))
948 sys.path.remove(aEnlever)
951 for pathCode in self.listeAEnlever:
953 sys.path.remove(aEnlever)
958 def closeEvent(self,event):
960 if res==2 : event.ignore()
963 def remplitIconesCommandes(self):
964 if self.maConfiguration.boutonDsMenuBar == False : return
965 if not hasattr(self, 'readercata') : return
966 from monLayoutBouton import MonLayoutBouton
967 if hasattr(self,'monLayoutBoutonRempli') : return
968 self.monLayoutBoutonRempli=MonLayoutBouton(self)
970 def handleAjoutEtape(self,nomEtape):
971 self.viewmanager.handleAjoutEtape(nomEtape)
973 def metMenuAJourUtilisateurs(self):
974 self.lesFonctionsUtilisateurs={}
975 if self.code not in self.mesScripts : return
976 if not hasattr(self.mesScripts[self.code],'dict_menu') : return
977 for monMenu in iter(self.mesScripts[self.code].dict_menu.items()) :
978 titre,lesFonctions= monMenu
979 self.menuOptions = self.menubar.addMenu("menuOptions")
980 self.menuOptions.setTitle(tr(titre))
981 for elt in lesFonctions :
982 laFonctionUtilisateur, label, lesArguments = elt
983 action = QAction(self)
984 action.setText(label)
985 #action.triggered.connect(self.appelleFonctionUtilisateur)
986 self.menuOptions.addAction(action)
987 self.lesFonctionsUtilisateurs[action]=(laFonctionUtilisateur, lesArguments)
988 self.menuOptions.triggered.connect(self.handleFonctionUtilisateur)
990 def handleFonctionUtilisateur(self,action) :
991 (laFonctionUtilisateur, lesArguments)=self.lesFonctionsUtilisateurs[action]
992 self.viewmanager.handleFonctionUtilisateur(laFonctionUtilisateur, lesArguments)
994 if __name__=='__main__':
997 rep=os.path.abspath(os.path.join(os.path.dirname(os.path.abspath(__file__),'..','Adao')))
999 from Adao import prefs
1000 from Adao import prefs_Adao
1001 #if hasattr(prefsCode,'encoding'):
1002 # Hack pour changer le codage par defaut des strings
1005 #sys.setdefaultencoding(prefsCode.encoding)
1006 #del sys.setdefaultencoding
1009 from Editeur import import_code
1010 from Editeur import session
1012 # Analyse des arguments de la ligne de commande
1013 options=session.parse(sys.argv)
1017 app = QApplication(sys.argv)
1018 #app.setMainWidget(mw) (qt3)