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
21 from __future__ import absolute_import
22 from __future__ import print_function
24 from builtins import str
31 from PyQt5.QtWidgets import QApplication, QMainWindow, QBoxLayout, QMenu, QAction, QMessageBox
32 from PyQt5.QtGui import QIcon
33 from PyQt5.QtCore import Qt
35 from Extensions.i18n import tr
36 from Extensions.eficas_exception import EficasException
37 from Extensions import param2
40 from myMain import Ui_Eficas
41 from .viewManager import MyTabview
42 from .getVersion import getEficasVersion
43 from Editeur import session
47 class Appli(Ui_Eficas,QMainWindow):
49 Class implementing the main user interface.
51 def __init__(self,code=None,salome=0,parent=None,ssCode=None,multi=False,langue='fr',ssIhm=False):
55 QMainWindow.__init__(self,parent)
56 Ui_Eficas.__init__(self)
59 version=getEficasVersion()
60 self.VERSION_EFICAS="Eficas QT5 Salome " + version
62 self.parentMainWindow=parent
65 self.top = self #(pour CONFIGURATION)
66 self.QWParent=None #(Pour lancement sans IHM)
75 self.ListePathCode=['Adao','ADAO','Carmel3D','Telemac','CF','MAP','ZCracks', 'SEP','SPECA','PSEN_Eficas','PSEN_N1']
76 self.listeCode=['Adao','ADAO','Carmel3D','Telemac','CF','MAP','ZCracks', 'SEP','SPECA','PSEN_Eficas','PSEN_N1']
77 self.repIcon=os.path.join( os.path.dirname(os.path.abspath(__file__)),'..','Editeur','icons')
83 Accas.SalomeEntry = eficasSalome.SalomeEntry
86 self.demande=multi # specifique PSEN
89 if self.multi == False :
90 self.definitCode(code,ssCode)
95 if not self.salome and hasattr (self, 'CONFIGURATION') and hasattr(self.CONFIGURATION,'lang') : langue=self.CONFIGURATION.lang
97 if langue=='fr': self.langue=langue
98 else : self.langue="ang"
100 self.suiteTelemac=False
101 if hasattr (self, 'CONFIGURATION') :
102 if self.CONFIGURATION.force_langue :
103 from .monChoixLangue import MonChoixLangue
104 widgetLangue = MonChoixLangue(self)
105 ret=widgetLangue.exec_()
106 self.suiteTelemac=self.CONFIGURATION.suiteTelemac
109 from Extensions import localisation
111 localisation.localise(None,self.langue,translatorFichier=self.CONFIGURATION.translatorFichier)
116 #if parent != None : self.parentCentralWidget = parent.centralWidget()
117 #else : self.parentCentralWidget = None
120 if hasattr (self, 'CONFIGURATION') and hasattr(self.CONFIGURATION,'taille') : self.taille=self.CONFIGURATION.taille
121 else : self.taille=1700
123 if self.code in ['MAP',] : self.resize(1440,self.height())
124 else : self.resize(self.taille,self.height())
127 icon = QIcon(self.repIcon+"/parametres.png")
128 self.actionParametres.setIcon(icon)
131 self.myQtab.removeTab(0)
132 self.blEntete= QBoxLayout(0,self.frameEntete)
133 self.blEntete.insertWidget(0,self.toolBar)
134 self.blEntete.insertWidget(0,self.menubar)
136 if hasattr (self, 'CONFIGURATION') and self.CONFIGURATION.closeEntete==True and self.salome: self.closeEntete()
138 eficas_root_dir = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
141 self.viewmanager = MyTabview(self)
142 self.recentMenu=QMenu(tr('&Recents'))
143 #self.menuFichier.insertMenu(self.actionOuvrir,self.recentMenu)
144 # actionARemplacer ne sert que pour l insert Menu
145 self.menuFichier.insertMenu(self.actionARemplacer ,self.recentMenu)
146 self.menuFichier.removeAction(self.actionARemplacer)
147 self.connecterSignaux()
148 self.toolBar.addSeparator()
149 if self.code != None : self.construitMenu()
151 self.setWindowTitle(self.VERSION_EFICAS)
155 #except EficasException, 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 .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 name='prefs_'+self.code
178 prefsCode=__import__(name)
180 self.repIni=prefsCode.repIni
182 self.format_fichier= ssCode #par defaut
183 prefsCode.NAME_SCHEME=ssCode
185 self.format_fichier="python" #par defaut
187 nameConf='configuration_'+self.code
188 configuration=__import__(nameConf)
189 self.CONFIGURATION = configuration.make_config(self,prefsCode.repIni)
190 self.CONFIGStyle = None
191 if hasattr(configuration,'make_config_style'):
192 self.CONFIGStyle = configuration.make_config_style(self,prefsCode.repIni)
193 #PN --> pb d exception qui font planter salome
194 # plus supporte en python 3
195 #if hasattr(prefsCode,'encoding'):
198 # sys.setdefaultencoding(prefsCode.encoding)
200 def construitMenu(self):
204 for intituleMenu in ("menuTraduction","menuOptions","menuMesh","menuExecution","menuN1"):
205 if hasattr(self,intituleMenu):
206 menu=getattr(self,intituleMenu)
207 menu.setAttribute(Qt.WA_DeleteOnClose)
209 delattr(self,intituleMenu)
210 for intituleAction in ("actionExecution","actionSaveRun",):
211 if hasattr(self,intituleAction):
212 action=getattr(self,intituleAction)
213 self.toolBar.removeAction(action)
214 if self.code.upper() in Appli.__dict__:
215 Appli.__dict__[self.code.upper()](self,)
216 if self.suiteTelemac : self.lookSuiteTelemac()
220 repAide=os.path.dirname(os.path.abspath(__file__))
221 fileName='index.html'
222 self.docPath=repAide+"/../Aide"
223 if hasattr(self,'CONFIGURATION') and hasattr(self.CONFIGURATION,'docPath') : self.docPath=self.CONFIGURATION.docPath
224 if hasattr(self,'CONFIGURATION') and hasattr(self.CONFIGURATION,'fileName'):fileName=self.CONFIGURATION.fileName
225 self.fileDoc=os.path.join(self.docPath,fileName)
226 self.actionCode.setText(tr("Aide specifique ")+str(self.code))
227 if not os.path.isfile(self.fileDoc) :
230 self.actionCode.setEnabled(False)
233 self.actionCode.setEnabled(True)
234 self.menuAide.addAction(self.actionCode)
240 dirCode=os.path.abspath(os.path.join(os.path.abspath(__file__),'../..',"ProcessOutputs_Eficas"))
241 sys.path.insert(0,dirCode)
243 self.definitCode(code,ssCode)
253 dirCode=os.path.abspath(os.path.join(os.path.abspath(__file__),'../..',code))
254 sys.path.insert(0,dirCode)
256 self.definitCode(code,ssCode)
262 self.menuN1 = self.menubar.addMenu(tr("Process Output"))
263 self.actionN1 = QAction(self)
264 self.actionN1.setText(tr("Process Output"))
265 self.menuN1.addAction(self.actionN1)
266 self.actionN1.triggered.connect(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 self.actionOpenProcess.triggered.connect(self.openProcess)
276 def ajoutExecution(self):
277 self.menuExecution = self.menubar.addMenu(tr("&Run"))
278 self.actionExecution = QAction(self)
279 if sys.platform[0:5]=="linux":
280 icon6 = QIcon(self.repIcon+"/roue.png")
281 self.actionExecution.setIcon(icon6)
283 self.actionExecution.setText(tr("Run"))
284 self.actionExecution.setObjectName("actionExecution")
285 self.menuExecution.addAction(self.actionExecution)
286 if not(self.actionExecution in self.toolBar.actions()):
287 self.toolBar.addAction(self.actionExecution)
288 self.actionExecution.setText(tr("Run"))
289 self.actionExecution.triggered.connect(self.run)
291 def ajoutSauveExecution(self):
292 self.actionSaveRun = QAction(self)
293 icon7 = QIcon(self.repIcon+"/export_MAP.png")
294 self.actionSaveRun.setIcon(icon7)
295 self.actionSaveRun.setObjectName("actionSaveRun")
296 self.menuExecution.addAction(self.actionSaveRun)
297 if not(self.actionSaveRun in self.toolBar.actions()):
298 self.toolBar.addAction(self.actionSaveRun)
299 self.actionSaveRun.setText(tr("Save Run"))
300 self.actionSaveRun.triggered.connect(self.saveRun)
302 def griserActionsStructures(self):
303 self.actionCouper.setEnabled(False)
304 self.actionColler.setEnabled(False)
305 self.actionCopier.setEnabled(False)
306 self.actionSupprimer.setEnabled(False)
308 def enleverActionsStructures(self):
309 self.toolBar.removeAction(self.actionCopier)
310 self.toolBar.removeAction(self.actionColler)
311 self.toolBar.removeAction(self.actionCouper)
312 self.menuEdition.removeAction(self.actionCouper)
313 self.menuEdition.removeAction(self.actionCopier)
314 self.menuEdition.removeAction(self.actionColler)
317 def enleverParametres(self):
318 self.toolBar.removeAction(self.actionParametres)
319 self.menuJdC.removeAction(self.actionParametres)
321 def enleverSupprimer(self):
322 self.toolBar.removeAction(self.actionSupprimer)
324 def enleverNewInclude(self):
325 self.actionNouvel_Include.setVisible(False)
327 def enleverRechercherDsCatalogue(self):
328 self.actionRechercherDsCatalogue.setVisible(False)
330 def connectRechercherDsCatalogue(self):
331 self.actionRechercherDsCatalogue.triggered.connect(self.handleRechercherDsCatalogue)
333 def ajoutSortieLegere(self):
334 if hasattr(self,'actionSortieLegere') : return
335 self.actionSortieLegere = QAction(self)
336 self.actionSortieLegere.setText(tr("Sortie Legere"))
337 self.menuFichier.insertAction(self.actionEnregistrer_sous,self.actionSortieLegere)
338 self.actionSortieLegere.triggered.connect(self.handleSortieLegere)
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"))
393 if self.first: self.first=0
394 self.action_Nouveau.triggered.disconnect(self.fileNew)
395 self.action_Nouveau.triggered.connect(self.newPSEN)
396 self.enleverActionsStructures()
397 self.enleverParametres()
398 self.enleverRechercherDsCatalogue()
399 self.enleverNewInclude()
400 self.ajoutExecution()
406 self.enleverActionsStructures()
407 self.enleverParametres()
408 self.enleverRechercherDsCatalogue()
409 self.enleverNewInclude()
410 self.ajoutExecution()
414 self.enleverActionsStructures()
415 self.enleverNewInclude()
416 self.connectRechercherDsCatalogue()
417 self.ajoutSortieLegere()
419 def lookSuiteTelemac(self):
420 self.enleverActionsStructures()
421 self.enleverNewInclude()
422 self.enleverParametres()
423 self.enleverSupprimer()
424 self.enleverRechercherDsCatalogue()
426 def ajoutHelpPSEN(self):
427 self.actionParametres_Eficas.setText('Help PSEN')
428 self.actionParametres_Eficas.triggered.connect(self.aidePSEN)
432 def ChercheGrpMesh(self):
433 Msg,listeGroup=self.ChercheGrpMeshInSalome()
435 self.viewmanager.handleAjoutGroup(listeGroup)
437 print ("il faut gerer les erreurs")
439 def ChercheGrpMaille(self):
440 # Normalement la variable self.salome permet de savoir si on est ou non dans Salome
442 Msg,listeGroup=self.ChercheGrpMailleInSalome() # recherche dans Salome
443 #Msg = None; listeGroup = None # recherche manuelle, i.e., sans Salome si ligne precedente commentee
445 raise ValueError('Salome non ouvert')
447 self.viewmanager.handleAjoutGroup(listeGroup)
449 print ("il faut gerer les erreurs")
452 def ChercheGrp(self):
453 #Msg,listeGroup=self.ChercheGrpMailleInSalome()
455 # self.viewmanager.handleAjoutGroup(listeGroup)
457 #print "il faut gerer "
461 def ajoutIcones(self) :
462 # Pour pallier les soucis de repertoire d icone
464 icon = QIcon(self.repIcon+"/new_file.png")
465 self.action_Nouveau.setIcon(icon)
466 icon1 = QIcon(self.repIcon+"/ouvrir.png")
467 self.actionOuvrir.setIcon(icon1)
468 icon2 = QIcon(self.repIcon+"/save.png")
469 self.actionEnregistrer.setIcon(icon2)
470 icon6 = QIcon(self.repIcon+"/delete.png")
471 self.actionSupprimer.setIcon(icon6)
472 icon7 = QIcon(self.repIcon+"/roue.png")
473 self.actionExecution.setIcon(icon7)
478 def connecterSignauxQT4(self) :
479 self.connect(self.recentMenu,SIGNAL('aboutToShow()'),self.handleShowRecentMenu)
481 self.connect(self.action_Nouveau,SIGNAL("triggered()"),self.fileNew)
482 self.connect(self.actionNouvel_Include,SIGNAL("triggered()"),self.NewInclude)
483 self.connect(self.actionOuvrir,SIGNAL("triggered()"),self.fileOpen)
484 self.connect(self.actionEnregistrer,SIGNAL("triggered()"),self.fileSave)
485 self.connect(self.actionEnregistrer_sous,SIGNAL("triggered()"),self.fileSaveAs)
486 self.connect(self.actionFermer,SIGNAL("triggered()"),self.fileClose)
487 self.connect(self.actionFermer_tout,SIGNAL("triggered()"),self.fileCloseAll)
488 self.connect(self.actionQuitter,SIGNAL("triggered()"),self.fileExit)
490 self.connect(self.actionEficas,SIGNAL("triggered()"),self.aidePPal)
491 self.connect(self.actionVersion,SIGNAL("triggered()"),self.version)
492 self.connect(self.actionParametres,SIGNAL("triggered()"),self.gestionParam)
494 self.connect(self.actionCouper,SIGNAL("triggered()"),self.editCut)
495 self.connect(self.actionCopier,SIGNAL("triggered()"),self.editCopy)
496 self.connect(self.actionColler,SIGNAL("triggered()"),self.editPaste)
497 self.connect(self.actionSupprimer,SIGNAL("triggered()"),self.supprimer)
498 self.connect(self.actionRechercher,SIGNAL("triggered()"),self.rechercher)
499 self.connect(self.actionDeplier_replier,SIGNAL("triggered()"),self.Deplier)
501 self.connect(self.actionRapport_de_Validation,SIGNAL("triggered()"),self.jdcRapport)
502 self.connect(self.actionRegles_du_JdC,SIGNAL("triggered()"),self.jdcRegles)
503 self.connect(self.actionFichier_Source,SIGNAL("triggered()"),self.jdcFichierSource)
504 self.connect(self.actionFichier_Resultat,SIGNAL("triggered()"),self.visuJdcPy)
510 self.actionTraduitV9V10 = QAction(self)
511 self.actionTraduitV9V10.setObjectName("actionTraduitV9V10")
512 self.actionTraduitV9V10.setText(tr("TraduitV9V10"))
513 self.actionTraduitV10V11 = QAction(self)
514 self.actionTraduitV10V11.setObjectName("actionTraduitV10V11")
515 self.actionTraduitV10V11.setText(tr("TraduitV10V11"))
516 self.actionTraduitV11V12 = QAction(self)
517 self.actionTraduitV11V12.setObjectName("actionTraduitV11V12")
518 self.actionTraduitV11V12.setText(tr("TraduitV11V12"))
519 self.actionSauveLigne = QAction(self)
520 self.actionSauveLigne.setText(tr("Sauve Format Ligne"))
522 #self.connect(self.actionParametres_Eficas,SIGNAL("triggered()"),self.optionEditeur)
523 self.connect(self.actionLecteur_Pdf,SIGNAL("triggered()"),self.optionPdf)
524 self.connect(self.actionTraduitV9V10,SIGNAL("triggered()"),self.traductionV9V10)
525 self.connect(self.actionTraduitV10V11,SIGNAL("triggered()"),self.traductionV10V11)
526 self.connect(self.actionTraduitV11V12,SIGNAL("triggered()"),self.traductionV11V12)
527 self.connect(self.actionSauveLigne,SIGNAL("triggered()"),self.sauveLigne)
531 self.actionChercheGrpMaille = QAction(self)
532 self.actionChercheGrpMaille.setText(tr("Acquiert groupe mailles"))
533 self.connect(self.actionChercheGrpMaille,SIGNAL("triggered()"),self.ChercheGrpMaille)
536 self.actionChercheGrp = QAction(self)
537 self.actionChercheGrp.setText(tr("Acquisition Groupe Maille"))
538 self.connect(self.actionChercheGrp,SIGNAL("triggered()"),self.ChercheGrp)
541 self.actionCode = QAction(self)
542 self.actionCode.setText(tr("Specificites Maille"))
543 self.connect(self.actionCode,SIGNAL("triggered()"),self.aideCode)
545 def connecterSignaux(self) :
547 self.recentMenu.aboutToShow.connect(self.handleShowRecentMenu)
548 self.action_Nouveau.triggered.connect(self.fileNew)
549 self.actionNouvel_Include.triggered.connect(self.NewInclude)
550 self.actionOuvrir.triggered.connect(self.fileOpen)
551 self.actionEnregistrer.triggered.connect(self.fileSave)
552 self.actionEnregistrer_sous.triggered.connect(self.fileSaveAs)
553 self.actionFermer.triggered.connect(self.fileClose)
554 self.actionFermer_tout.triggered.connect(self.fileCloseAll)
555 self.actionQuitter.triggered.connect(self.fileExit)
557 self.actionEficas.triggered.connect(self.aidePPal)
558 self.actionVersion.triggered.connect(self.version)
559 self.actionParametres.triggered.connect(self.gestionParam)
561 self.actionCouper.triggered.connect(self.editCut)
562 self.actionCopier.triggered.connect(self.editCopy)
563 self.actionColler.triggered.connect(self.editPaste)
564 self.actionSupprimer.triggered.connect(self.supprimer)
565 self.actionRechercher.triggered.connect(self.rechercher)
566 self.actionDeplier_replier.triggered.connect(self.Deplier)
568 self.actionRapport_de_Validation.triggered.connect(self.jdcRapport)
569 self.actionRegles_du_JdC.triggered.connect(self.jdcRegles)
570 self.actionFichier_Source.triggered.connect(self.jdcFichierSource)
571 self.actionFichier_Resultat.triggered.connect(self.visuJdcPy)
572 self.actionAfficher_l_Arbre.triggered.connect(self.ouvreArbre)
573 self.actionCacher_l_Arbre.triggered.connect(self.fermeArbre)
577 self.actionTraduitV9V10 = QAction(self)
578 self.actionTraduitV9V10.setObjectName("actionTraduitV9V10")
579 self.actionTraduitV9V10.setText(tr("TraduitV9V10"))
580 self.actionTraduitV10V11 = QAction(self)
581 self.actionTraduitV10V11.setObjectName("actionTraduitV10V11")
582 self.actionTraduitV10V11.setText(tr("TraduitV10V11"))
583 self.actionTraduitV11V12 = QAction(self)
584 self.actionTraduitV11V12.setObjectName("actionTraduitV11V12")
585 self.actionTraduitV11V12.setText(tr("TraduitV11V12"))
586 self.actionSauveLigne = QAction(self)
587 self.actionSauveLigne.setText(tr("Sauve Format Ligne"))
589 #self.actionParametres_Eficas.triggered.connect(self.optionEditeur)
590 self.actionTraduitV9V10.triggered.connect(self.traductionV9V10)
591 self.actionTraduitV10V11.triggered.connect(self.traductionV10V11)
592 self.actionTraduitV11V12.triggered.connect(self.traductionV11V12)
593 self.actionSauveLigne.triggered.connect(self.sauveLigne)
596 self.actionChercheGrpMaille = QAction(self)
597 self.actionChercheGrpMaille.setText(tr("Acquiert Groupe Maille"))
600 self.actionChercheGrp = QAction(self)
601 self.actionChercheGrp.setText(tr("Accquisition Groupe Maille"))
602 self.actionChercheGrp.triggered.connect(self.ChercheGrp)
605 self.actionCode = QAction(self)
606 self.actionCode.setText(tr("Specificites Maille"))
607 self.actionCode.triggered.connect(self.aideCode)
611 self.viewmanager.handleDeplier()
613 def ouvreFichiers(self) :
614 # Ouverture des fichiers de commandes donnes sur la ligne de commande
617 for study in session.d_env.studies:
619 d=session.get_unit(study,self)
620 self.viewmanager.handleOpen(fichier=study["comm"],units=d)
623 def get_source(self,file):
624 # appele par Editeur/session.py
626 p=convert.plugins['python']()
628 texte=p.convert('execnoparseur')
631 def initPatrons(self) :
632 # Mise a jour du menu des fichiers recemment ouverts
633 from Editeur import listePatrons
634 if not(self.code in listePatrons.sous_menus) :
635 if hasattr(self,"menuPatrons"):
636 self.menuPatrons.setAttribute(Qt.WA_DeleteOnClose)
637 self.menuPatrons.close()
638 delattr(self,"menuPatrons")
640 if (not hasattr(self,"menuPatrons")):
641 self.menuPatrons = QMenu(self.menubar)
642 self.menuPatrons.setObjectName("menuPatrons")
643 self.menubar.addAction(self.menuPatrons.menuAction())
644 self.menuPatrons.setTitle(tr("Patrons"))
646 self.menuPatrons.clear()
647 self.listePatrons = listePatrons.listePatrons(self.code)
649 for nomSsMenu in self.listePatrons.liste:
650 ssmenu=self.menuPatrons.addMenu(nomSsMenu)
651 for fichier in self.listePatrons.liste[nomSsMenu]:
652 id = ssmenu.addAction(fichier)
653 self.ficPatrons[id]=fichier
654 self.id.triggered.connect(self.handleOpenPatrons)
655 # self.Patrons.setItemParameter(id,idx)
658 def initRecents(self):
661 if sys.platform[0:5]=="linux" :
662 rep=os.path.join(os.environ['HOME'],'.config/Eficas',self.code)
664 rep=os.path.join('C:/','.config/Eficas',self.code)
665 monFichier=rep+"/listefichiers_"+self.code
671 l=(ligne.split("\n"))[0]
672 self.recent.append(l)
680 def addToRecentList(self, fn):
681 while fn in self.recent: self.recent.remove(fn)
682 self.recent.insert(0,fn)
683 if len(self.recent) > 9:
684 self.recent = self.recent[:9]
687 def addToRecentListQT4(self, fn):
689 Public slot to add a filename to the list of recently opened files.
691 @param fn name of the file to be added
693 self.recent.removeAll(fn)
694 self.recent.prepend(fn)
695 if len(self.recent) > 9:
696 self.recent = self.recent[:9]
700 def sauveRecents(self) :
702 rep=self.CONFIGURATION.rep_user
703 monFichier=rep+"/listefichiers_"+self.code
707 f=open(monFichier,'w')
708 if len(self.recent) == 0 : return
710 while ( index < len(self.recent)):
711 ligne=str(self.recent[index])+"\n"
723 def traductionV11V12(self):
724 from .gereTraduction import traduction
725 traduction(self.CONFIGURATION.repIni,self.viewmanager,"V11V12")
727 def traductionV10V11(self):
728 from .gereTraduction import traduction
729 traduction(self.CONFIGURATION.repIni,self.viewmanager,"V10V11")
731 def traductionV9V10(self):
732 from .gereTraduction import traduction
733 traduction(self.CONFIGURATION.repIni,self.viewmanager,"V9V10")
736 from .monVisu import DVisu
737 titre = tr("version ")
738 monVisuDialg=DVisu(parent=self,fl=0)
739 monVisuDialg.setWindowTitle(titre)
740 monVisuDialg.TB.setText(self.VERSION_EFICAS +tr(" pour ") + self.code)
741 monVisuDialg.adjustSize()
745 repAide=os.path.dirname(os.path.abspath(__file__))
746 maD=os.path.join( repAide,'..','Doc','html')
748 indexAide=os.path.join(maD,'index.html')
749 if sys.platform[0:5]=="linux" : cmd="xdg-open "+indexAide
750 else : cmd="start "+indexAide
753 QMessageBox.warning( self,tr( "Aide Indisponible"),tr( "l'aide n est pas installee "))
756 repAide=os.path.dirname(os.path.abspath(__file__))
757 maD=os.path.join( repAide,'..','Doc','html')
759 indexAide=os.path.join(maD,'index.html')
760 if sys.platform[0:5]=="linux" : cmd="xdg-open "+indexAide
761 else : cmd="start "+indexAide
764 QMessageBox.warning( self,tr( "Aide Indisponible"),tr( "l'aide n est pas installee "))
767 if self.code==None : return
770 if sys.platform[0:5]=="linux" : cmd="xdg-open "+self.fileDoc
771 else : cmd="start "+self.fileDoc
775 QMessageBox.warning( self,tr( "Aide Indisponible"),tr( "l'aide n est pas installee "))
778 def optionEditeur(self) :
780 name='monOptions_'+self.code
782 QMessageBox.critical( self,tr( "Parametrage"),tr( "Veuillez d abord choisir un code"))
786 optionCode=__import__(name)
789 QMessageBox.critical( self, tr("Parametrage"), tr("Pas de possibilite de personnalisation de la configuration "))
791 monOption=optionCode.Options(parent=self,modal = 0 ,configuration=self.CONFIGURATION)
794 def optionPdf(self) :
795 from monOptionsPdf import OptionPdf
796 monOption=OptionPdf(parent=self,modal = 0 ,configuration=self.CONFIGURATION)
799 def handleSortieLegere(self):
800 return self.viewmanager.saveLegerCurrentEditor()
802 def handleShowRecentMenu(self):
804 Private method to set up recent files menu.
806 self.recentMenu.clear()
808 for rp in self.recent:
809 id = self.recentMenu.addAction(rp)
810 self.ficRecents[id]=rp
811 id.triggered.connect(self.handleOpenRecent)
812 self.recentMenu.addSeparator()
813 self.recentMenu.addAction(tr('&Effacer'), self.handleClearRecent)
815 def handleOpenPatrons(self):
817 fichier=self.repIni+"/../Editeur/Patrons/"+self.code+"/"+self.ficPatrons[idx]
818 self.viewmanager.handleOpen(fichier=fichier, patron = 1)
820 def handleOpenRecent(self):
822 fichier=self.ficRecents[idx]
823 self.viewmanager.handleOpen(fichier=fichier, patron =0 )
825 def handleClearRecent(self):
826 self.recent = QStringList()
829 def handleRechercherDsCatalogue(self):
830 if not self.viewmanager : return
831 self.viewmanager.handleRechercherDsCatalogue()
835 self.viewmanager.newEditor()
836 except EficasException as exc:
837 msg = six.text_type(exc)
838 if msg != "": QMessageBox.warning(self, tr(u"Erreur"), msg)
840 def openProcess(self):
844 dirCode=os.path.abspath(os.path.join(os.path.abspath(__file__),'../..',"ProcessOutputs_Eficas"))
845 sys.path.insert(0,dirCode)
847 self.definitCode(code,ssCode)
856 self.viewmanager.handleOpen()
857 except EficasException as exc:
858 msg = six.text_type(exc)
860 QMessageBox.warning(self, tr(u"Erreur"), msg)
862 def sauveLigne(self):
863 return self.viewmanager.sauveLigneCurrentEditor()
866 return self.viewmanager.saveCurrentEditor()
868 def fileSaveAs(self):
869 return self.viewmanager.saveAsCurrentEditor()
872 self.viewmanager.handleClose(texte='&Fermer')
874 def fileCloseAll(self):
875 self.viewmanager.handleCloseAll(texte='&Fermer')
878 # On peut sortir sur Abort
879 res=self.viewmanager.handleCloseAll()
885 self.viewmanager.handleEditCopy()
888 self.viewmanager.handleEditCut()
891 self.viewmanager.handleEditPaste()
893 def rechercher(self):
894 self.viewmanager.handleRechercher()
897 self.viewmanager.run()
900 self.viewmanager.saveRun()
904 self.viewmanager.handleSupprimer()
906 def jdcFichierSource(self):
907 self.viewmanager.handleViewJdcFichierSource()
909 def jdcRapport(self):
910 self.viewmanager.handleViewJdcRapport()
913 self.viewmanager.handleViewJdcRegles()
915 def gestionParam(self):
916 self.viewmanager.handlegestionParam()
919 self.viewmanager.handleViewJdcPy()
921 def ouvreArbre(self):
922 self.viewmanager.ouvreArbre()
924 def fermeArbre(self):
925 self.viewmanager.fermeArbre()
927 def NewInclude(self):
928 self.viewmanager.newIncludeEditor()
931 for pathCode in self.ListePathCode:
933 aEnlever=os.path.abspath(os.path.join(os.path.dirname(__file__),'..',pathCode))
934 sys.path.remove(aEnlever)
937 for pathCode in self.listeAEnlever:
939 sys.path.remove(aEnlever)
944 def closeEvent(self,event):
946 if res==2 : event.ignore()
949 if __name__=='__main__':
952 rep=os.path.abspath(os.path.join(os.path.dirname(os.path.abspath(__file__),'..','ASTER')))
954 from Aster import prefsCode
955 if hasattr(prefsCode,'encoding'):
956 # Hack pour changer le codage par defaut des strings
959 sys.setdefaultencoding(prefsCode.encoding)
960 del sys.setdefaultencoding
963 from Editeur import import_code
964 from Editeur import session
966 # Analyse des arguments de la ligne de commande
967 options=session.parse(sys.argv)
971 app = QApplication(sys.argv)
972 #app.setMainWidget(mw) (qt3)