From: maintenance team Date: Mon, 9 Oct 2006 07:07:32 +0000 (+0000) Subject: Problem fixed: it's impossible to delete object which are used for another object... X-Git-Tag: V3_2_3pre1~13 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=dcd0ee95bfd80958ce0cf0a46fb2b4199614bdf3;p=modules%2Fgeom.git Problem fixed: it's impossible to delete object which are used for another object creation --- diff --git a/src/GEOMGUI/GEOM_msg_en.po b/src/GEOMGUI/GEOM_msg_en.po index 57a0ada96..6d538e649 100644 --- a/src/GEOMGUI/GEOM_msg_en.po +++ b/src/GEOMGUI/GEOM_msg_en.po @@ -2962,3 +2962,5 @@ msgstr "Settings" msgid "ERROR_SHAPE_TYPE" 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 " diff --git a/src/GEOMToolsGUI/GEOMToolsGUI.cxx b/src/GEOMToolsGUI/GEOMToolsGUI.cxx index c18dc6c65..4efbfbbad 100644 --- a/src/GEOMToolsGUI/GEOMToolsGUI.cxx +++ b/src/GEOMToolsGUI/GEOMToolsGUI.cxx @@ -288,6 +288,10 @@ void GEOMToolsGUI::OnEditDelete() _PTR(GenericAttribute) anAttr; GEOM_Displayer* disp = new GEOM_Displayer( appStudy ); + _PTR(SComponent) aGeom ( aStudy->FindComponent("GEOM") ); + if ( !aGeom ) + return; + // MAIN LOOP OF SELECTED OBJECTS for ( SALOME_ListIteratorOfListIO It( selected ); It.More(); It.Next() ) { @@ -301,6 +305,29 @@ void GEOMToolsGUI::OnEditDelete() if ( !strcmp( obj->GetIOR().c_str(), geomIOR ) ) 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); // Remove objects from Study