1 # Copyright (C) 2007-2015 CEA/DEN, EDF R&D, OPEN CASCADE
3 # Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 # CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 # This library is free software; you can redistribute it and/or
7 # modify it under the terms of the GNU Lesser General Public
8 # License as published by the Free Software Foundation; either
9 # version 2.1 of the License, or (at your option) any later version.
11 # This library is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 # Lesser General Public License for more details.
16 # You should have received a copy of the GNU Lesser General Public
17 # License along with this library; if not, write to the Free Software
18 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
24 # File : PYHELLOGUI.py
25 # Author : Vadim SANDLER, Open CASCADE S.A.S. (vadim.sandler@opencascade.com)
28 import PYHELLO_ORB__POA
29 import SALOME_ComponentPy
30 import SALOME_DriverPy
33 from PYHELLO_utils import *
35 class PYHELLO(PYHELLO_ORB__POA.PYHELLO_Gen,
36 SALOME_ComponentPy.SALOME_ComponentPy_i,
37 SALOME_DriverPy.SALOME_DriverPy_i):
39 Construct an instance of PYHELLO module engine.
40 The class PYHELLO implements CORBA interface PYHELLO_Gen (see PYHELLO_Gen.idl).
41 It is inherited from the classes SALOME_ComponentPy_i (implementation of
42 Engines::EngineComponent CORBA interface - SALOME component) and SALOME_DriverPy_i
43 (implementation of SALOMEDS::Driver CORBA interface - SALOME module's engine).
45 def __init__ ( self, orb, poa, contID, containerName, instanceName,
47 SALOME_ComponentPy.SALOME_ComponentPy_i.__init__(self, orb, poa,
48 contID, containerName, instanceName, interfaceName, 0)
49 SALOME_DriverPy.SALOME_DriverPy_i.__init__(self, interfaceName)
51 self._naming_service = SALOME_ComponentPy.SALOME_NamingServicePy_i( self._orb )
56 Get version information.
58 def getVersion( self ):
60 return salome_version.getVersion("PYHELLO", True)
63 Generate hello banner.
65 def makeBanner( self, name ):
66 banner = "Hello %s!" % name
70 Intentionnally raises an exception for test purposes.
72 def raiseAnException( self ):
74 exData = SALOME.ExceptionStruct( SALOME.BAD_PARAM, "Test exception in raiseAnException()",'',0)
75 raise SALOME.SALOME_Exception( exData )
80 def createObject( self, study, name ):
81 builder = study.NewBuilder()
82 father = findOrCreateComponent( study )
83 object = builder.NewObject( father )
84 attr = builder.FindOrCreateAttribute( object, "AttributeName" )
86 attr = builder.FindOrCreateAttribute( object, "AttributeLocalID" )
87 attr.SetValue( objectID() )
91 Dump module data to the Python script.
93 def DumpPython( self, study, isPublished, isMultiFile ):
96 father = study.FindComponent( moduleName() )
98 iter = study.NewChildIterator( father )
100 name = iter.Value().GetName()
101 if name: names.append( name )
106 abuffer += [ "from salome import lcc" ]
107 abuffer += [ "import PYHELLO_ORB" ]
109 abuffer += [ "pyhello = lcc.FindOrLoadComponent( 'FactoryServerPy', '%s' )" % moduleName() ]
111 abuffer += [ "pyhello.createObject( theStudy, '%s' )" % name for name in names ]
115 abuffer = [ " " + s for s in abuffer ]
116 abuffer[0:0] = [ "def RebuildData( theStudy ):" ]
117 abuffer += [ " pass" ]
119 return ("\n".join( abuffer ), 1)