1 # -*- coding: utf-8 -*-
3 # Copyright (C) 2008-2024 EDF R&D
5 # Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE
7 # Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
8 # CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
10 # This library is free software; you can redistribute it and/or
11 # modify it under the terms of the GNU Lesser General Public
12 # License as published by the Free Software Foundation; either
13 # version 2.1 of the License.
15 # This library is distributed in the hope that it will be useful,
16 # but WITHOUT ANY WARRANTY; without even the implied warranty of
17 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 # Lesser General Public License for more details.
20 # You should have received a copy of the GNU Lesser General Public
21 # License along with this library; if not, write to the Free Software
22 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
24 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
39 "findOrCreateComponent",
44 from omniORB import CORBA
45 from SALOME_NamingServicePy import SALOME_NamingServicePy_i
46 from LifeCycleCORBA import LifeCycleCORBA
49 import SALOMEDS_Attributes_idl
50 from salome.kernel.studyedit import getStudyEditor
77 This provide the name of the module component to be associated to the study.
79 # Note that this name should be (i) the name used for the class implementing
80 # the component CORBA interface and (ii) the name used to declare the component
81 # in the catalog of the module.
84 # _MEM_ we use here the tr() translation methode to manage constant parameters
85 # in the application. We could have specified instead constant values directly
86 # in the code below. It's a matter of convenience.
87 from PyQt5.QtCore import QObject
90 def componentUserName():
95 Get the reference pixmap for this module.
97 return "ADAO_small.png"
99 def studyItemPixmapOk():
101 Get the reference pixmap for items of this module.
103 return "ADAO_small_vert.png"
105 def studyItemPixmapNOk():
107 Get the reference pixmap for items of this module.
109 return "ADAO_small_rouge.png"
114 if __verbose__ is None:
116 __verbose__ = int( os.getenv( 'SALOME_VERBOSE', 0 ) )
131 # Get life cycle CORBA instance
140 def getStudyManager():
142 return salome.myStudy
150 if __engine__ is None:
151 __engine__ = getLCC().FindOrLoadComponent( "FactoryServer", componentName() )
160 if getORB() and getEngine():
161 IOR = getORB().object_to_string( getEngine() )
166 # Find or create OMA component object in a study
168 def findOrCreateComponent( study ):
169 father = study.FindComponent( componentName() )
171 builder = study.NewBuilder()
172 father = builder.NewComponent( componentName() )
173 attr = builder.FindOrCreateAttribute( father, "AttributeName" )
174 attr.SetValue( componentName() )
175 attr = builder.FindOrCreateAttribute( father, "AttributePixMap" )
176 attr.SetPixMap( modulePixmap() )
177 attr = builder.FindOrCreateAttribute( father, "AttributeLocalID" )
178 attr.SetValue( moduleID() )
180 builder.DefineComponentInstance( father, getEngine() )
190 def getObjectID( entry ): # study, entry ):
192 if entry: # study and entry:
193 sobj = getStudyEditor().study.FindObjectID( entry )
195 test, anAttr = sobj.FindAttribute( "AttributeLocalID" )
196 if test: ID = anAttr._narrow( SALOMEDS.AttributeLocalID ).Value()