Salome HOME
Merge from V6_1_BR 07/09/2010
[modules/smesh.git] / src / SMESHGUI / SMESHGUI_EditMeshDlg.cxx
index c8aa3710d2feee3cbab5bfc885446167c9a7096b..64559a58a041bc096a230d15f174ee9a2aa8a679 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
@@ -19,6 +19,7 @@
 //
 //  See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
 //
+
 // SMESH SMESHGUI : GUI for SMESH component
 // File   : SMESHGUI_EditMeshDlg.cxx
 // Author : Open CASCADE S.A.S.
 #include <vtkIntArray.h>
 #include <vtkProperty2D.h>
 #include <vtkPointData.h>
+#include <vtkConfigure.h>
+#if !defined(VTK_XVERSION)
+#define VTK_XVERSION (VTK_MAJOR_VERSION<<16)+(VTK_MINOR_VERSION<<8)+(VTK_BUILD_VERSION)
+#endif
 
 // Qt includes
 #include <QApplication>
@@ -145,7 +150,9 @@ namespace SMESH
     
       myPtsLabeledDataMapper = vtkLabeledDataMapper::New();
       myPtsLabeledDataMapper->SetInput(myPtsSelectVisiblePoints->GetOutput());
+#if (VTK_XVERSION < 0x050200)
       myPtsLabeledDataMapper->SetLabelFormat("%g");
+#endif
       myPtsLabeledDataMapper->SetLabelModeToLabelScalars();
     
       vtkTextProperty* aPtsTextProp = vtkTextProperty::New();
@@ -169,7 +176,7 @@ namespace SMESH
     }
 
     void SetPointsData ( SMDS_Mesh* theMesh, 
-                        TColStd_MapOfInteger & theNodesIdMap )
+                         TColStd_MapOfInteger & theNodesIdMap )
     {
       vtkPoints* aPoints = vtkPoints::New();
       aPoints->SetNumberOfPoints(theNodesIdMap.Extent());
@@ -177,9 +184,9 @@ namespace SMESH
       
       TColStd_MapIteratorOfMapOfInteger idIter( theNodesIdMap );
       for( int i = 0; idIter.More(); idIter.Next(), i++ ) {
-       const SMDS_MeshNode* aNode = theMesh->FindNode(idIter.Key());
-       aPoints->SetPoint( i, aNode->X(), aNode->Y(), aNode->Z() );
-       myIDs.push_back(idIter.Key());
+        const SMDS_MeshNode* aNode = theMesh->FindNode(idIter.Key());
+        aPoints->SetPoint( i, aNode->X(), aNode->Y(), aNode->Z() );
+        myIDs.push_back(idIter.Key());
       }
 
       myIdGrid->SetPoints(aPoints);
@@ -190,7 +197,7 @@ namespace SMESH
     }
 
     void SetElemsData( TColStd_MapOfInteger & theElemsIdMap, 
-                      std::list<gp_XYZ> & aGrCentersXYZ )
+                       std::list<gp_XYZ> & aGrCentersXYZ )
     {
       vtkPoints* aPoints = vtkPoints::New();
       aPoints->SetNumberOfPoints(theElemsIdMap.Extent());
@@ -198,14 +205,14 @@ namespace SMESH
       
       TColStd_MapIteratorOfMapOfInteger idIter( theElemsIdMap );
       for( ; idIter.More(); idIter.Next() ) {
-       myIDs.push_back(idIter.Key());
+        myIDs.push_back(idIter.Key());
       }
 
       gp_XYZ aXYZ;
       std::list<gp_XYZ>::iterator coordIt = aGrCentersXYZ.begin();
       for( int i = 0; coordIt != aGrCentersXYZ.end(); coordIt++, i++ ) {
-       aXYZ = *coordIt;
-       aPoints->SetPoint( i, aXYZ.X(), aXYZ.Y(), aXYZ.Z() );
+        aXYZ = *coordIt;
+        aPoints->SetPoint( i, aXYZ.X(), aXYZ.Y(), aXYZ.Z() );
       }
       myIdGrid->SetPoints(aPoints);
       aPoints->Delete();
@@ -234,20 +241,20 @@ namespace SMESH
       myIsPointsLabeled = theIsPointsLabeled && myIdGrid->GetNumberOfPoints();
       
       if ( myIsPointsLabeled ) {
-       myPointsNumDataSet->ShallowCopy(myIdGrid);
-       vtkDataSet *aDataSet = myPointsNumDataSet;
-       int aNbElem = myIDs.size();
-       vtkIntArray *anArray = vtkIntArray::New();
-       anArray->SetNumberOfValues( aNbElem );
-       for ( int i = 0; i < aNbElem; i++ )
-         anArray->SetValue( i, myIDs[i] );
-       aDataSet->GetPointData()->SetScalars( anArray );
-       anArray->Delete();
-       myPtsMaskPoints->SetInput( aDataSet );
-       myPointLabels->SetVisibility( theIsActorVisible );
+        myPointsNumDataSet->ShallowCopy(myIdGrid);
+        vtkDataSet *aDataSet = myPointsNumDataSet;
+        int aNbElem = myIDs.size();
+        vtkIntArray *anArray = vtkIntArray::New();
+        anArray->SetNumberOfValues( aNbElem );
+        for ( int i = 0; i < aNbElem; i++ )
+          anArray->SetValue( i, myIDs[i] );
+        aDataSet->GetPointData()->SetScalars( anArray );
+        anArray->Delete();
+        myPtsMaskPoints->SetInput( aDataSet );
+        myPointLabels->SetVisibility( theIsActorVisible );
       }
       else {
-       myPointLabels->SetVisibility( false );
+        myPointLabels->SetVisibility( false );
       }
     }
     
