1 # -*- coding: iso-8859-1 -*-
2 # Copyright (C) 2007-2011 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
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.
74 global myStudyId, myStudyName
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 getActiveStudyId(self):
86 """Get the active study id"""
87 print "SalomeOutsideGUI.getActiveStudyId: avoid use outside GUI"
90 def getActiveStudyName(self):
91 """Get the active study name"""
92 print "SalomeOutsideGUI.getActiveStudyName: avoid use outside GUI"
95 def SelectedCount(self):
96 """Get the number of active selections"""
97 print "SalomeOutsideGUI: no selection mecanism available outside GUI"
100 def getSelected(self, i):
101 """Get the selection number i """
102 print "SalomeOutsideGUI: no selection mecanism available outside GUI"
105 def AddIObject(self, Entry):
107 print "SalomeOutsideGUI.AddIOObject: not available outside GUI"
110 def RemoveIObject(self, Entry):
111 """Remove an entry"""
112 print "SalomeOutsideGUI.REmoveIOObject: not available outside GUI"
115 def ClearIObjects(self):
117 print "SalomeOutsideGUI.ClearIOObject: not available outside GUI"
120 def Display(self, Entry):
121 """Display an entry"""
122 print "SalomeOutsideGUI.Display: not available outside GUI"
125 def DisplayOnly(self, Entry):
126 """Display only an entry"""
127 print "SalomeOutsideGUI.DisplayOnly: not available outside GUI"
130 def Erase(self, Entry):
132 print "SalomeOutsideGUI.Erase: not available outside GUI"
135 def DisplayAll(self):
137 print "SalomeOutsideGUI.Erase: not available outside GUI"
142 print "SalomeOutsideGUI.EraseAll: not available outside GUI"
145 def IsInCurrentView(self, Entry):
146 """Indicate if an entry is in current view"""
147 print "SalomeOutsideGUI.IsIncurentView: not available outside GUI"
150 def getComponentName(self, ComponentUserName ):
151 """Get component name from component user name"""
152 print "SalomeOutsideGUI.getComponentName: not available outside GUI"
155 def getComponentUserName( self, ComponentName ):
156 """Get component user name from component name"""
157 print "SalomeOutsideGUI.getComponentUserName: not available outside GUI"
160 #--------------------------------------------------------------------------
163 def salome_iapp_init(embedded):
164 global salome_iapp_initial
165 global sg,IN_SALOME_GUI
167 if salome_iapp_initial:
168 salome_iapp_initial=0
170 import libSALOME_Swig
172 class SalomeGUI(libSALOME_Swig.SALOMEGUI_Swig):
173 getAllSelected = SalomeGUIgetAllSelected
175 # create a SALOMEGUI_Swig instance
177 IN_SALOME_GUI = sg.hasDesktop()
179 # Not embedded in GUI
180 sg=SalomeOutsideGUI()