From 65f1a30c2d075eb4b022983a5e3540c2278dbea0 Mon Sep 17 00:00:00 2001 From: "pascale.noyret" Date: Wed, 7 Jun 2017 10:28:17 +0200 Subject: [PATCH] Plie/Deplie MT --- Ihm/I_MACRO_ETAPE.py | 2 +- InterfaceQT4/browser.py | 7 +- InterfaceQT4/compofact.py | 7 +- InterfaceQT4/compomclist.py | 6 +- InterfaceQT4/eficas_go.py | 2 +- InterfaceQT4/groupe.py | 115 +++++++++++++++++++++++++++++- InterfaceQT4/monWidgetCommande.py | 14 ++++ InterfaceQT4/monWidgetFact.py | 9 +-- InterfaceQT4/monWidgetFactPlie.py | 4 +- 9 files changed, 148 insertions(+), 18 deletions(-) diff --git a/Ihm/I_MACRO_ETAPE.py b/Ihm/I_MACRO_ETAPE.py index b0ad4a70..1fb5f49b 100644 --- a/Ihm/I_MACRO_ETAPE.py +++ b/Ihm/I_MACRO_ETAPE.py @@ -775,7 +775,7 @@ class MACRO_ETAPE(I_ETAPE.ETAPE): Une MACRO_ETAPE peut ajouter plusieurs concepts dans le contexte Une fonction enregistree dans op_init peut egalement modifier le contexte """ - print ("update_context",self,self.nom,d.keys()) + #print ("update_context",self,self.nom,d.keys()) if hasattr(self,"jdc_aux") and self.jdc_aux: #ATTENTION: update_context NE DOIT PAS appeler reset_context # car il appelle directement ou indirectement update_context diff --git a/InterfaceQT4/browser.py b/InterfaceQT4/browser.py index 7c000b9a..712a813b 100644 --- a/InterfaceQT4/browser.py +++ b/InterfaceQT4/browser.py @@ -326,7 +326,6 @@ class JDCNode(QTreeWidgetItem,GereRegles): # posera des pb si un code decide d appeler FIN un mot clef # on resoudera a ce moment la # pour l instant pas de poussiere sous le tapis - #print( 'debut affichePanneau pour', self.item.nom) if not(self.item.isactif()) : from .monWidgetInactif import MonWidgetInactif self.fenetre = MonWidgetInactif(self,self.editor) @@ -527,11 +526,15 @@ class JDCNode(QTreeWidgetItem,GereRegles): if obj is None:obj=0 if obj == 0:return 0 try : + #if 1 : child=self.children[index] if plier == True : child.setPlie() else : child.setDeplie() except : child=self.children[index] + try : + if len(obj) > 1 : self.build_children() + except : pass self.tree.inhibeExpand=False #print (" fin append child") return child @@ -833,7 +836,7 @@ class JDCNode(QTreeWidgetItem,GereRegles): # item.appartientAUnNoeudPlie=False def setPlieChildren(self): - #print "dans setPlieChildren pour", self.item.nom + #print ("dans setPlieChildren pour", self.item.nom) self.plie=True for c in self.children : c.setPlieChildren() diff --git a/InterfaceQT4/compofact.py b/InterfaceQT4/compofact.py index ce43add5..164107ee 100644 --- a/InterfaceQT4/compofact.py +++ b/InterfaceQT4/compofact.py @@ -30,7 +30,8 @@ import six class Node(browser.JDCNode,typeNode.PopUpMenuNodePartiel): - def getPanelGroupe(self,parentQt,commande): + def getPanelGroupe(self,parentQt,commande,insertIn=-1): + import traceback maDefinition=self.item.get_definition() monObjet=self.item.object monNom=self.item.nom @@ -44,10 +45,10 @@ class Node(browser.JDCNode,typeNode.PopUpMenuNodePartiel): #elif hasattr(self,'plie') and self.plie==True : if hasattr(self,'plie') and self.plie==True : from .monWidgetFactPlie import MonWidgetFactPlie - widget=MonWidgetFactPlie(self,self.editor,parentQt,maDefinition,monObjet,self.niveau,maCommande) + widget=MonWidgetFactPlie(self,self.editor,parentQt,maDefinition,monObjet,self.niveau,maCommande,insertIn) else: from .monWidgetFact import MonWidgetFact - widget=MonWidgetFact(self,self.editor,parentQt,maDefinition,monObjet,self.niveau,maCommande) + widget=MonWidgetFact(self,self.editor,parentQt,maDefinition,monObjet,self.niveau,maCommande,insertIn) return widget diff --git a/InterfaceQT4/compomclist.py b/InterfaceQT4/compomclist.py index 3c15a674..8ae69573 100644 --- a/InterfaceQT4/compomclist.py +++ b/InterfaceQT4/compomclist.py @@ -36,7 +36,7 @@ class Node(browser.JDCNode,typeNode.PopUpMenuNodeMinimal): def createPopUpMenu(self): typeNode.PopUpMenuNodeMinimal.createPopUpMenu(self) - def getPanelGroupe(self,parentQt,commande): + def getPanelGroupe(self,parentQt,commande,insertIn=-1): maDefinition=self.item.get_definition() monObjet=self.item.object monNom=self.item.nom @@ -47,10 +47,10 @@ class Node(browser.JDCNode,typeNode.PopUpMenuNodeMinimal): if not (monObjet.isMCList()) : if hasattr(self,'plie') and self.plie==True : from .monWidgetFactPlie import MonWidgetFactPlie - widget=MonWidgetFactPlie(self,self.editor,parentQt,maDefinition,monObjet,self.niveau,maCommande) + widget=MonWidgetFactPlie(self,self.editor,parentQt,maDefinition,monObjet,self.niveau,maCommande,insertIn) else: from .monWidgetFact import MonWidgetFact - widget=MonWidgetFact(self,self.editor,parentQt,maDefinition,monObjet,self.niveau,maCommande) + widget=MonWidgetFact(self,self.editor,parentQt,maDefinition,monObjet,self.niveau,maCommande,insertIn) else : from .monWidgetBloc import MonWidgetBloc widget=MonWidgetBloc(self,self.editor,parentQt,maDefinition,monObjet,self.niveau,maCommande) diff --git a/InterfaceQT4/eficas_go.py b/InterfaceQT4/eficas_go.py index 8ca631a5..c0c1347c 100755 --- a/InterfaceQT4/eficas_go.py +++ b/InterfaceQT4/eficas_go.py @@ -51,7 +51,7 @@ def lance_eficas(code=None,fichier=None,ssCode=None,multi=False,langue='en'): from InterfaceQT4.qtEficas import Appli app = QApplication(sys.argv) - Eficas=Appli(code=code,ssCode=ssCode,multi=multi,langue=langue) + Eficas=Appli(code=code,salome=0,ssCode=ssCode,multi=multi,langue=langue) Eficas.show() res=app.exec_() diff --git a/InterfaceQT4/groupe.py b/InterfaceQT4/groupe.py index 097bf81d..b1c2c7c1 100644 --- a/InterfaceQT4/groupe.py +++ b/InterfaceQT4/groupe.py @@ -28,6 +28,7 @@ from Extensions.i18n import tr from .gereIcones import FacultatifOuOptionnel import Accas +import traceback # Import des panels @@ -104,13 +105,14 @@ class Groupe(QWidget,FacultatifOuOptionnel): def ajouteMCOptionnelDesBlocs(self): - #print ("Je passe dans ajouteMCOptionnelDesBlocs pour", self.node.item.nom) self.dictMCVenantDesBlocs={} i=0 self.calculOptionnel() liste=self.liste_mc for MC in self.liste_mc : self.dictMCVenantDesBlocs[MC]=self - while i < self.commandesLayout.count(): + # ce cas est le cas machine tournant sr le plie + try : + while i < self.commandesLayout.count(): from .monWidgetBloc import MonWidgetBloc widget=self.commandesLayout.itemAt(i).widget() i=i+1 @@ -121,6 +123,8 @@ class Groupe(QWidget,FacultatifOuOptionnel): if MC in self.dictMCVenantDesBlocs: print ("Pb Sur les MC" ) else : self.dictMCVenantDesBlocs[MC]=widget.dictMCVenantDesBlocs[MC] liste=liste+listeW + except : + pass return liste @@ -171,11 +175,118 @@ class Groupe(QWidget,FacultatifOuOptionnel): def Plie(self): self.node.setPlie() + if self.editor.code== 'MT' and (self.maCommande.obj.nom == "ZONE") : + #if (len(self.node.item.get_genealogie())==2): + index=self.maCommande.commandesLayout.indexOf(self) + self.maCommande.reafficheSeulement(self,index) + return + #else : + # self.reaffiche(self.node) + #return + #print ('je reaffiche dans Plie') self.reaffiche(self.node) def Deplie(self): self.node.setDeplie() + if self.editor.code== 'MT' and (self.maCommande.obj.nom == "ZONE") : + #if (len(self.node.item.get_genealogie())==2): + index=self.parentQt.commandesLayout.indexOf(self) + self.maCommande.reafficheSeulement(self,index) + return + #else : + # self.reaffiche(self.node) + #return + #print ('je reaffiche dans Plie') self.reaffiche(self.node) + + + #def Plie(self): + #print ('Deplie', self) + #print (self.obj.nom) + #print (self.node.setPlie) + #print (self.parentQt) + #print (self) + # self.node.setPlie() + #if self.editor.code== 'MT' and (self.maCommande.obj.nom == "ZONE") : + # itemAtraiter = self.node.item + # nodeAtraiter=self.node + #while (len(itemAtraiter.get_genealogie()) > 2 ): + # itemAtraiter=itemAtraiter.parent + # nodeAtraiter=nodeAtraiter.vraiParent + #ancien=nodeAtraiter.fenetre + #panneau = nodeAtraiter.getPanelGroupe(self,self.maCommande,insertIn=False) + #print (itemAtraiter,nodeAtraiter) + #self.parentQt.commandesLayout.replaceWidget(ancien,panneau,Qt.FindDirectChildrenOnly) + #nodeAtraiter.vraiParent.fenetre.commandesLayout.replaceWidget(ancien,panneau,Qt.FindDirectChildrenOnly) + #return + # if self.editor.code== 'MT' and (self.maCommande.obj.nom == "ZONE") : + # if (len(self.node.item.get_genealogie())==2): + #print (self) + #print (self.obj.nom) + #print (self.node.item.getlabeltext()) + #print (self.parentQt) + #print (self.editor.fenetreCentraleAffichee) + #print (self.maCommande) + # index=self.parentQt.commandesLayout.indexOf(self) + #print (index) + # self.maCommande.reafficheSeulement(self,index) + #self.disconnect() + #for c in self.children(): + # print (c) + # try : + # c.setParent(None) + # c.deleteLater() + # c.close() + # c.disconnect() + # except : + # print('poum') + #panneau = self.node.getPanelGroupe(self.parentQt,self.maCommande,insertIn=False) + # print (self.parentQt) + # print (self) + #self.parentQt.commandesLayout.replaceWidget(self,panneau,Qt.FindDirectChildrenOnly) + # self.parentQt.setUpdatesEnabled(True) + # print (dir(self.parentQt.commandesLayout)) + #self.parentQt.commandesLayout.updateGeometry() + # else : + # self.reaffiche(self.node) + # return + #print ('je reaffiche dans Plie') + # self.reaffiche(self.node) +# +# def Deplie(self): +# print ('Deplie', self) +# print (self.obj.nom) +# print (self.node.item.GetLabelText()) +# self.node.setDeplie() +# #if self.editor.code== 'MT' and (self.maCommande.obj.nom == "ZONE") and (len(self.node.item.get_genealogie())==2): +# #print (self.node.vraiParent.children) +# #if self.editor.code== 'MT' and (self.maCommande.obj.nom == "ZONE") : +# # itemAtraiter = self.node.item +# # nodeAtraiter=self.node +# # while (len(itemAtraiter.get_genealogie()) > 2 ): +# # itemAtraiter=itemAtraiter.parent +# # nodeAtraiter=nodeAtraiter.vraiParent +# # ancien=nodeAtraiter.fenetre +# # panneau = nodeAtraiter.getPanelGroupe(self,self.maCommande,insertIn=False) +# #print (itemAtraiter,nodeAtraiter) +# #self.parentQt.commandesLayout.replaceWidget(ancien,panneau,Qt.FindDirectChildrenOnly) +# # nodeAtraiter.vraiParent.fenetre.commandesLayout.replaceWidget(ancien,panneau,Qt.FindDirectChildrenOnly) +# # return +# if self.editor.code== 'MT' and (self.maCommande.obj.nom == "ZONE") : +# if (len(self.node.item.get_genealogie())==2): +# #panneau = self.node.getPanelGroupe(self.parentQt,self.maCommande,insertIn=False) +# #self.parentQt.commandesLayout.replaceWidget(self,panneau,Qt.FindDirectChildrenOnly) +# #index=self.parentQt.commandesLayout.indexOf(self) +# #index=self.maCommande.commandesLayout.indexOf(self) +# #print ('index = ', index) +# index=0 +# self.maCommande.reafficheSeulement(self,index) +# else : +# self.reaffiche(self.node) +# return +# +# #print ('je reaffiche') +# self.reaffiche(self.node) def traiteClicSurLabel(self,texte): if self.editor.code != "CARMELCND" : self.afficheOptionnel() diff --git a/InterfaceQT4/monWidgetCommande.py b/InterfaceQT4/monWidgetCommande.py index 0543e61a..ad2adae3 100644 --- a/InterfaceQT4/monWidgetCommande.py +++ b/InterfaceQT4/monWidgetCommande.py @@ -32,6 +32,8 @@ from .gereIcones import FacultatifOuOptionnel from PyQt5.QtWidgets import QApplication, QWidget, QSpacerItem, QSizePolicy from PyQt5.QtGui import QFont, QIcon from PyQt5.QtCore import QTimer +from PyQt5.QtCore import Qt + from Extensions.i18n import tr @@ -246,6 +248,18 @@ class MonWidgetCommande(Ui_WidgetCommande,Groupe): else : self.recentre() self.inhibeExpand=False + def reafficheSeulement(self,nodeAReafficher,index): + #print ('ds reafficheSeulement', nodeAReafficher) + parentNodeAReafficher=nodeAReafficher.parentQt + index=parentNodeAReafficher.commandesLayout.indexOf(nodeAReafficher) + oldFenetre=nodeAReafficher.node.fenetre + newWidget=nodeAReafficher.node.getPanelGroupe(parentNodeAReafficher,self,index) + nodeAReafficher.node.fenetre=newWidget + oldFenetre.setParent(None) + oldFenetre.close() + oldFenetre.deleteLater() + #print ("fin pour " , self.node.item.nom) + def recentre(self): QApplication.processEvents() diff --git a/InterfaceQT4/monWidgetFact.py b/InterfaceQT4/monWidgetFact.py index b3cae42a..609d0dff 100644 --- a/InterfaceQT4/monWidgetFact.py +++ b/InterfaceQT4/monWidgetFact.py @@ -33,13 +33,14 @@ from Extensions.i18n import tr class MonWidgetFactCommun(Groupe): """ """ - def __init__(self,node,editor,parentQt,definition, obj, niveau,commande): + def __init__(self,node,editor,parentQt,definition, obj, niveau,commande,insertIn=-1): #print "fact : ",node.item.nom Groupe.__init__(self,node,editor,parentQt, definition,obj,niveau,commande) labeltext,fonte,couleur = self.node.item.GetLabelText() self.GroupBox.setText(tr(labeltext)) self.GroupBox.setTextInteractionFlags(Qt.TextSelectableByMouse) - self.parentQt.commandesLayout.insertWidget(-1,self) + self.parentQt.commandesLayout.insertWidget(insertIn,self) + #else : self.parentQt.commandesLayout.insertWidget(0,self) self.doitAfficherOptionnel=False def enterEvent(self,event): @@ -58,8 +59,8 @@ class MonWidgetFactCommun(Groupe): if self.doitAfficherOptionnel and self.editor.code != "CARMELCND" :self.afficheOptionnel() class MonWidgetFact(Ui_WidgetFact,MonWidgetFactCommun): - def __init__(self,node,editor,parentQt,definition, obj, niveau,commande): - MonWidgetFactCommun.__init__(self,node,editor,parentQt, definition,obj,niveau,commande) + def __init__(self,node,editor,parentQt,definition, obj, niveau,commande,insertIn=True): + MonWidgetFactCommun.__init__(self,node,editor,parentQt, definition,obj,niveau,commande,insertIn) #class MonWidgetFactHorizontal(Ui_WidgetFactHorizon,MonWidgetFactCommun): # def __init__(self,node,editor,parentQt,definition, obj, niveau,commande): diff --git a/InterfaceQT4/monWidgetFactPlie.py b/InterfaceQT4/monWidgetFactPlie.py index 5a47a2e3..c0836c42 100644 --- a/InterfaceQT4/monWidgetFactPlie.py +++ b/InterfaceQT4/monWidgetFactPlie.py @@ -28,11 +28,11 @@ from Extensions.i18n import tr class MonWidgetFactPlie(Ui_WidgetFactPlie,Groupe): """ """ - def __init__(self,node,editor,parentQt,definition, obj, niveau,commande): + def __init__(self,node,editor,parentQt,definition, obj, niveau,commande,insertIn=-1): #print "fact plie : ",node.item.nom Groupe.__init__(self,node,editor,parentQt, definition,obj,niveau,commande) self.groupBox.setText(self.node.item.GetLabelText()[0]) - self.parentQt.commandesLayout.insertWidget(-1,self) + self.parentQt.commandesLayout.insertWidget(insertIn,self) def traiteClicSurLabel(self,texte): return -- 2.39.2