1 # -*- coding: iso-8859-1 -*-
2 # Copyright (C) 2007-2016 CEA/DEN, EDF R&D, OPEN CASCADE
4 # Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
5 # CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
7 # This library is free software; you can redistribute it and/or
8 # modify it under the terms of the GNU Lesser General Public
9 # License as published by the Free Software Foundation; either
10 # version 2.1 of the License, or (at your option) any later version.
12 # This library is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 # Lesser General Public License for more details.
17 # You should have received a copy of the GNU Lesser General Public
18 # License along with this library; if not, write to the Free Software
19 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
24 # File : salome_iapp.py
25 # Author : Paul RASCLE, EDF
28 ## @package salome_iapp
29 # Module salome gives access to Salome GUI ressources (if GUI has been launched).
31 import salome_ComponentGUI
33 #--------------------------------------------------------------------------
37 def ImportComponentGUI(ComponentName):
39 libName = "lib" + ComponentName + "_Swig"
40 command = "from " + libName + " import *"
42 constructor = ComponentName + "_Swig()"
43 command = "gui = " + constructor
47 print "Warning: ImportComponentGUI(",ComponentName,") outside GUI !"
48 print "calls to GUI methods may crash..."
49 return salome_ComponentGUI
51 #--------------------------------------------------------------------------
53 def SalomeGUIgetAllSelected(self):
54 selNumber = self.SelectedCount()
56 for i in range(selNumber):
57 listSelected.append(self.getSelected(i))
60 #--------------------------------------------------------------------------
65 #--------------------------------------------------------------------------
67 salome_iapp_initial = 1
69 class SalomeOutsideGUI(object):
71 Provides a replacement for class SalomeGUI outside GUI process.
77 """Indicate if GUI is running"""
80 def updateObjBrowser(self, bid):
81 """update the GUI object browser"""
82 print "SalomeOutsideGUI: no objectBrowser update outside GUI"
85 def getStudyName(self):
86 """Get the study name"""
87 print "SalomeOutsideGUI.getStudyName: avoid use outside GUI"
90 def SelectedCount(self):
91 """Get the number of active selections"""
92 print "SalomeOutsideGUI: no selection mecanism available outside GUI"
95 def getSelected(self, i):
96 """Get the selection number i """
97 print "SalomeOutsideGUI: no selection mecanism available outside GUI"
100 def AddIObject(self, Entry):
102 print "SalomeOutsideGUI.AddIOObject: not available outside GUI"
105 def RemoveIObject(self, Entry):
106 """Remove an entry"""
107 print "SalomeOutsideGUI.REmoveIOObject: not available outside GUI"
110 def ClearIObjects(self):
112 print "SalomeOutsideGUI.ClearIOObject: not available outside GUI"
115 def Display(self, Entry):
116 """Display an entry"""
117 print "SalomeOutsideGUI.Display: not available outside GUI"
120 def DisplayOnly(self, Entry):
121 """Display only an entry"""
122 print "SalomeOutsideGUI.DisplayOnly: not available outside GUI"
125 def Erase(self, Entry):
127 print "SalomeOutsideGUI.Erase: not available outside GUI"
130 def DisplayAll(self):
132 print "SalomeOutsideGUI.Erase: not available outside GUI"
137 print "SalomeOutsideGUI.EraseAll: not available outside GUI"
140 def IsInCurrentView(self, Entry):
141 """Indicate if an entry is in current view"""
142 print "SalomeOutsideGUI.IsIncurentView: not available outside GUI"
145 def getComponentName(self, ComponentUserName ):
146 """Get component name from component user name"""
147 print "SalomeOutsideGUI.getComponentName: not available outside GUI"
150 def getComponentUserName( self, ComponentName ):
151 """Get component user name from component name"""
152 print "SalomeOutsideGUI.getComponentUserName: not available outside GUI"
155 #--------------------------------------------------------------------------
158 def salome_iapp_init(embedded):
159 global salome_iapp_initial
160 global sg,IN_SALOME_GUI
162 if salome_iapp_initial:
163 salome_iapp_initial=0
165 import libSALOME_Swig
167 class SalomeGUI(libSALOME_Swig.SALOMEGUI_Swig):
168 getAllSelected = SalomeGUIgetAllSelected
170 # create a SALOMEGUI_Swig instance
172 inSalomeGUI = sg.hasDesktop()
174 # Not embedded in GUI
175 sg=SalomeOutsideGUI()
177 if IN_SALOME_GUI is None:
178 IN_SALOME_GUI = inSalomeGUI
181 def salome_iapp_close():
182 global salome_iapp_initial
183 salome_iapp_initial=1