@@ -270,7 +277,7 @@ namespace SMESH
       //myPtsSelectVisiblePoints->UnRegisterAllOutputs(); //vtk 5.0 porting
       myPtsSelectVisiblePoints->Delete();
 
-      //myPtsMaskPoints->UnRegisterAllOutputs();         //vtk 5.0 porting
+      //myPtsMaskPoints->UnRegisterAllOutputs();          //vtk 5.0 porting
       myPtsMaskPoints->Delete();
 
       myPointLabels->Delete();
@@ -282,8 +289,8 @@ namespace SMESH
 
 static const char * IconFirst[] = {
 "18 10 2 1",
-"      g None",
-".     g #000000",
+"       g None",
+".      g #000000",
 "         .     .  ",
 "  ..    ..    ..  ",
 "  ..   ...   ...  ",
@@ -300,7 +307,7 @@ static const char * IconFirst[] = {
 // purpose  :
 //=================================================================================
 SMESHGUI_EditMeshDlg::SMESHGUI_EditMeshDlg (SMESHGUI* theModule, 
-                                           int theAction)
+                                            int theAction)
   : QDialog(SMESH::GetDesktop(theModule)),
     mySMESHGUI(theModule),
     mySelectionMgr(SMESH::GetSelectionMgr(theModule)),
@@ -327,9 +334,9 @@ SMESHGUI_EditMeshDlg::SMESHGUI_EditMeshDlg (SMESHGUI* theModule,
 
   /***************************************************************/
   GroupConstructors = new QGroupBox(myAction == 1 ? 
-                                   tr("SMESH_MERGE_ELEMENTS") : 
-                                   tr("SMESH_MERGE_NODES"), 
-                                   this);
+                                    tr("SMESH_MERGE_ELEMENTS") : 
+                                    tr("SMESH_MERGE_NODES"), 
+                                    this);
 
   QButtonGroup* ButtonGroup = new QButtonGroup(this);
   QHBoxLayout* GroupConstructorsLayout = new QHBoxLayout(GroupConstructors);
@@ -359,48 +366,79 @@ SMESHGUI_EditMeshDlg::SMESHGUI_EditMeshDlg (SMESHGUI* theModule,
   GroupMeshLayout->addWidget(SelectMeshButton);
   GroupMeshLayout->addWidget(LineEditMesh);
 
+  /***************************************************************/
+  // Controls for switch dialog behaviour
+
+  TypeBox = new QGroupBox( tr( "SMESH_MODE" ), this );
+  GroupType = new QButtonGroup( this );
+  QHBoxLayout* aTypeBoxLayout = new QHBoxLayout( TypeBox );
+  aTypeBoxLayout->setMargin( MARGIN );
+  aTypeBoxLayout->setSpacing( SPACING );
+
+  QRadioButton* rb1 = new QRadioButton( tr( "SMESH_AUTOMATIC" ), TypeBox );
+  QRadioButton* rb2 = new QRadioButton( tr( "SMESH_MANUAL" ),   TypeBox );
+  GroupType->addButton( rb1, 0 );
+  GroupType->addButton( rb2, 1 );
+  aTypeBoxLayout->addWidget( rb1 );
+  aTypeBoxLayout->addWidget( rb2 );
+
+  myTypeId = 0;
+
   /***************************************************************/
   // Controls for coincident elements detecting
   GroupCoincident = new QGroupBox(myAction == 1 ? 
-                                 tr("COINCIDENT_ELEMENTS") : 
-                                 tr("COINCIDENT_NODES"), 
-                                 this);
+                                  tr("COINCIDENT_ELEMENTS") : 
+                                  tr("COINCIDENT_NODES"), 
+                                  this);
 
-  QGridLayout* GroupCoincidentLayout = new QGridLayout(GroupCoincident);
-  GroupCoincidentLayout->setSpacing(SPACING);
-  GroupCoincidentLayout->setMargin(MARGIN);
+  QVBoxLayout* aCoincidentLayout = new QVBoxLayout(GroupCoincident);
+
+  GroupCoincident->setLayout(aCoincidentLayout);
+
+  QHBoxLayout* aSpinBoxLayout = new QHBoxLayout( GroupCoincident );
   
   if (myAction == 0) { // case merge nodes
     TextLabelTolerance = new QLabel(tr("SMESH_TOLERANCE"), GroupCoincident);
     SpinBoxTolerance = new SMESHGUI_SpinBox(GroupCoincident);
     SpinBoxTolerance->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed));
 
