Salome HOME
Improvement 0018239: Create subMesh menu item
[modules/smesh.git] / src / SMESHGUI / SMESHGUI.cxx
index 509b176d95c10522157a1628802e8d587281c351..5fb5edaa2352645f3338aef6350b438097e3b6e8 100644 (file)
     _PTR(AttributeIOR) anIOR;
 
     int objectCount = 0;
+    QString aNameList;
     QString aParentComponent = QString::null;
+    Handle(SALOME_InteractiveObject) anIO;
     for( SALOME_ListIteratorOfListIO anIt( selected ); anIt.More(); anIt.Next() )
     {
-      _PTR(SObject) aSO = aStudy->FindObjectID(anIt.Value()->getEntry());
+      anIO = anIt.Value();
+      QString cur = anIO->getComponentDataType();
+      _PTR(SObject) aSO = aStudy->FindObjectID(anIO->getEntry());
       if (aSO) {
-       // check if object is not reference
-       _PTR(SObject) refobj;
-       if ( !aSO->ReferencedObject( refobj ) )
-         objectCount++;
+       // check if object is reference
+       _PTR(SObject) aRefSObj;
+       aNameList.append("\n    - ");
+       if ( aSO->ReferencedObject( aRefSObj ) ) {
+         QString aRefName = QString::fromStdString ( aRefSObj->GetName() );
+         aNameList.append( aRefName );
+         cur = QString::fromStdString ( aRefSObj->GetFatherComponent()->ComponentDataType() );
+       }
+       else
+         aNameList.append(anIO->getName());
+       objectCount++;
       }
 
-      QString cur = anIt.Value()->getComponentDataType();
       if( aParentComponent.isNull() )
         aParentComponent = cur;
       else if( !aParentComponent.isEmpty() && aParentComponent!=cur )
     if (SUIT_MessageBox::warning
        (SMESHGUI::desktop(),
         QObject::tr("SMESH_WRN_WARNING"),
-        QObject::tr("SMESH_REALLY_DELETE"),
+        QObject::tr("SMESH_REALLY_DELETE").arg( objectCount ).arg( aNameList ),
         SUIT_MessageBox::Yes | SUIT_MessageBox::No,
         SUIT_MessageBox::Yes) != SUIT_MessageBox::Yes)
       return;
          if ( engineIOR() == anIOR->Value().c_str() )
            continue;
        }
-
-       _PTR(SObject) refobj;
-       if ( aSO && aSO->ReferencedObject( refobj ) )
-         continue; // skip references
+       //Check the referenced object
+       _PTR(SObject) aRefSObject;
+       if ( aSO && aSO->ReferencedObject( aRefSObject ) )
+         aSO = aRefSObject; // Delete main Object instead of reference
 
         // 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)
@@ -2693,8 +2703,8 @@ void SMESHGUI::initialize( CAM_Application* app )
 
   createMenu( separator(), fileId );
 
-  int importId = createMenu( tr( "MEN_IMPORT" ), fileId, 11, 10 ),
-      exportId = createMenu( tr( "MEN_EXPORT" ), fileId, 12, 10 ),
+  int importId = createMenu( tr( "MEN_IMPORT" ), fileId, -1, 10 ),
+      exportId = createMenu( tr( "MEN_EXPORT" ), fileId, -1, 10 ),
       addId    = createMenu( tr( "MEN_ADD" ),    modifyId, 402 ),
       removeId = createMenu( tr( "MEN_REMOVE" ), modifyId, 403 ),
       renumId  = createMenu( tr( "MEN_RENUM" ),  modifyId, 404 ),
@@ -2918,6 +2928,8 @@ void SMESHGUI::initialize( CAM_Application* app )
   // popup for object browser
 
   createPopupItem( 150, OB, mesh, "&& selcount=1 && isImported" );      // FILE INFORMATION
+  createPopupItem( 703, OB, mesh, "&& isComputable");      // CREATE_SUBMESH
+  createPopupItem( 703, OB, subMesh, "&& isComputable" );  // CREATE_SUBMESH
   createPopupItem( 704, OB, mesh, "&& isComputable");      // EDIT_MESHSUBMESH
   createPopupItem( 704, OB, subMesh, "&& isComputable" );  // EDIT_MESHSUBMESH
   createPopupItem( 803, OB, group );                       // EDIT_GROUP