1 # -*- coding: iso-8859-1 -*-
2 # Copyright (C) 2007-2013 EDF R&D
4 # This library is free software; you can redistribute it and/or
5 # modify it under the terms of the GNU Lesser General Public
6 # License as published by the Free Software Foundation; either
7 # version 2.1 of the License.
9 # This library is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 # Lesser General Public License for more details.
14 # You should have received a copy of the GNU Lesser General Public
15 # License along with this library; if not, write to the Free Software
16 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
22 from determine import monEnvQT5
24 from PyQt5.QtWidgets import QApplication, QMainWindow, QBoxLayout, QMenu, QAction, QMessageBox
25 from PyQt5.QtGui import QIcon
26 from PyQt5.QtCore import Qt
28 from PyQt4.QtGui import *
29 from PyQt4.QtCore import *
31 from Extensions.i18n import tr
32 from Extensions.eficas_exception import EficasException
33 from Extensions import param2
36 from myMain import Ui_Eficas
37 from viewManager import MyTabview
38 from getVersion import getEficasVersion
39 from Editeur import session
43 class Appli(Ui_Eficas,QMainWindow):
45 Class implementing the main user interface.
47 def __init__(self,code=None,salome=0,parent=None,ssCode=None,multi=False,langue='fr',ssIhm=False):
51 QMainWindow.__init__(self,parent)
52 Ui_Eficas.__init__(self)
55 version=getEficasVersion()
56 self.VERSION_EFICAS="Eficas QT4 Salome "+version
57 if monEnvQT5 : self.VERSION_EFICAS="Eficas QT5 Salome "
59 self.parentMainWindow=parent
62 self.top = self #(pour CONFIGURATION)
63 self.QWParent=None #(Pour lancement sans IHM)
68 if monEnvQT5 : self.recent = []
69 else : self.recent = QStringList()
73 self.ListePathCode=['Adao','ADAO','Carmel3D','Telemac','CF','MAP','ZCracks', 'SEP','SPECA','PSEN_Eficas','PSEN_N1']
74 self.listeCode=['Adao','ADAO','Carmel3D','Telemac','CF','MAP','ZCracks', 'SEP','SPECA','PSEN_Eficas','PSEN_N1']
75 self.repIcon=os.path.join( os.path.dirname(os.path.abspath(__file__)),'..','Editeur','icons')
81 Accas.SalomeEntry = eficasSalome.SalomeEntry
84 self.demande=multi # specifique PSEN
87 if self.multi == False :
88 self.definitCode(code,ssCode)
93 if not self.salome and hasattr (self, 'CONFIGURATION') and hasattr(self.CONFIGURATION,'lang') : langue=self.CONFIGURATION.lang
95 if langue=='fr': self.langue=langue
96 else : self.langue="ang"
98 self.suiteTelemac=False
99 if hasattr (self, 'CONFIGURATION') :
100 if self.CONFIGURATION.force_langue :
101 from monChoixLangue import MonChoixLangue
102 widgetLangue = MonChoixLangue(self)
103 ret=widgetLangue.exec_()
104 self.suiteTelemac=self.CONFIGURATION.suiteTelemac
107 from Extensions import localisation
109 localisation.localise(None,self.langue)
112 #if parent != None : self.parentCentralWidget = parent.centralWidget()
113 #else : self.parentCentralWidget = None
116 if hasattr (self, 'CONFIGURATION') and hasattr(self.CONFIGURATION,'taille') : self.taille=self.CONFIGURATION.taille
117 else : self.taille=1700
119 if self.code in ['MAP',] : self.resize(1440,self.height())
120 else : self.resize(self.taille,self.height())
123 icon = QIcon(self.repIcon+"/parametres.png")
124 self.actionParametres.setIcon(icon)
127 self.myQtab.removeTab(0)
128 self.blEntete= QBoxLayout(0,self.frameEntete)
129 self.blEntete.insertWidget(0,self.toolBar)
130 self.blEntete.insertWidget(0,self.menubar)
132 if hasattr (self, 'CONFIGURATION') and self.CONFIGURATION.closeEntete==True and self.salome: self.closeEntete()
134 eficas_root_dir = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
137 self.viewmanager = MyTabview(self)
138 self.recentMenu=QMenu(tr('&Recents'))
139 #self.menuFichier.insertMenu(self.actionOuvrir,self.recentMenu)
140 # actionARemplacer ne sert que pour l insert Menu
141 self.menuFichier.insertMenu(self.actionARemplacer ,self.recentMenu)
142 self.menuFichier.removeAction(self.actionARemplacer)
143 if monEnvQT5 : self.connecterSignaux()
144 else : self.connecterSignauxQT4()
145 self.toolBar.addSeparator()
146 if self.code != None : self.construitMenu()
148 self.setWindowTitle(self.VERSION_EFICAS)
152 #except EficasException, exc:
154 # print "je suis dans le except"
155 #if self.salome == 0 : exit()
159 def closeEntete(self):
160 self.menuBar().close()
162 self.frameEntete.close()
164 def definitCode(self,code,ssCode) :
169 from monChoixCode import MonChoixCode
170 widgetChoix = MonChoixCode(self)
171 ret=widgetChoix.exec_()
173 if self.code == None:return # pour le cancel de la fenetre choix code
174 name='prefs_'+self.code
175 prefsCode=__import__(name)
177 self.repIni=prefsCode.repIni
179 self.format_fichier= ssCode #par defaut
180 prefsCode.NAME_SCHEME=ssCode
182 self.format_fichier="python" #par defaut
184 nameConf='configuration_'+self.code
185 configuration=__import__(nameConf)
186 self.CONFIGURATION = configuration.make_config(self,prefsCode.repIni)
187 self.CONFIGStyle = None
188 if hasattr(configuration,'make_config_style'):
189 self.CONFIGStyle = configuration.make_config_style(self,prefsCode.repIni)
190 #PN --> pb d exception qui font planter salome
191 # plus supporte en python 3
192 #if hasattr(prefsCode,'encoding'):
195 # sys.setdefaultencoding(prefsCode.encoding)
197 def construitMenu(self):
202 for intituleMenu in ("menuTraduction","menuOptions","menuMesh","menuExecution","menuN1"):
203 if hasattr(self,intituleMenu):
204 menu=getattr(self,intituleMenu)
205 menu.setAttribute(Qt.WA_DeleteOnClose)
207 delattr(self,intituleMenu)
208 for intituleAction in ("actionExecution","actionSaveRun",):
209 if hasattr(self,intituleAction):
210 action=getattr(self,intituleAction)
211 self.toolBar.removeAction(action)
212 if self.code.upper() in Appli.__dict__.keys():
213 listeTexte=apply(Appli.__dict__[self.code.upper()],(self,))
214 if self.suiteTelemac : self.lookSuiteTelemac()
218 repAide=os.path.dirname(os.path.abspath(__file__))
219 fileName='index.html'
220 self.docPath=repAide+"/../Aide"
221 if hasattr(self,'CONFIGURATION') and hasattr(self.CONFIGURATION,'docPath') : self.docPath=self.CONFIGURATION.docPath
222 if hasattr(self,'CONFIGURATION') and hasattr(self.CONFIGURATION,'fileName'):fileName=self.CONFIGURATION.fileName
223 self.fileDoc=os.path.join(self.docPath,fileName)
224 self.actionCode.setText(tr("Aide specifique ")+str(self.code))
225 if not os.path.isfile(self.fileDoc) :
228 self.actionCode.setEnabled(False)
231 self.actionCode.setEnabled(True)
232 self.menuAide.addAction(self.actionCode)
238 dirCode=os.path.abspath(os.path.join(os.path.abspath(__file__),'../..',"ProcessOutputs_Eficas"))
239 sys.path.insert(0,dirCode)
241 self.definitCode(code,ssCode)
251 dirCode=os.path.abspath(os.path.join(os.path.abspath(__file__),'../..',code))
252 sys.path.insert(0,dirCode)
254 self.definitCode(code,ssCode)
260 self.menuN1 = self.menubar.addMenu(tr("Process Output"))
261 self.actionN1 = QAction(self)
262 self.actionN1.setText(tr("Process Output"))
263 self.menuN1.addAction(self.actionN1)
264 if monEnvQT5 : self.actionN1.triggered.connect(self.newN1)
265 else : self.connect(self.actionN1,SIGNAL("triggered()"),self.newN1)
269 if hasattr(self,'actionOpenProcess'):return
271 self.actionOpenProcess = QAction(self)
272 self.actionOpenProcess.setText(tr("Open Process_Output File"))
273 self.menuN1.addAction(self.actionOpenProcess)
274 if monEnvQT5 : self.actionOpenProcess.triggered.connect(self.openProcess)
275 else : self.connect(self.actionOpenProcess,SIGNAL("triggered()"),self.openProcess)
277 def ajoutExecution(self):
278 self.menuExecution = self.menubar.addMenu(tr("&Run"))
279 self.actionExecution = QAction(self)
280 if sys.platform[0:5]=="linux":
281 icon6 = QIcon(self.repIcon+"/roue.png")
282 self.actionExecution.setIcon(icon6)
284 self.actionExecution.setText(tr("Run"))
285 self.actionExecution.setObjectName("actionExecution")
286 self.menuExecution.addAction(self.actionExecution)
287 if not(self.actionExecution in self.toolBar.actions()):
288 self.toolBar.addAction(self.actionExecution)
289 self.actionExecution.setText(tr("Run"))
290 if monEnvQT5 : self.actionExecution.triggered.connect(self.run)
291 else : self.connect(self.actionExecution,SIGNAL("triggered()"),self.run)
293 def ajoutSauveExecution(self):
294 self.actionSaveRun = QAction(self)
295 icon7 = QIcon(self.repIcon+"/export_MAP.png")
296 self.actionSaveRun.setIcon(icon7)
297 self.actionSaveRun.setObjectName("actionSaveRun")
298 self.menuExecution.addAction(self.actionSaveRun)
299 if not(self.actionSaveRun in self.toolBar.actions()):
300 self.toolBar.addAction(self.actionSaveRun)
301 self.actionSaveRun.setText(tr("Save Run"))
302 if monEnvQT5 : self.actionSaveRun.triggered.connect(self.saveRun)
303 else : self.connect(self.actionSaveRun,SIGNAL("triggered()"),self.saveRun)
305 def griserActionsStructures(self):
306 self.actionCouper.setEnabled(False)
307 self.actionColler.setEnabled(False)
308 self.actionCopier.setEnabled(False)
309 self.actionSupprimer.setEnabled(False)
311 def enleverActionsStructures(self):
312 self.toolBar.removeAction(self.actionCopier)
313 self.toolBar.removeAction(self.actionColler)
314 self.toolBar.removeAction(self.actionCouper)
315 self.menuEdition.removeAction(self.actionCouper)
316 self.menuEdition.removeAction(self.actionCopier)
317 self.menuEdition.removeAction(self.actionColler)
320 def enleverParametres(self):
321 self.toolBar.removeAction(self.actionParametres)
322 self.menuJdC.removeAction(self.actionParametres)
324 def enleverSupprimer(self):
325 self.toolBar.removeAction(self.actionSupprimer)
327 def enleverNewInclude(self):
328 self.actionNouvel_Include.setVisible(False)
330 def enleverRechercherDsCatalogue(self):
331 self.actionRechercherDsCatalogue.setVisible(False)
333 def connectRechercherDsCatalogue(self):
335 self.actionRechercherDsCatalogue.triggered.connect(self.handleRechercherDsCatalogue)
337 self.connect(self.actionRechercherDsCatalogue,SIGNAL("triggered()"),self.handleRechercherDsCatalogue)
339 def ajoutSortieLegere(self):
340 if hasattr(self,'actionSortieLegere') : return
341 self.actionSortieLegere = QAction(self)
342 self.actionSortieLegere.setText(tr("Sortie Legere"))
343 self.menuFichier.insertAction(self.actionEnregistrer_sous,self.actionSortieLegere)
345 self.actionSortieLegere.triggered.connect(self.handleSortieLegere)
347 self.connect(self.actionSortieLegere,SIGNAL("triggered()"),self.handleSortieLegere)
351 self.enleverNewInclude()
352 self.toolBar.addSeparator()
353 self.ajoutExecution()
355 self.menuOptions = self.menubar.addMenu("menuOptions")
356 self.menuOptions.addAction(self.actionParametres_Eficas)
357 self.menuOptions.setTitle(tr("Options"))
360 self.enleverActionsStructures()
361 self.enleverNewInclude()
364 self.menuTraduction = self.menubar.addMenu("menuTraduction")
365 self.menuTraduction.addAction(self.actionTraduitV11V12)
366 self.menuTraduction.addAction(self.actionTraduitV10V11)
367 self.menuTraduction.addAction(self.actionTraduitV9V10)
368 self.menuTraduction.setTitle(tr("Traduction"))
370 self.menuFichier.addAction(self.actionSauveLigne)
372 self.menuOptions = self.menubar.addMenu("menuOptions")
373 self.menuOptions.addAction(self.actionParametres_Eficas)
374 self.menuOptions.addAction(self.actionLecteur_Pdf)
375 self.menuOptions.setTitle(tr("Options"))
378 #if self.salome == 0 : return
379 self.enleverNewInclude()
380 self.menuMesh = self.menubar.addMenu(tr("Gestion Maillage"))
381 self.menuMesh.setObjectName("Mesh")
382 self.menuMesh.addAction(self.actionChercheGrpMaille)
383 #self.griserActionsStructures()
386 self.enleverNewInclude()
387 self.enleverRechercherDsCatalogue()
388 self.ajoutExecution()
389 self.ajoutSauveExecution()
390 self.griserActionsStructures()
393 self.enleverNewInclude()
394 self.toolBar.addSeparator()
395 self.ajoutExecution()
396 self.ajoutSauveExecution()
397 self.menuOptions = self.menubar.addMenu("menuOptions")
398 self.menuOptions.addAction(self.actionParametres_Eficas)
399 self.menuOptions.setTitle(tr("Options"))
405 self.action_Nouveau.triggered.disconnect(self.fileNew)
406 self.action_Nouveau.triggered.connect(self.newPSEN)
409 self.disconnect(self.action_Nouveau,SIGNAL("triggered()"),self.fileNew)
410 self.connect(self.action_Nouveau,SIGNAL("triggered()"),self.newPSEN)
411 self.enleverActionsStructures()
412 self.enleverParametres()
413 self.enleverRechercherDsCatalogue()
414 self.enleverNewInclude()
415 self.ajoutExecution()
421 self.enleverActionsStructures()
422 self.enleverParametres()
423 self.enleverRechercherDsCatalogue()
424 self.enleverNewInclude()
425 self.ajoutExecution()
429 self.enleverActionsStructures()
430 self.enleverNewInclude()
431 self.connectRechercherDsCatalogue()
432 self.ajoutSortieLegere()
434 def lookSuiteTelemac(self):
435 self.enleverActionsStructures()
436 self.enleverNewInclude()
437 self.enleverParametres()
438 self.enleverSupprimer()
439 self.enleverRechercherDsCatalogue()
441 def ajoutHelpPSEN(self):
442 self.actionParametres_Eficas.setText('Help PSEN')
443 if monEnvQT5 : self.actionParametres_Eficas.triggered.connect(self.aidePSEN)
444 else : self.connect(self.actionParametres_Eficas,SIGNAL("triggered()"),self.aidePSEN)
448 def ChercheGrpMesh(self):
449 Msg,listeGroup=self.ChercheGrpMeshInSalome()
451 self.viewmanager.handleAjoutGroup(listeGroup)
453 print "il faut gerer les erreurs"
455 def ChercheGrpMaille(self):
456 # Normalement la variable self.salome permet de savoir si on est ou non dans Salome
458 Msg,listeGroup=self.ChercheGrpMailleInSalome() # recherche dans Salomé
459 #Msg = None; listeGroup = None # recherche manuelle, i.e., sans Salomé si ligne précédente commentée
461 raise ValueError('Salome non ouvert')
463 self.viewmanager.handleAjoutGroup(listeGroup)
465 print "il faut gerer les erreurs"
468 def ChercheGrp(self):
469 #Msg,listeGroup=self.ChercheGrpMailleInSalome()
471 # self.viewmanager.handleAjoutGroup(listeGroup)
473 #print "il faut gerer "
477 def ajoutIcones(self) :
478 # Pour pallier les soucis de repertoire d icone
480 icon = QIcon(self.repIcon+"/new_file.png")
481 self.action_Nouveau.setIcon(icon)
482 icon1 = QIcon(self.repIcon+"/ouvrir.png")
483 self.actionOuvrir.setIcon(icon1)
484 icon2 = QIcon(self.repIcon+"/save.png")
485 self.actionEnregistrer.setIcon(icon2)
486 icon6 = QIcon(self.repIcon+"/delete.png")
487 self.actionSupprimer.setIcon(icon6)
488 icon7 = QIcon(self.repIcon+"/roue.png")
489 self.actionExecution.setIcon(icon7)
494 def connecterSignauxQT4(self) :
495 self.connect(self.recentMenu,SIGNAL('aboutToShow()'),self.handleShowRecentMenu)
497 self.connect(self.action_Nouveau,SIGNAL("triggered()"),self.fileNew)
498 self.connect(self.actionNouvel_Include,SIGNAL("triggered()"),self.NewInclude)
499 self.connect(self.actionOuvrir,SIGNAL("triggered()"),self.fileOpen)
500 self.connect(self.actionEnregistrer,SIGNAL("triggered()"),self.fileSave)
501 self.connect(self.actionEnregistrer_sous,SIGNAL("triggered()"),self.fileSaveAs)
502 self.connect(self.actionFermer,SIGNAL("triggered()"),self.fileClose)
503 self.connect(self.actionFermer_tout,SIGNAL("triggered()"),self.fileCloseAll)
504 self.connect(self.actionQuitter,SIGNAL("triggered()"),self.fileExit)
506 self.connect(self.actionEficas,SIGNAL("triggered()"),self.aidePPal)
507 self.connect(self.actionVersion,SIGNAL("triggered()"),self.version)
508 self.connect(self.actionParametres,SIGNAL("triggered()"),self.gestionParam)
510 self.connect(self.actionCouper,SIGNAL("triggered()"),self.editCut)
511 self.connect(self.actionCopier,SIGNAL("triggered()"),self.editCopy)
512 self.connect(self.actionColler,SIGNAL("triggered()"),self.editPaste)
513 self.connect(self.actionSupprimer,SIGNAL("triggered()"),self.supprimer)
514 self.connect(self.actionRechercher,SIGNAL("triggered()"),self.rechercher)
515 self.connect(self.actionDeplier_replier,SIGNAL("triggered()"),self.Deplier)
517 self.connect(self.actionRapport_de_Validation,SIGNAL("triggered()"),self.jdcRapport)
518 self.connect(self.actionRegles_du_JdC,SIGNAL("triggered()"),self.jdcRegles)
519 self.connect(self.actionFichier_Source,SIGNAL("triggered()"),self.jdcFichierSource)
520 self.connect(self.actionFichier_Resultat,SIGNAL("triggered()"),self.visuJdcPy)
525 self.actionTraduitV9V10 = QAction(self)
526 self.actionTraduitV9V10.setObjectName("actionTraduitV9V10")
527 self.actionTraduitV9V10.setText(tr("TraduitV9V10"))
528 self.actionTraduitV10V11 = QAction(self)
529 self.actionTraduitV10V11.setObjectName("actionTraduitV10V11")
530 self.actionTraduitV10V11.setText(tr("TraduitV10V11"))
531 self.actionTraduitV11V12 = QAction(self)
532 self.actionTraduitV11V12.setObjectName("actionTraduitV11V12")
533 self.actionTraduitV11V12.setText(tr("TraduitV11V12"))
534 self.actionSauveLigne = QAction(self)
535 self.actionSauveLigne.setText(tr("Sauve Format Ligne"))
537 #self.connect(self.actionParametres_Eficas,SIGNAL("triggered()"),self.optionEditeur)
538 self.connect(self.actionLecteur_Pdf,SIGNAL("triggered()"),self.optionPdf)
539 self.connect(self.actionTraduitV9V10,SIGNAL("triggered()"),self.traductionV9V10)
540 self.connect(self.actionTraduitV10V11,SIGNAL("triggered()"),self.traductionV10V11)
541 self.connect(self.actionTraduitV11V12,SIGNAL("triggered()"),self.traductionV11V12)
542 self.connect(self.actionSauveLigne,SIGNAL("triggered()"),self.sauveLigne)
546 self.actionChercheGrpMaille = QAction(self)
547 self.actionChercheGrpMaille.setText(tr("Acquiert groupe mailles"))
548 self.connect(self.actionChercheGrpMaille,SIGNAL("triggered()"),self.ChercheGrpMaille)
551 self.actionChercheGrp = QAction(self)
552 self.actionChercheGrp.setText(tr("Acquisition Groupe Maille"))
553 self.connect(self.actionChercheGrp,SIGNAL("triggered()"),self.ChercheGrp)
556 self.actionCode = QAction(self)
557 self.actionCode.setText(tr("Specificites Maille"))
558 self.connect(self.actionCode,SIGNAL("triggered()"),self.aideCode)
560 def connecterSignaux(self) :
562 self.recentMenu.aboutToShow.connect(self.handleShowRecentMenu)
563 self.action_Nouveau.triggered.connect(self.fileNew)
564 self.actionNouvel_Include.triggered.connect(self.NewInclude)
565 self.actionOuvrir.triggered.connect(self.fileOpen)
566 self.actionEnregistrer.triggered.connect(self.fileSave)
567 self.actionEnregistrer_sous.triggered.connect(self.fileSaveAs)
568 self.actionFermer.triggered.connect(self.fileClose)
569 self.actionFermer_tout.triggered.connect(self.fileCloseAll)
570 self.actionQuitter.triggered.connect(self.fileExit)
572 self.actionEficas.triggered.connect(self.aidePPal)
573 self.actionVersion.triggered.connect(self.version)
574 self.actionParametres.triggered.connect(self.gestionParam)
576 self.actionCouper.triggered.connect(self.editCut)
577 self.actionCopier.triggered.connect(self.editCopy)
578 self.actionColler.triggered.connect(self.editPaste)
579 self.actionSupprimer.triggered.connect(self.supprimer)
580 self.actionRechercher.triggered.connect(self.rechercher)
581 self.actionDeplier_replier.triggered.connect(self.Deplier)
583 self.actionRapport_de_Validation.triggered.connect(self.jdcRapport)
584 self.actionRegles_du_JdC.triggered.connect(self.jdcRegles)
585 self.actionFichier_Source.triggered.connect(self.jdcFichierSource)
586 self.actionFichier_Resultat.triggered.connect(self.visuJdcPy)
590 self.actionTraduitV9V10 = QAction(self)
591 self.actionTraduitV9V10.setObjectName("actionTraduitV9V10")
592 self.actionTraduitV9V10.setText(tr("TraduitV9V10"))
593 self.actionTraduitV10V11 = QAction(self)
594 self.actionTraduitV10V11.setObjectName("actionTraduitV10V11")
595 self.actionTraduitV10V11.setText(tr("TraduitV10V11"))
596 self.actionTraduitV11V12 = QAction(self)
597 self.actionTraduitV11V12.setObjectName("actionTraduitV11V12")
598 self.actionTraduitV11V12.setText(tr("TraduitV11V12"))
599 self.actionSauveLigne = QAction(self)
600 self.actionSauveLigne.setText(tr("Sauve Format Ligne"))
602 #self.actionParametres_Eficas.triggered.connect(self.optionEditeur)
603 self.actionTraduitV9V10.triggered.connect(self.traductionV9V10)
604 self.actionTraduitV10V11.triggered.connect(self.traductionV10V11)
605 self.actionTraduitV11V12.triggered.connect(self.traductionV11V12)
606 self.actionSauveLigne.triggered.connect(self.sauveLigne)
609 self.actionChercheGrpMaille = QAction(self)
610 self.actionChercheGrpMaille.setText(tr("Acquiert Groupe Maille"))
613 self.actionChercheGrp = QAction(self)
614 self.actionChercheGrp.setText(tr("Accquisition Groupe Maille"))
615 self.actionChercheGrp.triggered.connect(self.ChercheGrp)
618 self.actionCode = QAction(self)
619 self.actionCode.setText(tr("Specificites Maille"))
620 self.actionCode.triggered.connect(self.aideCode)
624 self.viewmanager.handleDeplier()
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.get_unit(study,self)
633 self.viewmanager.handleOpen(fichier=study["comm"],units=d)
636 def get_source(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.keys()) :
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.keys():
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 if monEnvQT5 : self.id.triggered.connect(self.handleOpenPatrons)
668 else : self.connect(id, SIGNAL('triggered()'),self.handleOpenPatrons)
669 # self.Patrons.setItemParameter(id,idx)
672 def initRecents(self):
673 if monEnvQT5 : self.recent = []
674 else : self.recent = QStringList()
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 if not monEnvQT5 : self.addToRecentListQT4(fn); return
697 while fn in self.recent: self.recent.remove(fn)
698 self.recent.insert(0,fn)
699 if len(self.recent) > 9:
700 self.recent = self.recent[:9]
703 def addToRecentListQT4(self, fn):
705 Public slot to add a filename to the list of recently opened files.
707 @param fn name of the file to be added
709 self.recent.removeAll(fn)
710 self.recent.prepend(fn)
711 if len(self.recent) > 9:
712 self.recent = self.recent[:9]
716 def sauveRecents(self) :
718 rep=self.CONFIGURATION.rep_user
719 monFichier=rep+"/listefichiers_"+self.code
723 f=open(monFichier,'w')
724 if len(self.recent) == 0 : return
726 while ( index < len(self.recent)):
727 ligne=str(self.recent[index])+"\n"
739 def traductionV11V12(self):
740 from gereTraduction import traduction
741 traduction(self.CONFIGURATION.repIni,self.viewmanager,"V11V12")
743 def traductionV10V11(self):
744 from gereTraduction import traduction
745 traduction(self.CONFIGURATION.repIni,self.viewmanager,"V10V11")
747 def traductionV9V10(self):
748 from gereTraduction import traduction
749 traduction(self.CONFIGURATION.repIni,self.viewmanager,"V9V10")
752 from monVisu import DVisu
753 titre = tr("version ")
754 monVisuDialg=DVisu(parent=self,fl=0)
755 monVisuDialg.setWindowTitle(titre)
756 monVisuDialg.TB.setText(self.VERSION_EFICAS +tr(" pour ") + self.code)
757 monVisuDialg.adjustSize()
761 repAide=os.path.dirname(os.path.abspath(__file__))
762 maD=os.path.join( repAide,'..','Doc','html')
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','html')
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.CONFIGURATION)
810 def optionPdf(self) :
811 from monOptionsPdf import OptionPdf
812 monOption=OptionPdf(parent=self,modal = 0 ,configuration=self.CONFIGURATION)
815 def handleSortieLegere(self):
816 return self.viewmanager.saveLegerCurrentEditor()
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 if monEnvQT5 : id.triggered.connect(self.handleOpenRecent)
828 else : self.connect(id, SIGNAL('triggered()'),self.handleOpenRecent)
829 self.recentMenu.addSeparator()
830 self.recentMenu.addAction(tr('&Effacer'), self.handleClearRecent)
832 def handleOpenPatrons(self):
834 fichier=self.repIni+"/../Editeur/Patrons/"+self.code+"/"+self.ficPatrons[idx]
835 self.viewmanager.handleOpen(fichier=fichier, patron = 1)
837 def handleOpenRecent(self):
839 fichier=self.ficRecents[idx]
840 self.viewmanager.handleOpen(fichier=fichier, patron =0 )
842 def handleClearRecent(self):
843 self.recent = QStringList()
846 def handleRechercherDsCatalogue(self):
847 if not self.viewmanager : return
848 self.viewmanager.handleRechercherDsCatalogue()
852 self.viewmanager.newEditor()
853 except EficasException, exc:
855 if msg != "": QMessageBox.warning(self, tr(u"Erreur"), msg)
857 def openProcess(self):
861 dirCode=os.path.abspath(os.path.join(os.path.abspath(__file__),'../..',"ProcessOutputs_Eficas"))
862 sys.path.insert(0,dirCode)
864 self.definitCode(code,ssCode)
873 self.viewmanager.handleOpen()
874 except EficasException, exc:
877 QMessageBox.warning(self, tr(u"Erreur"), msg)
879 def sauveLigne(self):
880 return self.viewmanager.sauveLigneCurrentEditor()
883 return self.viewmanager.saveCurrentEditor()
885 def fileSaveAs(self):
886 return self.viewmanager.saveAsCurrentEditor()
889 self.viewmanager.handleClose(texte='&Fermer')
891 def fileCloseAll(self):
892 self.viewmanager.handleCloseAll(texte='&Fermer')
895 # On peut sortir sur Abort
896 res=self.viewmanager.handleCloseAll()
902 self.viewmanager.handleEditCopy()
905 self.viewmanager.handleEditCut()
908 self.viewmanager.handleEditPaste()
910 def rechercher(self):
911 self.viewmanager.handleRechercher()
914 self.viewmanager.run()
917 self.viewmanager.saveRun()
921 self.viewmanager.handleSupprimer()
923 def jdcFichierSource(self):
924 self.viewmanager.handleViewJdcFichierSource()
926 def jdcRapport(self):
927 self.viewmanager.handleViewJdcRapport()
930 self.viewmanager.handleViewJdcRegles()
932 def gestionParam(self):
933 self.viewmanager.handlegestionParam()
936 self.viewmanager.handleViewJdcPy()
939 def NewInclude(self):
940 self.viewmanager.newIncludeEditor()
943 for pathCode in self.ListePathCode:
945 aEnlever=os.path.abspath(os.path.join(os.path.dirname(__file__),'..',pathCode))
946 sys.path.remove(aEnlever)
949 for pathCode in self.listeAEnlever:
951 sys.path.remove(aEnlever)
956 def closeEvent(self,event):
958 if res==2 : event.ignore()
961 if __name__=='__main__':
964 rep=os.path.abspath(os.path.join(os.path.dirname(os.path.abspath(__file__),'..','ASTER')))
966 from Aster import prefsCode
967 if hasattr(prefsCode,'encoding'):
968 # Hack pour changer le codage par defaut des strings
971 sys.setdefaultencoding(prefsCode.encoding)
972 del sys.setdefaultencoding
975 from Editeur import import_code
976 from Editeur import session
978 # Analyse des arguments de la ligne de commande
979 options=session.parse(sys.argv)
983 app = QApplication(sys.argv)
984 #app.setMainWidget(mw) (qt3)