-    GroupCoincidentLayout->addWidget(TextLabelTolerance, 0, 0);
-    GroupCoincidentLayout->addWidget(SpinBoxTolerance,   0, 1);
+    aSpinBoxLayout->addWidget(TextLabelTolerance);
+    aSpinBoxLayout->addWidget(SpinBoxTolerance);
+    aCoincidentLayout->addLayout(aSpinBoxLayout);
   }
   else {
     TextLabelTolerance = 0;
     SpinBoxTolerance = 0;
   }
 
-  int row = GroupCoincidentLayout->rowCount();
+  GroupCoincidentWidget = new QWidget(GroupCoincident);
+  QGridLayout* GroupCoincidentLayout = new QGridLayout(GroupCoincidentWidget);
+  GroupCoincidentLayout->setSpacing(SPACING);
+  GroupCoincidentLayout->setMargin(MARGIN);
 
-  ListCoincident = new QListWidget(GroupCoincident);
+  ListCoincident = new QListWidget(GroupCoincidentWidget);
   ListCoincident->setSelectionMode(QListWidget::ExtendedSelection);
 
-  DetectButton      = new QPushButton(tr("DETECT"),           GroupCoincident);
-  AddGroupButton    = new QPushButton(tr("SMESH_BUT_ADD"),    GroupCoincident);
-  RemoveGroupButton = new QPushButton(tr("SMESH_BUT_REMOVE"), GroupCoincident);
+  DetectButton      = new QPushButton(tr("DETECT"),           GroupCoincidentWidget);
+  AddGroupButton    = new QPushButton(tr("SMESH_BUT_ADD"),    GroupCoincidentWidget);
+  RemoveGroupButton = new QPushButton(tr("SMESH_BUT_REMOVE"), GroupCoincidentWidget);
+
+  SelectAllCB = new QCheckBox(tr("SELECT_ALL"), GroupCoincidentWidget);
 
