2 # -*- coding: iso-8859-1 -*-
3 # Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE
5 # Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
6 # CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
8 # This library is free software; you can redistribute it and/or
9 # modify it under the terms of the GNU Lesser General Public
10 # License as published by the Free Software Foundation; either
11 # version 2.1 of the License.
13 # This library is distributed in the hope that it will be useful,
14 # but WITHOUT ANY WARRANTY; without even the implied warranty of
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 # Lesser General Public License for more details.
18 # You should have received a copy of the GNU Lesser General Public
19 # License along with this library; if not, write to the Free Software
20 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
24 # File : salome_iapp.py
25 # Author : Paul RASCLE, EDF
29 ## @package salome_iapp
30 # Module salome gives access to Salome GUI ressources (if GUI has been launched).
33 import salome_ComponentGUI
35 #--------------------------------------------------------------------------
39 def ImportComponentGUI(ComponentName):
41 libName = "lib" + ComponentName + "_Swig"
42 command = "from " + libName + " import *"
44 constructor = ComponentName + "_Swig()"
45 command = "gui = " + constructor
49 print "Warning: ImportComponentGUI(",ComponentName,") outside GUI !"
50 print "calls to GUI methods may crash..."
51 return salome_ComponentGUI
53 #--------------------------------------------------------------------------
55 def SalomeGUIgetAllSelected(self):
56 selNumber = self.SelectedCount()
58 for i in range(selNumber):
59 listSelected.append(self.getSelected(i))
62 #--------------------------------------------------------------------------
67 #--------------------------------------------------------------------------
69 salome_iapp_initial = 1
71 class SalomeOutsideGUI(object):
73 Provides a replacement for class SalomeGUI outside GUI process.
76 global myStudyId, myStudyName
79 """Indicate if GUI is running"""
82 def updateObjBrowser(self, bid):
83 """update the GUI object browser"""
84 print "SalomeOutsideGUI: no objectBrowser update outside GUI"
87 def getActiveStudyId(self):
88 """Get the active study id"""
89 print "SalomeOutsideGUI.getActiveStudyId: avoid use outside GUI"
92 def getActiveStudyName(self):
93 """Get the active study name"""
94 print "SalomeOutsideGUI.getActiveStudyName: avoid use outside GUI"
97 def SelectedCount(self):
98 """Get the number of active selections"""
99 print "SalomeOutsideGUI: no selection mecanism available outside GUI"
102 def getSelected(self, i):
103 """Get the selection number i """
104 print "SalomeOutsideGUI: no selection mecanism available outside GUI"
107 def AddIObject(self, Entry):
109 print "SalomeOutsideGUI.AddIOObject: not available outside GUI"
112 def RemoveIObject(self, Entry):
113 """Remove an entry"""
114 print "SalomeOutsideGUI.REmoveIOObject: not available outside GUI"
117 def ClearIObjects(self):
119 print "SalomeOutsideGUI.ClearIOObject: not available outside GUI"
122 def Display(self, Entry):
123 """Display an entry"""
124 print "SalomeOutsideGUI.Display: not available outside GUI"
127 def DisplayOnly(self, Entry):
128 """Display only an entry"""
129 print "SalomeOutsideGUI.DisplayOnly: not available outside GUI"
132 def Erase(self, Entry):
134 print "SalomeOutsideGUI.Erase: not available outside GUI"
137 def DisplayAll(self):
139 print "SalomeOutsideGUI.Erase: not available outside GUI"
144 print "SalomeOutsideGUI.EraseAll: not available outside GUI"
147 def IsInCurrentView(self, Entry):
148 """Indicate if an entry is in current view"""
149 print "SalomeOutsideGUI.IsIncurentView: not available outside GUI"
152 def getComponentName(self, ComponentUserName ):
153 """Get component name from component user name"""
154 print "SalomeOutsideGUI.getComponentName: not available outside GUI"
157 def getComponentUserName( self, ComponentName ):
158 """Get component user name from component name"""
159 print "SalomeOutsideGUI.getComponentUserName: not available outside GUI"
162 #--------------------------------------------------------------------------
165 def salome_iapp_init(embedded):
166 global salome_iapp_initial
167 global sg,IN_SALOME_GUI
169 if salome_iapp_initial:
170 salome_iapp_initial=0
172 import libSALOME_Swig
174 class SalomeGUI(libSALOME_Swig.SALOMEGUI_Swig):
175 getAllSelected = SalomeGUIgetAllSelected
177 # create a SALOMEGUI_Swig instance
179 IN_SALOME_GUI = sg.hasDesktop()
181 # Not embedded in GUI
182 sg=SalomeOutsideGUI()