From: pascale.noyret Date: Mon, 3 May 2021 08:42:11 +0000 (+0200) Subject: pour pocRN X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=0e1f3659580973ac85424bb2c2a1d25e01aaf2e8;p=tools%2Feficas.git pour pocRN --- diff --git a/InterfaceQT4/eficas_go.py b/InterfaceQT4/eficas_go.py index 4b496933..7300db67 100755 --- a/InterfaceQT4/eficas_go.py +++ b/InterfaceQT4/eficas_go.py @@ -65,8 +65,8 @@ def lanceEficas(code=None, multi=False, langue='en', labelCode=None): res=app.exec_() sys.exit(res) -def getEficasSsIhm(code=None, multi=False, langue='en', labelCode=None,forceXML=False, genereXSD=False): -#------------------------------------------------------------------------------------------------------ +def getEficasSsIhm(code=None, multi=False, langue='en', labelCode=None,forceXML=False, genereXSD=False, fichierCata=None): +#------------------------------------------------------------------------------------------------------------------------- """ Lance l'appli EFICAS sans Ihm """ @@ -76,7 +76,7 @@ def getEficasSsIhm(code=None, multi=False, langue='en', labelCode=None,forceXML= if forceXML : options.withXSD=True from InterfaceQT4.qtEficasSsIhm import AppliSsIhm - Eficas=AppliSsIhm(code=code, salome=0, multi=multi, langue=langue, labelCode=labelCode, genereXSD=genereXSD) + Eficas=AppliSsIhm(code=code, salome=0, multi=multi, langue=langue, labelCode=labelCode, genereXSD=genereXSD, fichierCata=fichierCata) return Eficas @@ -198,9 +198,21 @@ def validateFonction(laFonction, debug=False): #maClasseAccas=getattr(self.cata,objEtape.monNomClasseAccas) return fonctionValidee - return laFonction +def createFromDocumentAccas(fichierCata=None,fichier=None,code=None): +#------------------------------------------------------------ + if fichier == None : print ('file is needed'); return None + if fichierCata == None : print ('cata file is needed'); return None + + from Noyau.N_OBJECT import activeSurcharge + activeSurcharge() + + from .editorSsIhm import JDCEditorSsIhm + monEficasSsIhm = getEficasSsIhm(code='Essai', fichierCata=fichierCata) + monEditeur=JDCEditorSsIhm(monEficasSsIhm,fichier) + return monEditeur.jdc + #from Noyau # --------------------------- toutes les fonctions après sont obseletes diff --git a/InterfaceQT4/qtEficasSsIhm.py b/InterfaceQT4/qtEficasSsIhm.py index 2e193630..b72fa260 100755 --- a/InterfaceQT4/qtEficasSsIhm.py +++ b/InterfaceQT4/qtEficasSsIhm.py @@ -40,7 +40,7 @@ class AppliSsIhm: """ 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): + def __init__(self,code=None,salome=1,parent=None,multi=False,langue='fr',ssIhm=True,labelCode=None,genereXSD=False,fichierCata=None): """ Constructor """ @@ -65,7 +65,8 @@ class AppliSsIhm: self.listeCode=['Adao','ADAO','Carmel3D','Telemac','CF','MAP','ZCracks', 'SEP','SPECA','PSEN_Eficas','PSEN_N1'] self.repIcon=os.path.join( os.path.dirname(os.path.abspath(__file__)),'..','Editeur','icons') - self.fichierCata=session.d_env.fichierCata + 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 diff --git a/Noyau/N_JDC.py b/Noyau/N_JDC.py index e006c83e..4f1e7ba9 100644 --- a/Noyau/N_JDC.py +++ b/Noyau/N_JDC.py @@ -646,6 +646,17 @@ Causes possibles : print((' `- JDC sdAccessible : PAR_LOT =', self.parLot)) return self.parLot == 'NON' + def getEtapesByName(self,name): + listeDEtapes=[] + for e in self.etapes : + if e.nom == name : listeDEtapes.append(e) + return listeDEtapes + + def getEtapeByConceptName(self,conceptName): + for e in self.etapes : + if e.sdnom == conceptName : return e + + def _build_reserved_kw_list(self): """Construit la liste des mots-cles reserves (interdits pour le nommage des concepts).""" @@ -658,3 +669,4 @@ Causes possibles : self._reserved_kw.difference_update( ['OPER', 'MACRO', 'BLOC', 'SIMP', 'FACT', 'FORM', 'GEOM', 'MCSIMP', 'MCFACT']) + diff --git a/Noyau/N_OBJECT.py b/Noyau/N_OBJECT.py index e7b68b02..d08f9fce 100644 --- a/Noyau/N_OBJECT.py +++ b/Noyau/N_OBJECT.py @@ -147,3 +147,31 @@ class ErrorObj(OBJECT): self.cr.fatal(_(u"Type non autorisé pour le mot-clé %s : '%s'"), self.nom, self.valeur) return self.cr + + +def newGetattr(self,name): + try : + fils=self.getChild(name) + if fils : + if fils.nature == 'MCSIMP' : return fils.valeur + if fils.nature == 'MCList' : + if fils[0].definition.max == 1 : return fils[0] + return fils + except : + raise AttributeError("%r object has no attribute %r" % (self.__class__.__name__, name)) + raise AttributeError("%r object has no attribute %r" % (self.__class__.__name__, name)) + +def newGetattrForEtape(self,name): + try : + lesFils=self.getEtapesByName(name) + if lesFils != [] : return lesFils + except : + raise AttributeError("%r object has no attribute %r" % (self.__class__.__name__, name)) + raise AttributeError("%r object has no attribute %r" % (self.__class__.__name__, name)) + +def activeSurcharge(): + from .N_MCCOMPO import MCCOMPO + MCCOMPO.__getattr__ = newGetattr + from .N_JDC import JDC + JDC.__getattr__ = newGetattrForEtape + diff --git a/Poc/essaiGetattr.py b/Poc/essaiGetattr.py new file mode 100755 index 00000000..741f6ee0 --- /dev/null +++ b/Poc/essaiGetattr.py @@ -0,0 +1,57 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- +# Copyright (C) 2007-2021 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 sys,os +import prefs +sys.path.append(os.path.join(os.path.abspath(os.path.dirname(__file__)),'..')) + +from InterfaceQT4 import eficas_go +jdd = eficas_go.createFromDocumentAccas('cataPocRN.py','edg32.comm') + + +monRodBank=jdd.RodBank[0] +print ('MonObjet ', monRodBank, ' a pour nom', monRodBank.sdnom) +print (monRodBank.rodbank_name) + +print ('on fait une erreur volontaire') +try : + monRodBank=jdd.rodrank[0] +except : pass + +monRodBank2=jdd.getEtapeByConceptName('RB') +assert monRodBank2 == monRodBank + + +techno=jdd.Techno_data[0] +print (techno.assembly_list) +print (techno.rodbank_list) +try : + print (techno.toto) +except : pass + +print (techno.radial_description) +print (techno.radial_description.nb_assembly) +print (techno.radial_description.assembly_map_6.xaxis) +print (techno.radial_description.assembly_map_6.yaxis) +print (techno.radial_description.assembly_map_6.assembly_map) +print (techno.radial_description.assembly_map_6.assembly_map[0][3]) +