-  SelectAllCB = new QCheckBox(tr("SELECT_ALL"), GroupCoincident);
+  if (myAction == 0)
+    GroupCoincidentWidget->hide();
+  else
+    GroupCoincident->hide();
+
+  GroupCoincidentLayout->addWidget(ListCoincident,    0,   0, 4, 2);
+  GroupCoincidentLayout->addWidget(DetectButton,      0,   2);
+  GroupCoincidentLayout->addWidget(AddGroupButton,    2, 2);
+  GroupCoincidentLayout->addWidget(RemoveGroupButton, 3, 2);
+  GroupCoincidentLayout->addWidget(SelectAllCB,       4, 0, 1, 3);
+  GroupCoincidentLayout->setRowMinimumHeight(1, 10);
+  GroupCoincidentLayout->setRowStretch(1, 5);
 
-  GroupCoincidentLayout->addWidget(ListCoincident,    row,   0, 4, 2);
-  GroupCoincidentLayout->addWidget(DetectButton,      row,   2);
-  GroupCoincidentLayout->addWidget(AddGroupButton,    row+2, 2);
-  GroupCoincidentLayout->addWidget(RemoveGroupButton, row+3, 2);
-  GroupCoincidentLayout->addWidget(SelectAllCB,       row+4, 0, 1, 3);
-  GroupCoincidentLayout->setRowMinimumHeight(row+1, 10);
-  GroupCoincidentLayout->setRowStretch(row+1, 5);
+  aCoincidentLayout->addWidget(GroupCoincidentWidget);
 
   /***************************************************************/
   // Controls for editing the selected group
