]> SALOME platform Git repositories - modules/geom.git/commitdiff
Salome HOME
Problem fixed: it's impossible to delete object which are used for another object...
authormaintenance team <salome-mnt@opencascade.com>
Mon, 9 Oct 2006 07:07:32 +0000 (07:07 +0000)
committermaintenance team <salome-mnt@opencascade.com>
Mon, 9 Oct 2006 07:07:32 +0000 (07:07 +0000)
src/GEOMGUI/GEOM_msg_en.po
src/GEOMToolsGUI/GEOMToolsGUI.cxx

index 57a0ada9645a36dedaed0a2bbc650f58dd9ec9c5..6d538e649f514049e66d9e12bf453ac752c2eb51 100644 (file)
@@ -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 "
index c18dc6c65b4e1a0c4c0a649838b22131d9248495..4efbfbbad598f31f00f9fc3c39dac89795f1c80c 100644 (file)
@@ -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