]> SALOME platform Git repositories - modules/adao.git/commitdiff
Salome HOME
Correcting StudyId stuffs
authorJean-Philippe ARGAUD <jean-philippe.argaud@edf.fr>
Fri, 14 Sep 2018 15:55:23 +0000 (17:55 +0200)
committerJean-Philippe ARGAUD <jean-philippe.argaud@edf.fr>
Fri, 14 Sep 2018 15:55:23 +0000 (17:55 +0200)
src/daEficas/configuration_ADAO.py
src/daSalome/daGUI/ADAOGUI.py
src/daSalome/daGUI/daGuiImpl/ADAOGUI_impl.py
src/daSalome/daGUI/daGuiImpl/adaoGuiHelper.py
src/daSalome/daGUI/daGuiImpl/adaoGuiManager.py
src/daSalome/daGUI/daGuiImpl/adaoModuleHelper.py
src/daSalome/daGUI/daGuiImpl/adaoStudyEditor.py

index b98df048422b6f8959ccc2d56593d82b95afdbec..9e5f5c21bac007df6644c2f9a00cdae3290dcda4 100644 (file)
@@ -36,13 +36,14 @@ from InterfaceQT4 import configuration
 
 # Classe de base permettant de lire, afficher
 # et sauvegarder les fichiers utilisateurs
-class CONFIG(configuration.configBase):
+class CONFIG(configuration.configBase): # configuration.CONFIG_BASE):
 
   def __init__(self,appli,repIni):
 
     # self.labels_eficas = ['lang']
     self.labels_eficas = ['lang','rep_cata','catalogues','closeAutreCommande','closeFrameRechercheCommande','closeEntete','taille']
     configuration.configBase.__init__(self,appli,repIni)
+    #~ configuration.CONFIG_BASE.__init__(self,appli,repIni)
 
     self.rep_user         = os.environ["HOME"]
     self.appli            = appli
index 98736ff7108192beefaeb1b74fcd301153bd7468..9206640eb4289905b75ad291e61b1e310a937210 100644 (file)
@@ -74,9 +74,9 @@ def deactivate():
 
 # called when active study is changed
 # active study ID is passed as parameter
-def activeStudyChanged( studyID ):
-  adaoLogger.debug("activeStudyChanged")
-  GuiImpl.activeStudyChanged( studyID )
+#~ def activeStudyChanged( studyID ):
+  #~ adaoLogger.debug("activeStudyChanged")
+  #~ GuiImpl.activeStudyChanged( studyID )
 
 # called when popup menu is invoked
 # popup menu and menu context are passed as parameters
index 141f1a96a2ac275ee77f1ee6121d0de4b90911f2..4b6a199ec352c77491379076558f6cd8c67faa2b 100644 (file)
@@ -46,16 +46,17 @@ class GUIcontext:
     def __init__(self):
         self.adaoCaseManager = AdaoCaseManager()
 
-__study2context__   = {}
-__current_context__ = None
-def _setContext( studyID ):
-    global __study2context__, __current_context__
-    QApplication.processEvents()
-    if studyID not in __study2context__:
-        __study2context__[studyID] = GUIcontext()
-        pass
-    __current_context__ = __study2context__[studyID]
-    return __current_context__
+#~ __study2context__   = {}
+#~ __current_context__ = None
+__current_context__ = GUIcontext()
+#~ def _setContext( studyID ):
+    #~ global __study2context__, __current_context__
+    #~ QApplication.processEvents()
+    #~ if studyID not in __study2context__:
+        #~ __study2context__[studyID] = GUIcontext()
+        #~ pass
+    #~ __current_context__ = __study2context__[studyID]
+    #~ return __current_context__
 
 # This object does not need to be embedded in a GUI context object. A single
 # instance for all studies is a priori sufficient.
@@ -91,36 +92,45 @@ def createPreferences():
 # called when module is activated
 # returns True if activating is successfull and False otherwise
 def activate():
-    ctx = _setContext( sgPyQt.getStudyId() )
+    #~ ctx = _setContext( sgPyQt.getStudyId() )
+    global __current_context__ ; ctx = __current_context__
+    QApplication.processEvents()
     ctx.adaoCaseManager.activate()
     return True
 
 # called when module is deactivated
 def deactivate():
