for leNode in lesNodes : listeNodes.append(leNode)
return listeNodes
+ def getParentsJusqua(self,jusqua):
+ listeDesParents=[]
+ aTraiter=self
+ while aTraiter != jusqua.getObject() :
+ listeDesParents.append(aTraiter.parent)
+ aTraiter=aTraiter.parent
+ return listeDesParents
+
--- /dev/null
+# -*- coding: iso-8859-1 -*-
+# 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
+#
+
+
+from __future__ import absolute_import
+from __future__ import print_function
+try :
+ from builtins import str
+except : pass
+
+import os, sys
+
+from Extensions.eficas_exception import EficasException
+from Extensions import param2
+
+from .getVersion import getEficasVersion
+from .viewManagerSsIhm import MyViewManagerSsIhm
+
+from Editeur import session
+
+
+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,fichierCata=None):
+ """
+ Constructor
+ """
+ version=getEficasVersion()
+ self.VERSION_EFICAS="Eficas QT5 Salome " + version
+ self.labelCode=labelCode
+
+ self.salome=salome
+ self.ssIhm=True
+ self.code=code
+ self.genereXSD=genereXSD
+
+ self.dict_reels={}
+ self.fichierIn=None
+ self.fichierOut=None
+
+ self.recent = []
+ self.ficRecents={}
+ self.mesScripts={}
+ self.listeAEnlever=[]
+ self.ListePathCode=['Adao','ADAO','Carmel3D','Telemac','CF','MAP','ZCracks', 'SEP','SPECA','PSEN_Eficas','PSEN_N1']
+ 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')
+
+ if session.d_env == {} : session.parse(sys.argv)
+ 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
+
+ if self.salome:
+ import Accas
+ try :
+ import eficasSalome
+ Accas.SalomeEntry = eficasSalome.SalomeEntry
+ except :
+ print ('eficas hors salome')
+
+ self.multi=multi
+ if self.multi :
+ print ('pas de multi sans ihm')
+
+
+ if langue=='fr': self.langue=langue
+ else : self.langue="ang"
+
+ if self.multi == False :
+ self.definitCode(code,None)
+ if code==None: return
+
+ self.suiteTelemac=False
+ self.viewmanager=MyViewManagerSsIhm(self)
+
+
+ def definitCode(self,code,ssCode) :
+ self.code=code
+ self.ssCode=ssCode
+ if self.code == None:return # pour le cancel de la fenetre choix code
+
+ try :
+ name='prefs_'+self.code
+ prefsCode=__import__(name)
+ self.repIni=prefsCode.repIni
+ except :
+ self.repIni=os.path.dirname(os.path.abspath(__file__))
+
+
+ if ssCode != None :
+ self.formatFichierOut = ssCode #par defaut
+ prefsCode.NAME_SCHEME = ssCode
+ else :
+ self.formatFichierIn = "python" #par defaut
+ self.formatFichierOut = "python" #par defaut
+
+ nameConf='configuration_'+self.code
+ try :
+ configuration=__import__(nameConf)
+ self.maConfiguration = configuration.make_config(self,self.repIni)
+ except :
+ from .configuration import makeConfig
+ #self.maConfiguration = configuration.makeConfig(self,prefsCode.repIni)
+ self.maConfiguration = makeConfig(self,self.repIni)
+
+ if hasattr (self,'maConfiguration') and self.maConfiguration.translatorFichier :
+ from Extensions import localisation
+ localisation.localise(None,self.langue,translatorFichier=self.maConfiguration.translatorFichier)
+ if self.withXSD : self.maConfiguration.withXSD=True
+
+
+ def getSource(self,file):
+ # appele par Editeur/session.py
+ import convert
+ p=convert.plugins['python']()
+ p.readfile(file)
+ texte=p.convert('execnoparseur')
+ 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')
+ sys.exit()
+ self.editor = self.viewmanager.getNewEditorNormal()
+
+ def initEditorNormal(self,fichier = None,jdc = None, units = None,include=0):
+ if (hasattr(self, 'editor')) and self.editor != None :
+ print ('un seul editeur par application')
+ sys.Exit()
+ #self.editor = JDCEditorSsIhm(self,fichier, jdc, self.myQtab,units=units,include=include)
+ self.editor = self.viewmanager.getNewEditorNormal()
+
+
+ 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)
+ 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
+ #if self.maConfiguration.afficheIhm==False : exit()
+ #else : return texteXSD
+
+
+#,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')
options = session.parse(sys.argv)
if options.code != None : code=options.code
- from InterfaceQT4.qtEficas import Appli
+ from InterfaceQT4.editorSsIhm import Appli
app = QApplication(sys.argv)
Eficas=Appli(code=code,salome=0,multi=multi,langue=langue,labelCode=labelCode)
if options.code != None : code=options.code
if forceXML : options.withXSD=True
- from .qtEficasSsIhm import AppliSsIhm
+ from .eficasSsIhm import AppliSsIhm
Eficas=AppliSsIhm(code=code, salome=0, multi=multi, langue=langue, labelCode=labelCode, genereXSD=genereXSD, fichierCata=fichierCata)
return Eficas
f.write(str(texteStructure))
f.close()
+def validateFile(code,fichierCata,fichier):
+ from Editeur import session
+ options=session.parse(['',])
+ from .eficasSsIhm import AppliSsIhm
+ from .editorSsIhm import JDCEditorSsIhm
+ monEficasSsIhm=AppliSsIhm(code=code, salome=0, fichierCata=fichierCata)
+ monEditeur=JDCEditorSsIhm(monEficasSsIhm,fichier)
+ return monEditeur.jdc.isValid()
def validateDataSet(code=None):
#------------------------------
if fichier == None : fichier=options.comm[0]
if code == None : code=options.code
- from .qtEficas import Appli
+ from .eficas import Appli
Eficas=Appli(code=code,salome=0,ssCode=ssCode,ssIhm=True,langue=langue)
from .ssIhm import QWParentSSIhm
from Editeur import session
options=session.parse(sys.argv)
- from .qtEficas import Appli
+ from .eficas import Appli
from .ssIhm import QWParentSSIhm
Eficas=QWParentSSIhm(code,version)
+++ /dev/null
-# -*- coding: iso-8859-1 -*-
-# 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
-#
-
-
-from __future__ import absolute_import
-from __future__ import print_function
-try :
- from builtins import str
-except : pass
-
-import os, sys
-
-from Extensions.eficas_exception import EficasException
-from Extensions import param2
-
-from .getVersion import getEficasVersion
-from .viewManagerSsIhm import MyViewManagerSsIhm
-
-from Editeur import session
-
-
-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,fichierCata=None):
- """
- Constructor
- """
- version=getEficasVersion()
- self.VERSION_EFICAS="Eficas QT5 Salome " + version
- self.labelCode=labelCode
-
- self.salome=salome
- self.ssIhm=True
- self.code=code
- self.genereXSD=genereXSD
-
- self.dict_reels={}
- self.fichierIn=None
- self.fichierOut=None
-
- self.recent = []
- self.ficRecents={}
- self.mesScripts={}
- self.listeAEnlever=[]
- self.ListePathCode=['Adao','ADAO','Carmel3D','Telemac','CF','MAP','ZCracks', 'SEP','SPECA','PSEN_Eficas','PSEN_N1']
- 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')
-
- if session.d_env == {} : session.parse(sys.argv)
- 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
-
- if self.salome:
- import Accas
- try :
- import eficasSalome
- Accas.SalomeEntry = eficasSalome.SalomeEntry
- except :
- print ('eficas hors salome')
-
- self.multi=multi
- if self.multi :
- print ('pas de multi sans ihm')
-
-
- if langue=='fr': self.langue=langue
- else : self.langue="ang"
-
- if self.multi == False :
- self.definitCode(code,None)
- if code==None: return
-
- self.suiteTelemac=False
- self.viewmanager=MyViewManagerSsIhm(self)
-
-
- def definitCode(self,code,ssCode) :
- self.code=code
- self.ssCode=ssCode
- if self.code == None:return # pour le cancel de la fenetre choix code
-
- try :
- name='prefs_'+self.code
- prefsCode=__import__(name)
- self.repIni=prefsCode.repIni
- except :
- self.repIni=os.path.dirname(os.path.abspath(__file__))
-
-
- if ssCode != None :
- self.formatFichierOut = ssCode #par defaut
- prefsCode.NAME_SCHEME = ssCode
- else :
- self.formatFichierIn = "python" #par defaut
- self.formatFichierOut = "python" #par defaut
-
- nameConf='configuration_'+self.code
- try :
- configuration=__import__(nameConf)
- self.maConfiguration = configuration.make_config(self,self.repIni)
- except :
- from .configuration import makeConfig
- #self.maConfiguration = configuration.makeConfig(self,prefsCode.repIni)
- self.maConfiguration = makeConfig(self,self.repIni)
-
- if hasattr (self,'maConfiguration') and self.maConfiguration.translatorFichier :
- from Extensions import localisation
- localisation.localise(None,self.langue,translatorFichier=self.maConfiguration.translatorFichier)
- if self.withXSD : self.maConfiguration.withXSD=True
-
-
- def getSource(self,file):
- # appele par Editeur/session.py
- import convert
- p=convert.plugins['python']()
- p.readfile(file)
- texte=p.convert('execnoparseur')
- 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')
- sys.exit()
- self.editor = self.viewmanager.getNewEditorNormal()
-
- def initEditorNormal(self,fichier = None,jdc = None, units = None,include=0):
- if (hasattr(self, 'editor')) and self.editor != None :
- print ('un seul editeur par application')
- sys.Exit()
- #self.editor = JDCEditorSsIhm(self,fichier, jdc, self.myQtab,units=units,include=include)
- self.editor = self.viewmanager.getNewEditorNormal()
-
-
- 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)
- 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
- #if self.maConfiguration.afficheIhm==False : exit()
- #else : return texteXSD
-
-
-#,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')
#--------------
def __init__( self, treeParent, item, itemExpand=False, ancien=False ):
#----------------------------------------------------------------------
- #print ("creation d'un noeud : ", item, " ",item.nom,"", treeParent, self)
-
+ #print ("creation d'un noeud : ", item, " ",item.nom,"", treeParent, treeParent.item.nom,self)
self.item = item
self.vraiParent = treeParent
self.childrenComplete=[]
self.oldValidite=None
self.item.fauxNoeudGraphique = self
- #self.plie=True # pas gere
-
- #from . import compocomm
- #from . import compoparam
- #from . import composimp
- #if (isinstance(self.item,compocomm.COMMTreeItem)) : name = tr("Commentaire")
- #elif (isinstance(self.item,compoparam.PARAMTreeItem)) : name = tr(str(item.getLabelText()[0]))
- #else : name = tr(item.getLabelText()[0])
if item.nom != tr(item.nom) : name = str(tr(item.nom)+" :")
- #value = tr(str(item.getText() ) )
-
-
- #if self.treeParent.plie==True :
- # self.plie = True
- # self.appartientAUnNoeudPlie = True
- # if self.treeParent.item.isMCList() : self.appartientAUnNoeudPlie = self.treeParent.appartientAUnNoeudPlie
- #else :
- # self.plie = False
- # self.appartientAUnNoeudPlie = False
- #if ancien and itemExpand : self.plie = False
- #if ancien and not itemExpand : self.plie = True
- #if (isinstance(self.item,composimp.SIMPTreeItem)) : self.plie=False
-
-
- #ajoutAuParentduNoeud=0
from . import compobloc
from . import compomclist
while (isinstance(self.treeParent,compobloc.Node) or ( isinstance(self.treeParent,compomclist.Node) and self.treeParent.item.isMCList())) :
self.treeParent=self.treeParent.vraiParent
-
- #if (isinstance(self,compobloc.Node) or (isinstance(self,compomclist.Node) and self.item.isMCList()) or ( hasattr(self.item.parent,'inhibeValidator') and isinstance(self,compomclist.Node) and self.item.parent.inhibeValidator)) :
- # Le dernier or ne sert que lorsqu'on est en train de creer une liste par les validator
- # QTreeWidgetItem.__init__(self,None,mesColonnes)
- #else :
- # QTreeWidgetItem.__init__(self,self.treeParent,mesColonnes)
-
- #self.setToolTip(0,self.item.getFr())
- #self.setToolTip(1,self.item.getFr())
- #repIcon=self.appliEficas.repIcon
-
- #couleur=self.item.getIconName()
- #monIcone = QIcon(repIcon+"/" + couleur + ".png")
-
- #self.setIcon(0,monIcone)
-
self.children = []
self.buildChildren()
- self.menu=None
- self.existeMenu=1
self.item.connect("valid",self.onValid,())
self.item.connect("supp" ,self.onSupp,())
self.item.connect("add" ,self.onAdd,())
self.item.connect("redessine" ,self.onRedessine,())
- self.state=""
- self.fenetre=None
- #try :
- # if self.item.getObject().isBLOC() :
- # self.setExpanded(True)
- # self.plie=False
- #except :
- # pass
def onValid(self):
#-----------------
- #print ('appel onValid pour', self.item.nom)
validite=self.item.isValid()
if self.oldValidite==validite : return
self.oldValidite=validite
#print ('appel de propageValide pour ', self.item.nom, validite,self.oldValidite)
- self.editor.connecteur.toWebApp('propageValide',self.item.idUnique, validite)
+ self.editor.connecteur.toWebApp('propageValide',self.getIdUnique(), validite)
def onAdd(self,ajout):
#-----------------------
- #print ('on add', '________ ajout', ajout , ' dans ', self.item.nom)
+ print ('on add', '________ ajout', ajout , ' dans ', self.item.nom)
self.buildChildren()
- # si on a un copie multiple
+ # si on a un copie multiple --> pas gere correctement
+ # pas gere du tout
if len(ajout) > 1 :
- self.editor.connecteur.toWebApp('remplacementNode',self.item.remplaceId,self.item.idUnique(),self.item.getDicoForFancy())
+ self.editor.connecteur.toWebApp('remplacementNode',self.item.remplaceId,self.getTreeParentIdUnique(),self.item.getDicoForFancy())
return
+ if self.item.nature != 'MCBLOC' : ouAjouter=self.getIdUnique()
+ else : ouAjouter=self.getTreeParentIdUnique()
+
mcAjoute= ajout[0]
- pos = 0; trouve=0
+ posDansSelf = 0; trouve=0
for c in self.children :
if c.item._object == mcAjoute :
trouve=1
break
- pos+=1
+ posDansSelf+=1
if not trouve : print ('souci au add *************************')
- if self.children[pos].item.nature == 'MCBLOC' : laListe=self.children[pos].item.getDicoForFancy()
- else : laListe=(self.children[pos].item.getDicoForFancy(),)
- self.editor.connecteur.toWebApp('appendChildren',self.getIdUnique(),laListe,pos)
+ if self.children[posDansSelf].item.nature == 'MCBLOC' : laListe=self.children[posDansSelf].item.getDicoForFancy()
+ else : laListe=(self.children[posDansSelf].item.getDicoForFancy(),)
+
+ posOuAjouter=posDansSelf
+ if self.item.nature == 'MCBLOC' :
+ mesParents=self.item.getParentsJusqua(self.treeParent.item)
+ mesParents.insert(0,self.item.getObject())
+ index=0
+ while index < len(mesParents) -1 :
+ parentTraite=mesParents[index+1]
+ jusqua=mesParents[index]
+ for c in parentTraite.mcListe:
+ if c == jusqua : break
+ posOuAjouter += c.longueurDsArbre()
+ index=index+1
+
+
+ self.editor.connecteur.toWebApp('appendChildren',ouAjouter,laListe,posOuAjouter)
+ print ('la pos ', posOuAjouter)
#print (' appel appendChild',self.item.idUnique,laListe,pos)
def onSupp(self,suppression):
def getIdUnique(self):
#---------------------
# surcharge pour mcliste
- return self.item.idUnique
+ return self.item.idUnique
+ def getTreeParentIdUnique(self):
+ #------------------------------
+ return self.treeParent.getIdUnique()
def buildChildren(self,posInsertion=10000):
#------------------------------------------
maCommande=commande
if hasattr(parentQt,'niveau'): self.niveau=parentQt.niveau+1
else : self.niveau=1
- #from .monWidgetBloc import MonWidgetBloc
- #widget=MonWidgetBloc(self,self.editor,parentQt,maDefinition,monObjet,self.niveau,maCommande)
class BLOCTreeItem(compofact.FACTTreeItem):
- def doPaste(self,node_selected,pos):
- objet_a_copier = self.item.getCopieObjet()
- # before est un effet de bord heureux sur l index
- child=self.appendBrother(objet_a_copier,'before')
- if self.editor.fenetreCentraleAffichee : self.editor.fenetreCentraleAffichee.node.affichePanneau()
- self.update_NodeLabelInBlack()
- self.parent().buildChildren()
- return child
-
- def getIdUnique(self):
- #---------------------
- return 3
+ #def doPaste(self,node_selected,pos):
+ # objet_a_copier = self.item.getCopieObjet()
+ # # before est un effet de bord heureux sur l index
+ # child=self.appendBrother(objet_a_copier,'before')
+ # if self.editor.fenetreCentraleAffichee : self.editor.fenetreCentraleAffichee.node.affichePanneau()
+ # self.update_NodeLabelInBlack()
+ # self.parent().buildChildren()
+ # return child
+
def select(self):
- browser.JDCNode.select(self)
- self.treeParent.tree.openPersistentEditor(self,1)
- self.monWidgetNom=self.treeParent.tree.itemWidget(self,1)
- self.monWidgetNom.returnPressed.connect(self.nomme)
- if self.item.getIconName() == "ast-red-square" : self.monWidgetNom.setDisabled(True)
- #else : self.monWidgetNom.setFocus() ;self.monWidgetNom.setDisabled(False)
-
- def nomme(self):
- nom=str(self.monWidgetNom.text())
- self.editor.initModif()
- test,mess = self.item.nommeSd(nom)
- if (test== 0):
- self.editor.afficheInfos(mess,'red')
- old=self.item.getText()
- self.monWidgetNom.setText(old)
- else :
- self.editor.afficheCommentaire(tr("Nommage du concept effectue"))
- self.onValid()
- try :
- self.fenetre.LENom.setText(nom)
- except :
- pass
-
+ pass
- def getPanel(self):
- from .monWidgetCommande import MonWidgetCommande
- return MonWidgetCommande(self,self.editor,self.item.object)
+ #def nomme(self):
+ # pass
- def createPopUpMenu(self):
- typeNode.PopUpMenuNode.createPopUpMenu(self)
+ #def getPanel(self):
+ # from .monWidgetCommande import MonWidgetCommande
+ # return MonWidgetCommande(self,self.editor,self.item.object)
+ #def createPopUpMenu(self):
+ # typeNode.PopUpMenuNode.createPopUpMenu(self)
+#
# def view3D(self) :
# from Editeur import TroisDPal
# troisD=TroisDPal.TroisDPilote(self.item,self.editor.appliEficas)