from salome import naming_service
from salome import CORBA
from salome import sg
+ from salome import SALOMEDS
import SALOME_ModuleCatalog
import SUPERV
import SUPERV_idl
modulecatalog = naming_service.Resolve("/Kernel/ModulCatalog")
+def createDataflowStudyObject( theStudy , aDataFlow , aBuilder ) :
+ aStudyObject = theStudy.FindObjectIOR( aDataFlow.G.getIOR() )
+ if aStudyObject == None :
+ aComponent = theStudy.FindComponent( "SUPERV" )
+ if aComponent == None :
+ print "createDataflowStudyObject Component SUPERV is None"
+ aComponent = aBuilder.NewComponent( "SUPERV" )
+ anAttr = aBuilder.FindOrCreateAttribute(aComponent, "AttributeName")
+ aName = anAttr._narrow( SALOMEDS.AttributeName )
+ aName.SetValue( modulecatalog.GetComponentInfo( "SUPERV" ).username )
+ anAttr = aBuilder.FindOrCreateAttribute( aComponent , "AttributePixMap" )
+ aPixmap = anAttr._narrow( SALOMEDS.AttributePixMap )
+ aPixmap.SetPixMap( "ICON_OBJBROWSER_Supervision" );
+ aBuilder.DefineComponentInstance( aComponent , SuperVision )
+ print "createDataflowStudyObject Component SUPERV is created"
+ aStudyObject = aBuilder.NewObject( aComponent )
+ anAttr = aBuilder.FindOrCreateAttribute( aStudyObject , "AttributeName" )
+ aName = anAttr._narrow( SALOMEDS.AttributeName )
+ aName.SetValue( aDataFlow.Name() )
+ anAttr = aBuilder.FindOrCreateAttribute( aStudyObject , "AttributeIOR" )
+ anIORAttr = anAttr._narrow( SALOMEDS.AttributeIOR )
+ anIORAttr.SetValue( aDataFlow.G.getIOR() )
+ return aStudyObject
+
+def addDataflowToStudy( theStudy , aDataFlow ) :
+ aBuilder = theStudy.NewBuilder()
+ aBuilder.NewCommand()
+ aStudyObject = createDataflowStudyObject( theStudy , aDataFlow , aBuilder )
+ if aStudyObject != None :
+ aBuilder.CommitCommand()
+ sg.updateObjBrowser( 1 )
+ print "addDataflowToStudy aStudyObject ",aDataFlow.Name()," added in study"
+ #theStudy.updateObjBrowser()
+ else :
+ print "addDataflowToStudy ERROR aStudyObject is None"
+ aBuilder.AbortCommand()
+ return aBuilder,aStudyObject
+
def PortInputFloat(obj, x):
return obj.Input( SuperVision.AnyValue( CORBA.Any(CORBA.TC_double, x)))