-    ctx = _setContext( sgPyQt.getStudyId() )
+    #~ ctx = _setContext( sgPyQt.getStudyId() )
+    global __current_context__ ; ctx = __current_context__
+    QApplication.processEvents()
     ctx.adaoCaseManager.deactivate()
 
 # called when active study is changed
 # active study ID is passed as parameter
-def activeStudyChanged( studyID ):
-    ctx = _setContext( sgPyQt.getStudyId() )
+def activeStudyChanged(): # studyID ):
+    #~ ctx = _setContext( sgPyQt.getStudyId() )
+    QApplication.processEvents()
 
 # called when popup menu is invoked
 # popup menu and menu context are passed as parameters
 def createPopupMenu( popup, context ):
-  activeStudyId = sgPyQt.getStudyId()
-  ctx = _setContext(sgPyQt.getStudyId())
-  selcount, selected = adaoGuiHelper.getAllSelected(activeStudyId)
+  #~ activeStudyId = sgPyQt.getStudyId()
+  #~ ctx = _setContext(sgPyQt.getStudyId())
+  global __current_context__ ; ctx = __current_context__
+  QApplication.processEvents()
+  selcount, selected = adaoGuiHelper.getAllSelected()# activeStudyId)
   if selcount == 1:
-    selectedItem = adaoGuiHelper.getSelectedItem(activeStudyId)
-    popup = ctx.adaoCaseManager.salome_manager.createPopupMenuOnItem(popup, activeStudyId, selectedItem)
+    selectedItem = adaoGuiHelper.getSelectedItem()# activeStudyId)
+    popup = ctx.adaoCaseManager.salome_manager.createPopupMenuOnItem(popup, selectedItem) # activeStudyId, selectedItem)
 
 def OnGUIEvent(actionId) :
     """
     Called when an event is raised from a graphic item (click on menu item or
     toolbar button). The actionId value is the ID associated to the item.
     """
-    ctx = _setContext( sgPyQt.getStudyId() )
+    #~ ctx = _setContext( sgPyQt.getStudyId() )
+    global __current_context__ ; ctx = __current_context__
+    QApplication.processEvents()
     ctx.adaoCaseManager.processGUIEvent(actionId)
 
 # called when module's preferences are changed
index 81f967690622715a25e72f3af1fb9bbcf56c7248..ed91e7a803a7695b4fe68b7526eaa57e0744e262 100644 (file)
@@ -49,12 +49,12 @@ def gui_information(parent, msg="Information" ):
     """
     QMessageBox.information( parent, "Information", msg, QMessageBox.Close)
 
-def getActiveStudyId():
-    """
-    This function returns the id of the active study. The concept of active study
-    makes sens only in the GUI context.
-    """
-    return salome.sg.getActiveStudyId()
+#~ def getActiveStudyId():
+    #~ """
+    #~ This function returns the id of the active study. The concept of active study
+    #~ makes sens only in the GUI context.
+    #~ """
+    #~ return salome.sg.getActiveStudyId()
 
 def refreshObjectBrowser():
     """
@@ -62,14 +62,15 @@ def refreshObjectBrowser():
     GUI is working.
     """
     if salome.sg is not None:
-        salome.sg.updateObjBrowser(0)
+        # salome.sg.updateObjBrowser(0)
+        salome.sg.updateObjBrowser()
 
 def selectItem(salomeStudyItem):
   if salome.sg is not None:
     salome.sg.ClearIObjects()
     salome.sg.AddIObject(salomeStudyItem)
 
