X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=InterfaceQT4%2FqtEficas.py;h=fb9cf98eec033163f6ec2dd36a63135b44b631bf;hb=a54fdbf858683f1439bc26f155ece0fec66ae026;hp=e25b0626fda5044af8869325b03038e4cfad82bd;hpb=61f2a263b67981f299c496ce7ef8bccc3ac6e68b;p=tools%2Feficas.git diff --git a/InterfaceQT4/qtEficas.py b/InterfaceQT4/qtEficas.py index e25b0626..fb9cf98e 100644 --- a/InterfaceQT4/qtEficas.py +++ b/InterfaceQT4/qtEficas.py @@ -1,155 +1,297 @@ # -*- coding: iso-8859-1 -*- +# Copyright (C) 2007-2013 EDF R&D +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# +# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +# import os, sys from PyQt4.QtGui import * from PyQt4.QtCore import * -from PyQt4.QtAssistant import * from myMain import Ui_Eficas from viewManager import MyTabview +from getVersion import getEficasVersion + +from Extensions.i18n import tr +from Extensions.eficas_exception import EficasException from Editeur import session -class Appli(Ui_Eficas,QMainWindow): +class Appli(Ui_Eficas,QMainWindow): """ Class implementing the main user interface. """ - def __init__(self,code="ASTER",salome=0,parent=None,ssCode=None): + def __init__(self,code=None,salome=0,parent=None,ssCode=None,multi=False,langue='fr',ssIhm=False): """ Constructor """ - self.VERSION_EFICAS="Eficas QT4 V2.0" + QMainWindow.__init__(self,parent) + Ui_Eficas.__init__(self) + self.setupUi(self) + self.myQtab.removeTab(0) + self.blEntete= QBoxLayout(0,self.frameEntete) + self.blEntete.insertWidget(0,self.toolBar) + self.blEntete.insertWidget(0,self.menubar) - self.ihm="QT" - self.code=code - self.ssCode=ssCode + + version=getEficasVersion() + self.VERSION_EFICAS="Eficas QT4 "+version self.salome=salome - self.top = self #(pour CONFIGURATION) + self.ihm="QT" + self.ssIhm=ssIhm + self.top = self #(pour CONFIGURATION) self.QWParent=None #(Pour lancement sans IHM) + self.code=code self.indice=0 self.dict_reels={} + self.recent = QStringList() + self.ficRecents={} + self.listeAEnlever=[] + self.ListeCode=['Aster','Carmel3D','Cuve2dg','Openturns_Study','Openturns_Wrapper','MAP','ZCracks', 'CarmelCND','MT'] + self.repIcon=os.path.join( os.path.dirname(os.path.abspath(__file__)),'../Editeur/icons') + + if self.salome: + import Accas + import eficasSalome + Accas.SalomeEntry = eficasSalome.SalomeEntry + + #self.ajoutIcones() + self.multi=multi + if langue=='fr': self.langue=langue + else : self.langue="ang" + if self.multi == False : + self.definitCode(code,ssCode) + if code==None: return + + eficas_root_dir = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) + + self.viewmanager = MyTabview(self) + self.recentMenu=self.menuFichier.addMenu(tr('&Recents')) + self.connecterSignaux() + self.toolBar.addSeparator() + if self.code != None : self.construitMenu() + - import prefs - prefs.code=code - name='prefs_'+prefs.code + self.setWindowTitle(self.VERSION_EFICAS) + self.ouvreFichiers() + + + + def definitCode(self,code,ssCode) : + self.code=code + self.ssCode=ssCode + if self.code==None : + self.cleanPath() + from monChoixCode import MonChoixCode + widgetChoix = MonChoixCode(self) + ret=widgetChoix.exec_() + import sys + if self.code == None:return # pour le cancel de la fenetre choix code + name='prefs_'+self.code prefsCode=__import__(name) - self.REPINI=prefsCode.REPINI - self.RepIcon=prefsCode.INSTALLDIR+"/Editeur/icons" - self.INSTALLDIR=prefsCode.INSTALLDIR + + self.repIni=prefsCode.repIni if ssCode != None : - self.format_fichier= ssCode #par defaut + self.format_fichier= ssCode #par defaut prefsCode.NAME_SCHEME=ssCode else : - self.format_fichier="python" #par defaut + self.format_fichier="python" #par defaut - if salome : - import sys - nameConf='configuration_'+prefs.code + nameConf='configuration_'+self.code configuration=__import__(nameConf) - self.CONFIGURATION = configuration.make_config(self,prefsCode.REPINI) + self.CONFIGURATION = configuration.make_config(self,prefsCode.repIni) self.CONFIGStyle = None if hasattr(configuration,'make_config_style'): - self.CONFIGStyle = configuration.make_config_style(self,prefsCode.REPINI) + self.CONFIGStyle = configuration.make_config_style(self,prefsCode.repIni) if hasattr(prefsCode,'encoding'): import sys reload(sys) sys.setdefaultencoding(prefsCode.encoding) - QMainWindow.__init__(self,parent) - Ui_Eficas.__init__(self) - self.setupUi(self) - self.ajoutIcones() - if code in Appli.__dict__.keys(): - listeTexte=apply(Appli.__dict__[code],(self,)) - - self.viewmanager = MyTabview(self) - self.recentMenu=self.menuFichier.addMenu(self.trUtf8('&Recents')) - self.connecterSignaux() - - - #if self.salome : - # from Editeur import session - # self.ouvreFichiers() - - self.recent = QStringList() - self.ficPatrons={} + def construitMenu(self): self.initPatrons() - self.ficRecents={} self.initRecents() - - self.ouvreFichiers() - self.setWindowTitle(self.VERSION_EFICAS) - - def ASTER(self) : - self.menuTraduction = self.menubar.addMenu("menuTraduction") - self.actionTraduitV7V8 = QAction(self) - self.actionTraduitV7V8.setObjectName("actionTraduitV7V8") - self.actionTraduitV8V9 = QAction(self) - self.actionTraduitV8V9.setObjectName("actionTraduitV8V9") - self.menuTraduction.addAction(self.actionTraduitV7V8) - self.menuTraduction.addAction(self.actionTraduitV8V9) - self.menuTraduction.setTitle(QApplication.translate("Eficas", "Traduction", None, QApplication.UnicodeUTF8)) - self.actionTraduitV7V8.setText(QApplication.translate("Eficas","TraduitV7V8", None, QApplication.UnicodeUTF8)) - self.actionTraduitV8V9.setText(QApplication.translate("Eficas","TraduitV8V9", None, QApplication.UnicodeUTF8)) - self.connect(self.actionTraduitV7V8,SIGNAL("activated()"),self.traductionV7V8) - self.connect(self.actionTraduitV8V9,SIGNAL("activated()"),self.traductionV8V9) - - - def Map(self): - self.MAP() - - def MAP(self): + self.initAides() + for intituleMenu in ("menuTraduction","menuOptions","menuMesh","menuExecution"): + if hasattr(self,intituleMenu): + menu=getattr(self,intituleMenu) + menu.setAttribute(Qt.WA_DeleteOnClose) + menu.close() + delattr(self,intituleMenu) + for intituleAction in ("actionExecution","actionSaveRun",): + if hasattr(self,intituleAction): + action=getattr(self,intituleAction) + self.toolBar.removeAction(action) + if self.code in Appli.__dict__.keys(): + listeTexte=apply(Appli.__dict__[self.code],(self,)) + + def initAides(self): + #print "je passe la" + repAide=os.path.dirname(os.path.abspath(__file__)) + fileName='index.html' + self.docPath=repAide+"/../Aide" + if hasattr(self,'CONFIGURATION') and hasattr(self.CONFIGURATION,'docPath') : self.docPath=self.CONFIGURATION.docPath + if hasattr(self,'CONFIGURATION') and hasattr(self.CONFIGURATION,'fileName'):fileName=self.CONFIGURATION.fileName + self.fileDoc=os.path.join(self.docPath,fileName) + self.actionCode.setText(tr("Aide specifique ")+str(self.code)) + if not os.path.isfile(self.fileDoc) : + self.fileDoc="" + self.docPath="" + self.actionCode.setEnabled(False) + return + + self.actionCode.setEnabled(True) + self.menuAide.addAction(self.actionCode) + + + def ajoutExecution(self): + self.menuExecution = self.menubar.addMenu(QApplication.translate("Eficas", "Execution", None, QApplication.UnicodeUTF8)) self.actionExecution = QAction(self) - icon6 = QIcon(self.RepIcon+"/compute.png") + icon6 = QIcon(self.repIcon+"/roue.png") self.actionExecution.setIcon(icon6) self.actionExecution.setObjectName("actionExecution") - self.menuJdC.addAction(self.actionExecution) - self.toolBar.addAction(self.actionExecution) - self.actionExecution.setText(QApplication.translate("Eficas", "Execution", None, QApplication.UnicodeUTF8)) + self.menuExecution.addAction(self.actionExecution) + if not(self.actionExecution in self.toolBar.actions()): + self.toolBar.addAction(self.actionExecution) + self.actionExecution.setText(QApplication.translate("Eficas", "Execution ", None, QApplication.UnicodeUTF8)) self.connect(self.actionExecution,SIGNAL("activated()"),self.run) - self.actionEnregistrer_Python = QAction(self) - self.actionEnregistrer_Python.setObjectName("actionEnregistrer_Python") - self.menuFichier.addAction(self.actionEnregistrer_Python) - self.actionEnregistrer_Python.setText(QApplication.translate("Eficas", "Sauve Python", None,QApplication.UnicodeUTF8)) - self.connect(self.actionEnregistrer_Python,SIGNAL("activated()"),self.saveRun) - - self.actionEnregistrerYACS = QAction(self) - self.actionEnregistrerYACS.setObjectName("actionEnregistrerYACS") - self.menuFichier.addAction(self.actionEnregistrerYACS) - self.actionEnregistrerYACS.setText(QApplication.translate("Eficas", "Sauve Schema YACS", None,QApplication.UnicodeUTF8)) - self.connect(self.actionEnregistrerYACS,SIGNAL("activated()"),self.saveYACS) - - self.actionExecutionYACS = QAction(self) - icon7 = QIcon(self.RepIcon+"/application.gif") - self.actionExecutionYACS.setIcon(icon7) - self.actionExecutionYACS.setObjectName("actionExecutionYACS") - self.menuJdC.addAction(self.actionExecutionYACS) - self.toolBar.addAction(self.actionExecutionYACS) - self.actionExecutionYACS.setText(QApplication.translate("Eficas", "Execution YACS", None, QApplication.UnicodeUTF8)) - self.connect(self.actionExecutionYACS,SIGNAL("activated()"),self.runYACS) + def ajoutSauveExecution(self): + self.actionSaveRun = QAction(self) + icon7 = QIcon(self.repIcon+"/export_MAP.png") + self.actionSaveRun.setIcon(icon7) + self.actionSaveRun.setObjectName("actionSaveRun") + self.menuExecution.addAction(self.actionSaveRun) + if not(self.actionSaveRun in self.toolBar.actions()): + self.toolBar.addAction(self.actionSaveRun) + self.actionSaveRun.setText(QApplication.translate("Eficas", "Save Run", None, QApplication.UnicodeUTF8)) + self.connect(self.actionSaveRun,SIGNAL("activated()"),self.saveRun) + + def griserActionsStructures(self): + self.actionCouper.setEnabled(False) + self.actionColler.setEnabled(False) + self.actionCopier.setEnabled(False) + self.actionSupprimer.setEnabled(False) + + def enleverNewInclude(self): + self.actionNouvel_Include.setVisible(False) + + def enleverRechercherDsCatalogue(self): + self.actionRechercherDsCatalogue.setVisible(False) + + def ZCRACKS(self): + self.enleverNewInclude() + self.toolBar.addSeparator() + self.ajoutExecution() + + self.menuOptions = self.menubar.addMenu("menuOptions") + self.menuOptions.addAction(self.actionParametres_Eficas) + self.menuOptions.setTitle(tr("Options")) + + def ADAO(self): + self.griserActionsStructures() + self.enleverNewInclude() + self.enleverRechercherDsCatalogue() + + def ASTER(self) : + self.menuTraduction = self.menubar.addMenu("menuTraduction") + self.menuTraduction.addAction(self.actionTraduitV11V12) + self.menuTraduction.addAction(self.actionTraduitV10V11) + self.menuTraduction.addAction(self.actionTraduitV9V10) + self.menuTraduction.setTitle(tr("Traduction")) + + self.menuFichier.addAction(self.actionSauveLigne) + + self.menuOptions = self.menubar.addMenu("menuOptions") + self.menuOptions.addAction(self.actionParametres_Eficas) + self.menuOptions.addAction(self.actionLecteur_Pdf) + self.menuOptions.setTitle(tr("Options")) + + def CARMEL3D(self): + #if self.salome == 0 : return + self.enleverNewInclude() + self.menuMesh = self.menubar.addMenu("menuMesh") + self.menuMesh.setObjectName("Mesh") + self.menuMesh.addAction(self.actionChercheGrpMaille) + self.griserActionsStructures() + + def CARMELCND(self): + self.enleverNewInclude() + self.enleverRechercherDsCatalogue() + self.ajoutExecution() + self.ajoutSauveExecution() + self.griserActionsStructures() + + def MAP(self): + self.enleverNewInclude() + self.toolBar.addSeparator() + self.ajoutExecution() + self.ajoutSauveExecution() + self.menuOptions = self.menubar.addMenu("menuOptions") + self.menuOptions.addAction(self.actionParametres_Eficas) + self.menuOptions.setTitle(tr("Options")) + + + def ChercheGrpMesh(self): + Msg,listeGroup=self.ChercheGrpMeshInSalome() + if Msg == None : + self.viewmanager.handleAjoutGroup(listeGroup) + else : + print "il faut gerer les erreurs" + + def ChercheGrpMaille(self): + Msg,listeGroup=self.ChercheGrpMailleInSalome() + if Msg == None : + self.viewmanager.handleAjoutGroup(listeGroup) + else : + print "il faut gerer les erreurs" + + def ChercheGrp(self): + #Msg,listeGroup=self.ChercheGrpMailleInSalome() + #if Msg == None : + # self.viewmanager.handleAjoutGroup(listeGroup) + #else : + print "il faut gerer " + def ajoutIcones(self) : # Pour pallier les soucis de repertoire d icone - icon = QIcon(self.RepIcon+"/New24.png") + icon = QIcon(self.repIcon+"/New24.png") self.action_Nouveau.setIcon(icon) - icon1 = QIcon(self.RepIcon+"/Open24.png") + icon1 = QIcon(self.repIcon+"/Open24.png") self.action_Ouvrir.setIcon(icon1) - icon2 = QIcon(self.RepIcon+"/Save24.png") + icon2 = QIcon(self.repIcon+"/Save24.png") self.actionEnregistrer.setIcon(icon2) - icon3 = QIcon(self.RepIcon+"/Cut24.png") + icon3 = QIcon(self.repIcon+"/Cut24.png") self.actionCouper.setIcon(icon3) - icon4 = QIcon(self.RepIcon+"/Copy24.png") + icon4 = QIcon(self.repIcon+"/Copy24.png") self.actionCopier.setIcon(icon4) - icon5 = QIcon(self.RepIcon+"/Paste24.png") + icon5 = QIcon(self.repIcon+"/Paste24.png") self.actionColler.setIcon(icon5) + icon6 = QIcon(self.repIcon+"/Delete24.png") + self.actionSupprimer.setIcon(icon6) + def connecterSignaux(self) : self.connect(self.recentMenu,SIGNAL('aboutToShow()'),self.handleShowRecentMenu) - self.connect(self.action_Nouveau,SIGNAL("activated()"),self.fileNew) + self.connect(self.action_Nouveau,SIGNAL("activated()"),self.fileNew) self.connect(self.actionNouvel_Include,SIGNAL("activated()"),self.NewInclude) self.connect(self.action_Ouvrir,SIGNAL("activated()"),self.fileOpen) self.connect(self.actionEnregistrer,SIGNAL("activated()"),self.fileSave) @@ -160,22 +302,61 @@ class Appli(Ui_Eficas,QMainWindow): self.connect(self.actionEficas,SIGNAL("activated()"),self.aidePPal) self.connect(self.actionVersion,SIGNAL("activated()"),self.version) + self.connect(self.actionParametres,SIGNAL("activated()"),self.gestionParam) self.connect(self.actionCouper,SIGNAL("activated()"),self.editCut) self.connect(self.actionCopier,SIGNAL("activated()"),self.editCopy) self.connect(self.actionColler,SIGNAL("activated()"),self.editPaste) self.connect(self.actionSupprimer,SIGNAL("activated()"),self.supprimer) + self.connect(self.actionRechercher,SIGNAL("activated()"),self.rechercher) + self.connect(self.actionDeplier_replier,SIGNAL("activated()"),self.Deplier) self.connect(self.actionRapport_de_Validation,SIGNAL("activated()"),self.jdcRapport) self.connect(self.actionFichier_Source,SIGNAL("activated()"),self.jdcFichierSource) self.connect(self.actionFichier_Resultat,SIGNAL("activated()"),self.visuJdcPy) - self.connect(self.actionParametres_Eficas,SIGNAL("activated()"),self.optionEditeur) - self.connect(self.actionLecteur_Pdf,SIGNAL("activated()"),self.optionPdf) #self.connect(self.helpIndexAction,SIGNAL("activated()"),self.helpIndex) #self.connect(self.helpContentsAction,SIGNAL("activated()"),self.helpContents) - + + # Pour Aster + self.actionTraduitV9V10 = QAction(self) + self.actionTraduitV9V10.setObjectName("actionTraduitV9V10") + self.actionTraduitV9V10.setText(tr("TraduitV9V10")) + self.actionTraduitV10V11 = QAction(self) + self.actionTraduitV10V11.setObjectName("actionTraduitV10V11") + self.actionTraduitV10V11.setText(tr("TraduitV10V11")) + self.actionTraduitV11V12 = QAction(self) + self.actionTraduitV11V12.setObjectName("actionTraduitV11V12") + self.actionTraduitV11V12.setText(tr("TraduitV11V12")) + self.actionSauveLigne = QAction(self) + self.actionSauveLigne.setText(tr("Sauve Format Ligne")) + + self.connect(self.actionParametres_Eficas,SIGNAL("activated()"),self.optionEditeur) + self.connect(self.actionLecteur_Pdf,SIGNAL("activated()"),self.optionPdf) + self.connect(self.actionTraduitV9V10,SIGNAL("activated()"),self.traductionV9V10) + self.connect(self.actionTraduitV10V11,SIGNAL("activated()"),self.traductionV10V11) + self.connect(self.actionTraduitV11V12,SIGNAL("activated()"),self.traductionV11V12) + self.connect(self.actionSauveLigne,SIGNAL("activated()"),self.sauveLigne) + + + # Pour Carmel + self.actionChercheGrpMaille = QAction(self) + self.actionChercheGrpMaille.setText(tr("Acquiert Groupe Maille")) + self.connect(self.actionChercheGrpMaille,SIGNAL("activated()"),self.ChercheGrpMaille) + + # Pour CarmelCND + self.actionChercheGrp = QAction(self) + self.actionChercheGrp.setText(tr("Accquisition Groupe Maille")) + self.connect(self.actionChercheGrp,SIGNAL("activated()"),self.ChercheGrp) + + # Pour Aide + self.actionCode = QAction(self) + self.actionCode.setText(tr("Specificites Maille")) + self.connect(self.actionCode,SIGNAL("activated()"),self.aideCode) + + def Deplier(self): + self.viewmanager.handleDeplier() def ouvreFichiers(self) : # Ouverture des fichiers de commandes donnes sur la ligne de commande @@ -186,6 +367,7 @@ class Appli(Ui_Eficas,QMainWindow): d=session.get_unit(study,self) self.viewmanager.handleOpen(fichier=study["comm"],units=d) + def get_source(self,file): # appele par Editeur/session.py import convert @@ -194,11 +376,22 @@ class Appli(Ui_Eficas,QMainWindow): texte=p.convert('execnoparseur') return texte - - def initPatrons(self) : - # Mise à jour du menu des fichiers recemment ouverts + # Mise a jour du menu des fichiers recemment ouverts from Editeur import listePatrons + if not(self.code in listePatrons.sous_menus.keys()) : + if hasattr(self,"menuPatrons"): + self.menuPatrons.setAttribute(Qt.WA_DeleteOnClose) + self.menuPatrons.close() + delattr(self,"menuPatrons") + return + if (not hasattr(self,"menuPatrons")): + self.menuPatrons = QMenu(self.menubar) + self.menuPatrons.setObjectName("menuPatrons") + self.menubar.addAction(self.menuPatrons.menuAction()) + self.menuPatrons.setTitle(QApplication.translate("Eficas", "Patrons", None, QApplication.UnicodeUTF8)) + else : + self.menuPatrons.clear() self.listePatrons = listePatrons.listePatrons(self.code) idx = 0 for nomSsMenu in self.listePatrons.liste.keys(): @@ -211,8 +404,10 @@ class Appli(Ui_Eficas,QMainWindow): idx=idx+1 def initRecents(self): + self.recent = QStringList() try : - rep=self.CONFIGURATION.rep_user + #if 1 : + rep=os.path.join(os.environ['HOME'],'.config/Eficas',self.code) monFichier=rep+"/listefichiers_"+self.code index=0 f=open(monFichier) @@ -223,6 +418,7 @@ class Appli(Ui_Eficas,QMainWindow): self.recent.append(l) index=index+1 except : + #else : pass try : f.close() @@ -240,8 +436,11 @@ class Appli(Ui_Eficas,QMainWindow): self.recent = self.recent[:9] def sauveRecents(self) : - rep=self.CONFIGURATION.rep_user - monFichier=rep+"/listefichiers_"+self.code + try : + rep=self.CONFIGURATION.rep_user + monFichier=rep+"/listefichiers_"+self.code + except : + return try : f=open(monFichier,'w') if len(self.recent) == 0 : return @@ -259,133 +458,167 @@ class Appli(Ui_Eficas,QMainWindow): - def traductionV7V8(self): + def traductionV11V12(self): from gereTraduction import traduction - traduction(self.CONFIGURATION.rep_ini,self.viewmanager,"V7V8") + traduction(self.CONFIGURATION.repIni,self.viewmanager,"V11V12") - def traductionV8V9(self): + def traductionV10V11(self): from gereTraduction import traduction - traduction(self.CONFIGURATION.rep_ini,self.viewmanager,"V8V9") + traduction(self.CONFIGURATION.repIni,self.viewmanager,"V10V11") + + def traductionV9V10(self): + from gereTraduction import traduction + traduction(self.CONFIGURATION.repIni,self.viewmanager,"V9V10") def version(self) : from monVisu import DVisu - titre = "version " + titre = tr("version ") monVisuDialg=DVisu(parent=self,fl=0) monVisuDialg.setWindowTitle(titre) - monVisuDialg.TB.setText(self.VERSION_EFICAS +QString(" pour ") + self.code) + monVisuDialg.TB.setText(self.VERSION_EFICAS +tr(" pour ") + self.code) monVisuDialg.adjustSize() monVisuDialg.show() def aidePPal(self) : - maD=self.INSTALLDIR+"/Aide" - docsPath = QDir(maD).absolutePath() - monAssistant=QAssistantClient(QString(""), self) - arguments=QStringList() - arguments << "-profile" <