mirror of
https://git.salome-platform.org/gitpub/modules/geom.git
synced 2024-11-11 16:19:17 +05:00
bos #19182: Additional fix for CreateFolder() service
This commit is contained in:
parent
5088f18afd
commit
8647067a5b
@ -226,23 +226,7 @@ SALOMEDS::SObject_ptr GEOM_Gen_i::PublishInStudy(SALOMEDS::SObject_ptr theSObjec
|
|||||||
SALOMEDS::StudyBuilder_var aStudyBuilder = aStudy->NewBuilder();
|
SALOMEDS::StudyBuilder_var aStudyBuilder = aStudy->NewBuilder();
|
||||||
SALOMEDS::UseCaseBuilder_wrap useCaseBuilder = aStudy->GetUseCaseBuilder();
|
SALOMEDS::UseCaseBuilder_wrap useCaseBuilder = aStudy->GetUseCaseBuilder();
|
||||||
|
|
||||||
SALOMEDS::SComponent_var aFather = aStudy->FindComponent("GEOM");
|
SALOMEDS::SComponent_var aFather = findOrCreateComponent();
|
||||||
if (aFather->_is_nil()) {
|
|
||||||
aFather = aStudyBuilder->NewComponent("GEOM");
|
|
||||||
anAttr = aStudyBuilder->FindOrCreateAttribute(aFather, "AttributeName");
|
|
||||||
SALOMEDS::AttributeName_var aName = SALOMEDS::AttributeName::_narrow(anAttr);
|
|
||||||
aName->SetValue("Geometry");
|
|
||||||
aName->UnRegister();
|
|
||||||
anAttr = aStudyBuilder->FindOrCreateAttribute(aFather, "AttributePixMap");
|
|
||||||
SALOMEDS::AttributePixMap_var aPixMap=SALOMEDS::AttributePixMap::_narrow(anAttr);
|
|
||||||
aPixMap->SetPixMap("ICON_OBJBROWSER_Geometry");
|
|
||||||
aPixMap->UnRegister();
|
|
||||||
aStudyBuilder->DefineComponentInstance(aFather, (GEOM::GEOM_Gen_var)GEOM_Gen::_this());
|
|
||||||
// add component to the use case tree
|
|
||||||
// (to support tree representation customization and drag-n-drop)
|
|
||||||
useCaseBuilder->SetRootCurrent();
|
|
||||||
useCaseBuilder->Append( aFather ); // component object is added as the top level item
|
|
||||||
}
|
|
||||||
if (aFather->_is_nil()) return aResultSO;
|
if (aFather->_is_nil()) return aResultSO;
|
||||||
|
|
||||||
if (CORBA::is_nil(theSObject)) {
|
if (CORBA::is_nil(theSObject)) {
|
||||||
@ -2195,6 +2179,41 @@ SALOMEDS::Study_var GEOM_Gen_i::getStudyServant()
|
|||||||
return aStudy;
|
return aStudy;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//============================================================================
|
||||||
|
// function : findOrCreateComponent()
|
||||||
|
// purpose : Find root study component; create if it does not exist
|
||||||
|
//============================================================================
|
||||||
|
SALOMEDS::SComponent_var GEOM_Gen_i::findOrCreateComponent()
|
||||||
|
{
|
||||||
|
SALOMEDS::SComponent_var aComponent;
|
||||||
|
|
||||||
|
SALOMEDS::Study_var aStudy = getStudyServant();
|
||||||
|
if (aStudy->_is_nil()) return aComponent;
|
||||||
|
|
||||||
|
SALOMEDS::GenericAttribute_var anAttr;
|
||||||
|
SALOMEDS::StudyBuilder_var aStudyBuilder = aStudy->NewBuilder();
|
||||||
|
SALOMEDS::UseCaseBuilder_wrap useCaseBuilder = aStudy->GetUseCaseBuilder();
|
||||||
|
|
||||||
|
aComponent = aStudy->FindComponent(ComponentDataType());
|
||||||
|
if (aComponent->_is_nil()) {
|
||||||
|
aComponent = aStudyBuilder->NewComponent(ComponentDataType());
|
||||||
|
anAttr = aStudyBuilder->FindOrCreateAttribute(aComponent.in(), "AttributeName");
|
||||||
|
SALOMEDS::AttributeName_var aName = SALOMEDS::AttributeName::_narrow(anAttr);
|
||||||
|
aName->SetValue("Geometry");
|
||||||
|
aName->UnRegister();
|
||||||
|
anAttr = aStudyBuilder->FindOrCreateAttribute(aComponent.in(), "AttributePixMap");
|
||||||
|
SALOMEDS::AttributePixMap_var aPixMap=SALOMEDS::AttributePixMap::_narrow(anAttr);
|
||||||
|
aPixMap->SetPixMap("ICON_OBJBROWSER_Geometry");
|
||||||
|
aPixMap->UnRegister();
|
||||||
|
aStudyBuilder->DefineComponentInstance(aComponent.in(), (GEOM::GEOM_Gen_var)GEOM_Gen::_this());
|
||||||
|
// add component to the use case tree
|
||||||
|
// (to support tree representation customization and drag-n-drop)
|
||||||
|
useCaseBuilder->SetRootCurrent();
|
||||||
|
useCaseBuilder->Append(aComponent.in()); // component object is added as the top level item
|
||||||
|
}
|
||||||
|
return aComponent;
|
||||||
|
}
|
||||||
|
|
||||||
//============================================================================
|
//============================================================================
|
||||||
// function : Undo
|
// function : Undo
|
||||||
// purpose :
|
// purpose :
|
||||||
@ -2866,6 +2885,11 @@ SALOMEDS::SObject_ptr GEOM_Gen_i::CreateFolder(const char* theName,
|
|||||||
{
|
{
|
||||||
SALOMEDS::SObject_var aFolderSO;
|
SALOMEDS::SObject_var aFolderSO;
|
||||||
|
|
||||||
|
if ( CORBA::is_nil(theFather) ) {
|
||||||
|
SALOMEDS::SComponent_var aComponent = findOrCreateComponent();
|
||||||
|
if (aComponent->_is_nil()) return aFolderSO._retn();
|
||||||
|
theFather = SALOMEDS::SObject::_narrow(aComponent);
|
||||||
|
}
|
||||||
if ( CORBA::is_nil(theFather) ) return aFolderSO._retn();
|
if ( CORBA::is_nil(theFather) ) return aFolderSO._retn();
|
||||||
|
|
||||||
SALOMEDS::GenericAttribute_var anAttr;
|
SALOMEDS::GenericAttribute_var anAttr;
|
||||||
|
@ -325,6 +325,8 @@ class GEOM_I_EXPORT GEOM_Gen_i: virtual public POA_GEOM::GEOM_Gen, virtual publi
|
|||||||
virtual GEOM::GEOM_BaseObject_ptr GetObject(const char* theEntry);
|
virtual GEOM::GEOM_BaseObject_ptr GetObject(const char* theEntry);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
SALOMEDS::SComponent_var findOrCreateComponent();
|
||||||
|
|
||||||
GEOM::ListOfGO* RestoreSubShapes (GEOM::GEOM_Object_ptr theObject,
|
GEOM::ListOfGO* RestoreSubShapes (GEOM::GEOM_Object_ptr theObject,
|
||||||
SALOMEDS::SObject_ptr theSObject,
|
SALOMEDS::SObject_ptr theSObject,
|
||||||
const GEOM::ListOfGO& theArgs,
|
const GEOM::ListOfGO& theArgs,
|
||||||
|
Loading…
Reference in New Issue
Block a user