ID 0019887: EDF 757 SMESH: It is possible to delete a referenced GEOM object from SMESH

This commit is contained in:
dmv 2008-06-19 07:15:20 +00:00
parent d606c0d54d
commit a0a59a9d9c

View File

@ -883,9 +883,23 @@ using namespace std;
LightApp_SelectionMgr* aSel = SMESHGUI::selectionMgr(); LightApp_SelectionMgr* aSel = SMESHGUI::selectionMgr();
SALOME_ListIO selected; aSel->selectedObjects( selected, QString::null, false ); SALOME_ListIO selected; aSel->selectedObjects( selected, QString::null, false );
_PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
_PTR(StudyBuilder) aStudyBuilder = aStudy->NewBuilder();
_PTR(GenericAttribute) anAttr;
_PTR(AttributeIOR) anIOR;
int objectCount = 0;
QString aParentComponent = QString::null; QString aParentComponent = QString::null;
for( SALOME_ListIteratorOfListIO anIt( selected ); anIt.More(); anIt.Next() ) for( SALOME_ListIteratorOfListIO anIt( selected ); anIt.More(); anIt.Next() )
{ {
_PTR(SObject) aSO = aStudy->FindObjectID(anIt.Value()->getEntry());
if (aSO) {
// check if object is not reference
_PTR(SObject) refobj;
if ( !aSO->ReferencedObject( refobj ) )
objectCount++;
}
QString cur = anIt.Value()->getComponentDataType(); QString cur = anIt.Value()->getComponentDataType();
if( aParentComponent.isNull() ) if( aParentComponent.isNull() )
aParentComponent = cur; aParentComponent = cur;
@ -893,6 +907,9 @@ using namespace std;
aParentComponent = ""; aParentComponent = "";
} }
if ( objectCount == 0 )
return; // No Valid Objects Selected
if ( aParentComponent != SMESHGUI::GetSMESHGUI()->name() ) { if ( aParentComponent != SMESHGUI::GetSMESHGUI()->name() ) {
SUIT_MessageBox::warn1 ( SMESHGUI::desktop(), SUIT_MessageBox::warn1 ( SMESHGUI::desktop(),
QObject::tr("ERR_ERROR"), QObject::tr("ERR_ERROR"),
@ -912,11 +929,6 @@ using namespace std;
SUIT_ViewManager* vm = anApp->activeViewManager(); SUIT_ViewManager* vm = anApp->activeViewManager();
int nbSf = vm->getViewsCount(); int nbSf = vm->getViewsCount();
_PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
_PTR(StudyBuilder) aStudyBuilder = aStudy->NewBuilder();
_PTR(GenericAttribute) anAttr;
_PTR(AttributeIOR) anIOR;
SALOME_ListIteratorOfListIO It(selected); SALOME_ListIteratorOfListIO It(selected);
aStudyBuilder->NewCommand(); // There is a transaction aStudyBuilder->NewCommand(); // There is a transaction
@ -932,6 +944,10 @@ using namespace std;
continue; continue;
} }
_PTR(SObject) refobj;
if ( aSO && aSO->ReferencedObject( refobj ) )
continue; // skip references
// put the whole hierarchy of sub-objects of the selected SO into a list and // put the whole hierarchy of sub-objects of the selected SO into a list and
// then treat them all starting from the deepest objects (at list back) // then treat them all starting from the deepest objects (at list back)