From: André Ribes Date: Wed, 16 Feb 2011 15:50:40 +0000 (+0100) Subject: Ajout des boutons save et close, travaux en cours X-Git-Tag: V6_4_0rc3~91 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=13c15fdbcf19a34489c2193f52f184d8b8944170;p=modules%2Fadao.git Ajout des boutons save et close, travaux en cours --- diff --git a/src/daSalome/daGUI/daEficasWrapper/adaoEficasWrapper.py b/src/daSalome/daGUI/daEficasWrapper/adaoEficasWrapper.py index 68cf220..353a78e 100644 --- a/src/daSalome/daGUI/daEficasWrapper/adaoEficasWrapper.py +++ b/src/daSalome/daGUI/daEficasWrapper/adaoEficasWrapper.py @@ -50,8 +50,12 @@ class AdaoEficasWrapper(eficasSalome.MyEficas): def init_gui(self): eficasSalome.MyEficas.__init__(self, self.__parent, code="ADAO", module="ADAO") + + # On réouvre tous les fichiers comm # On fait une copie pour ne pas tomber dans une boucle infinie + # Deprecated + # Normalement on ne ferme plus le GUI donc on ne passe plus par là save_CallbackId = self.__myCallbackId.copy() for editor, myCallbackId in save_CallbackId.iteritems(): self.notifyObserver(EficasEvent.EVENT_TYPES.REOPEN, callbackId=myCallbackId) diff --git a/src/daSalome/daGUI/daGuiImpl/Makefile.am b/src/daSalome/daGUI/daGuiImpl/Makefile.am index a6d8a9b..704fd44 100644 --- a/src/daSalome/daGUI/daGuiImpl/Makefile.am +++ b/src/daSalome/daGUI/daGuiImpl/Makefile.am @@ -28,6 +28,7 @@ mypkgpython_PYTHON = \ adaoGuiHelper.py \ adaoModuleHelper.py \ adaoStudyEditor.py \ + adaoLogger.py \ studyedit.py \ adaoCase.py \ enumerate.py diff --git a/src/daSalome/daGUI/daGuiImpl/adaoGuiHelper.py b/src/daSalome/daGUI/daGuiImpl/adaoGuiHelper.py index a042953..944cb78 100644 --- a/src/daSalome/daGUI/daGuiImpl/adaoGuiHelper.py +++ b/src/daSalome/daGUI/daGuiImpl/adaoGuiHelper.py @@ -65,6 +65,12 @@ def refreshObjectBrowser(): if salome.sg is not None: salome.sg.updateObjBrowser(0) +def selectItem(salomeStudyItem): + print "selectItem", salomeStudyItem + if salome.sg is not None: + salome.sg.ClearIObjects() + salome.sg.AddIObject(salomeStudyItem) + def getSelectedItem(salomeStudyId=getActiveStudyId()): """ Get the current selection. If more than one item are selected, the diff --git a/src/daSalome/daGUI/daGuiImpl/adaoGuiManager.py b/src/daSalome/daGUI/daGuiImpl/adaoGuiManager.py index e08249b..128a2b8 100644 --- a/src/daSalome/daGUI/daGuiImpl/adaoGuiManager.py +++ b/src/daSalome/daGUI/daGuiImpl/adaoGuiManager.py @@ -38,6 +38,7 @@ from daEficasWrapper.eficasWrapper import EficasObserver from daEficasWrapper.eficasWrapper import EficasEvent import adaoGuiHelper import adaoStudyEditor +import adaoLogger __cases__ = {} @@ -50,16 +51,20 @@ UI_ELT_IDS = Enumerate([ 'ADAO_MENU_ID', 'NEW_ADAOCASE_ID', 'OPEN_ADAOCASE_ID', + 'SAVE_ADAOCASE_ID', + 'CLOSE_ADAOCASE_ID', + 'EDIT_ADAOCASE_POP_ID', - 'REMOVE_ADAOCASE_POP_ID', 'YACS_EXPORT_POP_ID', ],offset=950) ACTIONS_MAP={ UI_ELT_IDS.NEW_ADAOCASE_ID:"newAdaoCase", UI_ELT_IDS.OPEN_ADAOCASE_ID:"openAdaoCase", + UI_ELT_IDS.SAVE_ADAOCASE_ID:"saveAdaoCase", + UI_ELT_IDS.CLOSE_ADAOCASE_ID:"closeAdaoCase", + UI_ELT_IDS.EDIT_ADAOCASE_POP_ID:"editAdaoCase", - UI_ELT_IDS.REMOVE_ADAOCASE_POP_ID:"removeAdaoCase", UI_ELT_IDS.YACS_EXPORT_POP_ID:"exportCaseToYACS", } @@ -84,19 +89,27 @@ class AdaoGuiUiComponentBuilder: a = sgPyQt.createAction( UI_ELT_IDS.NEW_ADAOCASE_ID, "New case", "New case", "Create a new adao case", "" ) sgPyQt.createMenu(a, mid) sgPyQt.createTool(a, tid) - a = sgPyQt.createAction( UI_ELT_IDS.OPEN_ADAOCASE_ID, "Open case", "Open case", "Open a adao case", "" ) + a = sgPyQt.createAction( UI_ELT_IDS.OPEN_ADAOCASE_ID, "Open case", "Open case", "Open an adao case", "" ) + sgPyQt.createMenu(a, mid) + sgPyQt.createTool(a, tid) + a = sgPyQt.createAction( UI_ELT_IDS.SAVE_ADAOCASE_ID, "Save case", "Save case", "Save an adao case", "" ) + sgPyQt.createMenu(a, mid) + sgPyQt.createTool(a, tid) + a = sgPyQt.createAction( UI_ELT_IDS.CLOSE_ADAOCASE_ID, "Close case", "Close case", "Close an adao case", "" ) sgPyQt.createMenu(a, mid) sgPyQt.createTool(a, tid) # the following action are used in context popup + a = sgPyQt.createAction( UI_ELT_IDS.CLOSE_ADAOCASE_ID, "Close case", "Close case", "Close the selected case", "" ) + a = sgPyQt.createAction( UI_ELT_IDS.EDIT_ADAOCASE_POP_ID, "Edit case", "Edit case", "Edit the selected study case", "" ) - a = sgPyQt.createAction( UI_ELT_IDS.REMOVE_ADAOCASE_POP_ID, "Remove case", "Remove case", "Remove the selected study case", "" ) a = sgPyQt.createAction( UI_ELT_IDS.YACS_EXPORT_POP_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): + popup.addAction( sgPyQt.action( UI_ELT_IDS.CLOSE_ADAOCASE_ID ) ) + popup.addAction( sgPyQt.action( UI_ELT_IDS.EDIT_ADAOCASE_POP_ID ) ) - popup.addAction( sgPyQt.action( UI_ELT_IDS.REMOVE_ADAOCASE_POP_ID ) ) popup.addAction( sgPyQt.action( UI_ELT_IDS.YACS_EXPORT_POP_ID ) ) return popup @@ -174,10 +187,14 @@ class AdaoGuiActionImpl(EficasObserver): # Actions from SALOME GUI def newAdaoCase(self): + + adaoLogger.debug("newAdaoCase") self.showEficas() self.__dlgEficasWrapper.fileNew() def openAdaoCase(self): + + adaoLogger.debug("openAdaoCase") self.showEficas() global __cases__ fichier = QtGui.QFileDialog.getOpenFileName(SalomePyQt.SalomePyQt().getDesktop(), @@ -201,7 +218,8 @@ class AdaoGuiActionImpl(EficasObserver): adaoGuiHelper.refreshObjectBrowser() def editAdaoCase(self): - # First we show eficas - all cases are reloaded + + adaoLogger.debug("editAdaoCase") global __cases__ # Take study item @@ -227,12 +245,20 @@ class AdaoGuiActionImpl(EficasObserver): # Case has been destroyed - create a new one self.__dlgEficasWrapper.fileNew() - def removeAdaoCase(self): + def closeAdaoCase(self): + + adaoLogger.debug("closeAdaoCase") global __cases__ - # First step: selectCase + # First step: get selected case salomeStudyId = adaoGuiHelper.getActiveStudyId() salomeStudyItem = adaoGuiHelper.getSelectedItem(salomeStudyId) + + # Check if there is a selected case + if salomeStudyItem is None: + print "[Close case] Please select a case" + return + callbackId = [salomeStudyId, salomeStudyItem] case_open_in_eficas = self.__dlgEficasWrapper.selectCase(callbackId) @@ -249,7 +275,14 @@ class AdaoGuiActionImpl(EficasObserver): adaoStudyEditor.removeItem(salomeStudyId, salomeStudyItem) adaoGuiHelper.refreshObjectBrowser() + def saveAdaoCase(self): + + adaoLogger.debug("saveAdaoCase") + global __cases__ + def exportCaseToYACS(self): + + adaoLogger.debug("exportCaseToYACS") global __cases__ # Get case from study @@ -290,6 +323,7 @@ class AdaoGuiActionImpl(EficasObserver): def _processEficasNewEvent(self, eficasWrapper, eficasEvent): global __cases__ + new_case = AdaoCase() case_name = eficasWrapper.getCaseName() new_case.set_name(case_name) @@ -301,32 +335,9 @@ class AdaoGuiActionImpl(EficasObserver): callbackId = [salomeStudyId, salomeStudyItem] self.__dlgEficasWrapper.setCallbackId(callbackId) - def _processEficasReOpenEvent(self, eficasWrapper, eficasEvent): - global __cases__ - try: - callbackId = eficasEvent.callbackId - [salomeStudyId, salomeStudyItem] = callbackId - case_key = (salomeStudyId, salomeStudyItem.GetID()) - case = __cases__[case_key] - # Search if case is in Eficas ! - callbackId = [salomeStudyId, salomeStudyItem] - case_open_in_eficas = self.__dlgEficasWrapper.selectCase(callbackId) - # If case is not in eficas Open It ! - if case_open_in_eficas == False: - if case.get_filename() != "": - self.__dlgEficasWrapper.Openfile(case.get_filename()) - callbackId = [salomeStudyId, salomeStudyItem] - self.__dlgEficasWrapper.setCallbackId(callbackId) - else: - # Since I am an empty case I destroy myself before reloading - adaoStudyEditor.removeItem(salomeStudyId, salomeStudyItem) - adaoGuiHelper.refreshObjectBrowser() - __cases__.pop(case_key) - callbackId = [salomeStudyId, salomeStudyItem] - self.__dlgEficasWrapper.removeCallbackId(callbackId) - except: - print "Oups - cannot reopen case !" - traceback.print_exc() + # We need to select the case + adaoGuiHelper.selectItem(salomeStudyItem.GetID()) + def _processEficasOpenEvent(self, eficasWrapper, eficasEvent): global __cases__ @@ -398,5 +409,37 @@ class AdaoGuiActionImpl(EficasObserver): adaoStudyEditor.removeItem(targetSalomeStudyId, targetSalomeStudyItem) adaoGuiHelper.refreshObjectBrowser() + # Deprecated + # Normalement on ne ferme plus le GUI donc on ne passe plus par là + def _processEficasReOpenEvent(self, eficasWrapper, eficasEvent): + + adaoLogger.warning("_processEficasReOpenEvent") + global __cases__ + + try: + callbackId = eficasEvent.callbackId + [salomeStudyId, salomeStudyItem] = callbackId + case_key = (salomeStudyId, salomeStudyItem.GetID()) + case = __cases__[case_key] + # Search if case is in Eficas ! + callbackId = [salomeStudyId, salomeStudyItem] + case_open_in_eficas = self.__dlgEficasWrapper.selectCase(callbackId) + # If case is not in eficas Open It ! + if case_open_in_eficas == False: + if case.get_filename() != "": + self.__dlgEficasWrapper.Openfile(case.get_filename()) + callbackId = [salomeStudyId, salomeStudyItem] + self.__dlgEficasWrapper.setCallbackId(callbackId) + else: + # Since I am an empty case I destroy myself before reloading + adaoStudyEditor.removeItem(salomeStudyId, salomeStudyItem) + adaoGuiHelper.refreshObjectBrowser() + __cases__.pop(case_key) + callbackId = [salomeStudyId, salomeStudyItem] + self.__dlgEficasWrapper.removeCallbackId(callbackId) + except: + print "Oups - cannot reopen case !" + traceback.print_exc() + def _processEficasUnknownEvent(self, eficasWrapper, eficasEvent): print "Unknown Eficas Event" diff --git a/src/daSalome/daGUI/daGuiImpl/adaoLogger.py b/src/daSalome/daGUI/daGuiImpl/adaoLogger.py index 42f3fdf..13c24d0 100644 --- a/src/daSalome/daGUI/daGuiImpl/adaoLogger.py +++ b/src/daSalome/daGUI/daGuiImpl/adaoLogger.py @@ -30,3 +30,7 @@ def debug(msg): def error(msg): adao_logger.setColor(termcolor.RED) adao_logger.error(msg) + +def warning(msg): + adao_logger.setColor(termcolor.BLUE) + adao_logger.warning(msg) diff --git a/src/daSalome/daYacsIntegration/daOptimizerLoop.py b/src/daSalome/daYacsIntegration/daOptimizerLoop.py index 43014a2..9e86cd8 100644 --- a/src/daSalome/daYacsIntegration/daOptimizerLoop.py +++ b/src/daSalome/daYacsIntegration/daOptimizerLoop.py @@ -171,6 +171,7 @@ class AssimilationAlgorithm_asynch(SALOMERuntime.OptimizerAlgASync): # Check if ObservationOperator is already set if self.da_study.getObservationOperatorType("Direct") == "Function" or self.da_study.getObservationOperatorType("Tangent") == "Function" or self.da_study.getObservationOperatorType("Adjoint") == "Function" : + print "Set Hooks" # Use proxy function for YACS self.hooks = OptimizerHooks(self) direct = tangent = adjoint = None @@ -186,6 +187,10 @@ class AssimilationAlgorithm_asynch(SALOMERuntime.OptimizerAlgASync): # Start Assimilation Study + import logging + logging.getLogger().setLevel(logging.DEBUG) + + print "ADD analyze" self.ADD.analyze() # Assimilation Study is finished