@@ -428,6 +466,8 @@ SMESHGUI_EditMeshDlg::SMESHGUI_EditMeshDlg (SMESHGUI* theModule,
   GroupEditLayout->addWidget(RemoveElemButton, 0, 2);
   GroupEditLayout->addWidget(SetFirstButton,   1, 1, 1, 2);
 
+  GroupEdit->hide();
+
   /***************************************************************/
   GroupButtons = new QGroupBox(this);
   QHBoxLayout* GroupButtonsLayout = new QHBoxLayout(GroupButtons);
@@ -455,10 +495,13 @@ SMESHGUI_EditMeshDlg::SMESHGUI_EditMeshDlg (SMESHGUI* theModule,
   /***************************************************************/
   DlgLayout->addWidget(GroupConstructors);
   DlgLayout->addWidget(GroupMesh);
+  DlgLayout->addWidget(TypeBox);
   DlgLayout->addWidget(GroupCoincident);
   DlgLayout->addWidget(GroupEdit);
   DlgLayout->addWidget(GroupButtons);
 
+  this->resize(10,10);
+
   Init(); // Initialisations
 }
 
@@ -478,12 +521,14 @@ SMESHGUI_EditMeshDlg::~SMESHGUI_EditMeshDlg()
 void SMESHGUI_EditMeshDlg::Init()
 {
   if (myAction == 0) {
-    SpinBoxTolerance->RangeStepAndValidator(0.0, COORD_MAX, 0.00001, 5);
+    SpinBoxTolerance->RangeStepAndValidator(0.0, COORD_MAX, 0.00001, "len_tol_precision");
     SpinBoxTolerance->SetValue(1e-05);
   }
 
   RadioButton->setChecked(true);
 
+  GroupType->button(0)->setChecked(true);
+
   myEditCurrentArgument = (QWidget*)LineEditMesh; 
 
   myActor = 0;
@@ -494,17 +539,6 @@ void SMESHGUI_EditMeshDlg::Init()
   mySMESHGUI->SetActiveDialogBox((QDialog*)this);
   myIsBusy = false;
   
-  // Costruction of the logical filter
-  SMESH_TypeFilter* aMeshOrSubMeshFilter = new SMESH_TypeFilter (MESHorSUBMESH);
-  SMESH_TypeFilter* aSmeshGroupFilter    = new SMESH_TypeFilter (GROUP);
-  
-  QList<SUIT_SelectionFilter*> aListOfFilters;
-  if (aMeshOrSubMeshFilter) aListOfFilters.append(aMeshOrSubMeshFilter);
-  if (aSmeshGroupFilter)    aListOfFilters.append(aSmeshGroupFilter);
-
-  myMeshOrSubMeshOrGroupFilter =
-    new SMESH_LogicalFilter (aListOfFilters, SMESH_LogicalFilter::LO_OR);
-  
   /* signals and slots connections */
   connect(buttonOk,     SIGNAL(clicked()), this, SLOT(ClickOnOk()));
   connect(buttonCancel, SIGNAL(clicked()), this, SLOT(ClickOnCancel()));
@@ -521,20 +555,23 @@ void SMESHGUI_EditMeshDlg::Init()
   connect(AddElemButton, SIGNAL (clicked()), this, SLOT(onAddElement()));
   connect(RemoveElemButton, SIGNAL (clicked()), this, SLOT(onRemoveElement()));
   connect(SetFirstButton, SIGNAL( clicked() ), this, SLOT( onSetFirst() ) );
+  connect(GroupType, SIGNAL(buttonClicked(int)), this, SLOT(onTypeChanged(int)));
 
   connect(mySMESHGUI, SIGNAL (SignalDeactivateActiveDialog()), this, SLOT(DeactivateActiveDialog()));
   connect(mySelectionMgr, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument()));
   /* to close dialog if study change */
   connect(mySMESHGUI, SIGNAL (SignalCloseAllDialogs()), this, SLOT(ClickOnCancel()));
 
-  SetFirstButton->setEnabled(false);
-  buttonOk->setEnabled(false);
-  buttonApply->setEnabled(false);
-
   // Init Mesh field from selection
   SelectionIntoArgument();
 
-  myHelpFileName = "merging_elements_page.html";
+  // Update Buttons
+  updateControls();
+  
+  if (myAction == 0)
+    myHelpFileName = "merging_nodes_page.html";
+  else
+    myHelpFileName = "merging_elements_page.html";
 }
 
 //=================================================================================
@@ -542,7 +579,7 @@ void SMESHGUI_EditMeshDlg::Init()
 // purpose  :
 //=================================================================================
 void SMESHGUI_EditMeshDlg::FindGravityCenter(TColStd_MapOfInteger & theElemsIdMap, 
-                                            std::list< gp_XYZ > & theGrCentersXYZ)
+                                             std::list< gp_XYZ > & theGrCentersXYZ)
 {
   if (!myActor)
     return;
@@ -582,12 +619,27 @@ bool SMESHGUI_EditMeshDlg::ClickOnApply()
     return false;
 
   try {
+    if (myTypeId == 0)
+      onDetect();
+
     SUIT_OverrideCursor aWaitCursor;
     SMESH::SMESH_MeshEditor_var aMeshEditor = myMesh->GetMeshEditor();
 
     SMESH::long_array_var anIds = new SMESH::long_array;
     SMESH::array_of_long_array_var aGroupsOfElements = new SMESH::array_of_long_array;
 
+    if ( ListCoincident->count() == 0) {
+      if (myAction == 0)
+        SUIT_MessageBox::warning(this,
+                                 tr("SMESH_WARNING"),
+                                 tr("SMESH_NO_NODES_DETECTED"));
+      else
+        SUIT_MessageBox::warning(this,
+                                 tr("SMESH_WARNING"),
+                                 tr("SMESH_NO_ELEMENTS_DETECTED"));
+      return false;
+    }
+
     aGroupsOfElements->length(ListCoincident->count());
 
     int anArrayNum = 0;
@@ -606,12 +658,22 @@ bool SMESHGUI_EditMeshDlg::ClickOnApply()
     else
       aMeshEditor->MergeElements (aGroupsOfElements.inout());
 
+    if ( myTypeId == 0 ) {
+      if (myAction ==0)
+        SUIT_MessageBox::information(SMESHGUI::desktop(), tr("SMESH_INFORMATION"),
+                                     tr("SMESH_MERGED_NODES").arg(QString::number(ListCoincident->count()).toLatin1().data()));
+      else
+        SUIT_MessageBox::information(SMESHGUI::desktop(), tr("SMESH_INFORMATION"),
+                                     tr("SMESH_MERGED_ELEMENTS").arg(QString::number(ListCoincident->count()).toLatin1().data()));
+    }
+      
+
   } catch(...) {
   }
   
   SMESH::UpdateView();
-
-  onDetect();
+  SMESHGUI::Modified();
+  
   return true;
 }
 
