}
std::string aSObjectName = GetName(theSObject);
- theStr<<thePrefix<<"aSComponent = theStudy.FindComponent('VISU')"<<endl;
theStr<<thePrefix<<aSObjectName<<" = aBuilder.NewObject(aSComponent)"<<endl;
theStr<<thePrefix<<"if "<<aSObjectName<<":"<<endl;
thePrefix += PREFIX;
}
}else if(strcmp(aTypeName.latin1(),"VIEW3D") == 0){
std::string aName = GetName(theSObject);
- theStr<<thePrefix<<"aSComponent = theStudy.FindComponent('VISU')"<<endl;
theStr<<thePrefix<<aName<<" = aBuilder.NewObject(aSComponent)"<<endl;
theStr<<thePrefix<<"if "<<aName<<":"<<endl;
aStr<<aPrefix<<"import visu"<<endl;
aStr<<endl;
aStr<<aPrefix<<"aVisu = visu.Initialize(orb,naming_service,lcc,myStudyManager,theStudy,0)"<<endl;
+ aStr<<aPrefix<<"aSComponent = visu.PublishComponent(theStudy)"<<endl;
aStr<<aPrefix<<"aMed = lcc.FindOrLoadComponent('FactoryServer','MED')"<<endl;
aStr<<aPrefix<<"aBuilder = theStudy.NewBuilder()"<<endl;
aStr<<aPrefix<<"aName2ObjectMap = {}"<<endl;
myLocalStudy = theStudy
myLocalVisu.SetCurrentStudy(myLocalStudy)
return myLocalVisu
+
+def PublishComponent(theStudyDocument):
+ aComponentDataType = myLocalVisu.ComponentDataType()
+ aSComponent = theStudyDocument.FindComponent(aComponentDataType)
+ if aSComponent == None:
+ aStudyBuilder = theStudyDocument.NewBuilder()
+ aStudyBuilder.NewCommand()
+ aLocked = theStudyDocument.GetProperties().IsLocked()
+ if aLocked:
+ theStudyDocument.GetProperties().SetLocked(0)
+ pass
+
+ aSComponent = aStudyBuilder.NewComponent(aComponentDataType);
+ aName = aStudyBuilder.FindOrCreateAttribute(aSComponent,"AttributeName")
+ aModuleCatalog = myNamingService.Resolve("/Kernel/ModulCatalog");
+ aComponent = aModuleCatalog.GetComponent(aComponentDataType);
+ if aComponent != None:
+ aComponentUserName = aComponent._get_componentusername()
+ aName.SetValue(aComponentUserName)
+ pass
+
+ aPixMap = aStudyBuilder.FindOrCreateAttribute(aSComponent,"AttributePixMap")
+ aPixMap.SetPixMap("ICON_OBJBROWSER_Visu")
+
+ aStudyBuilder.DefineComponentInstance(aSComponent,myLocalVisu);
+ if aLocked:
+ theStudyDocument.GetProperties().SetLocked(1);
+ pass
+
+ aStudyBuilder.CommitCommand();
+ pass
+ return aSComponent;
+
def StrToMap(theString) :
aPairList = split(theString,";")
aMap = {}