From: Jean-Philippe ARGAUD Date: Fri, 14 Sep 2018 15:55:23 +0000 (+0200) Subject: Correcting StudyId stuffs X-Git-Tag: V9_2_0b_ok_ADAO~9 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=365760bd908aa2caa5e4305458e38b7909eabc54;p=modules%2Fadao.git Correcting StudyId stuffs --- diff --git a/src/daEficas/configuration_ADAO.py b/src/daEficas/configuration_ADAO.py index b98df04..9e5f5c2 100644 --- a/src/daEficas/configuration_ADAO.py +++ b/src/daEficas/configuration_ADAO.py @@ -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 diff --git a/src/daSalome/daGUI/ADAOGUI.py b/src/daSalome/daGUI/ADAOGUI.py index 98736ff..9206640 100644 --- a/src/daSalome/daGUI/ADAOGUI.py +++ b/src/daSalome/daGUI/ADAOGUI.py @@ -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 diff --git a/src/daSalome/daGUI/daGuiImpl/ADAOGUI_impl.py b/src/daSalome/daGUI/daGuiImpl/ADAOGUI_impl.py index 141f1a9..4b6a199 100644 --- a/src/daSalome/daGUI/daGuiImpl/ADAOGUI_impl.py +++ b/src/daSalome/daGUI/daGuiImpl/ADAOGUI_impl.py @@ -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 diff --git a/src/daSalome/daGUI/daGuiImpl/adaoGuiHelper.py b/src/daSalome/daGUI/daGuiImpl/adaoGuiHelper.py index 81f9676..ed91e7a 100644 --- a/src/daSalome/daGUI/daGuiImpl/adaoGuiHelper.py +++ b/src/daSalome/daGUI/daGuiImpl/adaoGuiHelper.py @@ -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 diff --git a/src/daSalome/daGUI/daGuiImpl/adaoGuiManager.py b/src/daSalome/daGUI/daGuiImpl/adaoGuiManager.py index 2ca9851..5dbb739 100644 --- a/src/daSalome/daGUI/daGuiImpl/adaoGuiManager.py +++ b/src/daSalome/daGUI/daGuiImpl/adaoGuiManager.py @@ -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 diff --git a/src/daSalome/daGUI/daGuiImpl/adaoModuleHelper.py b/src/daSalome/daGUI/daGuiImpl/adaoModuleHelper.py index 97b7caf..feb76d7 100644 --- a/src/daSalome/daGUI/daGuiImpl/adaoModuleHelper.py +++ b/src/daSalome/daGUI/daGuiImpl/adaoModuleHelper.py @@ -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() diff --git a/src/daSalome/daGUI/daGuiImpl/adaoStudyEditor.py b/src/daSalome/daGUI/daGuiImpl/adaoStudyEditor.py index 07c18de..e1d1d8e 100644 --- a/src/daSalome/daGUI/daGuiImpl/adaoStudyEditor.py +++ b/src/daSalome/daGUI/daGuiImpl/adaoStudyEditor.py @@ -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