Salome HOME
New createDataflowStudyObject and addDataflowToStudy functions for DumpStudy function...
authorrahuel <rahuel@opencascade.com>
Fri, 29 Apr 2005 13:04:01 +0000 (13:04 +0000)
committerrahuel <rahuel@opencascade.com>
Fri, 29 Apr 2005 13:04:01 +0000 (13:04 +0000)
src/Supervision/SuperV.py

index 7b7acbd327a9e8bc21891e2d00cd3081ec05c25a..f68f82a6d4e04576d774b262ec46043d9feb70a4 100644 (file)
@@ -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)))