-def getSelectedItem(salomeStudyId=-100):
+def getSelectedItem():# salomeStudyId=-100):
     """
     Get the current selection. If more than one item are selected, the
     only first is considered. The object is return (not the id).
@@ -78,8 +79,8 @@ def getSelectedItem(salomeStudyId=-100):
     if salome.sg is None:
         raise Exception("GuiHelper.getSelectedItem can't be used without the GUI context")
 
-    if salomeStudyId != -100:
-      studyEditor = salome.kernel.studyedit.getStudyEditor(salomeStudyId)
+    #~ if salomeStudyId != -100:
+      #~ studyEditor = salome.kernel.studyedit.getStudyEditor(salomeStudyId)
     studyEditor = salome.kernel.studyedit.getStudyEditor()
     item = None
     listEntries=salome.sg.getAllSelected()
@@ -88,18 +89,18 @@ def getSelectedItem(salomeStudyId=-100):
         item = studyEditor.study.FindObjectID( entry )
     return item
 
-def getAllSelected(salomeStudyId):
+def getAllSelected():# salomeStudyId):
     """
     Returns all selected items in the specified study.
     """
     if salome.sg is None:
         raise OmaException("getSelectedItem can't be used without the GUI context", OmaException.TYPES.DEVEL)
 
-    study = adaoModuleHelper.getStudyManager().GetStudyByID( salomeStudyId )
+    study = adaoModuleHelper.getStudyManager().GetStudyByID( salomeStudyId )
     selcount = salome.sg.SelectedCount()
     seltypes = {}
     for i in range( selcount ):
-        __incObjToMap( seltypes, adaoModuleHelper.getObjectID( study, salome.sg.getSelected( i ) ) )
+        __incObjToMap( seltypes, adaoModuleHelper.getObjectID( salome.sg.getSelected( i ) ) ) # study, salome.sg.getSelected( i ) ) )
         pass
     return selcount, seltypes
 
index 2ca98519852b7e3b23b5b33dac9eb5e660034b09..5dbb739d4b9eadde6e31cc351286bba7c40af953 100644 (file)
@@ -194,13 +194,13 @@ class AdaoCaseManager(EficasObserver):
   def _processEficasNewEvent(self, eficasWrapper, eficasEvent):
     adao_case = eficasEvent.callbackId
     # Ajout dand l'etude
-    salomeStudyId   = adaoGuiHelper.getActiveStudyId()
-    salomeStudyItem = adaoStudyEditor.addInStudy(salomeStudyId, adao_case)
+    #~ salomeStudyId   = adaoGuiHelper.getActiveStudyId()
+    salomeStudyItem = adaoStudyEditor.addInStudy( adao_case ) # salomeStudyId, adao_case)
     # Affichage correct dans l'etude
     adaoGuiHelper.refreshObjectBrowser()
     adaoGuiHelper.selectItem(salomeStudyItem.GetID())
     # Finalisation des donnees du cas
-    adao_case.salome_study_id   = salomeStudyId
+    #~ adao_case.salome_study_id   = salomeStudyId
     adao_case.salome_study_item = salomeStudyItem
     # Ajout du cas
     self.cases[adao_case.eficas_editor] = adao_case
@@ -260,7 +260,7 @@ class AdaoCaseManager(EficasObserver):
   def _processEficasSaveEvent(self, eficasWrapper, eficasEvent):
     adao_case = eficasEvent.callbackId
     # On met a jour l'etude
-    adaoStudyEditor.updateItem(adao_case.salome_study_id, adao_case.salome_study_item, adao_case)
+    adaoStudyEditor.updateItem(adao_case.salome_study_item, adao_case) # adao_case.salome_study_id, adao_case.salome_study_item, adao_case)
     # Affichage correct dans l'etude
     adaoGuiHelper.refreshObjectBrowser()
     adaoGuiHelper.selectItem(adao_case.salome_study_item.GetID())
@@ -294,7 +294,7 @@ class AdaoCaseManager(EficasObserver):
     # Recuperation du cas
     adao_case = self.cases[editor]
     # Suppression de l'objet dans l'etude
-    adaoStudyEditor.removeItem(adao_case.salome_study_id, adao_case.salome_study_item)
+    adaoStudyEditor.removeItem(adao_case.salome_study_item) # adao_case.salome_study_id, adao_case.salome_study_item)
     # Suppression du cas
     self.cases.pop(editor)
     # Refresh GUI -> appelle currentSelectionChanged()
@@ -448,8 +448,8 @@ class AdaoGuiUiComponentBuilder:
         a = sgPyQt.createAction( UI_ELT_IDS.CLOSE_ADAOCASE_ID, "Close case", "Close case", "Close the selected case", "" )
         a = sgPyQt.createAction( UI_ELT_IDS.YACS_EXPORT_ID, "Export to YACS", "Export to YACS", "Generate a YACS graph executing this case", "" )
 
-    def createPopupMenuOnItem(self,popup,salomeSudyId, item):
-        if adaoStudyEditor.isValidAdaoCaseItem(salomeSudyId, item):
+    def createPopupMenuOnItem(self,popup,item): # salomeSudyId, item):
+        if adaoStudyEditor.isValidAdaoCaseItem(item): # Attention : appel ancien avec un coquille (StudyId) : (salomeSudyId, item):
           popup.addAction( sgPyQt.action( UI_ELT_IDS.CLOSE_ADAOCASE_ID ) )
           popup.addAction( sgPyQt.action( UI_ELT_IDS.YACS_EXPORT_ID ) )
         return popup
index 97b7caf6418a7b0f0ed619cce69d901d45b10615..feb76d7b1ede63667b5e363a91c27d4b53323616 100644 (file)
@@ -43,6 +43,7 @@ from SALOME_NamingServicePy import SALOME_NamingServicePy_i
 from LifeCycleCORBA import LifeCycleCORBA
 import SALOMEDS
 import SALOMEDS_Attributes_idl
+from salome.kernel.studyedit import getStudyEditor
 
 #import OMA_ORB
 
@@ -206,10 +207,10 @@ def findOrCreateComponent( study ):
 ###
 # Get object's ID
 ###
-def getObjectID( study, entry ):
+def getObjectID( entry ): # study, entry ):
     ID = unknownID()
-    if study and entry:
-        sobj = study.FindObjectID( entry )
+    if entry: # study and entry:
+        sobj = getStudyEditor().study.FindObjectID( entry )
         if sobj is not None:
             test, anAttr = sobj.FindAttribute( "AttributeLocalID" )
             if test: ID = anAttr._narrow( SALOMEDS.AttributeLocalID ).Value()
index 07c18de0e399eb02ef660b3991b55267c1f74b83..e1d1d8ea2bf178ba36b8e6353008944a107653dd 100644 (file)
@@ -49,14 +49,14 @@ ADAO_ITEM_TYPES = Enumerate([
 #   a SComponent is a reference in a study toward a SALOME component
 #
 
-def addInStudy(salomeStudyId, adaoCase):
+def addInStudy(adaoCase): # salomeStudyId, adaoCase):
     """
     This function adds in the specified SALOME study a study entry that corresponds
     to the specified adao case. This study case is put in a folder under
     the ADAO component and is identified by the case name.
     """
 
-    studyEditor = studyedit.getStudyEditor(salomeStudyId)
+    studyEditor = studyedit.getStudyEditor() # salomeStudyId)
 
     adaoRootEntry = studyEditor.findOrCreateComponent(
         moduleName    = adaoModuleHelper.componentName(),
@@ -79,9 +79,9 @@ def addInStudy(salomeStudyId, adaoCase):
 
     return salomeStudyItem
 
-def updateItem(salomeStudyId, salomeStudyItem, adaoCase):
+def updateItem(salomeStudyItem, adaoCase): # salomeStudyId, salomeStudyItem, adaoCase):
 
-    studyEditor = studyedit.getStudyEditor(salomeStudyId)
+    studyEditor = studyedit.getStudyEditor() # salomeStudyId)
 
     if salomeStudyItem.GetName()[:-2] != adaoCase.name:
       itemName  = adaoCase.name
@@ -99,22 +99,22 @@ def updateItem(salomeStudyId, salomeStudyItem, adaoCase):
         comment = itemValue,
         icon    = icon)
 
-def removeItem(salomeStudyId, item):
+def removeItem(item): # salomeStudyId, item):
     """
     Remove the item from the specified study.
     """
-    studyEditor = studyedit.getStudyEditor(salomeStudyId)
+    studyEditor = studyedit.getStudyEditor() # salomeStudyId)
     return studyEditor.removeItem(item,True)
 
 
-def isValidAdaoCaseItem(salomeStudyId,item):
+def isValidAdaoCaseItem(item): # salomeStudyId,item):
     """
     Return true if the specified item corresponds to a valid adaoCase
     """
     if item is None:
         return False
 
-    studyEditor = studyedit.getStudyEditor(salomeStudyId)
+    studyEditor = studyedit.getStudyEditor() # salomeStudyId)
     itemType = studyEditor.getTypeId(item)
     if itemType != ADAO_ITEM_TYPES.ADAO_CASE:
         return False