@@ -632,13 +694,17 @@ void SMESHGUI_EditMeshDlg::ClickOnOk()
 void SMESHGUI_EditMeshDlg::ClickOnCancel()
 {
   myIdPreview->SetPointsLabeled(false);
+  SMESH::SetPointRepresentation(false);
+  disconnect(mySelectionMgr, 0, this, 0);
+  disconnect(mySMESHGUI, 0, this, 0);
+  mySMESHGUI->ResetState();
+
   mySelectionMgr->clearFilters();
   //mySelectionMgr->clearSelected();
-  SMESH::SetPointRepresentation(false);
+
   if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
     aViewWindow->SetSelectionMode(ActorSelection);
-  disconnect(mySelectionMgr, 0, this, 0);
-  mySMESHGUI->ResetState();
+
   reject();
 }
 
@@ -659,10 +725,10 @@ void SMESHGUI_EditMeshDlg::ClickOnHelp()
     platform = "application";
 #endif
     SUIT_MessageBox::warning(this, tr("WRN_WARNING"),
-                            tr("EXTERNAL_BROWSER_CANNOT_SHOW_PAGE").
-                            arg(app->resourceMgr()->stringValue("ExternalBrowser", 
-                                                                platform)).
-                            arg(myHelpFileName));
+                             tr("EXTERNAL_BROWSER_CANNOT_SHOW_PAGE").
+                             arg(app->resourceMgr()->stringValue("ExternalBrowser", 
+                                                                 platform)).
+                             arg(myHelpFileName));
   }
 }
 
@@ -696,7 +762,7 @@ void SMESHGUI_EditMeshDlg::updateControls()
 {
   if (ListEdit->count() == 0)
     SetFirstButton->setEnabled(false);
-  bool enable = !(myMesh->_is_nil()) && ListCoincident->count();
+  bool enable = !(myMesh->_is_nil()) && (ListCoincident->count() || (myTypeId == 0));
   buttonOk->setEnabled(enable);
   buttonApply->setEnabled(enable);
 }
@@ -722,15 +788,15 @@ void SMESHGUI_EditMeshDlg::onDetect()
     switch (myAction) {
     case 0 :
       if(!mySubMeshOrGroup->_is_nil())
-       aMeshEditor->FindCoincidentNodesOnPart(mySubMeshOrGroup, SpinBoxTolerance->GetValue(), aGroupsArray);
+        aMeshEditor->FindCoincidentNodesOnPart(mySubMeshOrGroup, SpinBoxTolerance->GetValue(), aGroupsArray);
       else
-       aMeshEditor->FindCoincidentNodes(SpinBoxTolerance->GetValue(), aGroupsArray);
+        aMeshEditor->FindCoincidentNodes(SpinBoxTolerance->GetValue(), aGroupsArray);
       break;
     case 1 :
       if(!mySubMeshOrGroup->_is_nil())
-       aMeshEditor->FindEqualElements(mySubMeshOrGroup, aGroupsArray);
+        aMeshEditor->FindEqualElements(mySubMeshOrGroup, aGroupsArray);
       else
-       aMeshEditor->FindEqualElements(myMesh, aGroupsArray);
+        aMeshEditor->FindEqualElements(myMesh, aGroupsArray);
       break;
     }
     
