X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FKERNEL_PY%2Fsalome_iapp.py;h=49b78e6234cede67354c9cc58200967ee2c80067;hb=8469d4f02c5b4379665d4ec1b07709d3c8411114;hp=b7aa1557d240cacb290d435577274b168e2b1e97;hpb=1d633fa1c13b169da8b4f8a5cfad4587bf586b0b;p=modules%2Fkernel.git diff --git a/src/KERNEL_PY/salome_iapp.py b/src/KERNEL_PY/salome_iapp.py old mode 100755 new mode 100644 index b7aa1557d..49b78e623 --- a/src/KERNEL_PY/salome_iapp.py +++ b/src/KERNEL_PY/salome_iapp.py @@ -1,5 +1,5 @@ # -*- coding: iso-8859-1 -*- -# Copyright (C) 2007-2016 CEA/DEN, EDF R&D, OPEN CASCADE +# Copyright (C) 2007-2023 CEA, EDF, OPEN CASCADE # # Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, # CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS @@ -26,7 +26,7 @@ # Module : SALOME # $Header$ ## @package salome_iapp -# Module salome gives access to Salome GUI ressources (if GUI has been launched). +# Module salome gives access to Salome GUI resources (if GUI has been launched). # import salome_ComponentGUI @@ -34,12 +34,14 @@ import salome_ComponentGUI IN_SALOME_GUI=None -def ImportComponentGUI(ComponentName): +def ImportComponentGUI(ComponentName, updateOB=True): if IN_SALOME_GUI: libName = "lib" + ComponentName + "_Swig" command = "from " + libName + " import *" exec (command, globals()) constructor = ComponentName + "_Swig()" + if not updateOB : + constructor = ComponentName + "_Swig( False )" command = "gui = " + constructor exec (command, globals()) return gui # @UndefinedVariable @@ -66,40 +68,35 @@ def hasDesktop(): salome_iapp_initial = 1 -class SalomeOutsideGUI(object): +class SalomeOutsideGUI: """ Provides a replacement for class SalomeGUI outside GUI process. Do almost nothing """ - global myStudyId, myStudyName + global myStudyName def hasDesktop(self): """Indicate if GUI is running""" return False - def updateObjBrowser(self, bid): + def updateObjBrowser(self): """update the GUI object browser""" print("SalomeOutsideGUI: no objectBrowser update outside GUI") pass - def getActiveStudyId(self): - """Get the active study id""" - print("SalomeOutsideGUI.getActiveStudyId: avoid use outside GUI") - return myStudyId - - def getActiveStudyName(self): - """Get the active study name""" - print("SalomeOutsideGUI.getActiveStudyName: avoid use outside GUI") + def getStudyName(self): + """Get the study name""" + print("SalomeOutsideGUI.getStudyName: avoid use outside GUI") return myStudyName def SelectedCount(self): """Get the number of active selections""" - print("SalomeOutsideGUI: no selection mecanism available outside GUI") + print("SalomeOutsideGUI: no selection mechanism available outside GUI") return 0 def getSelected(self, i): """Get the selection number i """ - print("SalomeOutsideGUI: no selection mecanism available outside GUI") + print("SalomeOutsideGUI: no selection mechanism available outside GUI") return None def AddIObject(self, Entry): @@ -144,7 +141,7 @@ class SalomeOutsideGUI(object): def IsInCurrentView(self, Entry): """Indicate if an entry is in current view""" - print("SalomeOutsideGUI.IsIncurentView: not available outside GUI") + print("SalomeOutsideGUI.IsIncurrentView: not available outside GUI") return False def getComponentName(self, ComponentUserName ): @@ -156,7 +153,12 @@ class SalomeOutsideGUI(object): """Get component user name from component name""" print("SalomeOutsideGUI.getComponentUserName: not available outside GUI") return "" - + + def UpdateView(self): + """Update current view""" + print("SalomeOutsideGUI.UpdateView: not available outside GUI") + pass + #-------------------------------------------------------------------------- @@ -189,3 +191,16 @@ def salome_iapp_close(): pass +def register_module_in_study(name, syncCall=True): + try: + import salome + salome.salome_init() + session_server = salome.naming_service.Resolve("/Kernel/Session") + if session_server: + message = "register_module_in_study/"+name + if syncCall: + session_server.emitMessage(message) + else: + session_server.emitMessageOneWay(message) + except Exception: + pass