Salome HOME
Debug
[modules/smesh.git] / src / SMESHGUI / SMESHGUI_GroupDlg.cxx
index 9d76c2fee6c0ffd321cd9bf9bf28b5cf1c868c3a..32f66474c196d0369bf479ac7a36cfa464759201 100644 (file)
@@ -1062,6 +1062,10 @@ void SMESHGUI_GroupDlg::onObjectSelectionChanged()
           myIsBusy = false;
           return;
         }
+
+        if ( myFilterDlg && !myMesh->_is_nil()){
+          myFilterDlg->SetMesh( myMesh );
+        }
         myGroup = SMESH::SMESH_Group::_nil();
 
         // NPAL19389: create a group with a selection in another group
@@ -1087,7 +1091,6 @@ void SMESHGUI_GroupDlg::onObjectSelectionChanged()
           return;
         }
         myIsBusy = false;
-        myCurrentLineEdit = 0;
 
         myGroup = SMESH::SMESH_Group::_nil();
         myGroupOnGeom = SMESH::SMESH_GroupOnGeom::_nil();
@@ -1298,20 +1301,32 @@ void SMESHGUI_GroupDlg::onObjectSelectionChanged()
   }
   
   if (myActorsList.count() == 0) {
-    if (!myGroup->_is_nil())
-      myActorsList.append( SMESH::FindActorByObject(myGroup) );
-    else if(!myGroupOnGeom->_is_nil())
-      myActorsList.append( SMESH::FindActorByObject(myGroupOnGeom) );
-    else
-      myActorsList.append( SMESH::FindActorByObject(myMesh) );
+    if (!myGroup->_is_nil()) {
+      SMESH_Actor* anActor = SMESH::FindActorByObject(myGroup);
+      if ( anActor )
+        myActorsList.append( anActor  );
+    }
+    else if(!myGroupOnGeom->_is_nil()) {
+      SMESH_Actor* anActor = SMESH::FindActorByObject(myGroupOnGeom);
+      if ( anActor )
+        myActorsList.append( anActor );
+    }
+    else {
+      SMESH_Actor* anActor = SMESH::FindActorByObject( myMesh );
+      if ( anActor )
+        myActorsList.append( anActor );
+    }
   }
 
   // somehow, if we display the mesh, while selecting from another actor,
   // the mesh becomes pickable, and there is no way to select any element
   if (myActorsList.count() > 0) {
     QListIterator<SMESH_Actor*> it( myActorsList );
-    while ( it.hasNext() )
-      it.next()->SetPickable(true);
+    while ( it.hasNext() ) {
+      SMESH_Actor* anActor = it.next();
+      if ( IsActorVisible(anActor) )
+        anActor->SetPickable(true);
+    }
   }
 
   myIsBusy = false;
@@ -1405,11 +1420,14 @@ void SMESHGUI_GroupDlg::setCurrentSelection()
   QPushButton* send = (QPushButton*)sender();
   myCurrentLineEdit = 0;
   if (send == myMeshGroupBtn) {
-    myCurrentLineEdit = myMeshGroupLine;
+    disconnect(myMeshGroupBtn, SIGNAL(clicked()), this, SLOT(setCurrentSelection()));
+    mySelectionMgr->clearSelected();
     if (myCreate)
       setSelectionMode(6);
     else
       setSelectionMode(5);
+    connect(myMeshGroupBtn, SIGNAL(clicked()), this, SLOT(setCurrentSelection()));
+    myCurrentLineEdit = myMeshGroupLine;
     onObjectSelectionChanged();
   }
   else if (send == mySubMeshBtn) {
@@ -2257,8 +2275,11 @@ bool SMESHGUI_GroupDlg::SetAppropriateActor()
   
   if (myActorsList.count() > 0) {
     QListIterator<SMESH_Actor*> it( myActorsList );
-    while ( it.hasNext() )
-      it.next()->SetPickable(true);
+    while ( it.hasNext() ) {
+      SMESH_Actor* anActor = it.next();
+      if ( IsActorVisible(anActor) )
+        anActor->SetPickable(true);
+    }
   }
   
   return ( isActor || (myActorsList.count() > 0) );
@@ -2297,3 +2318,15 @@ void SMESHGUI_GroupDlg::restoreShowEntityMode()
   }
   myStoredShownEntity = 0;
 }
+
+//=======================================================================
+//function : IsActorVisible
+//purpose  : return visibility of the actor
+//=======================================================================
+bool SMESHGUI_GroupDlg::IsActorVisible( SMESH_Actor* theActor )
+{
+  SVTK_ViewWindow* aViewWindow = SMESH::GetCurrentVtkView();
+  if (theActor && aViewWindow)
+    return aViewWindow->isVisible(theActor->getIO());
+  return false;
+}