Salome HOME
les accents
[tools/eficas.git] / InterfaceQT4 / groupe.py
index d70b59436f09bd4ffdb3aa2cb5f5b0d919feb998..5c0a0cbd3727afbecb12a43ec574fb31c22855a3 100644 (file)
@@ -1,4 +1,4 @@
-# Copyright (C) 2007-2013   EDF R&D
+# Copyright (C) 2007-2017   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
 # Modules Python
 # Modules Eficas
 
-from determine import monEnvQT5
-if monEnvQT5:
-   from PyQt5.QtWidgets import QWidget
-   from PyQt5.QtCore import Qt
-else :
-   from PyQt4.QtGui import *
-   from PyQt4.QtCore import *
-from Extensions.i18n import tr
+from __future__ import absolute_import
+from __future__ import print_function
+from PyQt5.QtWidgets import QWidget
+from PyQt5.QtCore import Qt
 
 from Extensions.i18n import tr
-from gereIcones import FacultatifOuOptionnel
+
+from .gereIcones import FacultatifOuOptionnel
 import Accas 
+import traceback
 
     
 # Import des panels
@@ -62,12 +60,9 @@ class Groupe(QWidget,FacultatifOuOptionnel):
       self.afficheMots()
       self.listeMCAAjouter=[]
       self.dictMCVenantDesBlocs={}
-      if hasattr(self,'RBDeplie') and not monEnvQT5 : self.connect(self.RBDeplie,SIGNAL("clicked()"), self.Deplie)
-      if hasattr(self,'RBPlie')  and not monEnvQT5: self.connect(self.RBPlie,SIGNAL("clicked()"), self.Plie)
-      if hasattr(self,'RBDeplie')  and monEnvQT5: self.RBDeplie.clicked.connect(self.Deplie)
-      if hasattr(self,'RBPlie')  and monEnvQT5: self.RBPlie.clicked.connect( self.Plie)
+      if hasattr(self,'RBDeplie')  : self.RBDeplie.clicked.connect(self.Deplie)
+      if hasattr(self,'RBPlie')    : self.RBPlie.clicked.connect( self.Plie)
       self.setAcceptDrops(True)
-      #self.donneFocus()
      
   def donneFocus(self):
       for fenetre in self.listeFocus:
@@ -110,23 +105,26 @@ 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():
-          from monWidgetBloc import MonWidgetBloc
+      # 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
           if not(isinstance(widget,MonWidgetBloc)) : continue
           widget.calculOptionnel()
           listeW=widget.ajouteMCOptionnelDesBlocs() 
-          for MC in widget.dictMCVenantDesBlocs.keys():
-              if MC in self.dictMCVenantDesBlocs.keys(): print "Pb Sur les MC" 
+          for MC in widget.dictMCVenantDesBlocs:
+              if MC in self.dictMCVenantDesBlocs: print ("Pb Sur les MC" )
               else : self.dictMCVenantDesBlocs[MC]=widget.dictMCVenantDesBlocs[MC]
           liste=liste+listeW
+      except : 
+        pass
       return liste
 
 
@@ -159,7 +157,7 @@ class Groupe(QWidget,FacultatifOuOptionnel):
       listeNom=texteListeNom.split("+")[1:]
       firstNode=None
       for nom in listeNom:
-        if nom not in self.dictMCVenantDesBlocs.keys():
+        if nom not in self.dictMCVenantDesBlocs:
            #print "bizarre, bizarre"
            self.editor.init_modif()
            nouveau=self.node.append_child(nom)
@@ -177,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()