@@ -739,7 +805,7 @@ void SMESHGUI_EditMeshDlg::onDetect()
 
       QStringList anIDs;
       for (int j = 0; j < aGroup.length(); j++)
-       anIDs.append(QString::number(aGroup[j]));
+        anIDs.append(QString::number(aGroup[j]));
 
       ListCoincident->addItem(anIDs.join(" "));
     }
@@ -856,7 +922,11 @@ void SMESHGUI_EditMeshDlg::onAddGroup()
     return;
 
   QString anIDs = "";
-  SMESH::GetNameOfSelectedNodes(mySelector, myActor->getIO(), anIDs);
+  int aNbElements = 0;
+  aNbElements = SMESH::GetNameOfSelectedNodes(mySelector, myActor->getIO(), anIDs);
+
+  if (aNbElements < 1)
+    return;
   
   ListCoincident->clearSelection();
   ListCoincident->addItem(anIDs);
@@ -991,7 +1061,8 @@ void SMESHGUI_EditMeshDlg::SetEditCurrentArgument()
     SMESH::SetPointRepresentation(false);
     if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
       aViewWindow->SetSelectionMode(ActorSelection);
-    mySelectionMgr->installFilter(myMeshOrSubMeshOrGroupFilter);
+    if (myTypeId == 1)
+      mySelectionMgr->installFilter(myMeshOrSubMeshOrGroupFilter);
   }
 
   myEditCurrentArgument->setFocus();
@@ -1014,41 +1085,50 @@ void SMESHGUI_EditMeshDlg::SelectionIntoArgument()
     myActor = 0;
     
     int nbSel = SMESH::GetNameOfSelectedIObjects(mySelectionMgr, aString);
-    if (nbSel != 1)
+    if (nbSel != 1) {
+      myIdPreview->SetPointsLabeled(false);
+      SMESH::SetPointRepresentation(false);
+      mySelectionMgr->clearFilters();
+      if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
+        aViewWindow->SetSelectionMode(ActorSelection);
       return;
+    }
 
     SALOME_ListIO aList;
-    mySelectionMgr->selectedObjects(aList, SVTK_Viewer::Type());
+    mySelectionMgr->selectedObjects(aList);
     
     Handle(SALOME_InteractiveObject) IO = aList.First();
     myMesh = SMESH::GetMeshByIO(IO);
     
     if (myMesh->_is_nil())
       return;
+
+    LineEditMesh->setText(aString);
     
     myActor = SMESH::FindActorByEntry(IO->getEntry());
     if (!myActor)
       myActor = SMESH::FindActorByObject(myMesh);
-    if(!myActor)
-      return;
-    
-    mySubMeshOrGroup = SMESH::SMESH_IDSource::_nil();
     
-    if ((!SMESH::IObjectToInterface<SMESH::SMESH_subMesh>(IO)->_is_nil() || //SUBMESH OR GROUP
-         !SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(IO)->_is_nil()) &&
-        !SMESH::IObjectToInterface<SMESH::SMESH_IDSource>(IO)->_is_nil())
-      mySubMeshOrGroup = SMESH::IObjectToInterface<SMESH::SMESH_IDSource>(IO);
-     
-    LineEditMesh->setText(aString);
-
-    if (myAction == 0) {
-      SMESH::SetPointRepresentation(true);
-      if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
-       aViewWindow->SetSelectionMode(NodeSelection);
+    if ( myActor && myTypeId ==1 ) {
+      mySubMeshOrGroup = SMESH::SMESH_IDSource::_nil();
+      mySelectionMgr->installFilter(myMeshOrSubMeshOrGroupFilter);
+      
+      if ((!SMESH::IObjectToInterface<SMESH::SMESH_subMesh>(IO)->_is_nil() || //SUBMESH OR GROUP
+           !SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(IO)->_is_nil()) &&
+          !SMESH::IObjectToInterface<SMESH::SMESH_IDSource>(IO)->_is_nil())
+        mySubMeshOrGroup = SMESH::IObjectToInterface<SMESH::SMESH_IDSource>(IO);
+      
+      if (myAction == 0) {
+        SMESH::SetPointRepresentation(true);
+        if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
+          aViewWindow->SetSelectionMode(NodeSelection);
+      }
+      else
+        if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
+          aViewWindow->SetSelectionMode(CellSelection);
     }
-    else
-      if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
-       aViewWindow->SetSelectionMode(CellSelection);
+
+    updateControls();
   }
 }
 
