Problem fixed: it's impossible to delete object which are used for another object creation

This commit is contained in:
maintenance team 2006-10-09 07:07:32 +00:00
parent 4cb5895062
commit dcd0ee95bf
2 changed files with 29 additions and 0 deletions

View File

@ -2962,3 +2962,5 @@ msgstr "Settings"
msgid "ERROR_SHAPE_TYPE" msgid "ERROR_SHAPE_TYPE"
msgstr "Object of incorrect type selected!\nPlease, select face, shell or solid and try again" msgstr "Object of incorrect type selected!\nPlease, select face, shell or solid and try again"
msgid "DEP_OBJECT"
msgstr "Selected object has been used to create another one\n It can't be deleted "

View File

@ -288,6 +288,10 @@ void GEOMToolsGUI::OnEditDelete()
_PTR(GenericAttribute) anAttr; _PTR(GenericAttribute) anAttr;
GEOM_Displayer* disp = new GEOM_Displayer( appStudy ); GEOM_Displayer* disp = new GEOM_Displayer( appStudy );
_PTR(SComponent) aGeom ( aStudy->FindComponent("GEOM") );
if ( !aGeom )
return;
// MAIN LOOP OF SELECTED OBJECTS // MAIN LOOP OF SELECTED OBJECTS
for ( SALOME_ListIteratorOfListIO It( selected ); It.More(); It.Next() ) { for ( SALOME_ListIteratorOfListIO It( selected ); It.More(); It.Next() ) {
@ -301,6 +305,29 @@ void GEOMToolsGUI::OnEditDelete()
if ( !strcmp( obj->GetIOR().c_str(), geomIOR ) ) if ( !strcmp( obj->GetIOR().c_str(), geomIOR ) )
continue; continue;
//If the object has been used to create another one,then it can't be deleted
_PTR(ChildIterator) it (aStudy->NewChildIterator(aGeom));
for ( it->InitEx( true ); it->More(); it->Next() ) {
_PTR(SObject) chobj (it->Value());
CORBA::Object_var corbaObj = GeometryGUI::ClientSObjectToObject(chobj);
GEOM::GEOM_Object_var geomObj = GEOM::GEOM_Object::_narrow( corbaObj );
if( CORBA::is_nil(geomObj) )
continue;
GEOM::ListOfGO_var list = geomObj->GetDependency();
if( list->length() > 1 )
for(int i = 0; i < list->length(); i++ ){
CORBA::Object_var corbaObj_rem = GeometryGUI::ClientSObjectToObject(obj);
GEOM::GEOM_Object_var geomObj_rem = GEOM::GEOM_Object::_narrow( corbaObj_rem );
if( list[i]->_is_equivalent( geomObj_rem ) ){
SUIT_MessageBox::warn1 ( app->desktop(),
QObject::tr("WRN_WARNING"),
QObject::tr("DEP_OBJECT"),
QObject::tr("BUT_OK") );
return;
}
}
}
RemoveObjectWithChildren(obj, aStudy, views, disp); RemoveObjectWithChildren(obj, aStudy, views, disp);
// Remove objects from Study // Remove objects from Study