1 # Copyright (C) 2007-2019 CEA/DEN, EDF R&D, OPEN CASCADE
3 # This library is free software; you can redistribute it and/or
4 # modify it under the terms of the GNU Lesser General Public
5 # License as published by the Free Software Foundation; either
6 # version 2.1 of the License, or (at your option) any later version.
8 # This library is distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 # Lesser General Public License for more details.
13 # You should have received a copy of the GNU Lesser General Public
14 # License along with this library; if not, write to the Free Software
15 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 # File : SHAPERSTUDY_utils.py
22 # Author : Vadim SANDLER, Open CASCADE S.A.S. (vadim.sandler@opencascade.com)
38 "findOrCreateComponent",
43 from omniORB import CORBA
44 from SALOME_NamingServicePy import SALOME_NamingServicePy_i
45 from LifeCycleCORBA import LifeCycleCORBA
47 import SALOMEDS_Attributes_idl
48 import SHAPERSTUDY_ORB
52 # Get SHAPERSTUDY module's name
58 # Get module's pixmap name
69 if __verbose__ is None:
71 __verbose__ = int( os.getenv( 'SALOME_VERBOSE', 0 ) )
85 __orb__ = CORBA.ORB_init( [''], CORBA.ORB_ID )
96 __poa__ = getORB().resolve_initial_references("RootPOA")
101 # Get naming service instance
103 __naming_service__ = None
105 global __naming_service__
106 if __naming_service__ is None:
107 __naming_service__ = SALOME_NamingServicePy_i( getORB() )
109 return __naming_service__
112 # Get life cycle CORBA instance
118 __lcc__ = LifeCycleCORBA( getORB() )
128 if __study__ is None:
129 obj = getNS().Resolve( '/Study' )
130 __study__ = obj._narrow( SALOMEDS.Study )
135 # Get SHAPERSTUDY engine
140 if __engine__ is None:
141 __engine__ = getLCC().FindOrLoad_Component( "FactoryServer", moduleName() )
146 # Get SHAPERSTUDY engine IOR
150 if getORB() and getEngine():
151 IOR = getORB().object_to_string( getEngine() )
156 # Find or create SHAPERSTUDY component object in a study
158 def findOrCreateComponent():
160 builder = study.NewBuilder()
161 father = study.FindComponent( moduleName() )
163 father = builder.NewComponent( moduleName() )
164 attr = builder.FindOrCreateAttribute( father, "AttributeName" )
165 attr.SetValue( "ShaperStudy" )
166 attr = builder.FindOrCreateAttribute( father, "AttributePixMap" )
167 attr.SetPixMap( modulePixmap() )
168 #attr = builder.FindOrCreateAttribute( father, "AttributeLocalID" )
169 #attr.SetValue( moduleID() )
171 builder.DefineComponentInstance( father, getEngine() )
176 # load the SHAPER-STUDY file if it is not done yet
177 builder.LoadWith(father, getEngine())