@@ -1060,6 +1140,7 @@ void SMESHGUI_EditMeshDlg::DeactivateActiveDialog()
 {
   if (GroupConstructors->isEnabled()) {
     GroupConstructors->setEnabled(false);
+    TypeBox->setEnabled(false);
     GroupMesh->setEnabled(false);
     GroupCoincident->setEnabled(false);
     GroupEdit->setEnabled(false);
@@ -1081,6 +1162,7 @@ void SMESHGUI_EditMeshDlg::ActivateThisDialog()
   /* Emit a signal to deactivate the active dialog */
   mySMESHGUI->EmitSignalDeactivateDialog();
   GroupConstructors->setEnabled(true);
+  TypeBox->setEnabled(true);
   GroupMesh->setEnabled(true);
   GroupCoincident->setEnabled(true);
   GroupEdit->setEnabled(true);
@@ -1136,3 +1218,63 @@ void SMESHGUI_EditMeshDlg::keyPressEvent( QKeyEvent* e)
     ClickOnHelp();
   }
 }
+
+//=================================================================================
+// function : onTypeChanged()
+// purpose  : the type radio button management
+//=================================================================================
+void SMESHGUI_EditMeshDlg::onTypeChanged (int id)
+{
+  if (myTypeId == id)
+    return;
+
+  myTypeId = id;
+  switch (id) {
+  case 0:
+    myIdPreview->SetPointsLabeled(false);
+    SMESH::SetPointRepresentation(false);
+    if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
+      aViewWindow->SetSelectionMode(ActorSelection);
+    mySelectionMgr->clearFilters();
+    if (myAction == 0)
+      GroupCoincidentWidget->hide();
+    else
+      GroupCoincident->hide();
+    GroupEdit->hide();
+    break;
+  case 1:
+    SMESH::UpdateView();
+
+    // Costruction of the logical filter
+    SMESH_TypeFilter* aMeshOrSubMeshFilter = new SMESH_TypeFilter (MESHorSUBMESH);
+    SMESH_TypeFilter* aSmeshGroupFilter    = new SMESH_TypeFilter (GROUP);
+    
+    QList<SUIT_SelectionFilter*> aListOfFilters;
+    if (aMeshOrSubMeshFilter) aListOfFilters.append(aMeshOrSubMeshFilter);
+    if (aSmeshGroupFilter)    aListOfFilters.append(aSmeshGroupFilter);
+    
+    myMeshOrSubMeshOrGroupFilter =
+      new SMESH_LogicalFilter (aListOfFilters, SMESH_LogicalFilter::LO_OR);
+
+    if (myAction == 0) {
+      GroupCoincidentWidget->show();
+      SMESH::SetPointRepresentation(true);
+      if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
+        aViewWindow->SetSelectionMode(NodeSelection);
+    }
+    else {
+      GroupCoincident->show();
+      if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
+        aViewWindow->SetSelectionMode(CellSelection);
+    }
+    GroupEdit->show();
+    break;
+  }
+  updateControls();
+
+  qApp->processEvents();
+  updateGeometry();
+  resize(10,10);
+
+  SelectionIntoArgument();
+}