Salome HOME
PAL9963
authorasl <asl@opencascade.com>
Thu, 29 Sep 2005 07:00:14 +0000 (07:00 +0000)
committerasl <asl@opencascade.com>
Thu, 29 Sep 2005 07:00:14 +0000 (07:00 +0000)
src/SMESHGUI/SMESHGUI.cxx
src/SMESHGUI/SMESHGUI_Selection.cxx

index aade73a3e9c36c066f409d9c6627ee1aefaca024..d481b7d9ca0848397e22b028e7f2d9fc359bbcd0 100644 (file)
@@ -1155,12 +1155,46 @@ bool SMESHGUI::OnGUIEvent( int theCommandID )
       }
 
       SalomeApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
       }
 
       SalomeApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
-      SALOME_ListIO selected;
+      SALOME_ListIO sel_objects, to_process;
       if (aSel)
       if (aSel)
-        aSel->selectedObjects( selected );
+        aSel->selectedObjects( sel_objects );
+
+      SALOME_ListIteratorOfListIO anIt( sel_objects );
+      for( ; anIt.More(); anIt.Next() )
+      {
+       Handle( SALOME_InteractiveObject ) obj = anIt.Value();
+       if( obj->hasEntry() )
+       {
+         _PTR(SObject) SO = activeStudy()->studyDS()->FindObjectID( obj->getEntry() );
+         if( SO && QString( SO->GetID().c_str() ) == SO->GetFatherComponent()->GetID().c_str() )
+         { //component is selected
+           _PTR(SComponent) SC( SO->GetFatherComponent() );
+           _PTR(ChildIterator) anIter ( activeStudy()->studyDS()->NewChildIterator( SC ) );
+           anIter->InitEx( true );
+           while( anIter->More() )
+           {
+             _PTR(SObject) valSO ( anIter->Value() );
+             _PTR(SObject) refSO;
+             if( !valSO->ReferencedObject( refSO ) )
+             {
+               QString id = valSO->GetID().c_str(),
+                        comp = SC->ComponentDataType().c_str(),
+                       val = valSO->GetName().c_str();
+
+               Handle( SALOME_InteractiveObject ) new_obj = 
+                 new SALOME_InteractiveObject( id.latin1(), comp.latin1(), val.latin1() );
+               to_process.Append( new_obj );
+             }
+             anIter->Next();       
+           }
+           continue;
+         }
+       }
+       to_process.Append( obj );
+      }
 
       if (vtkwnd) {
 
       if (vtkwnd) {
-       SALOME_ListIteratorOfListIO It (selected);
+       SALOME_ListIteratorOfListIO It( to_process );
        for (; It.More(); It.Next()) {
          Handle(SALOME_InteractiveObject) IOS = It.Value();
          if (IOS->hasEntry()) {
        for (; It.More(); It.Next()) {
          Handle(SALOME_InteractiveObject) IOS = It.Value();
          if (IOS->hasEntry()) {
@@ -1176,7 +1210,7 @@ bool SMESHGUI::OnGUIEvent( int theCommandID )
        aSel->setSelectedObjects( l1 );
       }
       else
        aSel->setSelectedObjects( l1 );
       }
       else
-       aSel->setSelectedObjects( selected );
+       aSel->setSelectedObjects( to_process );
       break;
     }
 
       break;
     }
 
@@ -2548,7 +2582,8 @@ void SMESHGUI::initialize( CAM_Application* app )
 
   QString lc = QtxPopupMgr::Selection::defEquality();
   QString aClient = QString( "%1client in {%2}" ).arg( lc ).arg( "'VTKViewer'" );
 
   QString lc = QtxPopupMgr::Selection::defEquality();
   QString aClient = QString( "%1client in {%2}" ).arg( lc ).arg( "'VTKViewer'" );
-  QString aType = QString( "%1type in {%2}" ).arg( QtxPopupMgr::Selection::defEquality() ).arg( mesh_group );
+  QString aType = QString( "%1type in {%2}" ).arg( QtxPopupMgr::Selection::defEquality() );
+  aType = aType.arg( mesh_group );
   QString aMeshInVTK = aClient + "&&" + aType;
 
   //-------------------------------------------------
   QString aMeshInVTK = aClient + "&&" + aType;
 
   //-------------------------------------------------
@@ -2717,15 +2752,17 @@ void SMESHGUI::initialize( CAM_Application* app )
   aClient = "($client in {'VTKViewer' 'ObjectBrowser'})";
   QString anActiveVTK = QString("activeView = '%1'").arg(VTKViewer_Viewer::Type());
   QString aSelCount = QString( "%1 > 0" ).arg( QtxPopupMgr::Selection::defSelCountParam() );
   aClient = "($client in {'VTKViewer' 'ObjectBrowser'})";
   QString anActiveVTK = QString("activeView = '%1'").arg(VTKViewer_Viewer::Type());
   QString aSelCount = QString( "%1 > 0" ).arg( QtxPopupMgr::Selection::defSelCountParam() );
-  QString aRule = aClient + " and " + aType + " and " + aSelCount + " and " + anActiveVTK;
+
+  QString aRule = "type='Component' or (" + aClient + " and " + aType + " and " + aSelCount +
+     " and " + anActiveVTK + " and " + isNotEmpty + " %1 )";
   popupMgr()->insert( action( 301 ), -1, -1 ); // DISPLAY
   popupMgr()->insert( action( 301 ), -1, -1 ); // DISPLAY
-  popupMgr()->setRule( action( 301 ), aRule + "&&" + isNotEmpty + "&&" + isInvisible, true);
+  popupMgr()->setRule( action( 301 ), aRule.arg( "and (not isVisible)" ), true);
 
   popupMgr()->insert( action( 300 ), -1, -1 ); // ERASE
 
   popupMgr()->insert( action( 300 ), -1, -1 ); // ERASE
-  popupMgr()->setRule( action( 300 ), aRule + "&&" + isNotEmpty + "&& isVisible", true );
+  popupMgr()->setRule( action( 300 ), aRule.arg( "and isVisible" ), true );
 
   popupMgr()->insert( action( 302 ), -1, -1 ); // DISPLAY_ONLY
 
   popupMgr()->insert( action( 302 ), -1, -1 ); // DISPLAY_ONLY
-  popupMgr()->setRule( action( 302 ), aRule + "&&" + isNotEmpty, true );
+  popupMgr()->setRule( action( 302 ), aRule.arg( "" ), true );
 
   popupMgr()->insert( separator(), -1, -1 );
 
 
   popupMgr()->insert( separator(), -1, -1 );
 
index ee4b1e60dcd429085ba9cf9400c3daac51ca22c0..b6a899e342cb19693267f51ecdbda88bbae2fb1f 100644 (file)
@@ -350,6 +350,9 @@ int SMESHGUI_Selection::type( const QString& entry, _PTR(Study) study )
   if( objComponent->ComponentDataType()!="SMESH" )
     return -1;
 
   if( objComponent->ComponentDataType()!="SMESH" )
     return -1;
 
+  if( objComponent->GetIOR()==obj->GetIOR() )
+    return COMPONENT;
+
   int aLevel = obj->Depth() - objComponent->Depth(),
       aFTag = objFather->Tag(),
       anOTag = obj->Tag(),
   int aLevel = obj->Depth() - objComponent->Depth(),
       aFTag = objFather->Tag(),
       anOTag = obj->Tag(),
@@ -431,6 +434,8 @@ QString SMESHGUI_Selection::typeName( const int t )
     return "Mesh compound";
   case GROUP:
     return "Group";
     return "Mesh compound";
   case GROUP:
     return "Group";
+  case COMPONENT:
+    return "Component";
   default:
     return "Unknown";
   }
   default:
     return "Unknown";
   }