Salome HOME
Merge from V5_1_4_BR (5_1_4rc2) 09/06/2010
[modules/smesh.git] / src / SMESHGUI / SMESHGUI_GroupDlg.cxx
index 114a7fd973a694755128d2eaa056c291fbbf4299..28461ee4fb0d89afd3a644eb9098d11e41b47d63 100644 (file)
@@ -1,4 +1,4 @@
-//  Copyright (C) 2007-2008  CEA/DEN, EDF R&D, OPEN CASCADE
+//  Copyright (C) 2007-2010  CEA/DEN, EDF R&D, OPEN CASCADE
 //
 //  Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
 //  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
 //
 //  See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
 //
+
 //  SMESH SMESHGUI : GUI for SMESH component
 //  File   : SMESHGUI_GroupDlg.cxx
 //  Author : Natalia KOPNOVA, Open CASCADE S.A.S.
 //  SMESH includes
-
+//
 #include "SMESHGUI_GroupDlg.h"
 
 #include "SMESHGUI.h"
@@ -590,7 +591,8 @@ void SMESHGUI_GroupDlg::init (SMESH::SMESH_GroupBase_ptr theGroup,
     if (!aGroupShape->_is_nil())
     {
       _PTR(SObject) aGroupShapeSO = aStudy->FindObjectID(aGroupShape->GetStudyEntry());
-      aShapeName = aGroupShapeSO->GetName().c_str();
+      if ( aGroupShapeSO )
+        aShapeName = aGroupShapeSO->GetName().c_str();
     }
     myGeomGroupLine->setText( aShapeName );
     myNameChanged = true;
@@ -850,6 +852,7 @@ bool SMESHGUI_GroupDlg::onApply()
       }
     }
 
+    SMESHGUI::Modified();
     mySMESHGUI->updateObjBrowser(true);
     SMESH::UpdateView(); // asv: fix of BUG PAL5515
     mySelectionMgr->clearSelected();
@@ -955,6 +958,7 @@ bool SMESHGUI_GroupDlg::onApply()
       }
     }
 
+    SMESHGUI::Modified();
     mySMESHGUI->updateObjBrowser(true);
     mySelectionMgr->clearSelected();
     return true;
@@ -1062,6 +1066,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 +1095,6 @@ void SMESHGUI_GroupDlg::onObjectSelectionChanged()
           return;
         }
         myIsBusy = false;
-        myCurrentLineEdit = 0;
 
         myGroup = SMESH::SMESH_Group::_nil();
         myGroupOnGeom = SMESH::SMESH_GroupOnGeom::_nil();
@@ -1417,11 +1424,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) {
@@ -2230,14 +2240,20 @@ bool SMESHGUI_GroupDlg::SetAppropriateActor()
   } else {
     // try mesh actor
     SMESH_Actor* anActor = SMESH::FindActorByObject(myMesh);
-    if (anActor && anActor->hasIO())
-      {
-        isActor = true;
-        if (aViewWindow && !aViewWindow->isVisible(anActor->getIO()))
-          isActor = false;
-        else
-          myActorsList.append(anActor);
-      }
+    if (anActor && anActor->hasIO()) {
+      isActor = true;
+      if (aViewWindow && !aViewWindow->isVisible(anActor->getIO()))
+        isActor = false;
+      else
+        myActorsList.append(anActor);
+    }
+    
+    // try group actor
+    if (!isActor && !myGroup->_is_nil()) {
+      SMESH_Actor* anActor = SMESH::FindActorByObject(myGroup);
+      if (anActor && anActor->hasIO())
+        myActorsList.append(anActor);
+    }
     
     // try any visible actor of group or submesh of current mesh
     if (aViewWindow) {
@@ -2258,7 +2274,7 @@ bool SMESHGUI_GroupDlg::SetAppropriateActor()
             if (anActor && anActor->hasIO()) {
               Handle(SALOME_InteractiveObject) anIO = anActor->getIO();
               if (aViewWindow->isVisible(anIO)) {
-                if (anIO->hasEntry() && strncmp(anIO->getEntry(), meshEntry, len) == 0)
+                if (anIO->hasEntry() && strncmp(anIO->getEntry(), meshEntry, len) == 0 && !myActorsList.contains(anActor) )
                   myActorsList.append(anActor);
               }
             }