Salome HOME
Résolution du bug roundup n°32 (multi-études) TEST_MULTI_STUDIES
authorsalome <>
Wed, 22 Jun 2005 18:50:13 +0000 (18:50 +0000)
committersalome <>
Wed, 22 Jun 2005 18:50:13 +0000 (18:50 +0000)
src/EFICASGUI/EFICASGUI.py
src/EFICASGUI/dataEficas.py
src/EFICASGUI/eficasEtude.py
src/EFICASGUI/eficasSalome.py
src/EFICASGUI/salomedsgui.py

index 2e1238125cd5fcb0b598af87113e8457f51b698e..aa607ebe5fefa78213e9fac9fffdff692218862f 100644 (file)
@@ -8,7 +8,7 @@ import SalomePyQt
 # Variable globale pour stocker le Workspace de Salome
 
 WORKSPACE=None
-studyId=None
+currentStudyId=None
 
 # -----------------------------------------------------------------------------
 
@@ -65,19 +65,26 @@ def OnGUIEvent(commandID) :
 # -----------------------------------------------------------------------------
 
 def setSettings():
-   print "setSettings"
-   print sgPyQt.getStudyId()
+   """
+   Cette méthode permet les initialisations. On définit en particulier
+   l'identifiant de l'étude courante.
+   """
+   global currentStudyId
+   currentStudyId = sgPyQt.getStudyId()
+   print "setSettings: currentStudyId = " + str(currentStudyId)
+   # _CS_gbo_ Voir si on peut utiliser directement sgPyQt.getStudyId()
+   # dans salomedsgui?
+
 
 # -----------------------------------------------------------------------------
 
 def activeStudyChanged(ID):
-   global studyId
+   global currentStudyId
    # ne marche pas car sg est supposé résider dans une etude
    # studyId=sg.getActiveStudyId()
-   studyId=ID
-   print "studyId: ",sg.getActiveStudyId()
-   print "On a changé d'étude active",studyId
-   print sgPyQt.getStudyId()
+   currentStudyId=ID
+   print "_CS_GBO_ : EFICASGUI.activeStudyChanged : currentStudyId = ", currentStudyId
+   print "_CS_GBO_ : EFICASGUI.activeStudyChanged : sgPyQt.getStudyId() = ", sgPyQt.getStudyId()
 
 def definePopup(theContext, theObject, theParent):
    print "EFICASGUI --- definePopup"
@@ -102,8 +109,7 @@ def customPopup(popup, theContext, theObject, theParent):
 import eficasSalome
 
 def runEficas(ws):
-   print "runEficas"
-   eficasSalome.runEficas(ws,"ASTER")
+   eficasSalome.runEficas(ws,"ASTER",studyId=currentStudyId)
    
 def runEficaspourHomard(ws):
    print "runEficas"
@@ -114,18 +120,24 @@ def runEficasHomard(ws):
    eficasSalome.runEficas(None,"HOMARD")
 
 def runEficasFichier(ws):
+   """
+   Lancement d'eficas à partir d'un fichier sélectionné dans l'arbre
+   d'étude. 
+   """
    print "runEficasFichier"
    attr=None
    code="ASTER"
    a=salome.sg.getAllSelected()
    if len(a) == 1:
+      aGuiDS.setCurrentStudy(currentStudyId)
       boo,attr=aGuiDS.getExternalFileAttribute("FICHIER_EFICAS_ASTER",a[0])
       if boo :
          code = "ASTER" 
       else :
          boo,attr=aGuiDS.getExternalFileAttribute("FICHIER_EFICAS_HOMARD",a[0])
         code = "HOMARD"
-   eficasSalome.runEficas(ws,code,attr)
+   
+   eficasSalome.runEficas(ws,code,attr,studyId=currentStudyId)
 
 # Partie applicative
 
index 516552c7c9a893425ebb8b5b0b68929f033ba16d..a4a7bbace4dd3e2e4b3932f341e5beabea139591 100644 (file)
@@ -16,15 +16,17 @@ import sys
 #import import_code
 from Editeur import splash
 from Editeur import eficas
-from Editeur import session
 
+# _CS_gbo Mise en commentaire en attendant eficas 1.8
+#from Editeur import session
 
-def init(top,code="ASTER",fichier=None):
+
+def init(top,code="ASTER",fichier=None,studyId=None):
     splash.init_splash(top,code=code,titre="Lancement d'EFICAS pour %s" %code)
     splash._splash.configure(text="Chargement d'EFICAS en cours.\n Veuillez patienter ...")
     # Enregistrement dans l étude
     import eficasEtude
-    MaRef=eficasEtude.Eficas_In_Study(code)
+    MaRef=eficasEtude.Eficas_In_Study(code,studyId=studyId)
 
     #import eficas
     class MyEficas(eficas.EFICAS):
