Fixed problem: it's impossible to delete main object if its subshape have been used for annother geometrical object creation

This commit is contained in:
epa 2006-12-07 11:42:23 +00:00
parent aa13d2abfd
commit 02aab3a5b3
2 changed files with 45 additions and 17 deletions

View File

@ -309,23 +309,12 @@ void GEOMToolsGUI::OnEditDelete()
_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;
}
}
if(CheckSubObjectInUse(chobj, obj, aStudy)) return;
//check subobjects
for (_PTR(ChildIterator) it (aStudy->NewChildIterator(obj)); it->More(); it->Next()) {
_PTR(SObject) child (it->Value());
if(CheckSubObjectInUse( chobj, child, aStudy)) return;
}
}
RemoveObjectWithChildren(obj, aStudy, views, disp);
@ -681,6 +670,39 @@ void GEOMToolsGUI::RemoveObjectWithChildren(_PTR(SObject) obj,
}
}
//=====================================================================================
// function : CheckSubObjectInUse
// purpose : to be used by OnEditDelete() method
//=====================================================================================
bool GEOMToolsGUI::CheckSubObjectInUse(_PTR(SObject) checkobj,
_PTR(SObject) remobj,
_PTR(Study) aStudy)
{
CORBA::Object_var corbaObj = GeometryGUI::ClientSObjectToObject(checkobj);
GEOM::GEOM_Object_var geomObj = GEOM::GEOM_Object::_narrow( corbaObj );
if( CORBA::is_nil(geomObj) )
return false;
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(remobj);
GEOM::GEOM_Object_var geomObj_rem = GEOM::GEOM_Object::_narrow( corbaObj_rem );
if( list[i]->_is_equivalent( geomObj_rem ) ){
SalomeApp_Application* app =
dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
SUIT_MessageBox::warn1 ( app->desktop(),
QObject::tr("WRN_WARNING"),
QObject::tr("DEP_OBJECT"),
QObject::tr("BUT_OK") );
return true;
}
}
return false;
}
//=====================================================================================
// EXPORTED METHODS
//=====================================================================================

View File

@ -89,6 +89,12 @@ private:
_PTR(Study) aStudy,
QPtrList<SALOME_View> views,
GEOM_Displayer* disp);
//checks if the object passed as the first argument depends on the second arguments
bool CheckSubObjectInUse(_PTR(SObject) checkobj,
_PTR(SObject) remobj,
_PTR(Study) aStudy);
};
#endif