From: PASCALE NOYRET Date: Wed, 14 Feb 2024 17:35:24 +0000 (+0100) Subject: sauve etat du 14 fevrier X-Git-Tag: V_demo_28_mars_2024~44 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=7273cf2f1a5ae8bea151442238bd34be700ca36f;p=tools%2Feficas.git sauve etat du 14 fevrier --- diff --git a/Accas/IO/reader/old/reader_UQPython.py b/Accas/IO/reader/old/reader_UQPython.py new file mode 100644 index 00000000..1321e987 --- /dev/null +++ b/Accas/IO/reader/old/reader_UQPython.py @@ -0,0 +1,92 @@ +# Copyright (C) 2007-2022 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 +# + +from Accas.extensions.eficas_translation import tr + +# import traceback +# traceback.print_stack() + +from Accas.IO.reader.reader_python import Pythonparser + + +def entryPoint(): + """ + Return a dictionary containing the description needed to load the plugin + """ + return {"name": "pythonUQ", "factory": pythonUQParser} + + +class pythonUQParser(Pythonparser): + """ + This converter works like Pythonparser, except that it also initializes all + links between deterministic and probabilistic variables + """ + + def convert(self, outformat, appliEficas=None): + text = Pythonparser.convert(self, outformat, appliEficas) + return text + + def traitementApresLoad(self, jdc): + debug = 0 + if debug: + print("traitementApresLoad") + etapeIncertitude = jdc.getEtapesByName("ExpressionIncertitude") + if etapeIncertitude == []: + return + + incertitudeInput = etapeIncertitude[0].getChildOrChildInBloc("Input") + self.lesVariablesInput = incertitudeInput[0].getChildOrChildInBloc( + "VariableProbabiliste" + ) + for mc in self.lesVariablesInput: + # if debug : print (mc,'mc') + mcVDPath = mc.getChild("MCPath").valeur + if debug: + print(mcVDPath) + # a modifier lorsque le MCPath comprendra le nom des OPERs + if not (mcVDPath): + mc.parent.suppentite(mc) + break # on admet ici que le . comm n est pas valide + mcModelVariable = mc.getChild("ModelVariable") + mcModelVariable.definition.addInto(mcModelVariable.valeur) + # try : + # mcObjectName=mc.getChild('ObjectName') + # mcObjectName.changeStatut('f') + # except : + # pass + mcCherche = jdc.getObjetByMCPath(mcVDPath) + if not (mcCherche): + mc.parent.suppentite(mc) + break # on admet ici que le . comm n est pas valide + if debug: + print(mcCherche) + if mc.nature == "MCFACT": + mc[0].variableDeterministe = mcCherche + mcCherche.variableProbabiliste = mc[0] + else: + mc.variableDeterministe = mcCherche + mcCherche.variableProbabiliste = mc[0] + mcCherche.definition.siValide = mcCherche.changeValeursRefUQ + mcCherche.associeVariableUQ = True + itemConsigne = mc.getChild("Consigne") + itemConsigne.setValeur( + "la valeur entrée pour {} est {}".format( + mcCherche.nom, mcCherche.valeur + ) + ) diff --git a/Accas/IO/reader/reader_UQPython.py b/Accas/IO/reader/reader_UQPython.py old mode 100644 new mode 100755 index 1321e987..b5eb6db3 --- a/Accas/IO/reader/reader_UQPython.py +++ b/Accas/IO/reader/reader_UQPython.py @@ -17,20 +17,18 @@ # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com # +import re from Accas.extensions.eficas_translation import tr - -# import traceback -# traceback.print_stack() - from Accas.IO.reader.reader_python import Pythonparser - def entryPoint(): """ Return a dictionary containing the description needed to load the plugin """ - return {"name": "pythonUQ", "factory": pythonUQParser} - + return { + 'name' : 'pythonUQ', + 'factory' : pythonUQParser + } class pythonUQParser(Pythonparser): """ @@ -39,54 +37,42 @@ class pythonUQParser(Pythonparser): """ def convert(self, outformat, appliEficas=None): - text = Pythonparser.convert(self, outformat, appliEficas) + text=Pythonparser.convert(self, outformat, appliEficas) return text - def traitementApresLoad(self, jdc): - debug = 0 - if debug: - print("traitementApresLoad") - etapeIncertitude = jdc.getEtapesByName("ExpressionIncertitude") - if etapeIncertitude == []: - return - - incertitudeInput = etapeIncertitude[0].getChildOrChildInBloc("Input") - self.lesVariablesInput = incertitudeInput[0].getChildOrChildInBloc( - "VariableProbabiliste" - ) - for mc in self.lesVariablesInput: - # if debug : print (mc,'mc') - mcVDPath = mc.getChild("MCPath").valeur - if debug: - print(mcVDPath) - # a modifier lorsque le MCPath comprendra le nom des OPERs - if not (mcVDPath): - mc.parent.suppentite(mc) - break # on admet ici que le . comm n est pas valide - mcModelVariable = mc.getChild("ModelVariable") + def traitementApresLoad(self,jdc): + debug=0 + if debug : print ('traitementApresLoad') + etapeIncertitude=jdc.getEtapesByName('ExpressionIncertitude') + if etapeIncertitude==[] : return + + incertitudeInput = etapeIncertitude[0].getChildOrChildInBloc('Input')[0] + self.lesVariablesInput = incertitudeInput.getChildOrChildInBloc('VariableProbabiliste') + for mc in self.lesVariablesInput : + if debug : print (mc,'mc') + mcVDPath=mc.getChild('MCPath').valeur + if debug : print(mcVDPath) + if not (mcVDPath) : + try: mc.parent.suppentite(mc) + except : pass + break # on admet ici que le . comm n est pas valide + mcModelVariable=mc.getChild('ModelVariable') mcModelVariable.definition.addInto(mcModelVariable.valeur) - # try : - # mcObjectName=mc.getChild('ObjectName') - # mcObjectName.changeStatut('f') - # except : - # pass - mcCherche = jdc.getObjetByMCPath(mcVDPath) - if not (mcCherche): - mc.parent.suppentite(mc) - break # on admet ici que le . comm n est pas valide - if debug: - print(mcCherche) - if mc.nature == "MCFACT": - mc[0].variableDeterministe = mcCherche - mcCherche.variableProbabiliste = mc[0] - else: - mc.variableDeterministe = mcCherche - mcCherche.variableProbabiliste = mc[0] - mcCherche.definition.siValide = mcCherche.changeValeursRefUQ - mcCherche.associeVariableUQ = True - itemConsigne = mc.getChild("Consigne") - itemConsigne.setValeur( - "la valeur entrée pour {} est {}".format( - mcCherche.nom, mcCherche.valeur - ) - ) + + mcDeterministe=jdc.getObjetByMCPath(mcVDPath) + if debug : print ('mcDeterministe', mcDeterministe, 'trouve a partir de ', mcVDPath) + if not (mcDeterministe) : + try: mc.parent.suppentite(mc) + except : pass + break # on admet ici que le . comm n est pas valide + if debug : print('mcDeterministe',mcDeterministe, mcDeterministe.nom) + + mc.variableDeterministe=mcDeterministe + if debug : print ('variableDeterministe pour ', mc, 'mis a ', mcDeterministe) + mcDeterministe.variableProbabiliste=mc + if debug : print ('variableProbabiliste pour ', mcDeterministe, 'mis a ', mc) + + mcDeterministe.definition.siValide = mcDeterministe.changeValeursRefUQ + mcDeterministe.associeVariableUQ = True + # il ne faut pas mettre la consigne a jour. Elle le sera a la validation sans erreur sur les valeurs + diff --git a/Accas/accessor/A_MACRO_ETAPE.py b/Accas/accessor/A_MACRO_ETAPE.py index 2466143a..c8a432f1 100644 --- a/Accas/accessor/A_MACRO_ETAPE.py +++ b/Accas/accessor/A_MACRO_ETAPE.py @@ -132,7 +132,7 @@ class MACRO_ETAPE(A_ETAPE.ETAPE): nom=fichier, appliEficas=self.jdc.appliEficas, cata=self.jdc.cata, - cata_ord_dico=self.jdc.cata_ordonne_dico, + dicoCataOrdonne=self.jdc.dicoCataOrdonne, context_ini=context_ini, jdc_pere=self.jdc, etape_include=self, diff --git a/Accas/accessor/A_MCCOMPO.py b/Accas/accessor/A_MCCOMPO.py index 95f77e80..5b3da9b6 100644 --- a/Accas/accessor/A_MCCOMPO.py +++ b/Accas/accessor/A_MCCOMPO.py @@ -158,7 +158,7 @@ class MCCOMPO(A_OBJECT.OBJECT): # Attention : les mots clefs listes (+sieurs fact ) # n ont pas toutes ces methodes. a priori pas appele mais if self.nature != "MCLIST": - self.listeMc = self.getListeMcOrdonnee(genea, self.jdc.cata_ordonne_dico) + self.listeMc = self.getListeMcOrdonnee(genea, self.jdc.dicoCataOrdonne) listeNomsPresents = self.dictMcPresents() for regle in self.getRegles(): (monToolTip, regleOk) = regle.verif(listeNomsPresents) @@ -214,7 +214,7 @@ class MCCOMPO(A_OBJECT.OBJECT): Retourne l'index dans la liste des fils de self du nouveau fils de nom nom_fils Permet de savoir a quelle position il faut ajouter un nouveau mot-cle """ - cata_ordonne = self.jdc.cata_ordonne_dico + cata_ordonne = self.jdc.dicoCataOrdonne liste_noms_mc_ordonnee = self.getListeMcOrdonneeBrute( self.getGenealogie(), cata_ordonne ) diff --git a/Accas/catalog/analyse_ordre_catalogue.py b/Accas/catalog/analyse_ordre_catalogue.py index 58e7fabe..c69a3fe5 100644 --- a/Accas/catalog/analyse_ordre_catalogue.py +++ b/Accas/catalog/analyse_ordre_catalogue.py @@ -79,7 +79,7 @@ def traiteReel(objet, listeSimpReel): listeSimpReel.append(objet.nom) -def analyseNiveau(cata_ordonne_dico, niveau, listeSimpReel): +def analyseNiveau(dicoCataOrdonne, niveau, listeSimpReel): """ Analyse un niveau dans un catalogue de commandes """ @@ -87,10 +87,10 @@ def analyseNiveau(cata_ordonne_dico, niveau, listeSimpReel): # Il n'y a pas de sous niveaux for oper in niveau.entites: traiteEntite(oper, listeSimpReel) - cata_ordonne_dico[oper.nom] = oper + dicoCataOrdonne[oper.nom] = oper else: for niv in niveau.lNiveaux: - analyseNiveau(cata_ordonne_dico, niv) + analyseNiveau(dicoCataOrdonne, niv) def analyseCatalogue(cata): @@ -101,17 +101,17 @@ def analyseCatalogue(cata): Elle retourne un dictionnaire qui contient toutes les commandes du catalogue indexees par leur nom """ - cata_ordonne_dico = {} + dicoCataOrdonne = {} listeSimpReel = [] if cata.JdC.lNiveaux == (): # Il n'y a pas de niveaux for oper in cata.JdC.commandes: traiteEntite(oper, listeSimpReel) - cata_ordonne_dico[oper.nom] = oper + dicoCataOrdonne[oper.nom] = oper else: for niv in cata.JdC.lNiveaux: - analyseNiveau(cata_ordonne_dico, niv, listeSimpReel) - return cata_ordonne_dico, listeSimpReel + analyseNiveau(dicoCataOrdonne, niv, listeSimpReel) + return dicoCataOrdonne, listeSimpReel if __name__ == "__main__": diff --git a/Accas/catalog/catadesc.py b/Accas/catalog/catadesc.py index 197fe8ef..78b24dbf 100644 --- a/Accas/catalog/catadesc.py +++ b/Accas/catalog/catadesc.py @@ -18,16 +18,16 @@ # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com # -# Classe permettant d ajouter un catalogue par un utilisateur -# Attention plus utilisé car peu utile +# Classe permettant a un utilisateur d ajouter un catalogue # permet d avoir les valeurs par defaut dans le tuple # Exemple dans un pref.py -# self.catalogues = (CatalogDescription("monCata", os.path.join(repIni, "monCata.py")),) +# gere les ssCodes autrefois utilises par Map +# self.catalogues = (CatalogDescription("monCataVO", os.path.join(repIni, "monCata.py")),) class CatalogDescription(object): def __init__( self, - labelCode, + versionCode, fichierCata, formatFichierOut="python", formatFichierIn="python", @@ -40,8 +40,8 @@ class CatalogDescription(object): """ This class can be used to describe an Eficas catalog. - :type labelCode: string - :param labelCode: unique labelCode for the catalog + :type versionCode: string + :param versionCode: unique versionCode for the catalog :type fichierCata: string :param fichierCata: path of the file containing the catalog itself @@ -72,7 +72,7 @@ class CatalogDescription(object): """ - self.labelCode = labelCode + self.versionCode = versionCode self.fichierCata = fichierCata self.formatFichierOut = formatFichierOut self.formatFichierIn = formatFichierIn @@ -80,7 +80,7 @@ class CatalogDescription(object): self.code = code self.ssCode = ssCode if userName is None: - self.userName = labelCode + self.userName = versionCode else: self.userName = userName self.selectable = selectable @@ -93,7 +93,7 @@ class CatalogDescription(object): desc = CatalogDescription( code=cataTuple[0], ssCode=cataTuple[1], - labelCode=cataTuple[0] + cataTuple[1], + versionCode=cataTuple[0] + cataTuple[1], fichierCata=cataTuple[2], formatFichierOut=cataTuple[3], formatFichierIn=cataTuple[4], @@ -102,7 +102,7 @@ class CatalogDescription(object): if cataTuple[0] == "MAP": desc = CatalogDescription( code=cataTuple[0], - labelCode=cataTuple[1], + versionCode=cataTuple[1], fichierCata=cataTuple[2], ssCode=cataTuple[3], formatFichierOut="MAP", @@ -111,7 +111,7 @@ class CatalogDescription(object): elif len(cataTuple) == 4: desc = CatalogDescription( code=cataTuple[0], - labelCode=cataTuple[1], + versionCode=cataTuple[1], fichierCata=cataTuple[2], formatFichierOut=cataTuple[3], formatFichierIn="python", @@ -119,7 +119,7 @@ class CatalogDescription(object): elif len(cataTuple) == 5: desc = CatalogDescription( code=cataTuple[0], - labelCode=cataTuple[1], + versionCode=cataTuple[1], fichierCata=cataTuple[2], formatFichierOut=cataTuple[3], formatFichierIn=cataTuple[4], @@ -127,7 +127,7 @@ class CatalogDescription(object): elif len(cataTuple) == 6: desc = CatalogDescription( code=cataTuple[0], - labelCode=cataTuple[1], + versionCode=cataTuple[1], fichierCata=cataTuple[2], formatFichierOut=cataTuple[3], formatFichierIn=cataTuple[4], diff --git a/Accas/catalog/reader_cata.py b/Accas/catalog/reader_cata.py index 8f84b8df..2c5c0695 100644 --- a/Accas/catalog/reader_cata.py +++ b/Accas/catalog/reader_cata.py @@ -58,17 +58,17 @@ class ReaderCataCommun(object): pathGui='InterfaceGUI.'+ self.appliEficas.GUIPath + '.monChoixCata' MonChoixCata =__import__(pathGui, globals(), locals(), ['MonChoixCata,']) widgetChoix = MonChoixCata.MonChoixCata( - self.appliEficas, [cata.labelCode for cata in cataListeChoix], title + self.appliEficas, [cata.versionCode for cata in cataListeChoix], title ) ret = widgetChoix.exec_() #if ret == QDialog.Accepted: if ret == 1: cata = cataListeChoix[widgetChoix.CBChoixCata.currentIndex()] self.fichierCata = cata.fichierCata - self.labelCode = cata.labelCode + self.versionCode = cata.versionCode self.appliEficas.formatFichierOut = cata.formatFichierOut self.appliEficas.formatFichierIn = cata.formatFichierIn - titre='{} pour {} avec le catalogue {}'.format(self.appliEficas.versionEficas,self.code,self.labelCode) + titre='{} pour {} avec le catalogue {}'.format(self.appliEficas.versionEficas,self.code,self.versionCode) self.appliEficas.setWindowTitle(titre) widgetChoix.close() else: @@ -76,7 +76,7 @@ class ReaderCataCommun(object): raise EficasException() def choisitCata(self): - # ____________________ + #--------------------# listeCataPossibles = [] @@ -89,11 +89,12 @@ class ReaderCataCommun(object): else: print(("Catalog description cannot be interpreted: ", catalogue)) - if self.labelCode is None: + if self.versionCode is None: listeCataPossibles = listeTousLesCatas else: + # a priori impossible sans l idee du sousCode for catalogue in listeTousLesCatas: - if catalogue.code == self.code and catalogue.ssCode == self.ssCode: + if catalogue.code == self.code and catalogue.versionCode == self.versionCode: listeCataPossibles.append(catalogue) if len(listeCataPossibles) == 0: @@ -104,12 +105,12 @@ class ReaderCataCommun(object): if self.appliEficas.salome == 0: sys.exit(1) return - if self.labelCode is not None: + if self.versionCode is not None: # La version a ete fixee for cata in listeCataPossibles: - if self.labelCode == cata.labelCode: + if self.versionCode == cata.versionCode: self.fichierCata = cata.fichierCata - self.labelCode = cata.labelCode + self.versionCode = cata.versionCode self.appliEficas.formatFichierOut = cata.formatFichierOut self.appliEficas.formatFichierIn = cata.formatFichierIn else: @@ -125,21 +126,14 @@ class ReaderCataCommun(object): if self.appliEficas.fichierCata != None: trouve = False for catalogue in listeTousLesCatas: - if os.path.abspath(catalogue.fichierCata) == ( - os.path.abspath(self.appliEficas.fichierCata) - ): + if os.path.abspath(catalogue.fichierCata) == ( os.path.abspath(self.appliEficas.fichierCata)): listeCataPossibles = (catalogue,) trouve = True break if not trouve: + # utilise par Telemac catalogue = CatalogDescription.createFromTuple( - ( - self.code, - self.code, - self.appliEficas.fichierCata, - "python", - "python", - ) + ( self.code, self.code, self.appliEficas.fichierCata, "python", "python",) ) listeCataPossibles = (catalogue,) @@ -153,20 +147,18 @@ class ReaderCataCommun(object): return # le label est fixe dans la ligne de commande - if self.labelCode is not None: + if self.versionCode is not None: # La version a ete fixee for cata in listeCataPossibles: - if self.labelCode == cata.labelCode: + if self.versionCode == cata.versionCode: self.fichierCata = cata.fichierCata self.appliEficas.formatFichierIn = cata.formatFichierIn self.appliEficas.formatFichierOut = cata.formatFichierOut else: cataListeChoix = [] for cata in listeCataPossibles: - if cata.default: - cataListeChoix.insert(0, cata) - else: - cataListeChoix.append(cata) + if cata.default: cataListeChoix.insert(0, cata) + else: cataListeChoix.append(cata) if len(cataListeChoix) == 0: self.appliEficas.afficheMessage( @@ -177,27 +169,21 @@ class ReaderCataCommun(object): elif len(cataListeChoix) == 1: self.fichierCata = cataListeChoix[0].fichierCata - self.labelCode = cataListeChoix[0].labelCode + self.versionCode = cataListeChoix[0].versionCode self.appliEficas.formatFichierOut = cataListeChoix[0].formatFichierOut self.appliEficas.formatFichierIn = cataListeChoix[0].formatFichierIn else: # plusieurs catalogues sont disponibles : il faut demander a l'utilisateur # lequel il veut utiliser ... - if self.appliEficas.ssIhm: - print("Unable to know which catafile is choosen") - exit() - self.askChoixCatalogue(cataListeChoix) + print ('PN : --> passer la commande askChoixCatalogue dans Editor avec sortie pour non QT / non Web') + #self.appliEficas.afficheMessage( tr("Import du catalogue"), tr('Aucun catalogue choisi'), critique = True) self.demandeCatalogue = True + self.askChoixCatalogue(cataListeChoix) if self.fichierCata == None: if self.appliEficas.salome == 0: - print( - ( - "Pas de catalogue pour code %s, version %s" - % (self.code, self.labelCode) - ) - ) + print( "Pas de catalogue pour code %s, version %s" % (self.code, self.versionCode)) sys.exit(1) else: self.appliEficas.close() @@ -217,11 +203,10 @@ class ReaderCata(ReaderCataCommun): self.demandeCatalogue = False self.code = self.appliEficas.code self.titre = self.appliEficas.code - self.ssCode = self.appliEficas.ssCode # on positionne par defaut mais est-ce vraiment necessaire self.appliEficas.formatFichierIn = "python" self.appliEficas.formatFichierOut = "python" - self.labelCode = self.appliEficas.labelCode + self.versionCode = self.appliEficas.versionCode self.fichierCata = self.appliEficas.fichierCata self.openCata() self.traiteIcones() @@ -231,7 +216,7 @@ class ReaderCata(ReaderCataCommun): self.creeDicoCasToCata() def openCata(self): - # _________________________________ + # _________________ """ Ouvre le catalogue standard du code courant, cad le catalogue present dans le repertoire Cata @@ -244,8 +229,7 @@ class ReaderCata(ReaderCataCommun): if self.code == "NonConnu": self.code = self.cata.JdC.code modeleMetier = None dicoEltDif = {} - if not (self.appliEficas.genereXSD): - if self.appliEficas.maConfiguration.withXSD or self.appliEficas.withXSD: + if not(self.appliEficas.genereXSD) and self.appliEficas.withXSD: try: import pyxb except: @@ -293,11 +277,7 @@ class ReaderCata(ReaderCataCommun): # print ('dans readerCata _________', dicoEltDif) except Exception as e : - if self.appliEficas.ssIhm == False: - self.appliEficas.afficheMessage( - "XSD driver", "unable to load xsd driver", critique=False - ) - print (e) + self.appliEficas.afficheMessage( "XSD driver", "unable to load xsd driver" + str(e), critique=False) modeleMetier = None self.cata.DicoNomTypeDifferentNomElt = dicoEltDif @@ -310,7 +290,7 @@ class ReaderCata(ReaderCataCommun): self.cata.JdC.importedBy = self.cata.importedBy else: self.cata.JdC.importedBy = [] - self.cata.JdC.labelCode = self.labelCode + self.cata.JdC.versionCode = self.versionCode if not (hasattr(self.cata, "dict_condition")): self.cata.dict_condition = {} @@ -327,10 +307,7 @@ class ReaderCata(ReaderCataCommun): sys.exit(1) # # retrouveOrdreCataStandard fait une analyse textuelle du catalogue - # retrouveOrdreCataImpose qui utilise une numerotation - # des mots cles a la creation - #if self.appliEficas.maConfiguration.modeNouvCommande == "initial": self.retrouveOrdreCata() - #else : self.retrouveOrdreCataImpose() + # retrouveOrdreCataImpose utilise une numerotation des mots cles a la creation self.retrouveOrdreCata() self.retrouveOrdreCataImpose() if hasattr(self.cata, "ordreDesCommandes"): @@ -365,23 +342,16 @@ class ReaderCata(ReaderCataCommun): # uiinfo.traite_UIinfo(self.cata) - # - # traitement des clefs documentaires - # - self.titre = ( - self.versionEficas - + " " - + tr(" avec le catalogue ") + self.versionEficas + tr(" avec le catalogue ") + os.path.basename(self.fichierCata) ) - if self.appliEficas.ssIhm == False: - self.appliEficas.setWindowTitle(self.titre) self.editor.titre = self.titre + if hasattr(self.appliEficas, 'setWindowTitle') : + self.appliEficas.setWindowTitle(self.titre) - # incertitude --> change le convert - if hasattr(self.cata, "avecIncertitude"): - self.appliEficas.ajoutUQ() + # incertitude ou modification du Catalogue + if hasattr(self.cata, "avecIncertitude"): self.appliEficas.ajoutUQ() if hasattr(self.cata, "modifieCatalogueDeterministe"): self.cata.modifieCatalogueDeterministe(self.cata) @@ -402,11 +372,14 @@ class ReaderCata(ReaderCataCommun): if k[0 : len(nomCata) + 1] == nomCata + ".": del sys.modules[k] - # permet d ajouter des scripts appelables par des fonctions supplementaires + # permettait d ajouter des scripts appelables par des fonctions supplementaires # dans l ihm - mesScriptsNomFichier = "mesScripts_" + self.code.upper() - try: self.appliEficas.mesScripts[self.code] = __import__(mesScriptsNomFichier) - except: pass + # par exemple permet d ajouter des morceaux dans le jeu de données + # mecanisme mis en place pout MT et laisse pour pouvoir eventuellement + # etre repris + # mesScriptsNomFichier = "mesScripts_" + self.code.upper() + # try: self.appliEficas.mesScripts[self.code] = __import__(mesScriptsNomFichier) + # except: pass try: #import importlib.util @@ -428,9 +401,7 @@ class ReaderCata(ReaderCataCommun): Pour chaque entite du catalogue on cree une liste de nom ordreMC qui contient le nom des mots cles dans le bon ordre """ - self.cata_ordonne_dico, self.appliEficas.liste_simp_reel = analyse_ordre_catalogue.analyseCatalogue(self.cata) - # self.appliEficas.liste_simp_reel = () - # self.cata_ordonne_dico = {} + self.dicoCataOrdonne, self.appliEficas.liste_simp_reel = analyse_ordre_catalogue.analyseCatalogue(self.cata) def retrouveOrdreCataImpose(self): """ diff --git a/Accas/catalog/reader_cata_XML.py b/Accas/catalog/reader_cata_XML.py index 5423a700..879735b1 100644 --- a/Accas/catalog/reader_cata_XML.py +++ b/Accas/catalog/reader_cata_XML.py @@ -1,4 +1,4 @@ -# -*- coding: utf-8 -*- +sC -*- coding: utf-8 -*- # Copyright (C) 2007-2024 EDF R&D # # This library is free software; you can redistribute it and/or @@ -38,17 +38,19 @@ from Accas.catalog.readercata import ReaderCataCommun class ReaderCata(ReaderCataCommun): +# essai de lecture de catalogue en XML +# obsolete def __init__(self, appliEficas, editor): self.appliEficas = appliEficas self.editor = editor self.versionEficas = self.appliEficas.versionEficas self.code = self.appliEficas.code - self.ssCode = self.appliEficas.ssCode - # PN ?? bizarre le 22/04/20 + + # PN ?? bizarre le 22/04/24 self.appliEficas.formatfichierOut = "python" self.appliEficas.formatfichierIn = "xml" self.modeNouvCommande = self.appliEficas.maConfiguration.modeNouvCommande - self.labelCode = self.appliEficas.labelCode + self.versionCode = self.appliEficas.versionCode self.version_cata = None self.ficCata = None self.OpenCata() @@ -72,7 +74,7 @@ class ReaderCata(ReaderCataCommun): self.cata = SchemaMed uiinfo.traite_UIinfo(self.cata) #self.commandesOrdreCatalogue = [] - self.cata_ordonne_dico, self.appliEficas.liste_simp_reel = autre_analyse_cata.analyseCatalogue(self.cata) + self.dicoCataOrdonne, self.appliEficas.liste_simp_reel = autre_analyse_cata.analyseCatalogue(self.cata) self.liste_groupes = None def dumpToXml(self): diff --git a/Accas/extensions/commande_comm.py b/Accas/extensions/commande_comm.py index 7b401fe4..5581a775 100644 --- a/Accas/extensions/commande_comm.py +++ b/Accas/extensions/commande_comm.py @@ -192,7 +192,7 @@ class COMMANDE_COMM(P_OBJECT.OBJECT, A_OBJECT.OBJECT): procedure=self.valeur, definition=self.jdc.definition, cata=self.jdc.cata, - cata_ord_dico=self.jdc.cata_ordonne_dico, + dicoCataOrdonne=self.jdc.dicoCataOrdonne, context_ini=context_ini, ) J.analyse() diff --git a/Accas/extensions/jdc_include.py b/Accas/extensions/jdc_include.py index e4e29dc9..8a51e64e 100644 --- a/Accas/extensions/jdc_include.py +++ b/Accas/extensions/jdc_include.py @@ -37,7 +37,7 @@ class JDC_POURSUITE(JDC): definition=None, procedure=None, cata=None, - cata_ord_dico=None, + dicoCataOrdonne=None, parent=None, nom="SansNom", appliEficas=None, @@ -54,7 +54,7 @@ class JDC_POURSUITE(JDC): definition=definition, procedure=procedure, cata=cata, - cata_ord_dico=cata_ord_dico, + dicoCataOrdonne=dicoCataOrdonne, parent=parent, nom=nom, appli=appliEficas, @@ -233,7 +233,7 @@ class JDC_POURSUITE(JDC): JDC.supprime(self) self.jdc_pere = None self.etape_include = None - # self.cata_ordonne_dico={} + # self.dicoCataOrdonne={} self.appliEficas = None # self.context_ini={} diff --git a/Accas/processing/P_JDC.py b/Accas/processing/P_JDC.py index b87529f0..fef390a5 100644 --- a/Accas/processing/P_JDC.py +++ b/Accas/processing/P_JDC.py @@ -59,13 +59,13 @@ NONE = None from Accas.processing.P_utils import SEP - def __init__( self, definition=None, procedure=None, cata=None, cata_ord_dico=None, + def __init__( self, definition=None, procedure=None, cata=None, dicoCataOrdonne=None, parent=None, nom="SansNom", appliEficas=None, context_ini=None, **args): self.procedure = procedure self.definition = definition self.cata = cata self._build_reserved_kw_list() - self.cata_ordonne_dico = cata_ord_dico + self.dicoCataOrdonne = dicoCataOrdonne self.nom = nom self.appliEficas = appliEficas self.parent = parent @@ -190,9 +190,6 @@ Causes possibles : if isinstance(sd, ASSD): self.sdsDict[sdnom] = sd - # if self.appliEficas != None: - # self.appliEficas.afficheInfos( - # 'Interpretation du fichier de commandes en cours ...') # On sauve le contexte pour garder la memoire des constantes # En mode edition (EFICAS) ou lors des verifications le contexte diff --git a/Accas/processing/P_JDC_CATA.py b/Accas/processing/P_JDC_CATA.py index bed5d9fa..62d84cc3 100644 --- a/Accas/processing/P_JDC_CATA.py +++ b/Accas/processing/P_JDC_CATA.py @@ -85,7 +85,7 @@ class JDC_CATA(P_ENTITE.ENTITE): self.listeUserASSDDumpes = set() self.listeTypeTXMAvecBlancs = set() - def __call__( self, procedure=None, cata=None, cata_ord_dico=None, nom="SansNom", + def __call__( self, procedure=None, cata=None, dicoCataOrdonne=None, nom="SansNom", parent=None, **args): """ Construit l'objet JDC a partir de sa definition (self), @@ -94,7 +94,7 @@ class JDC_CATA(P_ENTITE.ENTITE): definition=self, procedure=procedure, cata=cata, - cata_ord_dico=cata_ord_dico, + dicoCataOrdonne=dicoCataOrdonne, nom=nom, parent=parent, **args diff --git a/Accas/processing/P_MCCOMPO.py b/Accas/processing/P_MCCOMPO.py index 97305c67..ea930c30 100644 --- a/Accas/processing/P_MCCOMPO.py +++ b/Accas/processing/P_MCCOMPO.py @@ -244,9 +244,9 @@ class MCCOMPO(P_OBJECT.OBJECT): Ordonne la liste suivant l'ordre du catalogue. Seulement pour IHM graphique """ - if self.jdc and self.jdc.cata_ordonne_dico != None: + if self.jdc and self.jdc.dicoCataOrdonne != None: liste_noms_mc_ordonnee = self.getListeMcOrdonneeBrute( - self.getGenealogie(), self.jdc.cata_ordonne_dico + self.getGenealogie(), self.jdc.dicoCataOrdonne ) return self.ordonneListeMc(mcListe, liste_noms_mc_ordonnee) else: diff --git a/Accas/processing/P_MCSIMP.py b/Accas/processing/P_MCSIMP.py index 175f051c..5a3a0a45 100644 --- a/Accas/processing/P_MCSIMP.py +++ b/Accas/processing/P_MCSIMP.py @@ -57,6 +57,7 @@ class MCSIMP(P_OBJECT.OBJECT): self.nom = nom self.val = val self.parent = parent + self.associeVariableUQ = False self.objPyxbDeConstruction = objPyxbDeConstruction if parent: self.jdc = self.parent.jdc diff --git a/CatasDeTests/qtEficasEssai.py b/CatasDeTests/qtEficasEssai.py index 5ccf1878..c2eaca7b 100755 --- a/CatasDeTests/qtEficasEssai.py +++ b/CatasDeTests/qtEficasEssai.py @@ -33,4 +33,4 @@ sys.path.append(os.path.join(os.path.abspath(os.path.dirname(__file__)),'..')) import prefs from InterfaceQT4 import eficas_go print (prefs.code) -eficas_go.lanceEficas(code=prefs.code) +eficas_go.lanceQtEficas(code=prefs.code) diff --git a/Codes/Adao/qtDico.py b/Codes/Adao/qtDico.py index 09866c03..e8a0f18f 100755 --- a/Codes/Adao/qtDico.py +++ b/Codes/Adao/qtDico.py @@ -30,7 +30,7 @@ __import__(name) from InterfaceQT4 import eficas_go -dico=eficas_go.lanceEficas_param(code=prefs.code,fichier="/local00/home/A96028/GitEficas/eficas/Adao/exemple01.comm",version="V760",macro="ASSIMILATION_STUDY") +dico=eficas_go.lanceQtEficas_param(code=prefs.code,fichier="/local00/home/A96028/GitEficas/eficas/Adao/exemple01.comm",version="V760",macro="ASSIMILATION_STUDY") #print dico import pprint diff --git a/Codes/Adao/qtEficas_Adao.py b/Codes/Adao/qtEficas_Adao.py index 9ff2b4c3..cb6fdb82 100755 --- a/Codes/Adao/qtEficas_Adao.py +++ b/Codes/Adao/qtEficas_Adao.py @@ -32,4 +32,4 @@ __import__(name) #sys.setdefaultencoding('latin1') from InterfaceQT4 import eficas_go -eficas_go.lanceEficas(code=prefs.code) +eficas_go.lanceQtEficas(code=prefs.code) diff --git a/Codes/OldCodes/MT/qtEficasMT.py b/Codes/OldCodes/MT/qtEficasMT.py index 3fa63c87..1b05143e 100755 --- a/Codes/OldCodes/MT/qtEficasMT.py +++ b/Codes/OldCodes/MT/qtEficasMT.py @@ -33,4 +33,4 @@ sys.path.append(os.path.join(os.path.abspath(os.path.dirname(__file__)),'..')) import prefs from InterfaceQT4 import eficas_go -eficas_go.lanceEficas(code=prefs.code) +eficas_go.lanceQtEficas(code=prefs.code) diff --git a/Codes/OldCodes/PSEN_Eficas/mesScripts.py b/Codes/OldCodes/PSEN_Eficas/mesScripts.py index 15f80ed6..987c91d9 100755 --- a/Codes/OldCodes/PSEN_Eficas/mesScripts.py +++ b/Codes/OldCodes/PSEN_Eficas/mesScripts.py @@ -19,7 +19,7 @@ def import_zone(listeparam,appli) : # simulation de la recuperation zone #import eficasSalome #eficasSalome.runEficas(code='MT',fichier='/home/I29518/test_zone.comm') - appli.viewmanager.handleOpen(fichier='/home/A96028/Install_EficasV1/EficasV1/MT/MT_include.comm') + appli.editorManager.handleOpen(fichier='/home/A96028/Install_EficasV1/EficasV1/MT/MT_include.comm') def import_zone2(listeparam,appli) : editor=listeparam[0] diff --git a/Codes/ReacteurNumerique/lanceEficas.py b/Codes/ReacteurNumerique/lanceEficas.py index 8dc5baaa..e7da3cf3 100755 --- a/Codes/ReacteurNumerique/lanceEficas.py +++ b/Codes/ReacteurNumerique/lanceEficas.py @@ -38,4 +38,4 @@ if prefFile.is_file(): print ('Unable to import {}').format(prefFile) exit(1) from Editeur import eficas_go -eficas_go.lanceEficas(code=code,GUIPath='QT5') +eficas_go.lanceQtEficas(code=code,GUIPath='QT5') diff --git a/Codes/ReacteurNumerique/qtEficasReacteurNumerique.py b/Codes/ReacteurNumerique/qtEficasReacteurNumerique.py index a4704710..d9181a63 100755 --- a/Codes/ReacteurNumerique/qtEficasReacteurNumerique.py +++ b/Codes/ReacteurNumerique/qtEficasReacteurNumerique.py @@ -24,12 +24,9 @@ # Modules Python # Modules Eficas import prefs -name='prefs_'+prefs.code -#__import__(name) - import os, sys sys.path.append(os.path.join(os.path.abspath(os.path.dirname(__file__)),'..','..')) from Editeur import eficas_go -print (prefs.code) -eficas_go.lanceEficas(code=prefs.code, GUIPath='QT5') +print ('lancement d eficas pour : ', prefs.code) +eficas_go.lanceQtEficas(code=prefs.code, GUIPath='QT5') diff --git a/Codes/Telemac/qtEficas_Telemac.py b/Codes/Telemac/qtEficas_Telemac.py index a4704710..3fed7197 100755 --- a/Codes/Telemac/qtEficas_Telemac.py +++ b/Codes/Telemac/qtEficas_Telemac.py @@ -32,4 +32,4 @@ sys.path.append(os.path.join(os.path.abspath(os.path.dirname(__file__)),'..','.. from Editeur import eficas_go print (prefs.code) -eficas_go.lanceEficas(code=prefs.code, GUIPath='QT5') +eficas_go.lanceQtEficas(code=prefs.code, GUIPath='QT5') diff --git a/Codes/Telemac/reecrit_cas_en_comm.py b/Codes/Telemac/reecrit_cas_en_comm.py index 32212e57..1c8b2768 100755 --- a/Codes/Telemac/reecrit_cas_en_comm.py +++ b/Codes/Telemac/reecrit_cas_en_comm.py @@ -53,5 +53,5 @@ for f in ('t2d_weirs.cas',): print ("traitement de : ", 'CasEn/'+f) # on veut ouvrir un fichier directement au lancement d'Eficas - eficas_go.lanceEficas_ssIhm_reecrit(code='TELEMAC',fichier = 'CasEn/'+f,ou = 'CasEn_Reecrits',cr=True) + eficas_go.lanceQtEficas_ssIhm_reecrit(code='TELEMAC',fichier = 'CasEn/'+f,ou = 'CasEn_Reecrits',cr=True) print ("\n") diff --git a/Codes/WebTest/qtEficas_essai.py b/Codes/WebTest/qtEficas_essai.py index a4704710..3fed7197 100755 --- a/Codes/WebTest/qtEficas_essai.py +++ b/Codes/WebTest/qtEficas_essai.py @@ -32,4 +32,4 @@ sys.path.append(os.path.join(os.path.abspath(os.path.dirname(__file__)),'..','.. from Editeur import eficas_go print (prefs.code) -eficas_go.lanceEficas(code=prefs.code, GUIPath='QT5') +eficas_go.lanceQtEficas(code=prefs.code, GUIPath='QT5') diff --git a/Codes/cinqC/qtEficas5C.py b/Codes/cinqC/qtEficas5C.py index 6f739aaa..86f48543 100755 --- a/Codes/cinqC/qtEficas5C.py +++ b/Codes/cinqC/qtEficas5C.py @@ -29,4 +29,4 @@ import os, sys sys.path.append(os.path.join(os.path.abspath(os.path.dirname(__file__)),'..','..')) from Editeur import eficas_go -eficas_go.lanceEficas(code=prefs.code, GUIPath='cinqC') +eficas_go.lanceQtEficas(code=prefs.code, GUIPath='cinqC') diff --git a/Editeur/a b/Editeur/a deleted file mode 100644 index 635c5eb5..00000000 --- a/Editeur/a +++ /dev/null @@ -1,61 +0,0 @@ - def __init__(self, appliEficas, fichier=None, jdc=None, units=None, include=0): - def readFile(self, fn): - def _newJDC(self, texte = "", units=None): - def _newJDCInclude(self, units=None): - def getSource(self, file): - def __generateTempFilename(self, prefix, suffix): - def generDico(self): - def generDicoPourWeb(self, obj=None): - def generDicoPython(self): - def viewJdcSource(self): - def viewJdcPy(self): - def viewJdcRapport(self): - def viewJdcRegles(self): - def getJdcRapport(self): - def getFileName(self): - def initModif(self): - def writeFile(self, fn, txt=None, formatLigne="beautifie"): - def getTextJDC(self, format=None, pourRun=0, formatLigne="beautifie"): - def verifieChecksum(self, text): - def getChecksum(self, texte): - def getDico(self): - def chercheGroupes(self): - def chercheDico(self): - def saveFileLegerAs(self, fileName=None): - def saveFileComplet(self, fichier=None, formatLigne="beautifie"): - def saveUQFile(self, fichier=None): - def sauvePourPersalys(self, fichier=None): - def exeUQ(self, fichier=None, path=None): - def ajoutCommentaire(self): - def informe(self, titre, txt, critique=True): - def afficheInfos(self, txt, couleur=None): - def _viewText(self, txt, caption="FILE_VIEWER", largeur=1200, hauteur=600): - def saveFile(self, fichier, formatLigne="beautifie"): - def sauveLigneFile(self): - def updateJdc(self, itemApres, texte): - def updateJdcEtape(self, itemApres, texte): - def deleteEtape(self, etape): - def deleteMC(self, etape, MCFils, listeAvant=()): - def ajoutMC(self, etape, MCFils, valeurs, listeAvant=()): - def ajoutMCinMCFactUnique(self, etape, MCFils, valeurs, listeAvant=()): - def ajoutMCFact(self, etape, MCFils, listeAvant=()): - def setValeurMCSimpInEtape(self, etape, listeAvant, valeur): - def getValeur(self, nomEtape, MCFils, listeAvant=()): - def getMCDsEtape(self, etape, MCFils, listeAvant=()): - def setValeur(self, nomEtape, MCFils, valeur, listeAvant=()): - def changeIntoMC(self, etape, MCFils, valeurs, listeAvant=()): - def reCalculeValiditeMCApresChgtInto(self, nomEtape, MCFils, listeAvant=()): - def dumpXsd(self, avecEltAbstrait=False): - def dumpStructure(self): - def dumpGitStringFormat(self): - def changeDefautDefMC(self, nomEtape, listeMC, valeurs): - def changeIntoDefMC(self, etape, listeMC, valeurs, rechercheParNom=False): - def deleteDefinitionMC(self, etape, listeAvant, nomDuMC): - def ajoutDefinitionMC(self, nomEtape, listeAvant, nomDuMC, typ, **args): - def ajoutDefinitionMCFact(self, nomEtape, listeAvant, nomDuMC, listeMC, **args): - def changeIntoMCandSet(self, etape, listeMC, into, valeurs): - def ajoutVersionCataDsJDC(self, txt): - def verifieVersionCataDuJDC(self, text): - def traduitCatalogue(self, texte): - def insertInDB(self): - def dumpStringDataBase(self, nomDataBaseACreer=None): diff --git a/Editeur/configuration.py b/Editeur/configuration.py index f8d3efed..1bda98f0 100644 --- a/Editeur/configuration.py +++ b/Editeur/configuration.py @@ -51,9 +51,9 @@ class BaseConfiguration(object): if self.salome: name = "prefs_eficas_salome.ini" else: name = "prefs_eficas.ini" - if sys.platform == 'linux' : repUser = os.path.join( os.path.expanduser("~"), '.config/Eficas',self.code) - else : repUser = os.path.join('C:/','.config/Eficas',self.code) - self.fichierPrefsUtilisateur = os.path.join(repUser, name) + if sys.platform == 'linux' : self.repUser = os.path.join( os.path.expanduser("~"), '.config/Eficas',self.code) + else : self.repUser = os.path.join('C:/','.config/Eficas',self.code) + self.fichierPrefsUtilisateur = os.path.join(self.repUser, name) self.labelsStandards = ('PdfReader', 'saveDir', 'modeNouvCommande', 'afficheUQ', 'closeAutreCommande', 'closeFrameRechercheCommande', 'closeFrameRechercheCommandeSurPageDesCommandes', 'closeEntete', 'closeArbre', 'demandeLangue', 'suiteTelemac', @@ -87,6 +87,7 @@ class BaseConfiguration(object): else : self.saveDir = os.path.join('C:/','Eficas',self.code) + # ---------------------------- def setValeursParDefaut(self): # ---------------------------- @@ -142,9 +143,9 @@ class BaseConfiguration(object): # pour garder ce qui existait pour Aster self.repMat = None - # -------------------------------------- + # --------------------------------- def lectureFichierIniStandard(self): - # -------------------------------------- + # ---------------------------------- if self.salome : name = "prefs_salome_" + self.appliEficas.code else : name = "prefs_" + self.appliEficas.code diff --git a/Editeur/editor.py b/Editeur/editor.py index 0012a0f1..0d15b339 100755 --- a/Editeur/editor.py +++ b/Editeur/editor.py @@ -40,14 +40,14 @@ class Editor: def __init__(self, appliEficas, fichier=None, jdc=None, units=None, include=0): # ----------------------------------------------------------------------------# - if debug: print("dans le init de JDCEditorSsIhm") + if debug: print("dans le init de Editor") self.appliEficas = appliEficas + self.fichier = fichier self.fichierComplet = fichier - if fichier != None: - self.extensionFichier = os.path.splitext(fichier)[1] - else: - self.extensionFichier = None + if fichier != None: self.extensionFichier = os.path.splitext(fichier)[1] + else: self.extensionFichier = None + self.jdc = jdc self.first = True self.jdc_item = None @@ -56,10 +56,6 @@ class Editor: self.dict_reels = {} self.liste_simp_reel = [] - if self.appliEficas != None: - self.salome = self.appliEficas.salome - else: - self.salome = 0 # ces attributs sont mis a jour par definitCode appelee par newEditor self.code = self.appliEficas.maConfiguration.code @@ -85,35 +81,30 @@ class Editor: self.formatFichierOut = self.appliEficas.formatFichierOut self.formatFichierIn = self.appliEficas.formatFichierIn - # if self.appliEficas.maConfiguration.dumpXSD==True : self.appliEficas.dumpXsd() - self.dict_reels = {} - self.liste_simp_reel = [] - self.dicoNouveauxMC = {} - self.dicoNouveauxFact = {} - - try: - if self.maConfiguration.writerModule : + if self.maConfiguration.writerModule : + try: _module = __import__(self.maConfiguration.writermodule) info = _module.entryPoint() writer.plugins.addEntryPoint(info) - except: + except: pass - try: - if self.maConfiguration.readerModule : + if self.maConfiguration.readerModule : + try: # print self.maConfiguration.readerModule _module = __import__(self.maConfiguration.readerModule) info = _module.entryPoint() reader.plugins.addEntryPoint(info) - except: - pass + except: + pass self.mesWriters = writer - try: self.XMLWriter = writer.plugins["xml"]() - except: self.XMLWriter = None - try: self.pythonWriter = writer.plugins["python"]() - except: self.pythonWriter = None - + if "xml" in writer.plugins.keys(): + self.XMLWriter = writer.plugins["xml"]() + else : self.XMLWriter = None + if "python" in writer.plugins.keys(): + self.XMLWriter = writer.plugins["python"]() + else : self.XMLWriter = None if self.formatFichierOut in writer.plugins.keys(): self.myWriter = writer.plugins[self.formatFichierOut]() @@ -140,7 +131,7 @@ class Editor: except: #else : print("mauvaise lecture du fichier") - if self.salome: + if self.appliEficas.salome: try: self.appliEficas.addJdcInSalome(self.fichier) except: @@ -167,7 +158,7 @@ class Editor: txt_exception = None if not jdc: if self.extensionFichier == ".xml": - if self.appliEficas.maConfiguration.withXSD: + if self.appliEficas.withXSD: self.jdc.analyseXML() else: print("run MDM with -x option (MDM for XML)") @@ -194,7 +185,7 @@ class Editor: # Il faut convertir le contenu du fichier en fonction du format formatIn = self.appliEficas.formatFichierIn - if self.extensionFichier == ".xml" and self.appliEficas.maConfiguration.withXSD: + if self.extensionFichier == ".xml" and self.appliEficas.withXSD: formatIn = "xml" if formatIn in reader.plugins: # Le convertisseur existe on l'utilise @@ -235,13 +226,13 @@ class Editor: CONTEXT.unsetCurrentStep() # le jdc n est pas charge - if not (hasattr(self.readercata, "cata_ordonne_dico")): + if not (hasattr(self.readercata, "dicoCataOrdonne")): return jdc = self.readercata.cata.JdC( procedure=text, appliEficas=self.appliEficas, cata=self.readercata.cata, - cata_ord_dico=self.readercata.cata_ordonne_dico, + dicoCataOrdonne=self.readercata.dicoCataOrdonne, nom=jdcName, repMat=self.maConfiguration.repMat, ) @@ -265,7 +256,7 @@ class Editor: procedure=texte, appliEficas=self.appliEficas, cata=self.readercata.cata, - cata_ord_dico=self.readercata.cata_ordonne_dico, + dicoCataOrdonne=self.readercata.dicoCataOrdonne, repMat=self.maConfiguration.repMat, ) @@ -296,7 +287,7 @@ class Editor: procedure="", appliEficas=self.appliEficas, cata=self.readercata.cata, - cata_ord_dico=self.readercata.cata_ordonne_dico, + dicoCataOrdonne=self.readercata.dicoCataOrdonne, repMat=self.maConfiguration.repMat, ) jaux.editor = self @@ -306,7 +297,7 @@ class Editor: procedure="", appliEficas=self.appliEficas, cata=self.readercata.cata, - cata_ord_dico=self.readercata.cata_ordonne_dico, + dicoCataOrdonne=self.readercata.dicoCataOrdonne, jdc_pere=jaux, repMat=self.maConfiguration.repMat, ) @@ -1141,14 +1132,7 @@ class Editor: if nomDuMC in self.dicoNouveauxMC: del self.dicoNouveauxMC[nomDuMC] self.dicoNouveauxMC[nomDuMC] = ( - "ajoutDefinitionMC", - nomEtape, - listeAvant, - nomDuMC, - typ, - args, - ) - # print self.dicoNouveauxMC + "ajoutDefinitionMC", nomEtape, listeAvant, nomDuMC, typ, args,) # ---------------------------------------------------------------------# def ajoutDefinitionMCFact(self, nomEtape, listeAvant, nomDuMC, listeMC, **args): diff --git a/Editeur/editor_manager.py b/Editeur/editor_manager.py new file mode 100644 index 00000000..ad4d4ab7 --- /dev/null +++ b/Editeur/editor_manager.py @@ -0,0 +1,162 @@ +# -*- coding: utf-8 -*- +# Copyright (C) 2007-2024 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 + +# -------------------------- +class EditorManager(object): +# -------------------------- + """ + classe mere des managers d editeur pour Qt et le web + permettent de gerer plusieurs ouvertures de fichiers simultannees en IHM + utilisee sans etre derivee pour le dumpXSD ou les transformations + """ + counter = 0 + # remplace par l index du viewManager + + # -------------------------------- + def __init__(self, appliEficas): + # -------------------------------- + self.appliEficas = appliEficas + self.mesIndexes = {} + self.dictEditors = {} + self.editors = [] + self.doubles = {} + + + # ---------------------------------------------------------------- + def getEditor(self, fichier=None, jdc=None, units=None, include=0): + # ---------------------------------------------------------------- + """ + Retourne un nouvel editeur ou None si doublon + """ + + if fichier == None : + self.appliEficas.afficheMessage('Eficas sans Ihm', + 'nom de fichier obligatoire pour obtenir un editor') + return None + for indexEditor in self.dictEditors: + editor = self.dictEditors[indexEditor] + if self.samePath(fichier, editor.getFileName()): + self.appliEficas.afficheMessage('Eficas sans Ihm', 'Fichier deja ouvert') + return None + from Editeur.editor import Editor + editor = Editor(self.appliEficas, fichier, jdc, units, include) + if not editor.jdc : + self.appliEficas.afficheMessage('Eficas sans Ihm', 'impossible d allouer un editor') + return None + self.editors.append(editor) + self.dictEditors[EditorManager.counter] = editor + EditorManager.counter += 1 + return editor + + # ------------------------- + def samePath(self, f1, f2): + # -------------------------- + """ + compare two paths. + """ + if f1 is None or f2 is None: return 0 + if os.path.normcase(os.path.normpath(f1)) == os.path.normcase( os.path.normpath(f2)): + return 1 + return 0 + + #------------------------------- + def indexChanged(self, newIndex): + #-------------------------------- + if newIndex in self.dictEditors: + editor = self.dictEditors[newIndex] + if editor.jdc != None: + CONTEXT.unsetCurrentJdC() + CONTEXT.setCurrentJdC(editor.jdc) + self.appliEficas.maConfiguration = editor.maConfiguration + self.appliEficas.code = editor.maConfiguration.code + self.appliEficas.setWindowTitle(editor.titre) + self.appliEficas.construitMenu() + return 1 + else : + return 0 + + + # ----------------------------- + def getFileName(self, index): + # ------------------------------- + if not (index in self.dictEditors): + # print("editor non trouve") + return + return self.dictEditors[index].getFileName() + + + # --------------------------------------------- + def handleGetJdcRapport(self, index): + # --------------------------------------------- + if not (index in self.dictEditors): + # print("editor non trouve") + return + return self.dictEditors[index].getJdcRapport() + + # --------------------------------------------- + def handleViewJdcRapport(self, index): + # --------------------------------------------- + # print(index) + if not (index in self.dictEditors): + # print("editor non trouve") + return + self.dictEditors[index].viewJdcRapport() + + # --------------------------------------------- + def generDico(self, index): + # --------------------------------------------- + # print(index) + if not (index in self.dictEditors): + # print("editor non trouve") + return + return self.dictEditors[index].generDico() + + # --------------------------------------------- + def isJdcValid(self, index): + # --------------------------------------------- + # print(index) + if not (index in self.dictEditors): + # print("editor non trouve") + return + return self.dictEditors[index].jdc.isValid() + + # --------------------------------------------- + def fileSaveAs(self, index, fileName): + # --------------------------------------------- + # print(index) + if not (index in self.dictEditors): + # print("editor non trouve") + return + return self.dictEditors[index].saveFile(fileName) + + # --------------------------------------------- + def fileLegerSaveAs(self, index, fileName): + # --------------------------------------------- + # print (index) + if not (index in self.dictEditors): + # print("editor non trouve") + return + self.dictEditors[index].saveFileLegerAs(fileName) + + + + diff --git a/Editeur/eficas_appli.py b/Editeur/eficas_appli.py index ed723de3..41bd147a 100755 --- a/Editeur/eficas_appli.py +++ b/Editeur/eficas_appli.py @@ -20,7 +20,6 @@ import os, sys from Accas.extensions.eficas_exception import EficasException -from Editeur.viewManagerSsIhm import MyViewManagerSsIhm from Editeur import session from Editeur.getVersion import getEficasVersion @@ -30,51 +29,49 @@ class EficasAppli: Class implementing the main user interface. """ - def __init__( self, code=None, salome=1, parent=None, multi=False, langue="fr", - ssIhm=True, labelCode=None, genereXSD=False, versionCode=None, ssCode=None, fichierCata=None, - GUIPath=None, - ): + def __init__(self, code=None, versionCode=None, salome=1, multi=False, langue="fr", ssCode=None, fichierCata=None, GUIPath=None): + #-------------------------------------------------------------------------------------------------------------------------------- """ - Constructor + Constructor d appli eficas. classe mere de appli-qtEficas et de appli-web eficas et utilisee sans IHM pour les + transformations des catas en XSD, des comm en XML et de validation des donnees + les parametres sont : + nom du code (exple Adao) + versionCode (version du code permet de retrouver le catalogue dans le fichier prefs : exple V10-4) + salome : lance ou non a partir de salome + multi (permet de ne pas specifier le code mais de le demander ) + langue des messages + ssCode (utilise pour MAP permet de distinguer un patron specifique, un catalogue specifique...) + fichier catalogue utilise """ - version = getEficasVersion() - self.versionEficas = "Eficas QT5 Salome " + version - self.labelCode = labelCode - self.GUIPath = None - - self.salome = salome - self.ssIhm = True self.code = code - self.genereXSD = genereXSD - self.versionCode = versionCode self.ssCode = ssCode + self.multi = multi + self.salome = salome + version = getEficasVersion() + self.versionEficas = "Eficas Salome " + version + self.GUIPath = GUIPath self.dict_reels = {} self.fichierIn = None self.fichierOut = None - self.recent = [] self.ficRecents = {} self.mesScripts = {} self.listePathAEnlever = [] - self.repIcon = os.path.join( os.path.dirname(os.path.abspath(__file__)), "..", "Editeur", "icons") if fichierCata == None: self.fichierCata = session.d_env.fichierCata else: self.fichierCata = fichierCata - if session.d_env.labelCode: self.labelCode = session.d_env.labelCode - self.withXSD = session.d_env.withXSD + self.versionCode = versionCode + if session.d_env.versionCode: self.versionCode = session.d_env.versionCode if self.salome: try: from Accas import eficasSalome Accas.SalomeEntry = eficasSalome.SalomeEntry - except: - print("eficas hors salome") - - self.multi = multi - # on peut avoir multi et sans Ihm si on est en Web - # if self.multi: print("pas de multi sans ihm") + except e: + print ("impossible d importer les salome entry") + print (str(e)) if langue == "fr": self.langue = langue else: self.langue = "ang" @@ -88,19 +85,22 @@ class EficasAppli: self.maConfiguration = BaseConfiguration(self) self.suiteTelemac = False - self.viewmanager = MyViewManagerSsIhm(self) self.withUQ = False + self.genereXSD = False + from Editeur.editor_manager import EditorManager + self.editorManager = EditorManager(self) def ajoutUQ(self): + #----------------- self.withUQ = True self.formatFichierIn = "pythonUQ" # par defaut def definitCode(self, code, ssCode): + #----------------------------------- # ssCode sert pour Map self.code = code self.ssCode = ssCode - if self.code == None: - return # pour le cancel de la fenetre choix code + if self.code == None: return if ssCode != None: self.formatFichierOut = ssCode # par defaut @@ -109,6 +109,7 @@ class EficasAppli: self.formatFichierIn = "python" # par defaut self.formatFichierOut = "python" # par defaut + self.listePathAEnlever = [] from Editeur.configuration import BaseConfiguration self.maConfiguration = BaseConfiguration(self) @@ -117,10 +118,12 @@ class EficasAppli: localisation.localise( None, self.langue, translatorFile=self.maConfiguration.translatorFile, ) - if self.withXSD: - self.maConfiguration.withXSD = True + + # Comment faire si Multi ? + self.withXSD = session.d_env.withXSD def getSource(self, file): + #------------------------- # appele par Editeur/session.py import Accas.IO.reader @@ -130,47 +133,55 @@ class EficasAppli: return texte def initEditor(self, fichier=None, jdc=None, units=None, include=0): + #------------------------------------------------------------------ if (hasattr(self, "editor")) and self.editor != None: - print("un seul editeur par application") + print("un seul editeur par application eficas_appli ") sys.exit() - self.editor = self.viewmanager.getNewEditor() + self.editor = self.editorManager.getNewEditor() def fileNew(self): + #----------------- self.editor = self.initEditor() def getEditor(self): + #------------------- if (hasattr(self, "editor")) and self.editor != None: return self.editor self.initEditor() return self.editor def fileOpen(self, fichier): + #--------------------------- fichierIn = os.path.abspath(fichier) try: - monEditor = self.viewmanager.handleOpen(fichierIn) + monEditor = self.editorManager.handleOpen(fichierIn) except EficasException as exc: print("poum") monEditor = None return monEditor def fileSave(self): + #------------------- if self.editor == None: return False ok, newName = editor.saveFileAs() print("ok, newName ", ok, newName) def fileSaveAs(self, fileName): + #-----------------_------------ if self.editor == None: return False ok = editor.saveFileAs() print("ok ", ok) def dumpXsd(self, avecEltAbstrait=False): + #----------------------------------------- currentCata = CONTEXT.getCurrentCata() texteXSD = currentCata.dumpXsd(avecEltAbstrait) return texteXSD def afficheMessage(self, titre, texte,critical=True): + #----------------------------------------------------- print ('__________________________') print (tr(titre)) print ('') @@ -178,15 +189,6 @@ class EficasAppli: print ('__________________________') -# ,self.fileSaveAs -# ,self.fileClose -# ,self.fileExit -# ,self.jdcRapport -# ,self.jdcRegles -# ,self.jdcFichierSource -# ,self.visuJdcPy - - if __name__ == "__main__": # Modules Eficas - monEficas = AppliSsIhm(code="Adao", salome=0, labelCode="V83") + pass diff --git a/Editeur/eficas_go.py b/Editeur/eficas_go.py index aeb084af..2e141905 100755 --- a/Editeur/eficas_go.py +++ b/Editeur/eficas_go.py @@ -28,8 +28,8 @@ if sys.version_info[0] < 3: sys.exit() -def lanceEficas(code=None, multi=False, langue="en", labelCode=None, GUIPath='QT5', salome=0): -# ------------------------------------------------------------------------------------------- +def lanceQtEficas(code=None, versionCode = None, multi=False, langue="en", GUIPath='QT5', salome=0): +# --------------------------------------------------------------------------------------------------- """ Lance l'appli EFICAS avec Ihm QT """ @@ -39,27 +39,31 @@ def lanceEficas(code=None, multi=False, langue="en", labelCode=None, GUIPath='QT print("Please, set qt environment") return + if not GUIPath in ('QT5','cinqC') : + print ('Attention, lancement de Eficas pour QT avec GUIPath = {}'.format(GUIPath)) + from Editeur import session options = session.parse(sys.argv) if options.code != None: code = options.code + if options.versionCode != None: + versionCode = options.versionCode - if GUIPath == 'QT5' or GUIPath == 'cinqC' : - pathAbso=os.path.abspath(os.path.join(os.path.dirname(__file__),'..','InterfaceGUI',GUIPath)) - if pathAbso not in sys.path : sys.path.insert(0,pathAbso) + pathAbso=os.path.abspath(os.path.join(os.path.dirname(__file__),'..','InterfaceGUI',GUIPath)) + if pathAbso not in sys.path : sys.path.insert(0,pathAbso) from qt_eficas import QtEficasAppli app = QApplication(sys.argv) - Eficas = QtEficasAppli(code=code, salome=salome, multi=multi, langue=langue, labelCode=labelCode, GUIPath=GUIPath) + Eficas = QtEficasAppli(code=code, versionCode = versionCode, salome=salome, multi=multi, langue=langue, GUIPath=GUIPath) + Eficas.show() res = app.exec_() sys.exit(res) -def getEficas( code=None, multi=False, langue="en", ssCode=None, labelCode=None, - forceXML=False, genereXSD=False, fichierCata=None,GUIPath=None, salome = False): -# ----------------------------------------------------------------------------------- +def getEficas( code=None, multi=False, langue="en", forceXML=False, fichierCata=None,GUIPath=None): +# ------------------------------------------------------------------------------------------------------------------ """ instancie l'appli EFICAS sans Ihm """ @@ -70,20 +74,25 @@ def getEficas( code=None, multi=False, langue="en", ssCode=None, labelCode=None, code = options.code if forceXML: options.withXSD = True - if GUIPath in ('QT5', 'cinqC', 'Web') : + if GUIPath in ('QT5', 'cinqC') : pathAbso=os.path.abspath(os.path.join(os.path.dirname(__file__),'..','InterfaceGUI',GUIPath)) if pathAbso not in sys.path : sys.path.insert(0,pathAbso) + from qt_eficas import QtEficasAppli as EficasAppli + if GUIPath in ( 'Web') : + pathAbso=os.path.abspath(os.path.join(os.path.dirname(__file__),'..','InterfaceGUI',GUIPath)) + if pathAbso not in sys.path : sys.path.insert(0,pathAbso) + from web_eficas import WebEficasAppli as EficasAppli + else : + print ('lancement de Eficas avec GUIPath = {}'.format(GUIPath)) + from Editeur.eficas_appli import EficasAppli - from Editeur.eficas_appli import EficasAppli - Eficas = EficasAppli( code=code, salome=salome, multi=multi, langue=langue, - ssCode=ssCode, labelCode=labelCode, genereXSD=genereXSD, fichierCata=fichierCata) + Eficas = EficasAppli(code=code, multi=multi, langue=langue, ssCode=ssCode, versionCode=versionCode, fichierCata=fichierCata, GUIPath=GUIPath) return Eficas def genereXSD(code=None): # ----------------------- from Editeur import session - options = session.parse(sys.argv) if code != None: options.code = code @@ -91,7 +100,8 @@ def genereXSD(code=None): print("Use -c cata_name.py") return - monEficas = getEficas(code=options.code, genereXSD=True) + monEficas = getEficas(code=options.code) + monEficas.genereXSD = True monEditor = monEficas.getEditor() texteXSD = monEditor.dumpXsd(avecEltAbstrait=options.avecEltAbstrait) diff --git a/Editeur/session.py b/Editeur/session.py index 70462058..48a44ec8 100644 --- a/Editeur/session.py +++ b/Editeur/session.py @@ -20,41 +20,28 @@ """ Ce module centralise les informations issues de la ligne de commande. -La ligne de commande est parsee avec l'aide du module python optparse. -Les options possibles sont : -l, -j, -p, -d, -i, -f comme definies ci-dessous. - -Un exemple typique d'utilisation est : ->>> ./appli.py -v V7.3 -d 1 -j aa -i 11 iii -p ppp -i 22 ii -j bb -f ff - -qui demande a l'application d'ouvrir trois jeux de commandes. - -Le premier (aa) a un include (11,iii) et est la suite du fichier poursuite ppp -qui a lui meme un include (22,ii). - -Le deuxieme bb est un jeu de commandes simple. - -Le troisieme est decrit dans le fichier ff de type .ini -qui est parse par le module Configparser. -Chaque section du fichier decrit un jeu de commandes. -Un include est specifie par: numero logique=nom du fichier -Une poursuite est specifiee par: poursuite=reference a un jeu de commande -Cette reference correspond a un nom de section decrivant le jeu de commandes. -Le jeu de commandes maitre est donne par l'entree globale jdc dans la section jdc. - -Exemple: -[jdc] -jdc=a -[a] -comm=aa -poursuite=pours -11=iii -[pours] -comm=ppp -22=ii - -La session utilisera le catalogue V7.3 en mode debug. """ +#Version Obsolete pour Aster mais qui explique l utilisation de poursuite et include +#La ligne de commande est parsee avec l'aide du module python optparse. +#Les options possibles sont : -l, -j, -p, -d, -i, -f comme definies ci-dessous. +# +#Un exemple typique d'utilisation est : +#>>> ./appli.py -v V7.3 -d 1 -j aa -i 11 iii -p ppp -i 22 ii -j bb -f ff +#qui demande a l'application d'ouvrir trois jeux de commandes. +#Le premier (aa) a un include (11,iii) et est la suite du fichier poursuite ppp +#qui a lui meme un include (22,ii). +# +#Le deuxieme bb est un jeu de commandes simple. +#Le troisieme est decrit dans le fichier ff de type .ini +#qui est parse par le module Configparser. +#Chaque section du fichier decrit un jeu de commandes. +#Un include est specifie par: numero logique=nom du fichier +#Une poursuite est specifiee par: poursuite=reference a un jeu de commande +#Cette reference correspond a un nom de section decrivant le jeu de commandes. +#Le jeu de commandes maitre est donne par l'entree globale jdc dans la section jdc. + + from builtins import str import optparse @@ -341,7 +328,7 @@ def createparser(): "--label", action="store", type="string", - dest="labelCode", + dest="versionCode", help=tr("version de catalogue a utiliser"), ) @@ -404,8 +391,8 @@ def parse(args): options.comm = [] if not hasattr(options, "fichierCata"): options.fichierCata = None - if not hasattr(options, "labelCode"): - options.labelCode = None + if not hasattr(options, "versionCode"): + options.versionCode = None if not hasattr(options, "fichierXMLOut"): options.fichierXMLOut = None if options.withXSD: diff --git a/Editeur/viewManagerSsIhm.py b/Editeur/viewManagerSsIhm.py deleted file mode 100644 index 7cfab02c..00000000 --- a/Editeur/viewManagerSsIhm.py +++ /dev/null @@ -1,245 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright (C) 2007-2024 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 - -# -------------------------------- -class MyViewManagerSsIhm(object): - # -------------------------------- - # Symetrique de ViewManager mais pas d heritage entre les 2 - # beaucoup de fonctions sont pretes mesi pas ou peu usitees - # developpement pas termine - - # -------------------------------- - def __init__(self, appliEficas): - # -------------------------------- - self.appliEficas = appliEficas - self.tabWidgets = [] - self.mesIndexes = {} - self.dictEditors = {} - self.untitledCount = 0 - self.doubles = {} - - # ------------------------------------------------------ - def handleOpen(self, fichier=None, units=None): - # ------------------------------------------------------ - result = None - if fichier is None: - # print("nom de fichier obligatoire") - return None - - for handler in self.dictEditors: - editor = self.dictEditors[handler] - if self.samePath(fichier, editor.getFileName()): - # print("fichier deja ouvert . pas de nouvel editor") - return handler - - monNewHandler = self.getNewHandler(fichier, units) - return monNewHandler - - # ---------------------------------------------------------------------- - def getNewHandler(self, fichier=None, jdc=None, units=None, include=0): - # ---------------------------------------------------------------------- - # il faudrait decider entre e handler ou non - # le cas d usage n est pas tout a fait identique : - # avec handler pour les utilisateurs avance - # sans pour les utilisateurs encore plus ancvances et les tests - - from editorSsIhm import JDCEditorSsIhm - - editor = JDCEditorSsIhm( - self.appliEficas, fichier, jdc, units=units, include=include - ) - - if editor.jdc: # le fichier est bien un jdc - monHandler = JdcSsIhmHandler(self) - self.dictEditors[monHandler] = editor - return monHandler - else: - # print("impossible de construire le jdc") - return None - - # ------------------------------------------------------------------- - def getNewEditor(self, fichier=None, jdc=None, units=None, include=0): - # ------------------------------------------------------------------------ - - from editorSsIhm import JDCEditorSsIhm - editor = JDCEditorSsIhm( - self.appliEficas, fichier, jdc, units=units, include=include - ) - self.editor = editor - return editor - - # ----------------------------- - def samePath(self, f1, f2): - # ------------------------------ - """ - compare two paths. - """ - if f1 is None or f2 is None: - return 0 - if os.path.normcase(os.path.normpath(f1)) == os.path.normcase( - os.path.normpath(f2) - ): - return 1 - return 0 - - # --------------------------------- - def handleViewJdcPy(self, handler): - # --------------------------------- - if not (handler in self.dictEditors): - # print("editor non trouve") - return - self.dictEditors[handler].viewJdcPy() - - # --------------------------------- - def getFileName(self, handler): - # --------------------------------- - if not (handler in self.dictEditors): - # print("editor non trouve") - return - return self.dictEditors[handler].getFileName() - - # --------------------------------------------- - def handleViewJdcSource(self, handler): - # --------------------------------------------- - # print(handler) - if not (handler in self.dictEditors): - # print("editor non trouve") - return - self.dictEditors[handler].viewJdcSource() - - # --------------------------------------------- - def handleViewJdcRapport(self, handler): - # --------------------------------------------- - # print(handler) - if not (handler in self.dictEditors): - # print("editor non trouve") - return - self.dictEditors[handler].viewJdcRapport() - - # --------------------------------------------- - def handleGetJdcRapport(self, handler): - # --------------------------------------------- - if not (handler in self.dictEditors): - # print("editor non trouve") - return - return self.dictEditors[handler].getJdcRapport() - - # --------------------------------------------- - def handleViewJdcRapport(self, handler): - # --------------------------------------------- - # print(handler) - if not (handler in self.dictEditors): - # print("editor non trouve") - return - self.dictEditors[handler].viewJdcRapport() - - # --------------------------------------------- - def generDico(self, handler): - # --------------------------------------------- - # print(handler) - if not (handler in self.dictEditors): - # print("editor non trouve") - return - return self.dictEditors[handler].generDico() - - # --------------------------------------------- - def isJdcValid(self, handler): - # --------------------------------------------- - # print(handler) - if not (handler in self.dictEditors): - # print("editor non trouve") - return - return self.dictEditors[handler].jdc.isValid() - - # --------------------------------------------- - def fileSaveAs(self, handler, fileName): - # --------------------------------------------- - # print(handler) - if not (handler in self.dictEditors): - # print("editor non trouve") - return - return self.dictEditors[handler].saveFile(fileName) - - # --------------------------------------------- - def fileLegerSaveAs(self, handler, fileName): - # --------------------------------------------- - # print (handler) - if not (handler in self.dictEditors): - # print("editor non trouve") - return - self.dictEditors[handler].saveFileLegerAs(fileName) - -# -------------------------------- -class JdcSsIhmHandler(object): -# ------------------------------ - # retourne a l utilisateur - - def __init__(self, viewManager): - # -------------------------------------- - self.viewManagerSsIhm = viewManager - - def viewJdcPy(self): - # --------------------- - self.viewManagerSsIhm.handleViewJdcPy(self) - - def viewJdcSource(self): - # --------------------- - self.viewManagerSsIhm.handleViewJdcSource(self) - - def getFileName(self): - # --------------------- - self.viewManagerSsIhm.getFileName(self) - - def viewJdcRapport(self): - # --------------------- - self.viewManagerSsIhm.handleViewJdcRapport(self) - - def getJdcRapport(self): - # --------------------- - return self.viewManagerSsIhm.handleGetJdcRapport(self) - - def getDicoPython(self): - # ------------------------- - return self.viewManagerSsIhm.generDico(self) - - def isJdcValid(self): - # ------------------------- - return self.viewManagerSsIhm.isJdcValid(self) - - def fileSaveAs(self, fileName): - # ------------------------- - return self.viewManagerSsIhm.fileSaveAs(self, fileName) - - def fileLegerSaveAs(self, fileName): - # ----------------------------------- - return self.viewManagerSsIhm.fileLegerSaveAs(self, fileName) - - def handleSortieUQ(self, fileName): - # ----------------------------------- - return self.viewManagerSsIhm.handleSortieUQ(self, fileName) - - def handleExeUQ(self, fileName): - # ----------------------------------- - # est-ce que cela a un sens de faire l exe hors IHM ? - return self.viewManagerSsIhm.handleExeUQ(self, fileName) - - diff --git a/InterfaceGUI/QT5/composimp.py b/InterfaceGUI/QT5/composimp.py index 29a78314..56959be8 100644 --- a/InterfaceGUI/QT5/composimp.py +++ b/InterfaceGUI/QT5/composimp.py @@ -152,7 +152,7 @@ class NodeCommun: else: from InterfaceGUI.QT5.monWidgetCB import MonWidgetCBSD widget = MonWidgetCBSD( self, maDefinition, monNom, monObjet, parentQt, maCommande) - elif self.item.waitSalome() and self.editor.salome: + elif self.item.waitSalome() and self.editor.appliEficas.salome: from InterfaceGUI.QT5.monWidgetSimpSalome import MonWidgetSimpSalome widget = MonWidgetSimpSalome( self, maDefinition, monNom, monObjet, parentQt, maCommande) elif self.item.waitTxm(): @@ -185,7 +185,7 @@ class NodeCommun: listeAAfficher = self.item.getSdAvantDuBonType() # a changer selon UserASSD ou UserASSDMultiple mctype = maDefinition.type[0] - enable_salome_selection = self.editor.salome and ( + enable_salome_selection = self.editor.appliEficas.salome and ( ("grma" in repr(mctype)) or ("grno" in repr(mctype)) or ("SalomeEntry" in repr(mctype)) diff --git a/InterfaceGUI/QT5/gereIcones.py b/InterfaceGUI/QT5/gereIcones.py index 6dbcb0f7..77d7e142 100644 --- a/InterfaceGUI/QT5/gereIcones.py +++ b/InterfaceGUI/QT5/gereIcones.py @@ -39,21 +39,22 @@ class FacultatifOuOptionnel(object): """ Gere les boutons """ def setReglesEtAide(self): listeRegles = () - try: - listeRegles = self.node.item.getRegles() + # PN fevrier 24 pourquoi ce try ? + # FACT multiple ? + try: listeRegles = self.node.item.getRegles() except: + print ('FacultatifOuOptionnel, dans le except pour', self.node.item.nom) pass if hasattr(self, "RBRegle"): - if listeRegles == (): - self.RBRegle.close() + if listeRegles == (): self.RBRegle.close() else: - icon3 = QIcon(self.repIcon + "/lettreRblanc30.png") - self.RBRegle.setIcon(icon3) + icon = QIcon(self.repIcon + "/lettreRblanc30.png") + self.RBRegle.setIcon(icon) self.RBRegle.clicked.connect(self.viewRegles) cle_doc = None - if not hasattr(self, "RBInfo"): - return + + if not hasattr(self, "RBInfo"): return icon = QIcon(self.repIcon + "/point-interrogation30.png") self.RBInfo.setIcon(icon) @@ -122,15 +123,8 @@ class FacultatifOuOptionnel(object): mc = self.node.item.get_definition() mctype = mc.type[0] - enable_salome_selection = self.editor.salome and ( - ("grma" in repr(mctype)) - or ("grno" in repr(mctype)) - or ("SalomeEntry" in repr(mctype)) - or ( - hasattr(mctype, "enable_salome_selection") - and mctype.enable_salome_selection - ) - ) + enable_salome_selection = "grma" in repr(mctype) or "grno" in repr(mctype) or "SalomeEntry" in repr(mctype) + # or (hasattr(mctype, "enable_salome_selection" and mctype.enable_salome_selection)) if enable_salome_selection: icon = QIcon(self.repIcon + "/flecheSalome.png") diff --git a/InterfaceGUI/QT5/groupe.py b/InterfaceGUI/QT5/groupe.py index 6067c0d6..c04f30e6 100644 --- a/InterfaceGUI/QT5/groupe.py +++ b/InterfaceGUI/QT5/groupe.py @@ -99,7 +99,7 @@ class Groupe(QWidget, FacultatifOuOptionnel): try: # if 1 : self.listeMc = self.obj.getListeMcOrdonnee( - genea, self.jdc.cata_ordonne_dico + genea, self.jdc.dicoCataOrdonne ) listeNomsPresents = self.obj.dictMcPresents() for regle in self.obj.getRegles(): diff --git a/InterfaceGUI/QT5/qt_editor.py b/InterfaceGUI/QT5/qt_editor.py index 098bb052..9b959122 100755 --- a/InterfaceGUI/QT5/qt_editor.py +++ b/InterfaceGUI/QT5/qt_editor.py @@ -47,7 +47,7 @@ from Editeur.editor import Editor class QtEditor(Editor, Ui_baseWidget, QWidget): -# ----------------------------------------------------- # +# -------------------------------------------- # """ Editeur de jdc """ @@ -104,7 +104,7 @@ class QtEditor(Editor, Ui_baseWidget, QWidget): # ou se trouve le fichier de traduction si demandeCatalogue if self.appliEficas.readercata.demandeCatalogue == True: nomFichierTranslation = ( - "translatorFile" + "_" + str(self.appliEficas.readercata.labelCode) + "translatorFile" + "_" + str(self.appliEficas.readercata.versionCode) ) if hasattr(self.appliEficas.maConfiguration, nomFichierTranslation): translatorFile = getattr( @@ -115,10 +115,8 @@ class QtEditor(Editor, Ui_baseWidget, QWidget): None, self.appliEficas.langue, translatorFile=translatorFile ) - if self.jdc_item and self.appliEficas.ssIhm == False: - self.tree = browser.JDCTree(self.jdc_item, self) self.appliEficas.construitMenu() - + if self.jdc_item : self.tree = browser.JDCTree(self.jdc_item, self) self.adjustSize() # --------------------# @@ -232,7 +230,7 @@ class QtEditor(Editor, Ui_baseWidget, QWidget): def closeIt(self): # ----------------# """ - Public method called by the viewmanager to finally get rid of us. + Public method called by the editorManager to finally get rid of us. """ if self.jdc: self.jdc.supprime() @@ -755,7 +753,7 @@ class QtEditor(Editor, Ui_baseWidget, QWidget): appliEficas=self.appliEficas, ) - if self.salome: + if self.appliEficas.salome: self.appliEficas.addJdcInSalome(self.fichierComplet) self.modified = 0 @@ -843,7 +841,7 @@ class QtEditor(Editor, Ui_baseWidget, QWidget): else: sys.exit(1) - if self.salome: + if self.appliEficas.salome: self.appliEficas.addJdcInSalome(self.fichier) self.modified = 0 nouveauTitre = ( @@ -923,7 +921,7 @@ class QtEditor(Editor, Ui_baseWidget, QWidget): ret, fichier = Editor.saveUQFile(self, fn) if ret: self.fichier = fichier - if self.salome and ret: + if self.appliEficas.salome and ret: self.appliEficas.addJdcInSalome(self.fichier) return (1, self.fichier) if self.appliEficas.salome: diff --git a/InterfaceGUI/QT5/qt_editor_manager.py b/InterfaceGUI/QT5/qt_editor_manager.py new file mode 100644 index 00000000..0a095cd6 --- /dev/null +++ b/InterfaceGUI/QT5/qt_editor_manager.py @@ -0,0 +1,512 @@ +# -*- coding: utf-8 -*- +# Copyright (C) 2007-2024 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 +from Accas.extensions.eficas_translation import tr +from Editeur.editor_manager import EditorManager +from PyQt5.QtWidgets import QFileDialog, QMessageBox +from PyQt5.QtCore import QFileInfo + +Dictextensions = {"MAP": ".map", "TELEMAC" :".cas"} + +#-----------------------------------# +class QtEditorManager(EditorManager): +#-----------------------------------# + """ + classe qui gere la QTtab de la fenetre Eficas + c'est a dire la gestion des differents onglets de la mainWindow + gere egalement l ouverture d un fichier via le menu ( c est l equivalent + l ouverture d un onglet + """ + + #-------------------------------- + def __init__(self, appliEficas): + #-------------------------------- + super().__init__(appliEficas) + self.tabWidgets = [] + self.untitledCount = 0 + self.myQtab = self.appliEficas.myQtab + self.myQtab.currentChanged.connect(self.indexChanged) + self.myQtab.tabCloseRequested.connect(self.closeTab) + + #---------------------- + def indexChanged(self): + #---------------------- + index = self.myQtab.currentIndex() + EditorManager.indexChanged(self,index) + + #---------------------------------------------- + def handleOpen(self, fichier=None, units=None): + #---------------------------------------------- + result = None + if self.appliEficas.code == None: + self.appliEficas.definitCode(None, None) + if self.appliEficas.code == None: return + + if fichier is None: + if self.appliEficas.code in Dictextensions: + chaine = "JDC (*" + Dictextensions[self.appliEficas.code] + ");;" + extensions = tr(chaine + "All Files (*)") + else: + extensions = tr("Fichiers JDC (*.comm);;" "Tous les Fichiers (*)") + + fichier = QFileDialog.getOpenFileName( + self.appliEficas, + tr("Ouvrir Fichier"), + self.appliEficas.maConfiguration.saveDir, + extensions,) + fichier = fichier[0] + + if len(fichier) == 0: return None + + fichier = os.path.abspath(fichier) + ulfile = os.path.abspath(fichier) + self.appliEficas.maConfiguration.saveDir = os.path.split(ulfile)[0] + self.appliEficas.addToRecentList(fichier) + maPage = self.getEditor(fichier, units=units) + if maPage: result = maPage + if maPage: self.myQtab.setTabText( + self.myQtab.indexOf(maPage), os.path.basename(fichier)) + return result + + #-------------------------------- + def closeTab(self, indexAFermer): + #-------------------------------- + self.handleClose(indexAFermer=indexAFermer) + + #-------------------------------------------------------- + def handleClose(self, index = None, texte=tr("&Quitter")): + #-------------------------------------------------------- + self.appliEficas.sauveRecents() + if not index : index = self.myQtab.currentIndex() + if index < 0: return + + res = self.checkDirty(self.dictEditors[index], texte) + if res == 2: return 2 # l utilisateur a annule + idx = index + while idx < len(self.dictEditors) - 1: + self.dictEditors[idx] = self.dictEditors[idx + 1] + idx = idx + 1 + del self.dictEditors[len(self.dictEditors) - 1] + try: + del self.doubles[self.dictEditors[index]] + except: + pass + self.myQtab.removeTab(index) + return res + + #------------- + def run(self): + #------------- + index = self.myQtab.currentIndex() + if index < 0: return + editor = self.dictEditors[index] + editor.run() + + #----------------- + def saveRun(self): + #------------------ + index = self.myQtab.currentIndex() + if index < 0: return + editor = self.dictEditors[index] + editor.saveRun() + + #--------------------------------------------- + def handleCloseAll(self, texte=tr("Quitter")): + #--------------------------------------------- + res = 0 + self.appliEficas.sauveRecents() + while len(self.dictEditors) > 0: + self.myQtab.setCurrentIndex(0) + res = self.handleClose(0, texte) + if res == 2: return res # l utilsateur a annule + return res + + #-------------------------- + def handleRechercher(self): + #-------------------------- + # print "passage dans handleRechercher" + index = self.myQtab.currentIndex() + if index < 0: return + editor = self.dictEditors[index] + editor.handleRechercher() + + #------------------------------------- + def handleRechercherDsCatalogue(self): + #------------------------------------- + # print "passage dans handleRechercher" + index = self.myQtab.currentIndex() + if index < 0: + return + editor = self.dictEditors[index] + editor.handleRechercherDsCatalogue() + + #----------------------- + def handleDeplier(self): + #----------------------- + index = self.myQtab.currentIndex() + if index < 0: return + editor = self.dictEditors[index] + editor.handleDeplier() + + #------------------------ + def handleEditCopy(self): + #------------------------ + # print "passage dans handleEditCopy" + index = self.myQtab.currentIndex() + if index < 0: return + editor = self.dictEditors[index] + editor.handleEditCopy() + + #----------------------- + def handleEditCut(self): + #----------------------- + # print "passage dans handleEditCut" + index = self.myQtab.currentIndex() + if index < 0: return + editor = self.dictEditors[index] + editor.handleEditCut() + + #----------------------- + def handleEditPaste(self): + #------------------------- + # print "passage dans handleEditPaste" + index = self.myQtab.currentIndex() + if index < 0: + return + editor = self.dictEditors[index] + editor.handleEditPaste() + + #-------------------------- + def handleSupprimer(self): + #------------------------- + index = self.myQtab.currentIndex() + if index < 0: return + editor = self.dictEditors[index] + editor.handleSupprimer() + + #------------------------------------ + def handleAjoutEtape(self, nomEtape): + #------------------------------------ + index = self.myQtab.currentIndex() + if index < 0: return + editor = self.dictEditors[index] + editor.handleAjoutEtape(nomEtape) + + #------------------------------ + def newEditor(self, include=0): + #------------------------------ + if self.appliEficas.multi == True: + self.appliEficas.definitCode(None, None) + if self.appliEficas.code == None: + return + maPage = self.getEditor(include=include) + + #-------------------------- + def newIncludeEditor(self): + #-------------------------- + self.newEditor(include=1) + + #------------------------------------ + def handleViewJdcFichierSource(self): + #------------------------------------ + index = self.myQtab.currentIndex() + if index < 0: + return + self.dictEditors[index].viewJdcSource() + + #-------------------- + def ouvreArbre(self): + #-------------------- + index = self.myQtab.currentIndex() + if index < 0: return + self.dictEditors[index].ouvreArbre() + + #-------------------- + def fermeArbre(self): + #-------------------- + index = self.myQtab.currentIndex() + if index < 0: return + self.dictEditors[index].fermeArbre() + + #-------------------------- + def ajoutCommentaire(self): + #-------------------------- + index = self.myQtab.currentIndex() + if index < 0: return + editor = self.dictEditors[index] + editor.ajoutCommentaire() + + #----------------------------- + def handleViewJdcRegles(self): + #----------------------------- + index = self.myQtab.currentIndex() + if index < 0: return + self.dictEditors[index].viewJdcRegles() + + #---------------------------- + def handleGestionParam(self): + #---------------------------- + index = self.myQtab.currentIndex() + if index < 0: + QMessageBox.warning( + self.appliEficas, + tr("Creation Parametre indisponible"), + tr("les parametres sont lies a un jeu de donnees"), + ) + return + self.dictEditors[index].gestionParam() + + #------------------------------ + def handleViewJdcRapport(self): + #------------------------------ + index = self.myQtab.currentIndex() + if index < 0: return + self.dictEditors[index].viewJdcRapport() + + #------------------------- + def handleViewJdcPy(self): + #------------------------- + index = self.myQtab.currentIndex() + if index < 0: + return + self.dictEditors[index].viewJdcPy() + + #-------------------- + def handleSave(self): + #-------------------- + index = self.myQtab.currentIndex() + if index < 0: return + editor = self.dictEditors[index] + if editor in self.doubles: + QMessageBox.warning( + None, + tr("Fichier Duplique"), + tr("Le fichier ne sera pas sauvegarde."), + ) + return + ok, newName = editor.saveFile() + if ok: + fileName = os.path.basename(newName) + self.myQtab.setTabText(index, fileName) + return ok + + #------------------------ + def handleSortieUQ(self): + #------------------------ + index = self.myQtab.currentIndex() + if index < 0: + return + editor = self.dictEditors[index] + ok, newName = editor.saveUQFile() + return ok + + #--------------------------------- + def handleSauvePourPersalys(self): + #--------------------------------- + index = self.myQtab.currentIndex() + if index < 0: + return + editor = self.dictEditors[index] + ok = editor.sauvePourPersalys() + return ok + + #--------------------- + def handleExeUQ(self): + #--------------------- + index = self.myQtab.currentIndex() + if index < 0: return + editor = self.dictEditors[index] + ok = editor.exeUQ() + return ok + + #------------------------- + def handleSaveLigne(self): + #------------------------- + index = self.myQtab.currentIndex() + if index < 0: return + editor = self.dictEditors[index] + ok, newName = editor.saveLigneFile() + return ok + + #---------------------- + def handleSaveAs(self): + #---------------------- + index = self.myQtab.currentIndex() + editor = self.dictEditors[index] + oldName = editor.fichier + ok, newName = editor.saveFileAs() + if ok: + fileName = os.path.basename(newName) + self.myQtab.setTabText(index, fileName) + if editor in self.doubles: + if oldName != newName: + del self.doubles[editor] + return ok + + #---------------------------------- + def displayJDC(self, jdc, fn=None): + #---------------------------------- + """ + Public slot to display a file in an editor. + sert pour les includes + # a revoir + # insert filename into list of recently opened files + """ + titre = None + if fn != None: + titre = fn.split("/")[-1] + editor = self.getEditor(fichier=fn, jdc=jdc, include=1) + self.appliEficas.addToRecentList(editor.getFileName()) + + #------------------------------------------------------------------ + def getEditor(self, fichier=None, jdc=None, units=None, include=0): + #------------------------------------------------------------------ + newWin = 0 + double = None + for indexEditor in self.dictEditors: + editor = self.dictEditors[indexEditor] + if self.samePath(fichier, editor.getFileName()): + msgBox = QMessageBox() + msgBox.setWindowTitle(tr("Fichier")) + msgBox.setText(tr("Le fichier %s est deja ouvert", str(fichier))) + msgBox.addButton(tr("&Duplication"), 0) + msgBox.addButton(tr("&Abandonner"), 1) + abort = msgBox.exec_() + if abort: + break + double = editor + else: + from qt_editor import QtEditor + editor = QtEditor(self.appliEficas, fichier, jdc, self.myQtab, units, include) + if double != None: self.doubles[editor] = double + if editor.jdc: # le fichier est bien un jdc + self.editors.append(editor) + newWin = 1 + else: + editor.closeIt() + if newWin: self.addView(editor, fichier) + elif editor.jdc: self.myQtab.setCurrentIndex(indexEditor) + + index = self.myQtab.currentIndex() + if index != -1: self.dictEditors[index] = editor + return editor + + #------------------------------------ + def addView(self, win, fichier=None): + #------------------------------------ + if fichier is None: + self.untitledCount += 1 + self.myQtab.addTab( + win, tr("Fichier non encore nomme") + str(self.untitledCount) + ) + # self.myQtab.addTab(win, str(self.appliEficas.code)) + else: + liste = fichier.split("/") + txt = liste[-1] + if not QFileInfo(fichier).isWritable(): + txt = "%s (ro)" % txt + self.myQtab.addTab(win, txt) + self.myQtab.setCurrentWidget(win) + self.currentEditor = win + win.setFocus() + + + #----------------------------------- + def checkDirty(self, editor, texte): + #----------------------------------- + """ + Private method to check dirty status and open a message window. + + @param editor editor window to check + @return flag indicating successful reset of the dirty flag (boolean) + """ + res = 1 + if (editor.modified) and (editor in self.doubles): + msgBox = QMessageBox(None) + msgBox.setWindowTitle(tr("Fichier Duplique")) + msgBox.setText(tr("Le fichier ne sera pas sauvegarde.")) + msgBox.addButton(texte, 0) + msgBox.addButton(tr("&Annuler"), 1) + res = msgBox.exec_() + if res == 0: + return 1 + return 2 + if editor.modified: + fn = editor.getFileName() + if fn is None: + fn = tr("Noname") + msgBox = QMessageBox(None) + msgBox.setWindowTitle(tr("Fichier Modifie")) + msgBox.setText(tr("Le fichier ne sera pas sauvegarde.")) + msgBox.addButton(tr("&Sauvegarder"), 1) + msgBox.addButton(tr("&Quitter sans sauvegarder"), 0) + msgBox.addButton(tr("&Annuler"), 2) + res = msgBox.exec_() + if res == 2: return res + if res == 0 and self.appliEficas.maConfiguration.afficheUQ: + if fn is None: + ret, fichier = editor.saveUQFile(self) + else: + ret, fichier = editor.saveUQFile(self, fn) + return 2 + if res == 0: + (ok, newName) = editor.saveFile() + if ok: + fileName = os.path.basename(newName) + index = self.myQtab.currentIndex() + self.myQtab.setTabText(index, fileName) + return ok + return res + + #--------------------------------------- + def handleAjoutGroup(self, listeGroup): + #--------------------------------------- + index = self.myQtab.currentIndex() + if index < 0: return + editor = self.dictEditors[index] + editor.handleAjoutGroup(listeGroup) + + #------------------------------------------------------------------------ + def handleFonctionUtilisateur(self, laFonctionUtilisateur, lesArguments): + #------------------------------------------------------------------------ + # fonction qui permettait d ajouter une fonction utilisateur + # et d inserer du texte genere dans un Jeu de donnees machine tournante + index = self.myQtab.currentIndex() + if index < 0: + return + editor = self.dictEditors[index] + if editor.getEtapeCourante() == None: + QMessageBox.information( + self.appliEficas, + tr("Selectionner une etape"), + tr( "Le texte ne peut pas etre insere dans un fichier vide"), + ) + return + + listeParam = [] + for p in lesArguments: + if hasattr(editor, p): + listeParam.append(getattr(editor, p)) + if p == "editor": + listeParam.append(editor) + if p == "etapeCourante": + listeParam.append(editor.getEtapeCourante()) + laFonctionUtilisateur(*listeParam) diff --git a/InterfaceGUI/QT5/qt_eficas.py b/InterfaceGUI/QT5/qt_eficas.py index a7f219b3..a2a3f45f 100755 --- a/InterfaceGUI/QT5/qt_eficas.py +++ b/InterfaceGUI/QT5/qt_eficas.py @@ -28,7 +28,7 @@ from PyQt5.QtCore import Qt, QSize from Editeur import session from Editeur.eficas_appli import EficasAppli from UiQT5.myMain import Ui_Eficas -from InterfaceGUI.QT5.view_manager import ViewManager +from InterfaceGUI.QT5.qt_editor_manager import QtEditorManager from Accas.extensions.eficas_translation import tr from Accas.extensions.eficas_exception import EficasException @@ -37,44 +37,42 @@ from Accas.extensions import param2 class QtEficasAppli(EficasAppli, Ui_Eficas, QMainWindow): """ - Class implementing the main user interface. + Class implementing the main QT user interface. """ - def __init__( self, code=None, salome=1, parent=None, multi=False, langue="en", ssIhm=False, - labelCode=None, GUIPath="InterfaceGUI.QT5",): + #---------------------------------------------------------------------------------------------------------------------------------------------- + def __init__(self, code=None, versionCode=None, salome=1, multi=False, langue="fr", ssCode=None, fichierCata=None, GUIPath="InterfaceGUI.QT5"): + #---------------------------------------------------------------------------------------------------------------------------------------------- """ Constructor """ - if ssIhm == True: - print("mauvaise utilisation de la classe AppliWithGui. Utiliser Appli SVP") - exit() - - QMainWindow.__init__(self, parent) + QMainWindow.__init__(self) Ui_Eficas.__init__(self) - EficasAppli.__init__( self, code, salome, parent, multi=multi, langue=langue, ssIhm=True, labelCode=labelCode,) - app = QApplication + self.setupUi(self) + + EficasAppli.__init__( self, code, versionCode, salome, multi, langue, ssCode, fichierCata, GUIPath) + print (self.myQtab) + + self.editorManager = QtEditorManager(self) - self.ssIhm = False - self.multi = multi - self.demande = multi # voir PSEN self.GUIPath = GUIPath + self.suiteTelemac = self.maConfiguration.suiteTelemac + self.multi = multi if self.multi : self.definitCode(code, None) - if self.code == None: - return + if self.code == None: return - self.suiteTelemac = False if self.maConfiguration.demandeLangue: from InterfaceGUI.QT5.monChoixLangue import MonChoixLangue widgetLangue = MonChoixLangue(self) ret = widgetLangue.exec_() - self.suiteTelemac = self.maConfiguration.suiteTelemac from Accas.extensions import localisation localisation.localise(None, self.langue, translatorFile=self.maConfiguration.translatorFile,) - self.setupUi(self) + self.repIcon = os.path.join( os.path.dirname(os.path.abspath(__file__)),"..", "..", "Editeur", "icons") + app = QApplication if not self.salome: self.resize(self.maConfiguration.taille, self.height()) @@ -116,8 +114,6 @@ class QtEficasAppli(EficasAppli, Ui_Eficas, QMainWindow): if self.maConfiguration.closeEntete : self.closeEntete() - - self.viewmanager = ViewManager(self) self.recentMenu = QMenu(tr("&Recents")) # actionARemplacer ne sert que pour l insert Menu @@ -127,8 +123,7 @@ class QtEficasAppli(EficasAppli, Ui_Eficas, QMainWindow): self.connecterSignaux() if hasattr(self, 'toolBar') : self.toolBar.addSeparator() - if self.code != None: - self.construitMenu() + if self.code != None: self.construitMenu() self.setWindowTitle(self.versionEficas) try: @@ -140,26 +135,30 @@ class QtEficasAppli(EficasAppli, Ui_Eficas, QMainWindow): print("je suis dans le except du ouvreFichier") if self.salome == 0 : exit(1) + #-------------------- def closeEntete(self): + #-------------------- self.menuBar().close() self.toolBar.close() self.frameEntete.close() + #----------------------------------- def definitCode(self, code, ssCode): + #----------------------------------- self.code = code self.ssCode = ssCode if self.code == None: - self.cleanPath() from InterfaceGUI.QT5.monChoixCode import MonChoixCode widgetChoix = MonChoixCode(self) ret = widgetChoix.exec_() - # widgetChoix.show() if self.code == None: return # pour le cancel de la fenetre choix code EficasAppli.definitCode(self, self.code, ssCode) + #----------------------- def construitMenu(self): + #----------------------- self.initPatrons() self.initRecents() self.initAides() @@ -186,7 +185,9 @@ class QtEficasAppli(EficasAppli, Ui_Eficas, QMainWindow): if hasattr(self, "maConfiguration") and self.maConfiguration.ajoutExecution: self.ajoutExecution() + #------------------- def initAides(self): + #------------------- # print "je passe la" repAide = os.path.dirname(os.path.abspath(__file__)) fileName = "index.html" @@ -211,7 +212,9 @@ class QtEficasAppli(EficasAppli, Ui_Eficas, QMainWindow): self.menuAide.addAction(self.actionCode) + #----------------- def ajoutUQ(self): + #----------------- EficasAppli.ajoutUQ(self) self.menuUQ = self.menubar.addMenu(tr("Incertitude")) self.actionSaveUQ = QAction(self) @@ -232,7 +235,9 @@ class QtEficasAppli(EficasAppli, Ui_Eficas, QMainWindow): # self.actionEnregistrer_sous.setDisabled(True) + #------------------------ def ajoutExecution(self): + #------------------------ self.menuExecution = self.menubar.addMenu(tr("&Run")) self.actionExecution = QAction(self) if sys.platform[0:5] == "linux": @@ -247,7 +252,9 @@ class QtEficasAppli(EficasAppli, Ui_Eficas, QMainWindow): self.actionExecution.setText(tr("Run")) self.actionExecution.triggered.connect(self.run) + #----------------------------- def ajoutSauveExecution(self): + #----------------------------- self.actionSaveRun = QAction(self) icon7 = QIcon(self.repIcon + "/export_MAP.png") self.actionSaveRun.setIcon(icon7) @@ -258,13 +265,17 @@ class QtEficasAppli(EficasAppli, Ui_Eficas, QMainWindow): self.actionSaveRun.setText(tr("Save Run")) self.actionSaveRun.triggered.connect(self.saveRun) + #--------------------------------- def griserActionsStructures(self): + #--------------------------------- self.actionCouper.setEnabled(False) self.actionColler.setEnabled(False) self.actionCopier.setEnabled(False) self.actionSupprimer.setEnabled(False) + #--------------------------------- def enleverActionsStructures(self): + #--------------------------------- self.toolBar.removeAction(self.actionCopier) self.toolBar.removeAction(self.actionColler) self.toolBar.removeAction(self.actionCouper) @@ -272,20 +283,30 @@ class QtEficasAppli(EficasAppli, Ui_Eficas, QMainWindow): self.menuEdition.removeAction(self.actionCopier) self.menuEdition.removeAction(self.actionColler) + #--------------------------- def enleverParametres(self): + #--------------------------- self.toolBar.removeAction(self.actionParametres) self.menuJdC.removeAction(self.actionParametres) + #--------------------------- def enleverSupprimer(self): + #--------------------------- self.toolBar.removeAction(self.actionSupprimer) + #--------------------------- def enlevernewInclude(self): + #--------------------------- self.actionNouvel_Include.setVisible(False) + #------------------------------------- def enleverRechercherDsCatalogue(self): + #------------------------------------- self.actionRechercherDsCatalogue.setVisible(False) + #------------------------------------- def connectRechercherDsCatalogue(self): + #------------------------------------ if hasattr(self, "rechercherDejaLa"): return self.rechercherDejaLa = True @@ -293,7 +314,9 @@ class QtEficasAppli(EficasAppli, Ui_Eficas, QMainWindow): self.handleRechercherDsCatalogue ) + #----------------------------- def ajoutSortieComplete(self): + #--------------------------- if hasattr(self, "actionSortieComplete"): return self.actionSortieComplete = QAction(self) @@ -325,7 +348,7 @@ class QtEficasAppli(EficasAppli, Ui_Eficas, QMainWindow): def ChercheGrpMesh(self): Msg, listeGroup = self.ChercheGrpMeshInSalome() if Msg == None: - self.viewmanager.handleAjoutGroup(listeGroup) + self.editorManager.handleAjoutGroup(listeGroup) else: print("il faut gerer les erreurs") @@ -337,7 +360,7 @@ class QtEficasAppli(EficasAppli, Ui_Eficas, QMainWindow): except: raise ValueError("Salome non ouvert") if Msg == None: - self.viewmanager.handleAjoutGroup(listeGroup) + self.editorManager.handleAjoutGroup(listeGroup) else: print("il faut gerer les erreurs") @@ -417,19 +440,19 @@ class QtEficasAppli(EficasAppli, Ui_Eficas, QMainWindow): self.actionCode.triggered.connect(self.aideCode) def handleDeplier(self): - self.viewmanager.handleDeplier() + self.editorManager.handleDeplier() def handleSortieUQ(self): - self.viewmanager.handleSortieUQ() + self.editorManager.handleSortieUQ() def handleExeUQ(self): - self.viewmanager.handleExeUQ() + self.editorManager.handleExeUQ() def handleSauvePourPersalys(self): - self.viewmanager.handleSauvePourPersalys() + self.editorManager.handleSauvePourPersalys() def ajoutCommentaire(self): - self.viewmanager.ajoutCommentaire() + self.editorManager.ajoutCommentaire() def ouvreFichiers(self): # Ouverture des fichiers de commandes donnes sur la ligne de commande @@ -438,7 +461,7 @@ class QtEficasAppli(EficasAppli, Ui_Eficas, QMainWindow): for study in session.d_env.studies: os.chdir(cwd) d = session.getUnit(study, self) - self.viewmanager.handleOpen(fichier=study["comm"], units=d) + self.editorManager.handleOpen(fichier=study["comm"], units=d) def getSource(self, file): # appele par Editeur/session.py @@ -477,89 +500,85 @@ class QtEficasAppli(EficasAppli, Ui_Eficas, QMainWindow): # self.Patrons.setItemParameter(id,idx) idx = idx + 1 + #---------------------- def initRecents(self): - self.recent = [] - try: - rep = os.path.join(os.path.expanduser("~"), ".config/Eficas", self.code) - monFichier = rep + "/listefichiers_" + self.code - index = 0 - f = open(monFichier) - while index < 9: - ligne = f.readline() - if ligne != "": - l = (ligne.split("\n"))[0] - self.recent.append(l) - index = index + 1 - except: - pass - + #---------------------- + self.recemmentUtilises = [] + rep = self.maConfiguration.repUser + monFichier = rep + "/listefichiers_" + self.code + index = 0 try: - f.close() + with open(monFichier) as f: + while index < 9: + ligne = f.readline() + if ligne != "": + l = (ligne.split("\n"))[0] + self.recemmentUtilises.append(l) + index = index + 1 except: pass + #------------------------------ def addToRecentList(self, fn): - while fn in self.recent: - self.recent.remove(fn) - self.recent.insert(0, fn) - if len(self.recent) > 9: - self.recent = self.recent[:9] - - def addToRecentListQT4(self, fn): - """ - Public slot to add a filename to the list of recently opened files. - - @param fn name of the file to be added - """ - self.recent.removeAll(fn) - self.recent.prepend(fn) - if len(self.recent) > 9: - self.recent = self.recent[:9] - index = 0 - self.sauveRecents() - + #------------------------------ + while fn in self.recemmentUtilises: + self.recemmentUtilises.remove(fn) + self.recemmentUtilises.insert(0, fn) + if len(self.recemmentUtilises) > 9: + self.recemmentUtilises = self.recemmentUtilises[:9] + + #---------------------- def sauveRecents(self): + #---------------------- + if len(self.recemmentUtilises) == 0: return + rep = self.maConfiguration.repUser + if not (os.path.isdir(rep)) : + try: + os.makedirs(rep) + except: + self.afficheMessage ('liste des fichiers recents','creation de la directory impossible') + return + + monFichier = rep + "/listefichiers_" + self.code try: - rep = self.maConfiguration.repUser - monFichier = rep + "/listefichiers_" + self.code - except: - return - try: - f = open(monFichier, "w") - if len(self.recent) == 0: - return index = 0 - while index < len(self.recent): - ligne = str(self.recent[index]) + "\n" - f.write(ligne) - index = index + 1 + with open(monFichier, "w") as f: + while index < len(self.recemmentUtilises): + ligne = str(self.recemmentUtilises[index]) + "\n" + f.write(ligne) + index = index + 1 except: - pass - try: - f.close() - except: - pass + self.afficheMessage ('liste des fichiers recents','impossible de sauvegarder la liste des fichiers recents') + #------------------------- def traductionV11V12(self): + #------------------------- from InterfaceGUI.QT5.gereTraduction import traduction - traduction(self.maConfiguration.repIni, self.viewmanager, "V11V12") + traduction(self.maConfiguration.repIni, self.editorManager, "V11V12") + #-------------------------- def traductionV10V11(self): + #--------------------------- from InterfaceGUI.QT5.gereTraduction import traduction - traduction(self.maConfiguration.repIni, self.viewmanager, "V10V11") + traduction(self.maConfiguration.repIni, self.editorManager, "V10V11") + #---------------------------- def traductionV9V10(self): + #---------------------------- from InterfaceGUI.QT5.gereTraduction import traduction - traduction(self.maConfiguration.repIni, self.viewmanager, "V9V10") + traduction(self.maConfiguration.repIni, self.editorManager, "V9V10") + #-------------------------------------------------- def afficheMessage(self, titre, texte,critical=True): + #-------------------------------------------------- if critical : QMessageBox.critical( None, tr(titre), tr(texte)) else : QMessageBox.warning( None, tr(titre), tr(texte)) - + #---------------- def version(self): + #---------------- from InterfaceGUI.QT5.monVisu import DVisu titre = tr("version ") @@ -572,7 +591,9 @@ class QtEficasAppli(EficasAppli, Ui_Eficas, QMainWindow): monVisuDialg.adjustSize() monVisuDialg.show() + #---------------- def aidePPal(self): + #---------------- repAide = os.path.dirname(os.path.abspath(__file__)) maD = os.path.join(repAide, "..", "Doc") try: @@ -587,26 +608,11 @@ class QtEficasAppli(EficasAppli, Ui_Eficas, QMainWindow): self, tr("Aide Indisponible"), tr("l'aide n est pas installee ") ) - def aidePSEN(self): - repAide = os.path.dirname(os.path.abspath(__file__)) - maD = os.path.join(repAide, "..", "Doc") - try: - indexAide = os.path.join(maD, "index.html") - if sys.platform[0:5] == "linux": - cmd = "xdg-open " + indexAide - else: - cmd = "start " + indexAide - os.system(cmd) - except: - QMessageBox.warning( - self, tr("Aide Indisponible"), tr("l'aide n est pas installee ") - ) - + #---------------- def aideCode(self): - if self.code == None: - return + #---------------- + if self.code == None: return try: - # if 1 : if sys.platform[0:5] == "linux": cmd = "xdg-open " + self.fileDoc else: @@ -618,7 +624,9 @@ class QtEficasAppli(EficasAppli, Ui_Eficas, QMainWindow): self, tr("Aide Indisponible"), tr("l'aide n est pas installee ") ) + #------------------------ def optionEditeur(self): + #------------------------ try: name = "monOptions_" + self.code except: @@ -649,7 +657,7 @@ class QtEficasAppli(EficasAppli, Ui_Eficas, QMainWindow): monOption.show() def handleSortieComplete(self): - return self.viewmanager.saveCompleteCurrentEditor() + return self.editorManager.saveCompleteCurrentEditor() def handleShowRecentMenu(self): """ @@ -657,7 +665,7 @@ class QtEficasAppli(EficasAppli, Ui_Eficas, QMainWindow): """ self.recentMenu.clear() - for rp in self.recent: + for rp in self.recemmentUtilises: id = self.recentMenu.addAction(rp) self.ficRecents[id] = rp id.triggered.connect(self.handleOpenRecent) @@ -673,25 +681,25 @@ class QtEficasAppli(EficasAppli, Ui_Eficas, QMainWindow): + "/" + self.ficPatrons[idx] ) - self.viewmanager.handleOpen(fichier=fichier, patron=1) + self.editorManager.handleOpen(fichier=fichier, patron=1) def handleOpenRecent(self): idx = self.sender() fichier = self.ficRecents[idx] - self.viewmanager.handleOpen(fichier=fichier, patron=0) + self.editorManager.handleOpen(fichier=fichier, patron=0) def handleClearRecent(self): - self.recent = [] + self.recemmentUtilises = [] self.sauveRecents() def handleRechercherDsCatalogue(self): - if not self.viewmanager: + if not self.editorManager: return - self.viewmanager.handleRechercherDsCatalogue() + self.editorManager.handleRechercherDsCatalogue() def fileNew(self): try: - self.viewmanager.newEditor() + self.editorManager.newEditor() except EficasException as exc: msg = str(exc) if msg != "": @@ -700,85 +708,78 @@ class QtEficasAppli(EficasAppli, Ui_Eficas, QMainWindow): def fileOpen(self): try: - self.viewmanager.handleOpen() + self.editorManager.handleOpen() except EficasException as exc: msg = str(exc) if msg != "": QMessageBox.warning(self, tr("Erreur"), msg) def saveLigne(self): - return self.viewmanager.handleSaveLigne() + return self.editorManager.handleSaveLigne() def fileSave(self): - return self.viewmanager.handleSave() + return self.editorManager.handleSave() def fileSaveAs(self): - return self.viewmanager.handleSaveAs() + return self.editorManager.handleSaveAs() def fileClose(self): - self.viewmanager.handleClose(texte="&Fermer") + self.editorManager.handleClose(texte="&Fermer") def fileCloseAll(self): - self.viewmanager.handleCloseAll(texte="&Fermer") + self.editorManager.handleCloseAll(texte="&Fermer") def fileExit(self): # On peut sortir sur Abort - res = self.viewmanager.handleCloseAll() + res = self.editorManager.handleCloseAll() if res != 2: self.close() return res def editCopy(self): - self.viewmanager.handleEditCopy() + self.editorManager.handleEditCopy() def editCut(self): - self.viewmanager.handleEditCut() + self.editorManager.handleEditCut() def editPaste(self): - self.viewmanager.handleEditPaste() + self.editorManager.handleEditPaste() def rechercher(self): - self.viewmanager.handleRechercher() + self.editorManager.handleRechercher() def run(self): - self.viewmanager.run() + self.editorManager.run() def saveRun(self): - self.viewmanager.saveRun() + self.editorManager.saveRun() def supprimer(self): - self.viewmanager.handleSupprimer() + self.editorManager.handleSupprimer() def jdcFichierSource(self): - self.viewmanager.handleViewJdcFichierSource() + self.editorManager.handleViewJdcFichierSource() def jdcRapport(self): - self.viewmanager.handleViewJdcRapport() + self.editorManager.handleViewJdcRapport() def jdcRegles(self): - self.viewmanager.handleViewJdcRegles() + self.editorManager.handleViewJdcRegles() def gestionParam(self): - self.viewmanager.handleGestionParam() + self.editorManager.handleGestionParam() def visuJdcPy(self): - self.viewmanager.handleViewJdcPy() + self.editorManager.handleViewJdcPy() def ouvreArbre(self): - self.viewmanager.ouvreArbre() + self.editorManager.ouvreArbre() def fermeArbre(self): - self.viewmanager.fermeArbre() + self.editorManager.fermeArbre() def newInclude(self): - self.viewmanager.newIncludeEditor() - - def cleanPath(self): - for pathCode in self.listeAPathEnlever: - try: - sys.path.remove(aEnlever) - except: - pass + self.editorManager.newIncludeEditor() def closeEvent(self, event): res = self.fileExit() @@ -797,7 +798,7 @@ class QtEficasAppli(EficasAppli, Ui_Eficas, QMainWindow): self.monLayoutBoutonRempli = MonLayoutBouton(self) def handleAjoutEtape(self, nomEtape): - self.viewmanager.handleAjoutEtape(nomEtape) + self.editorManager.handleAjoutEtape(nomEtape) def metMenuAJourUtilisateurs(self): self.lesFonctionsUtilisateurs = {} @@ -823,7 +824,7 @@ class QtEficasAppli(EficasAppli, Ui_Eficas, QMainWindow): def handleFonctionUtilisateur(self, action): (laFonctionUtilisateur, lesArguments) = self.lesFonctionsUtilisateurs[action] - self.viewmanager.handleFonctionUtilisateur(laFonctionUtilisateur, lesArguments) + self.editorManager.handleFonctionUtilisateur(laFonctionUtilisateur, lesArguments) if __name__ == "__main__": diff --git a/InterfaceGUI/QT5/view_manager.py b/InterfaceGUI/QT5/view_manager.py deleted file mode 100644 index cbda035b..00000000 --- a/InterfaceGUI/QT5/view_manager.py +++ /dev/null @@ -1,535 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright (C) 2007-2024 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 -from Accas.extensions.eficas_translation import tr -from PyQt5.QtWidgets import QFileDialog, QMessageBox -from PyQt5.QtCore import QFileInfo - -Dictextensions = {"MAP": ".map"} - -#------------------------# -class ViewManager(object): -#------------------------# - def __init__(self, appliEficas): - #-------------------------------- - self.appliEficas = appliEficas - self.tabWidgets = [] - self.mesIndexes = {} - self.appliEficas = appliEficas - self.editors = [] - self.dictEditors = {} - self.untitledCount = 0 - self.doubles = {} - - self.myQtab = self.appliEficas.myQtab - - self.myQtab.currentChanged.connect(self.indexChanged) - self.myQtab.tabCloseRequested.connect(self.closeTab) - - def indexChanged(self): - #---------------------- - index = self.myQtab.currentIndex() - if index in self.dictEditors: - editor = self.dictEditors[index] - if editor.jdc != None: - CONTEXT.unsetCurrentJdC() - CONTEXT.setCurrentJdC(editor.jdc) - self.appliEficas.maConfiguration = editor.maConfiguration - self.appliEficas.code = editor.maConfiguration.code - self.appliEficas.setWindowTitle(editor.titre) - self.appliEficas.construitMenu() - - def handleOpen(self, fichier=None, patron=0, units=None): - #-------------------------------------------------------- - result = None - if fichier is None: - if self.appliEficas.demande == True: - self.appliEficas.definitCode(None, None) - if self.appliEficas.code == None: - return - - if self.appliEficas.code in Dictextensions: - chaine = "JDC (*" + Dictextensions[self.appliEficas.code] + ");;" - extensions = tr(chaine + "All Files (*)") - elif self.appliEficas.code == "TELEMAC": - extensions = tr("CAS (*.cas);;All Files (*)") - else: - extensions = tr("Fichiers JDC (*.comm);;" "Tous les Fichiers (*)") - - fichier = QFileDialog.getOpenFileName( - self.appliEficas, - tr("Ouvrir Fichier"), - self.appliEficas.maConfiguration.saveDir, - extensions, - ) - fichier = fichier[0] - if len(fichier) == 0: - return None - fichier = os.path.abspath(fichier) - ulfile = os.path.abspath(fichier) - self.appliEficas.maConfiguration.saveDir = os.path.split(ulfile)[0] - self.appliEficas.addToRecentList(fichier) - maPage = self.getEditor(fichier, units=units) - if maPage: - result = maPage - if maPage: - self.myQtab.setTabText( - self.myQtab.indexOf(maPage), os.path.basename(fichier) - ) - return result - - def closeTab(self, indexAFermer): - #-------------------------------- - self.handleClose(indexAFermer=indexAFermer) - - def handleClose(self, doitSauverRecent=1, texte=tr("&Quitter"), indexAFermer=None): - #---------------------------------------------------------------------------------- - if doitSauverRecent: - self.appliEficas.sauveRecents() - if indexAFermer == None: - index = self.myQtab.currentIndex() - else: - index = indexAFermer - if index < 0: - return - res = self.checkDirty(self.dictEditors[index], texte) - if res == 2: - return 2 # l utilisateur a annule - idx = index - while idx < len(self.dictEditors) - 1: - self.dictEditors[idx] = self.dictEditors[idx + 1] - idx = idx + 1 - del self.dictEditors[len(self.dictEditors) - 1] - try: - del self.doubles[self.dictEditors[index]] - except: - pass - self.myQtab.removeTab(index) - return res - - def run(self): - #------------- - index = self.myQtab.currentIndex() - if index < 0: - return - editor = self.dictEditors[index] - editor.run() - - def saveRun(self): - #------------------ - index = self.myQtab.currentIndex() - if index < 0: - return - editor = self.dictEditors[index] - editor.saveRun() - - def handleCloseAll(self, texte=tr("Quitter")): - #--------------------------------------------- - res = 0 - self.appliEficas.sauveRecents() - while len(self.dictEditors) > 0: - self.myQtab.setCurrentIndex(0) - res = self.handleClose(0, texte) - if res == 2: - return res # l utilsateur a annule - return res - - def handleRechercher(self): - #-------------------------- - # print "passage dans handleRechercher" - index = self.myQtab.currentIndex() - if index < 0: - return - editor = self.dictEditors[index] - editor.handleRechercher() - - def handleRechercherDsCatalogue(self): - #------------------------------------- - # print "passage dans handleRechercher" - index = self.myQtab.currentIndex() - if index < 0: - return - editor = self.dictEditors[index] - editor.handleRechercherDsCatalogue() - - def handleDeplier(self): - #----------------------- - index = self.myQtab.currentIndex() - if index < 0: - return - editor = self.dictEditors[index] - editor.handleDeplier() - - def handleEditCopy(self): - #------------------------ - # print "passage dans handleEditCopy" - index = self.myQtab.currentIndex() - if index < 0: - return - editor = self.dictEditors[index] - editor.handleEditCopy() - - def handleEditCut(self): - #----------------------- - # print "passage dans handleEditCut" - index = self.myQtab.currentIndex() - if index < 0: - return - editor = self.dictEditors[index] - editor.handleEditCut() - - def handleEditPaste(self): - #------------------------- - # print "passage dans handleEditPaste" - index = self.myQtab.currentIndex() - if index < 0: - return - editor = self.dictEditors[index] - editor.handleEditPaste() - - def handleSupprimer(self): - #------------------------- - index = self.myQtab.currentIndex() - if index < 0: - return - editor = self.dictEditors[index] - editor.handleSupprimer() - - def handleAjoutEtape(self, nomEtape): - #------------------------------------ - index = self.myQtab.currentIndex() - if index < 0: - return - editor = self.dictEditors[index] - editor.handleAjoutEtape(nomEtape) - - def newEditor(self, include=0): - #------------------------------ - if self.appliEficas.demande == True: - self.appliEficas.definitCode(None, None) - if self.appliEficas.code == None: - return - maPage = self.getEditor(include=include) - - def newIncludeEditor(self): - #-------------------------- - self.newEditor(include=1) - - def handleViewJdcFichierSource(self): - #------------------------------------ - index = self.myQtab.currentIndex() - if index < 0: - return - self.dictEditors[index].viewJdcSource() - - def ouvreArbre(self): - #-------------------- - index = self.myQtab.currentIndex() - if index < 0: - return - self.dictEditors[index].ouvreArbre() - - def fermeArbre(self): - #-------------------- - index = self.myQtab.currentIndex() - if index < 0: - return - self.dictEditors[index].fermeArbre() - - def ajoutCommentaire(self): - #-------------------------- - index = self.myQtab.currentIndex() - if index < 0: - return - editor = self.dictEditors[index] - editor.ajoutCommentaire() - - def handleViewJdcRegles(self): - #----------------------------- - index = self.myQtab.currentIndex() - if index < 0: - return - self.dictEditors[index].viewJdcRegles() - - def handleGestionParam(self): - #---------------------------- - index = self.myQtab.currentIndex() - if index < 0: - QMessageBox.warning( - self.appliEficas, - tr("Creation Parametre indisponible"), - tr("les parametres sont lies a un jeu de donnees"), - ) - return - self.dictEditors[index].gestionParam() - - def handleViewJdcRapport(self): - #------------------------------ - index = self.myQtab.currentIndex() - if index < 0: - return - self.dictEditors[index].viewJdcRapport() - - def handleViewJdcPy(self): - #------------------------- - index = self.myQtab.currentIndex() - if index < 0: - return - self.dictEditors[index].viewJdcPy() - - def handleSave(self): - #-------------------- - index = self.myQtab.currentIndex() - if index < 0: return - editor = self.dictEditors[index] - if editor in self.doubles: - QMessageBox.warning( - None, - tr("Fichier Duplique"), - tr("Le fichier ne sera pas sauvegarde."), - ) - return - ok, newName = editor.saveFile() - if ok: - fileName = os.path.basename(newName) - self.myQtab.setTabText(index, fileName) - return ok - - def handleSortieUQ(self): - #------------------------ - index = self.myQtab.currentIndex() - if index < 0: - return - editor = self.dictEditors[index] - ok, newName = editor.saveUQFile() - return ok - - def handleSauvePourPersalys(self): - #--------------------------------- - index = self.myQtab.currentIndex() - if index < 0: - return - editor = self.dictEditors[index] - ok = editor.sauvePourPersalys() - return ok - - def handleExeUQ(self): - #--------------------- - index = self.myQtab.currentIndex() - if index < 0: - return - editor = self.dictEditors[index] - ok = editor.exeUQ() - return ok - - def handleSaveLigne(self): - #------------------------- - index = self.myQtab.currentIndex() - if index < 0: - return - editor = self.dictEditors[index] - ok, newName = editor.saveLigneFile() - return ok - - def handleSaveAs(self): - #---------------------- - index = self.myQtab.currentIndex() - editor = self.dictEditors[index] - oldName = editor.fichier - ok, newName = editor.saveFileAs() - if ok: - fileName = os.path.basename(newName) - self.myQtab.setTabText(index, fileName) - if editor in self.doubles: - if oldName != newName: - del self.doubles[editor] - return ok - - def displayJDC(self, jdc, fn=None): - #---------------------------------- - """ - Public slot to display a file in an editor. - @param fn name of file to be opened - # insert filename into list of recently opened files - """ - titre = None - if fn != None: - titre = fn.split("/")[-1] - editor = self.getEditor(fichier=fn, jdc=jdc, include=1) - self.appliEficas.addToRecentList(editor.getFileName()) - - def getEditor(self, fichier=None, jdc=None, units=None, include=0): - #------------------------------------------------------------------ - newWin = 0 - double = None - indexEditor = 0 - for indexEditor in self.dictEditors: - editor = self.dictEditors[indexEditor] - if self.samePath(fichier, editor.getFileName()): - msgBox = QMessageBox() - msgBox.setWindowTitle(tr("Fichier")) - msgBox.setText(tr("Le fichier %s est deja ouvert", str(fichier))) - msgBox.addButton(tr("&Duplication"), 0) - msgBox.addButton(tr("&Abandonner"), 1) - abort = msgBox.exec_() - if abort: - break - double = editor - else: - from qt_editor import QtEditor - editor = QtEditor( self.appliEficas, fichier, jdc, self.myQtab, units=units, include=include,) - if double != None: - self.doubles[editor] = double - if editor.jdc: # le fichier est bien un jdc - self.editors.append(editor) - newWin = 1 - else: - editor.closeIt() - - if newWin: - self.addView(editor, fichier) - elif editor.jdc: - self.myQtab.setCurrentIndex(indexEditor) - - index = self.myQtab.currentIndex() - if index != -1: - self.dictEditors[index] = editor - return editor - - def addView(self, win, fichier=None): - #------------------------------------ - if fichier is None: - self.untitledCount += 1 - self.myQtab.addTab( - win, tr("Fichier non encore nomme") + str(self.untitledCount) - ) - # self.myQtab.addTab(win, str(self.appliEficas.code)) - else: - liste = fichier.split("/") - txt = liste[-1] - if not QFileInfo(fichier).isWritable(): - txt = "%s (ro)" % txt - self.myQtab.addTab(win, txt) - self.myQtab.setCurrentWidget(win) - self.currentEditor = win - win.setFocus() - - def getOpenStartDir(self): - #------------------------- - # TODO PN --> Les Preferences - try: - userDir = os.path.expanduser("~/Eficas_install/") - return userDir - except: - return "" - - def samePath(self, f1, f2): - """ - compare two paths. - """ - if f1 is None or f2 is None: - return 0 - if os.path.normcase(os.path.normpath(f1)) == os.path.normcase( - os.path.normpath(f2) - ): - return 1 - return 0 - - def checkDirty(self, editor, texte): - """ - Private method to check dirty status and open a message window. - - @param editor editor window to check - @return flag indicating successful reset of the dirty flag (boolean) - """ - res = 1 - if (editor.modified) and (editor in self.doubles): - msgBox = QMessageBox(None) - msgBox.setWindowTitle(tr("Fichier Duplique")) - msgBox.setText(tr("Le fichier ne sera pas sauvegarde.")) - msgBox.addButton(texte, 0) - msgBox.addButton(tr("&Annuler"), 1) - res = msgBox.exec_() - if res == 0: - return 1 - return 2 - if editor.modified: - fn = editor.getFileName() - if fn is None: - fn = tr("Noname") - msgBox = QMessageBox(None) - msgBox.setWindowTitle(tr("Fichier Modifie")) - msgBox.setText(tr("Le fichier ne sera pas sauvegarde.")) - msgBox.addButton(tr("&Sauvegarder"), 1) - msgBox.addButton(tr("&Quitter sans sauvegarder"), 0) - msgBox.addButton(tr("&Annuler"), 2) - res = msgBox.exec_() - if res == 2: - return res - if res == 0 and self.appliEficas.maConfiguration.afficheUQ: - if fn is None: - ret, fichier = editor.saveUQFile(self) - else: - ret, fichier = editor.saveUQFile(self, fn) - return 2 - if res == 0: - (ok, newName) = editor.saveFile() - if ok: - fileName = os.path.basename(newName) - index = self.myQtab.currentIndex() - self.myQtab.setTabText(index, fileName) - return ok - return res - - def handleAjoutGroup(self, listeGroup): - index = self.myQtab.currentIndex() - if index < 0: - return - editor = self.dictEditors[index] - editor.handleAjoutGroup(listeGroup) - - def handleFonctionUtilisateur(self, laFonctionUtilisateur, lesArguments): - # Peut-etre a blinder un peu plus sur le nb d argument - index = self.myQtab.currentIndex() - if index < 0: - return - editor = self.dictEditors[index] - if editor.getEtapeCourante() == None: - QMessageBox.information( - self.appliEficas, - tr("Selectionner une etape"), - tr( - "Le texte ne peut pas etre insere dans un fichier vide,\nCreer un materiau vide ou une zone vide et inserer le catalogue apres" - ), - ) - return - - listeParam = [] - for p in lesArguments: - if hasattr(editor, p): - listeParam.append(getattr(editor, p)) - if p == "editor": - listeParam.append(editor) - if p == "etapeCourante": - listeParam.append(editor.getEtapeCourante()) - laFonctionUtilisateur(*listeParam) diff --git a/InterfaceGUI/cinqC/qt_editor.py b/InterfaceGUI/cinqC/qt_editor.py index 4b39b144..c88f5159 100644 --- a/InterfaceGUI/cinqC/qt_editor.py +++ b/InterfaceGUI/cinqC/qt_editor.py @@ -49,7 +49,6 @@ class QtEditor(Ui_editor5C, Editor, QWidget): QWidget.__init__(self,None) self.setupUi(self) - appliEficas.maConfiguration.withXSD=1 Editor.__init__(self,appliEficas, fichier, jdc=jdc) comploader.chargerComposants(self.appliEficas.GUIPath) self.initQTSignals() @@ -77,7 +76,7 @@ class QtEditor(Ui_editor5C, Editor, QWidget): self.message='' #self.commandesOrdreCatalogue =self.readercata.commandesOrdreCatalogue - nomFichierTranslation='translatorFile'+'_'+str(self.appliEficas.readercata.labelCode) + nomFichierTranslation='translatorFile'+'_'+str(self.appliEficas.readercata.versionCode) if hasattr(self.appliEficas.maConfiguration,nomFichierTranslation) : translatorFile=getattr(self.appliEficas.maConfiguration,nomFichierTranslation) from Accas.extensions import localisation @@ -99,7 +98,7 @@ class QtEditor(Ui_editor5C, Editor, QWidget): self.jdcSelection.analyse() if debug : print (self.jdcSelection.etapes) self.jdcSelectionItem = Objecttreeitem.makeObjecttreeitem( self, "nom", self.jdcSelection ) - if self.jdcSelectionItem and self.appliEficas.ssIhm==False : + if self.jdcSelectionItem : self.treeJdcSelection = browser.JDCTree( self.jdcSelectionItem, self ) if debug : print (self.treeJdcSelection) self.widgetSelection = self.treeJdcSelection.racine.children[0].fenetre @@ -169,7 +168,7 @@ class QtEditor(Ui_editor5C, Editor, QWidget): self.jdcLabels=self._newJDC(texte=texte) self.jdcLabels.analyse() jdcLabelsItem = Objecttreeitem.makeObjecttreeitem( self, "nom", self.jdcLabels ) - if jdcLabelsItem and self.appliEficas.ssIhm==False : + if jdcLabelsItem : treeJdcLabels = browser.JDCTree( jdcLabelsItem, self ) widgetLabels = treeJdcLabels.racine.children[0].fenetre widgetLabels.show() @@ -190,17 +189,12 @@ class QtEditor(Ui_editor5C, Editor, QWidget): def afficheMessage(self,titre,message,critique=True): #---------------------------------------------------- - if self.appliEficas.ssIhm: - print ('******************', titre, '*************') - print (message) - print ('*******************************') - else: - if critique : - from PyQt5.QtWidgets import QMessageBox - QMessageBox.critical(self, titre, message) - else : - from PyQt5.QtWidgets import QMessageBox - QMessageBox.information(self, titre, message) + if critique : + from PyQt5.QtWidgets import QMessageBox + QMessageBox.critical(self, titre, message) + else : + from PyQt5.QtWidgets import QMessageBox + QMessageBox.information(self, titre, message) def appelleExecutionRequete(self,requete,chercheUneSeuleValeur=True): diff --git a/InterfaceGUI/cinqC/qt_eficas.py b/InterfaceGUI/cinqC/qt_eficas.py index 4b4299fa..bfe5a0e3 100644 --- a/InterfaceGUI/cinqC/qt_eficas.py +++ b/InterfaceGUI/cinqC/qt_eficas.py @@ -31,10 +31,11 @@ class QtEficasAppli(Ui_Eficas5C, QtEficasAppli): Class implementing the 5C user interface. """ - def __init__(self,code='5C', salome=0, multi = 0, labelCode=None, langue='en', GUIPath="InterfaceGUI.cinqC"): - super().__init__(code=code, salome=salome, multi=multi, langue=langue, labelCode=labelCode, GUIPath=GUIPath) - self.GUIPath=GUIPath - self.viewmanager.newEditor() + def __init__(self,code='5C', salome=0, multi = 0, versionCode=None, langue='en', GUIPath="InterfaceGUI.cinqC"): + super().__init__(code=code, salome=salome, multi=multi, langue=langue, versionCode=versionCode, GUIPath=GUIPath) + self.withXSD = True + self.GUIPath = GUIPath + self.editorManager.newEditor() def connecterSignaux(self) : @@ -47,7 +48,7 @@ class QtEficasAppli(Ui_Eficas5C, QtEficasAppli): def fileOpen(self) : print ('aChanger') - print ( self.viewmanager) + print ( self.editorManager) def closeEvent(self,event): diff --git a/InterfaceGUI/common/Objecttreeitem.py b/InterfaceGUI/common/Objecttreeitem.py index c6c94cbf..81338a1f 100644 --- a/InterfaceGUI/common/Objecttreeitem.py +++ b/InterfaceGUI/common/Objecttreeitem.py @@ -295,7 +295,7 @@ class ObjectTreeItem(TreeItem, Delegate): le nouveau mot-cle """ liste_noms_mc_ordonnee = self.getListeMcOrdonneeBrute( - self.getGenealogie(), self.getJdc().cata_ordonne_dico + self.getGenealogie(), self.getJdc().dicoCataOrdonne ) liste_noms_mc_presents = self.object.listeMcPresents() l = [] @@ -514,7 +514,7 @@ class SequenceTreeItem(ObjectTreeItem): self._object.remove(item.getObject()) # la liste peut etre retournee vide ! message = "Mot-clef " + item.getObject().nom + " supprime" - self.appliEficas.afficheInfos(message) + self.appliEficas.afficheMessages(message) return 1 except: return 0 diff --git a/Tests/old/EficasEngineTest.py b/Tests/old/EficasEngineTest.py index d0f2ae83..0954da4f 100644 --- a/Tests/old/EficasEngineTest.py +++ b/Tests/old/EficasEngineTest.py @@ -35,7 +35,7 @@ import difflib from PyQt4.QtGui import * from myMain import Ui_Eficas -from viewManager import MyTabview +from editorManager import MyTabview from getVersion import getEficasVersion from Accas.extensions.eficas_translation import tr @@ -79,7 +79,7 @@ class EficasEngineTestCase(unittest.TestCase): def close(self): if ( self.editor != None ): - vm=self.Eficas.viewmanager + vm=self.Eficas.editorManager index=vm.myQtab.currentIndex() idx=index while idx < len(vm.dict_editors) -1 : @@ -99,9 +99,9 @@ class EficasEngineTestCase(unittest.TestCase): result=True try: - self.Eficas.viewmanager.handleOpen(fileName) - index=self.Eficas.viewmanager.myQtab.currentIndex() - self.editor=self.Eficas.viewmanager.dict_editors[index] + self.Eficas.editorManager.handleOpen(fileName) + index=self.Eficas.editorManager.myQtab.currentIndex() + self.editor=self.Eficas.editorManager.dict_editors[index] except: result=False pass diff --git a/Tools/qtEficasGui.py b/Tools/qtEficasGui.py index 497570de..9a5bab0f 100755 --- a/Tools/qtEficasGui.py +++ b/Tools/qtEficasGui.py @@ -43,4 +43,4 @@ sys.path[:0]=[INSTALLDIR] #sys.path.append(os.path.join(os.path.abspath(os.path.dirname(__file__)),'../..')) from Editeur import eficas_go -eficas_go.lanceEficas(code='NonConnu') +eficas_go.lanceQtEficas(code='NonConnu') diff --git a/Web/accasConnecteur.py b/Web/accasConnecteur.py index 245009b5..6ebb80ef 100644 --- a/Web/accasConnecteur.py +++ b/Web/accasConnecteur.py @@ -51,7 +51,7 @@ class AccasConnecteur : if self.monEficas == None : self.toWebApp('afficheInfos', 'erreur à la construction de l appli Eficas', 'rouge') return - # faire l equivalent du viewmanager + # faire l equivalent du editorManager if fichierCata == None and fichierComm : self.toWebApp('afficheInfos', 'pour ouvrir un JDC, il faut connaitre le catalogue', 'rouge') return diff --git a/Web/testFlask/appelleEficasGo.py b/Web/testFlask/appelleEficasGo.py index 90d308e4..910c5cd5 100755 --- a/Web/testFlask/appelleEficasGo.py +++ b/Web/testFlask/appelleEficasGo.py @@ -32,4 +32,4 @@ sys.path.append(os.path.join(os.path.abspath(os.path.dirname(__file__)),'..')) import prefs from InterfaceSsIhm import eficas_go -eficas_go.lanceEficas_Web(code=prefs.code) +eficas_go.lanceQtEficas_Web(code=prefs.code)