@@ -35,9 +37,11 @@ def init(top,code="ASTER",fichier=None):
         def contexte(self):
             self.salome=MaRef
 
-    if fichier != None :
-       options=session.parse(sys.argv+[fichier])
-    else :
-       options=session.parse(sys.argv)
+    # _CS_gbo Mise en commentaire en attendant eficas 1.8
+    # if fichier != None :
+    #  options=session.parse(sys.argv+[fichier])
+    #else :
+    #  options=session.parse(sys.argv)
+    
     moi=MyEficas(top,code=code)
     moi.contexte()
index b8ad89c65a1c9285f2251a2e36cc90633abb93ab..fa2f8b6992ad9de11dd89ae6873a5116fff8594b 100644 (file)
@@ -4,7 +4,7 @@
 # Author    : Pascale NOYRET, EDF
 # Project   : SALOME
 # Copyright : EDF 2003
-#  $Header: /home/salome/PlateFormePAL/Bases_CVS_EDF/Modules_EDF/EFICAS_SRC/src/EFICASGUI/eficasEtude.py,v 1.2 2005/01/06 11:12:12 salome Exp $
+#  $Header: /home/salome/PlateFormePAL/Bases_CVS_EDF/Modules_EDF/EFICAS_SRC/src/EFICASGUI/eficasEtude.py,v 1.3 2005/06/03 07:25:24 salome Exp $
 #=============================================================================
 
 import salome
@@ -18,25 +18,31 @@ aGuiDS=salomedsgui.guiDS()
 
 class Eficas_In_Study:
 
-      def __init__(self,code):
+      def __init__(self,code,studyId=None):
+          print "#######################################################"
+          print "#######################################################"
+          print "#######################################################"
+          print "_CS_GBO_ : Eficas_In_Study:init: studyId = ", studyId
+          print "#######################################################"
+          print "#######################################################"        
           import SMESH_utils
+          self.aGuiDS=salomedsgui.guiDS(studyId=studyId)
           self.enregistre()
          self.code=code
           self.liste_deja_la=[]
           
       def  enregistre(self):
-           self.fatherId=aGuiDS.enregistre("Eficas")
+           self.fatherId=self.aGuiDS.enregistre("Eficas")
            salome.sg.updateObjBrowser(0)
 
-      def  rangeInStudy(self,fichier, suf=""):
+      def rangeInStudy(self,fichier, suf=""):
           if fichier not in self.liste_deja_la :
                self.liste_deja_la.append(fichier)
                 Nom=re.split("/",fichier)[-1]
 
-
-                self.commId=aGuiDS.createItemInStudy(self.fatherId,Nom)
+                self.commId=self.aGuiDS.createItemInStudy(self.fatherId,Nom)
                if self.commId != None:
-                   aGuiDS.setExternalFileAttribute(self.commId,"FICHIER_EFICAS_"+self.code+suf,fichier)
+                   self.aGuiDS.setExternalFileAttribute(self.commId,"FICHIER_EFICAS_"+self.code+suf,fichier)
                    salome.sg.updateObjBrowser(0)
 
       def creeConfigTxt(self,fichier,dico):
index d0c5650a1cc9acdb3d9b96987f94c9ca8a83620c..c30d1259415ea8b669274dccc068a1d67bdcdbf6 100644 (file)
@@ -19,17 +19,13 @@ root=Tkinter.Tk()
 root.withdraw()
 
 
-def runEficas(ws,code="ASTER",fichier=None):
+def runEficas(ws,code="ASTER",fichier=None,studyId=None):
     global initialised
     if not initialised:
         t=Tkinter.Toplevel()
         t.withdraw()
-        print t.geometry()
-        print t.winfo_geometry()
-        import dataEficas; dataEficas.init(t,code,fichier)
+        import dataEficas; dataEficas.init(t,code,fichier,studyId=studyId)
         t.update()
-        print t.geometry()
-        print t.winfo_geometry()
         t.deiconify()
         t.update()
 
index 7f2cd697eed7e68b4f58cca5f261a9753b22b3da..2cd5d3481b11aba6d050f0a8a41f7021f994f24d 100644 (file)
@@ -39,9 +39,21 @@ class guiDS:
     _father = None
     _component = None
 
-    def __init__(self):
+    def __init__(self,studyId=None):
         self._myStudyManager = salome.myStudyManager
-        self._myStudy = salome.myStudy
+        # Par défaut les réferences à l'étude sont celles fournies par
+        # le module salome.
+        if studyId is None:
+            self._myStudy = salome.myStudy
+            self._myBuilder = self._myStudy.NewBuilder()
+        else:
+            self.setCurrentStudy(studyId)
+
+    def setCurrentStudy(self,studyId):
+        """
+        Définit les références à l'étude et son builder associé
+        """
+        self._myStudy = self._myStudyManager.GetStudyByID(studyId)
         self._myBuilder = self._myStudy.NewBuilder()
 
     def enregistre(self,myModule):