From 3f6de2ab5e4488c65b1a1fd021cbe875fe2c4eed Mon Sep 17 00:00:00 2001 From: rahuel Date: Fri, 29 Apr 2005 13:04:01 +0000 Subject: [PATCH] New createDataflowStudyObject and addDataflowToStudy functions for DumpStudy functionnality --- src/Supervision/SuperV.py | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/src/Supervision/SuperV.py b/src/Supervision/SuperV.py index 7b7acbd..f68f82a 100644 --- a/src/Supervision/SuperV.py +++ b/src/Supervision/SuperV.py @@ -15,6 +15,7 @@ try : 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 @@ -54,6 +55,44 @@ SuperVision = lcc.FindOrLoadComponent("SuperVisionContainer","SUPERV") 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))) -- 2.39.2