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)
71 self.definitCode(code,None)
73 print ('il faut trouver le chemin du code')
76 self.suiteTelemac=False
77 if hasattr (self, 'maConfiguration') :
78 if self.maConfiguration.demandeLangue :
79 from InterfaceQT4.monChoixLangue import MonChoixLangue
80 widgetLangue = MonChoixLangue(self)
81 ret=widgetLangue.exec_()
82 self.suiteTelemac=self.maConfiguration.suiteTelemac
85 if not self.salome and hasattr (self, 'maConfiguration') and hasattr(self.maConfiguration,'lang') : self.langue=self.maConfiguration.lang
86 from Extensions import localisation
88 if hasattr (self, 'maConfiguration') : localisation.localise(None,self.langue,translatorFichier=self.maConfiguration.translatorFichier)
91 #if parent != None : self.parentCentralWidget = parent.centralWidget()
92 #else : self.parentCentralWidget = None
95 if hasattr (self, 'maConfiguration') and hasattr(self.maConfiguration,'taille') : self.taille=self.maConfiguration.taille
96 else : self.taille=1700
98 self.resize(self.taille,self.height())
101 icon = QIcon(self.repIcon+"/parametres.png")
102 self.actionParametres.setIcon(icon)
103 if hasattr (self, 'maConfiguration') and self.maConfiguration.boutonDsMenuBar :
104 self.frameEntete.setMaximumSize(QSize(16777215,100))
105 self.frameEntete.setMinimumSize(QSize(0,100))
106 if hasattr (self, 'maConfiguration') and self.maConfiguration.enleverActionStructures :
107 self.enleverActionsStructures()
108 if hasattr (self, 'maConfiguration') and self.maConfiguration.enleverParametres :
109 self.enleverParametres()
110 if hasattr (self, 'maConfiguration') and self.maConfiguration.enleverSupprimer :
111 self.enleverSupprimer()
114 self.myQtab.removeTab(0)
115 self.blEnteteGlob = QBoxLayout(2,self.frameEntete)
116 self.blEnteteGlob.setSpacing(0)
117 self.blEnteteGlob.setContentsMargins(0,0,0,0)
119 self.blEntete = QBoxLayout(0)
120 self.blEntete.insertWidget(0,self.toolBar)
121 self.blEntete.insertWidget(0,self.menubar)
122 self.blEnteteGlob.insertLayout(0,self.blEntete)
126 if hasattr (self, 'maConfiguration') and self.maConfiguration.boutonDsMenuBar :
127 self.blEnteteCommmande = QBoxLayout(0)
128 self.blEnteteCommmande.insertWidget(0,self.toolBarCommande)
129 self.toolBarCommande.setIconSize(QSize(96,96))
130 self.blEnteteGlob.insertLayout(-1,self.blEnteteCommmande)
132 self.toolBarCommande.close()
135 if hasattr (self, 'maConfiguration') and self.maConfiguration.closeEntete==True and self.salome: self.closeEntete()
137 eficas_root_dir = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
139 self.viewmanager = MyViewManager(self)
140 self.recentMenu=QMenu(tr('&Recents'))
141 #self.menuFichier.insertMenu(self.actionOuvrir,self.recentMenu)
143 # actionARemplacer ne sert que pour l insert Menu
144 self.menuFichier.insertMenu(self.actionARemplacer ,self.recentMenu)
145 self.menuFichier.removeAction(self.actionARemplacer)
146 self.connecterSignaux()
147 self.toolBar.addSeparator()
150 if self.code != None : self.construitMenu()
152 self.setWindowTitle(self.VERSION_EFICAS)
155 #print ('attention try devient if 1')
157 except EficasException as exc:
159 print ("je suis dans le except")
160 if self.salome == 0 : exit()
164 def closeEntete(self):
165 self.menuBar().close()
167 self.frameEntete.close()
169 def definitCode(self,code,ssCode) :
174 from InterfaceQT4.monChoixCode import MonChoixCode
175 widgetChoix = MonChoixCode(self)
176 ret=widgetChoix.exec_()
178 if self.code == None:return # pour le cancel de la fenetre choix code
179 AppliSsIhm.definitCode(self,self.code,ssCode)
181 #PN --> pb d exception qui font planter salome
182 # plus supporte en python 3
184 #if hasattr(prefsCode,'encoding'):
187 # sys.setdefaultencoding(prefsCode.encoding)
189 def construitMenu(self):
193 for intituleMenu in ("menuTraduction","menuOptions","menuMesh","menuExecution","menuN1"):
194 if hasattr(self,intituleMenu):
195 menu=getattr(self,intituleMenu)
196 menu.setAttribute(Qt.WA_DeleteOnClose)
198 delattr(self,intituleMenu)
199 for intituleAction in ("actionExecution","actionSaveRun"):
200 if hasattr(self,intituleAction):
201 action=getattr(self,intituleAction)
202 self.toolBar.removeAction(action)
203 if self.code.upper() in Appli.__dict__:
204 Appli.__dict__[self.code.upper()](self,)
205 if self.suiteTelemac : self.lookSuiteTelemac()
206 self.metMenuAJourUtilisateurs()
207 if hasattr (self, 'maConfiguration') and self.maConfiguration.ajoutExecution :
208 self.ajoutExecution()
212 repAide=os.path.dirname(os.path.abspath(__file__))
213 fileName='index.html'
214 self.docPath=repAide+"/../Aide"
215 if hasattr(self,'maConfiguration') and hasattr(self.maConfiguration,'docPath') : self.docPath=self.maConfiguration.docPath
216 if hasattr(self,'maConfiguration') and hasattr(self.maConfiguration,'fileName'):fileName=self.maConfiguration.fileName
217 self.fileDoc=os.path.join(self.docPath,fileName)
218 self.actionCode.setText(tr("Aide specifique ")+str(self.code))
219 if not os.path.isfile(self.fileDoc) :
222 self.actionCode.setEnabled(False)
225 self.actionCode.setEnabled(True)
226 self.menuAide.addAction(self.actionCode)
232 dirCode=os.path.abspath(os.path.join(os.path.abspath(__file__),'../..',"ProcessOutputs_Eficas"))
233 sys.path.insert(0,dirCode)
235 self.definitCode(code,ssCode)
245 dirCode=os.path.abspath(os.path.join(os.path.abspath(__file__),'../..',code))
246 sys.path.insert(0,dirCode)
248 self.definitCode(code,ssCode)
255 self.menuN1 = self.menubar.addMenu(tr("Process Output"))
256 self.actionN1 = QAction(self)
257 self.actionN1.setText(tr("Process Output"))
258 self.menuN1.addAction(self.actionN1)
259 self.actionN1.triggered.connect(self.newN1)
262 if hasattr(self,'actionOpenProcess'):return
264 self.actionOpenProcess = QAction(self)
265 self.actionOpenProcess.setText(tr("Open Process_Output File"))
266 self.menuN1.addAction(self.actionOpenProcess)
267 self.actionOpenProcess.triggered.connect(self.openProcess)
269 def ajoutExecution(self):
270 self.menuExecution = self.menubar.addMenu(tr("&Run"))
271 self.actionExecution = QAction(self)
272 if sys.platform[0:5]=="linux":
273 icon6 = QIcon(self.repIcon+"/roue.png")
274 self.actionExecution.setIcon(icon6)
276 self.actionExecution.setText(tr("Run"))
277 self.actionExecution.setObjectName("actionExecution")
278 self.menuExecution.addAction(self.actionExecution)
279 if not(self.actionExecution in self.toolBar.actions()):
280 self.toolBar.addAction(self.actionExecution)
281 self.actionExecution.setText(tr("Run"))
282 self.actionExecution.triggered.connect(self.run)
284 def ajoutSauveExecution(self):
285 self.actionSaveRun = QAction(self)
286 icon7 = QIcon(self.repIcon+"/export_MAP.png")
287 self.actionSaveRun.setIcon(icon7)
288 self.actionSaveRun.setObjectName("actionSaveRun")
289 self.menuExecution.addAction(self.actionSaveRun)
290 if not(self.actionSaveRun in self.toolBar.actions()):
291 self.toolBar.addAction(self.actionSaveRun)
292 self.actionSaveRun.setText(tr("Save Run"))
293 self.actionSaveRun.triggered.connect(self.saveRun)
295 def griserActionsStructures(self):
296 self.actionCouper.setEnabled(False)
297 self.actionColler.setEnabled(False)
298 self.actionCopier.setEnabled(False)
299 self.actionSupprimer.setEnabled(False)
301 def enleverActionsStructures(self):
302 self.toolBar.removeAction(self.actionCopier)
303 self.toolBar.removeAction(self.actionColler)
304 self.toolBar.removeAction(self.actionCouper)
305 self.menuEdition.removeAction(self.actionCouper)
306 self.menuEdition.removeAction(self.actionCopier)
307 self.menuEdition.removeAction(self.actionColler)
310 def enleverParametres(self):
311 self.toolBar.removeAction(self.actionParametres)
312 self.menuJdC.removeAction(self.actionParametres)
314 def enleverSupprimer(self):
315 self.toolBar.removeAction(self.actionSupprimer)
317 def enlevernewInclude(self):
318 self.actionNouvel_Include.setVisible(False)
320 def enleverRechercherDsCatalogue(self):
321 self.actionRechercherDsCatalogue.setVisible(False)
323 def connectRechercherDsCatalogue(self):
324 if hasattr(self,'rechercherDejaLa') : return
325 self.rechercherDejaLa=True
326 self.actionRechercherDsCatalogue.triggered.connect(self.handleRechercherDsCatalogue)
328 def ajoutSortieComplete(self):
329 if hasattr(self,'actionSortieComplete') : return
330 self.actionSortieComplete = QAction(self)
331 self.actionSortieComplete.setText(tr("Sortie Complete"))
332 self.menuFichier.insertAction(self.actionEnregistrer_sous,self.actionSortieComplete)
333 self.actionSortieComplete.triggered.connect(self.handleSortieComplete)
337 self.enlevernewInclude()
338 self.toolBar.addSeparator()
342 self.enlevernewInclude()
343 self.toolBar.addSeparator()
344 self.ajoutExecution()
346 self.menuOptions = self.menubar.addMenu("menuOptions")
347 self.menuOptions.addAction(self.actionParametres_Eficas)
348 self.menuOptions.setTitle(tr("Options"))
351 self.enleverActionsStructures()
352 self.enlevernewInclude()
355 self.menuTraduction = self.menubar.addMenu("menuTraduction")
356 self.menuTraduction.addAction(self.actionTraduitV11V12)
357 self.menuTraduction.addAction(self.actionTraduitV10V11)
358 self.menuTraduction.addAction(self.actionTraduitV9V10)
359 self.menuTraduction.setTitle(tr("Traduction"))
361 self.menuFichier.addAction(self.actionSauveLigne)
363 self.menuOptions = self.menubar.addMenu("menuOptions")
364 self.menuOptions.addAction(self.actionParametres_Eficas)
365 self.menuOptions.addAction(self.actionLecteur_Pdf)
366 self.menuOptions.setTitle(tr("Options"))
369 #if self.salome == 0 : return
370 self.enlevernewInclude()
371 self.menuMesh = self.menubar.addMenu(tr("Gestion Maillage"))
372 self.menuMesh.setObjectName("Mesh")
373 self.menuMesh.addAction(self.actionChercheGrpMaille)
374 #self.griserActionsStructures()
377 self.enlevernewInclude()
378 self.enleverRechercherDsCatalogue()
379 self.ajoutExecution()
380 self.ajoutSauveExecution()
381 self.griserActionsStructures()
384 self.enlevernewInclude()
385 self.toolBar.addSeparator()
386 self.ajoutExecution()
387 self.ajoutSauveExecution()
388 self.menuOptions = self.menubar.addMenu("menuOptions")
389 self.menuOptions.addAction(self.actionParametres_Eficas)
390 self.menuOptions.setTitle(tr("Options"))
392 def MAPIDENTIFICATION(self):
393 self.enlevernewInclude()
394 self.enleverSupprimer()
395 #self.ajoutExecution()
396 self.enleverRechercherDsCatalogue()
397 self.enleverActionsStructures()
398 self.enleverParametres()
401 try : self.action_Nouveau.triggered.disconnect(self.fileNew)
403 try : self.action_Nouveau.triggered.disconnect(self.newPSEN)
406 self.action_Nouveau.triggered.connect(self.newPSEN)
407 self.enleverActionsStructures()
408 self.enleverParametres()
409 self.enleverRechercherDsCatalogue()
410 self.enlevernewInclude()
411 self.ajoutExecution()
417 self.enleverActionsStructures()
418 self.enleverParametres()
419 self.enleverRechercherDsCatalogue()
420 self.enlevernewInclude()
421 self.ajoutExecution()
425 self.enleverActionsStructures()
426 self.enlevernewInclude()
427 self.connectRechercherDsCatalogue()
428 self.ajoutSortieComplete()
430 def lookSuiteTelemac(self):
431 self.enleverActionsStructures()
432 self.enlevernewInclude()
433 self.enleverParametres()
434 self.enleverSupprimer()
435 self.enleverRechercherDsCatalogue()
437 def ajoutHelpPSEN(self):
438 self.actionParametres_Eficas.setText('Help PSEN')
439 self.actionParametres_Eficas.triggered.connect(self.aidePSEN)
443 def ChercheGrpMesh(self):
444 Msg,listeGroup=self.ChercheGrpMeshInSalome()
446 self.viewmanager.handleAjoutGroup(listeGroup)
448 print ("il faut gerer les erreurs")
450 def ChercheGrpMaille(self):
451 # Normalement la variable self.salome permet de savoir si on est ou non dans Salome
453 Msg,listeGroup=self.ChercheGrpMailleInSalome() # recherche dans Salome
454 #Msg = None; listeGroup = None # recherche manuelle, i.e., sans Salome si ligne precedente commentee
456 raise ValueError('Salome non ouvert')
458 self.viewmanager.handleAjoutGroup(listeGroup)
460 print ("il faut gerer les erreurs")
463 def ChercheGrp(self):
464 #Msg,listeGroup=self.ChercheGrpMailleInSalome()
466 # self.viewmanager.handleAjoutGroup(listeGroup)
468 #print "il faut gerer "
472 def ajoutIcones(self) :
473 # Pour pallier les soucis de repertoire d icone
475 icon = QIcon(self.repIcon+"/new_file.png")
476 self.action_Nouveau.setIcon(icon)
477 icon1 = QIcon(self.repIcon+"/ouvrir.png")
478 self.actionOuvrir.setIcon(icon1)
479 icon2 = QIcon(self.repIcon+"/save.png")
480 self.actionEnregistrer.setIcon(icon2)
481 icon6 = QIcon(self.repIcon+"/delete.png")
482 self.actionSupprimer.setIcon(icon6)
483 icon7 = QIcon(self.repIcon+"/roue.png")
484 self.actionExecution.setIcon(icon7)
489 def connecterSignauxQT4(self) :
490 self.connect(self.recentMenu,SIGNAL('aboutToShow()'),self.handleShowRecentMenu)
492 self.connect(self.action_Nouveau,SIGNAL("triggered()"),self.fileNew)
493 self.connect(self.actionNouvel_Include,SIGNAL("triggered()"),self.newInclude)
494 self.connect(self.actionOuvrir,SIGNAL("triggered()"),self.fileOpen)
495 self.connect(self.actionEnregistrer,SIGNAL("triggered()"),self.fileSave)
496 self.connect(self.actionEnregistrer_sous,SIGNAL("triggered()"),self.fileSaveAs)
497 self.connect(self.actionFermer,SIGNAL("triggered()"),self.fileClose)
498 self.connect(self.actionFermer_tout,SIGNAL("triggered()"),self.fileCloseAll)
499 self.connect(self.actionQuitter,SIGNAL("triggered()"),self.fileExit)
501 self.connect(self.actionEficas,SIGNAL("triggered()"),self.aidePPal)
502 self.connect(self.actionVersion,SIGNAL("triggered()"),self.version)
503 self.connect(self.actionParametres,SIGNAL("triggered()"),self.gestionParam)
505 self.connect(self.actionCouper,SIGNAL("triggered()"),self.editCut)
506 self.connect(self.actionCopier,SIGNAL("triggered()"),self.editCopy)
507 self.connect(self.actionColler,SIGNAL("triggered()"),self.editPaste)
508 self.connect(self.actionSupprimer,SIGNAL("triggered()"),self.supprimer)
509 self.connect(self.actionRechercher,SIGNAL("triggered()"),self.rechercher)
510 self.connect(self.actionDeplier_replier,SIGNAL("triggered()"),self.handleDeplier)
512 self.connect(self.actionRapport_de_Validation,SIGNAL("triggered()"),self.jdcRapport)
513 self.connect(self.actionRegles_du_JdC,SIGNAL("triggered()"),self.jdcRegles)
514 self.connect(self.actionFichier_Source,SIGNAL("triggered()"),self.jdcFichierSource)
515 self.connect(self.actionFichier_Resultat,SIGNAL("triggered()"),self.visuJdcPy)
521 self.actionTraduitV9V10 = QAction(self)
522 self.actionTraduitV9V10.setObjectName("actionTraduitV9V10")
523 self.actionTraduitV9V10.setText(tr("TraduitV9V10"))
524 self.actionTraduitV10V11 = QAction(self)
525 self.actionTraduitV10V11.setObjectName("actionTraduitV10V11")
526 self.actionTraduitV10V11.setText(tr("TraduitV10V11"))
527 self.actionTraduitV11V12 = QAction(self)
528 self.actionTraduitV11V12.setObjectName("actionTraduitV11V12")
529 self.actionTraduitV11V12.setText(tr("TraduitV11V12"))
530 self.actionSauveLigne = QAction(self)
531 self.actionSauveLigne.setText(tr("Sauve Format Ligne"))
533 #self.connect(self.actionParametres_Eficas,SIGNAL("triggered()"),self.optionEditeur)
534 self.connect(self.actionLecteur_Pdf,SIGNAL("triggered()"),self.optionPdf)
535 self.connect(self.actionTraduitV9V10,SIGNAL("triggered()"),self.traductionV9V10)
536 self.connect(self.actionTraduitV10V11,SIGNAL("triggered()"),self.traductionV10V11)
537 self.connect(self.actionTraduitV11V12,SIGNAL("triggered()"),self.traductionV11V12)
538 self.connect(self.actionSauveLigne,SIGNAL("triggered()"),self.sauveLigne)
542 self.actionChercheGrpMaille = QAction(self)
543 self.actionChercheGrpMaille.setText(tr("Acquiert groupe mailles"))
544 self.connect(self.actionChercheGrpMaille,SIGNAL("triggered()"),self.ChercheGrpMaille)
547 self.actionChercheGrp = QAction(self)
548 self.actionChercheGrp.setText(tr("Acquisition Groupe Maille"))
549 self.connect(self.actionChercheGrp,SIGNAL("triggered()"),self.ChercheGrp)
552 self.actionCode = QAction(self)
553 self.actionCode.setText(tr("Specificites Maille"))
554 self.connect(self.actionCode,SIGNAL("triggered()"),self.aideCode)
556 def connecterSignaux(self) :
558 self.recentMenu.aboutToShow.connect(self.handleShowRecentMenu)
559 self.action_Nouveau.triggered.connect(self.fileNew)
560 self.actionNouvel_Include.triggered.connect(self.newInclude)
561 self.actionOuvrir.triggered.connect(self.fileOpen)
562 self.actionEnregistrer.triggered.connect(self.fileSave)
563 self.actionEnregistrer_sous.triggered.connect(self.fileSaveAs)
564 self.actionFermer.triggered.connect(self.fileClose)
565 self.actionFermer_tout.triggered.connect(self.fileCloseAll)
566 self.actionQuitter.triggered.connect(self.fileExit)
568 self.actionEficas.triggered.connect(self.aidePPal)
569 self.actionVersion.triggered.connect(self.version)
570 self.actionParametres.triggered.connect(self.gestionParam)
571 self.actionCommentaire.triggered.connect(self.ajoutCommentaire)
573 self.actionCouper.triggered.connect(self.editCut)
574 self.actionCopier.triggered.connect(self.editCopy)
575 self.actionColler.triggered.connect(self.editPaste)
576 self.actionSupprimer.triggered.connect(self.supprimer)
577 self.actionRechercher.triggered.connect(self.rechercher)
578 self.actionDeplier_replier.triggered.connect(self.handleDeplier)
580 self.actionRapport_de_Validation.triggered.connect(self.jdcRapport)
581 self.actionRegles_du_JdC.triggered.connect(self.jdcRegles)
582 self.actionFichier_Source.triggered.connect(self.jdcFichierSource)
583 self.actionFichier_Resultat.triggered.connect(self.visuJdcPy)
584 self.actionAfficher_l_Arbre.triggered.connect(self.ouvreArbre)
585 self.actionCacher_l_Arbre.triggered.connect(self.fermeArbre)
589 self.actionTraduitV9V10 = QAction(self)
590 self.actionTraduitV9V10.setObjectName("actionTraduitV9V10")
591 self.actionTraduitV9V10.setText(tr("TraduitV9V10"))
592 self.actionTraduitV10V11 = QAction(self)
593 self.actionTraduitV10V11.setObjectName("actionTraduitV10V11")
594 self.actionTraduitV10V11.setText(tr("TraduitV10V11"))
595 self.actionTraduitV11V12 = QAction(self)
596 self.actionTraduitV11V12.setObjectName("actionTraduitV11V12")
597 self.actionTraduitV11V12.setText(tr("TraduitV11V12"))
598 self.actionSauveLigne = QAction(self)
599 self.actionSauveLigne.setText(tr("Sauve Format Ligne"))
601 #self.actionParametres_Eficas.triggered.connect(self.optionEditeur)
602 self.actionTraduitV9V10.triggered.connect(self.traductionV9V10)
603 self.actionTraduitV10V11.triggered.connect(self.traductionV10V11)
604 self.actionTraduitV11V12.triggered.connect(self.traductionV11V12)
605 self.actionSauveLigne.triggered.connect(self.sauveLigne)
608 self.actionChercheGrpMaille = QAction(self)
609 self.actionChercheGrpMaille.setText(tr("Acquiert Groupe Maille"))
612 self.actionChercheGrp = QAction(self)
613 self.actionChercheGrp.setText(tr("Accquisition Groupe Maille"))
614 self.actionChercheGrp.triggered.connect(self.ChercheGrp)
617 self.actionCode = QAction(self)
618 self.actionCode.setText(tr("Specificites Maille"))
619 self.actionCode.triggered.connect(self.aideCode)
622 def handleDeplier(self):
623 self.viewmanager.handleDeplier()
625 def ajoutCommentaire(self):
626 self.viewmanager.ajoutCommentaire()
628 def ouvreFichiers(self) :
629 # Ouverture des fichiers de commandes donnes sur la ligne de commande
632 for study in session.d_env.studies:
634 d=session.getUnit(study,self)
635 self.viewmanager.handleOpen(fichier=study["comm"],units=d)
638 def getSource(self,file):
639 # appele par Editeur/session.py
641 p=convert.plugins['python']()
643 texte=p.convert('execnoparseur')
646 def initPatrons(self) :
647 # Mise a jour du menu des fichiers recemment ouverts
648 from Editeur import listePatrons
649 if not(self.code in listePatrons.sous_menus) :
650 if hasattr(self,"menuPatrons"):
651 self.menuPatrons.setAttribute(Qt.WA_DeleteOnClose)
652 self.menuPatrons.close()
653 delattr(self,"menuPatrons")
655 if (not hasattr(self,"menuPatrons")):
656 self.menuPatrons = QMenu(self.menubar)
657 self.menuPatrons.setObjectName("menuPatrons")
658 self.menubar.addAction(self.menuPatrons.menuAction())
659 self.menuPatrons.setTitle(tr("Patrons"))
661 self.menuPatrons.clear()
662 self.listePatrons = listePatrons.listePatrons(self.code)
664 for nomSsMenu in self.listePatrons.liste:
665 ssmenu=self.menuPatrons.addMenu(nomSsMenu)
666 for fichier in self.listePatrons.liste[nomSsMenu]:
667 id = ssmenu.addAction(fichier)
668 self.ficPatrons[id]=fichier
669 self.id.triggered.connect(self.handleOpenPatrons)
670 # self.Patrons.setItemParameter(id,idx)
673 def initRecents(self):
676 rep=os.path.join(os.path.expanduser("~"),'.config/Eficas',self.code)
677 monFichier=rep+"/listefichiers_"+self.code
683 l=(ligne.split("\n"))[0]
684 self.recent.append(l)
692 def addToRecentList(self, fn):
693 while fn in self.recent: self.recent.remove(fn)
694 self.recent.insert(0,fn)
695 if len(self.recent) > 9:
696 self.recent = self.recent[:9]
699 def addToRecentListQT4(self, fn):
701 Public slot to add a filename to the list of recently opened files.
703 @param fn name of the file to be added
705 self.recent.removeAll(fn)
706 self.recent.prepend(fn)
707 if len(self.recent) > 9:
708 self.recent = self.recent[:9]
712 def sauveRecents(self) :
714 rep=self.maConfiguration.rep_user
715 monFichier=rep+"/listefichiers_"+self.code
719 f=open(monFichier,'w')
720 if len(self.recent) == 0 : return
722 while ( index < len(self.recent)):
723 ligne=str(self.recent[index])+"\n"
735 def traductionV11V12(self):
736 from .gereTraduction import traduction
737 traduction(self.maConfiguration.repIni,self.viewmanager,"V11V12")
739 def traductionV10V11(self):
740 from .gereTraduction import traduction
741 traduction(self.maConfiguration.repIni,self.viewmanager,"V10V11")
743 def traductionV9V10(self):
744 from .gereTraduction import traduction
745 traduction(self.maConfiguration.repIni,self.viewmanager,"V9V10")
748 from .monVisu import DVisu
749 titre = tr("version ")
750 monVisuDialg=DVisu(parent=self,fl=0)
751 monVisuDialg.setWindowTitle(titre)
752 if self.code != None : monVisuDialg.TB.setText(self.VERSION_EFICAS +tr(" pour ") + self.code)
753 else : monVisuDialg.TB.setText(self.VERSION_EFICAS )
754 monVisuDialg.adjustSize()
758 repAide=os.path.dirname(os.path.abspath(__file__))
759 maD=os.path.join( repAide,'..','Doc')
761 indexAide=os.path.join(maD,'index.html')
762 if sys.platform[0:5]=="linux" : cmd="xdg-open "+indexAide
763 else : cmd="start "+indexAide
766 QMessageBox.warning( self,tr( "Aide Indisponible"),tr( "l'aide n est pas installee "))
769 repAide=os.path.dirname(os.path.abspath(__file__))
770 maD=os.path.join( repAide,'..','Doc')
772 indexAide=os.path.join(maD,'index.html')
773 if sys.platform[0:5]=="linux" : cmd="xdg-open "+indexAide
774 else : cmd="start "+indexAide
777 QMessageBox.warning( self,tr( "Aide Indisponible"),tr( "l'aide n est pas installee "))
780 if self.code==None : return
783 if sys.platform[0:5]=="linux" : cmd="xdg-open "+self.fileDoc
784 else : cmd="start "+self.fileDoc
788 QMessageBox.warning( self,tr( "Aide Indisponible"),tr( "l'aide n est pas installee "))
791 def optionEditeur(self) :
793 name='monOptions_'+self.code
795 QMessageBox.critical( self,tr( "Parametrage"),tr( "Veuillez d abord choisir un code"))
799 optionCode=__import__(name)
802 QMessageBox.critical( self, tr("Parametrage"), tr("Pas de possibilite de personnalisation de la configuration "))
804 monOption=optionCode.Options(parent=self,modal = 0 ,configuration=self.maConfiguration)
807 def optionPdf(self) :
808 from monOptionsPdf import OptionPdf
809 monOption=OptionPdf(parent=self,modal = 0 ,configuration=self.maConfiguration)
812 def handleSortieComplete(self):
813 return self.viewmanager.saveCompleteCurrentEditor()
815 def handleShowRecentMenu(self):
817 Private method to set up recent files menu.
819 self.recentMenu.clear()
821 for rp in self.recent:
822 id = self.recentMenu.addAction(rp)
823 self.ficRecents[id]=rp
824 id.triggered.connect(self.handleOpenRecent)
825 self.recentMenu.addSeparator()
826 self.recentMenu.addAction(tr('&Effacer'), self.handleClearRecent)
828 def handleOpenPatrons(self):
830 fichier=self.repIni+"/../Editeur/Patrons/"+self.code+"/"+self.ficPatrons[idx]
831 self.viewmanager.handleOpen(fichier=fichier, patron = 1)
833 def handleOpenRecent(self):
835 fichier=self.ficRecents[idx]
836 self.viewmanager.handleOpen(fichier=fichier, patron =0 )
838 def handleClearRecent(self):
839 self.recent = QStringList()
842 def handleRechercherDsCatalogue(self):
843 if not self.viewmanager : return
844 self.viewmanager.handleRechercherDsCatalogue()
848 self.viewmanager.newEditor()
849 except EficasException as exc:
851 if msg != "": QMessageBox.warning(self, tr(u"Erreur"), msg)
853 def openProcess(self):
857 dirCode=os.path.abspath(os.path.join(os.path.abspath(__file__),'../..',"ProcessOutputs_Eficas"))
858 sys.path.insert(0,dirCode)
860 self.definitCode(code,ssCode)
869 self.viewmanager.handleOpen()
870 except EficasException as exc:
873 QMessageBox.warning(self, tr(u"Erreur"), msg)
875 def sauveLigne(self):
876 return self.viewmanager.sauveLigneCurrentEditor()
879 return self.viewmanager.saveCurrentEditor()
881 def fileSaveAs(self):
882 return self.viewmanager.saveAsCurrentEditor()
885 self.viewmanager.handleClose(texte='&Fermer')
887 def fileCloseAll(self):
888 self.viewmanager.handleCloseAll(texte='&Fermer')
891 # On peut sortir sur Abort
892 res=self.viewmanager.handleCloseAll()
898 self.viewmanager.handleEditCopy()
901 self.viewmanager.handleEditCut()
904 self.viewmanager.handleEditPaste()
906 def rechercher(self):
907 self.viewmanager.handleRechercher()
910 self.viewmanager.run()
913 self.viewmanager.saveRun()
917 self.viewmanager.handleSupprimer()
919 def jdcFichierSource(self):
920 self.viewmanager.handleViewJdcFichierSource()
922 def jdcRapport(self):
923 self.viewmanager.handleViewJdcRapport()
926 self.viewmanager.handleViewJdcRegles()
928 def gestionParam(self):
929 self.viewmanager.handleGestionParam()
932 self.viewmanager.handleViewJdcPy()
934 def ouvreArbre(self):
935 self.viewmanager.ouvreArbre()
937 def fermeArbre(self):
938 self.viewmanager.fermeArbre()
940 def newInclude(self):
941 self.viewmanager.newIncludeEditor()
944 for pathCode in self.ListePathCode:
946 aEnlever=os.path.abspath(os.path.join(os.path.dirname(__file__),'..',pathCode))
947 sys.path.remove(aEnlever)
950 for pathCode in self.listeAEnlever:
952 sys.path.remove(aEnlever)
957 def closeEvent(self,event):
959 if res==2 : event.ignore()
962 def remplitIconesCommandes(self):
963 if self.maConfiguration.boutonDsMenuBar == False : return
964 if not hasattr(self, 'readercata') : return
965 from monLayoutBouton import MonLayoutBouton
966 if hasattr(self,'monLayoutBoutonRempli') : return
967 self.monLayoutBoutonRempli=MonLayoutBouton(self)
969 def handleAjoutEtape(self,nomEtape):
970 self.viewmanager.handleAjoutEtape(nomEtape)
972 def metMenuAJourUtilisateurs(self):
973 self.lesFonctionsUtilisateurs={}
974 if self.code not in self.mesScripts : return
975 if not hasattr(self.mesScripts[self.code],'dict_menu') : return
976 for monMenu in iter(self.mesScripts[self.code].dict_menu.items()) :
977 titre,lesFonctions= monMenu
978 self.menuOptions = self.menubar.addMenu("menuOptions")
979 self.menuOptions.setTitle(tr(titre))
980 for elt in lesFonctions :
981 laFonctionUtilisateur, label, lesArguments = elt
982 action = QAction(self)
983 action.setText(label)
984 #action.triggered.connect(self.appelleFonctionUtilisateur)
985 self.menuOptions.addAction(action)
986 self.lesFonctionsUtilisateurs[action]=(laFonctionUtilisateur, lesArguments)
987 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
1002 from Editeur import import_code
1003 from Editeur import session
1005 # Analyse des arguments de la ligne de commande
1006 options=session.parse(sys.argv)
1010 app = QApplication(sys.argv)
1011 #app.setMainWidget(mw) (qt3)