1 # -*- coding: iso-8859-1 -*-
2 # Copyright (C) 2007-2008 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.
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
23 # File : salome_iapp.py
24 # Author : Paul RASCLE, EDF
28 ## @package salome_iapp
29 # Module salome gives access to Salome GUI ressources (if GUI has been launched).
32 import salome_ComponentGUI
34 #--------------------------------------------------------------------------
38 def ImportComponentGUI(ComponentName):
40 libName = "lib" + ComponentName + "_Swig"
41 command = "from " + libName + " import *"
43 constructor = ComponentName + "_Swig()"
44 command = "gui = " + constructor
48 print "Warning: ImportComponentGUI(",ComponentName,") outside GUI !"
49 print "calls to GUI methods may crash..."
50 return salome_ComponentGUI
52 #--------------------------------------------------------------------------
54 def SalomeGUIgetAllSelected(self):
55 selNumber = self.SelectedCount()
57 for i in range(selNumber):
58 listSelected.append(self.getSelected(i))
61 #--------------------------------------------------------------------------
66 #--------------------------------------------------------------------------
68 salome_iapp_initial = 1
70 class SalomeOutsideGUI(object):
72 Provides a replacement for class SalomeGUI outside GUI process.
75 global myStudyId, myStudyName
78 """Indicate if GUI is running"""
81 def updateObjBrowser(self, bid):
82 """update the GUI object browser"""
83 print "SalomeOutsideGUI: no objectBrowser update outside GUI"
86 def getActiveStudyId(self):
87 """Get the active study id"""
88 print "SalomeOutsideGUI.getActiveStudyId: avoid use outside GUI"
91 def getActiveStudyName(self):
92 """Get the active study name"""
93 print "SalomeOutsideGUI.getActiveStudyName: avoid use outside GUI"
96 def SelectedCount(self):
97 """Get the number of active selections"""
98 print "SalomeOutsideGUI: no selection mecanism available outside GUI"
101 def getSelected(self, i):
102 """Get the selection number i """
103 print "SalomeOutsideGUI: no selection mecanism available outside GUI"
106 def AddIObject(self, Entry):
108 print "SalomeOutsideGUI.AddIOObject: not available outside GUI"
111 def RemoveIObject(self, Entry):
112 """Remove an entry"""
113 print "SalomeOutsideGUI.REmoveIOObject: not available outside GUI"
116 def ClearIObjects(self):
118 print "SalomeOutsideGUI.ClearIOObject: not available outside GUI"
121 def Display(self, Entry):
122 """Display an entry"""
123 print "SalomeOutsideGUI.Display: not available outside GUI"
126 def DisplayOnly(self, Entry):
127 """Display only an entry"""
128 print "SalomeOutsideGUI.DisplayOnly: not available outside GUI"
131 def Erase(self, Entry):
133 print "SalomeOutsideGUI.Erase: not available outside GUI"
136 def DisplayAll(self):
138 print "SalomeOutsideGUI.Erase: not available outside GUI"
143 print "SalomeOutsideGUI.EraseAll: not available outside GUI"
146 def IsInCurrentView(self, Entry):
147 """Indicate if an entry is in current view"""
148 print "SalomeOutsideGUI.IsIncurentView: not available outside GUI"
151 def getComponentName(self, ComponentUserName ):
152 """Get component name from component user name"""
153 print "SalomeOutsideGUI.getComponentName: not available outside GUI"
156 def getComponentUserName( self, ComponentName ):
157 """Get component user name from component name"""
158 print "SalomeOutsideGUI.getComponentUserName: not available outside GUI"
161 #--------------------------------------------------------------------------
164 def salome_iapp_init(embedded):
165 global salome_iapp_initial
166 global sg,IN_SALOME_GUI
168 if salome_iapp_initial:
169 salome_iapp_initial=0
171 import libSALOME_Swig
173 class SalomeGUI(libSALOME_Swig.SALOMEGUI_Swig):
174 getAllSelected = SalomeGUIgetAllSelected
176 # create a SALOMEGUI_Swig instance
178 IN_SALOME_GUI = sg.hasDesktop()
180 # Not embedded in GUI
181 sg=SalomeOutsideGUI()