Salome HOME
SMH: Preparation version 3.0.0 - merge (HEAD+POLYWORK)
[modules/smesh.git] / src / SMESHGUI / SMESHGUI_MergeNodesDlg.cxx
1 //  SMESH SMESHGUI : GUI for SMESH component
2 //
3 //  Copyright (C) 2003  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 //  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
5 //
6 //  This library is free software; you can redistribute it and/or
7 //  modify it under the terms of the GNU Lesser General Public
8 //  License as published by the Free Software Foundation; either
9 //  version 2.1 of the License.
10 //
11 //  This library is distributed in the hope that it will be useful,
12 //  but WITHOUT ANY WARRANTY; without even the implied warranty of
13 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14 //  Lesser General Public License for more details.
15 //
16 //  You should have received a copy of the GNU Lesser General Public
17 //  License along with this library; if not, write to the Free Software
18 //  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
19 //
20 //  See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
21 //
22 //
23 //
24 //  File   : SMESHGUI_MergeNodesDlg.cxx
25 //  Author : Michael ZORIN
26 //  Module : SMESH
27 //  $Header:
28
29 #include "SMESHGUI_MergeNodesDlg.h"
30
31 #include "SMESHGUI.h"
32 #include "SMESHGUI_Utils.h"
33 #include "SMESHGUI_VTKUtils.h"
34 #include "SMESHGUI_IdValidator.h"
35 #include "SMESHGUI_SpinBox.h"
36
37 #include "SMESH_Actor.h"
38 #include "SMESH_TypeFilter.hxx"
39 #include "SMDS_Mesh.hxx"
40
41 #include "GEOMBase.h"
42
43 #include "SUIT_ResourceMgr.h"
44
45 #include "SVTK_ViewModel.h"
46 #include "SVTK_ViewWindow.h"
47 #include "SVTK_Selector.h"
48 #include "SVTK_Selection.h"
49 #include "SALOME_ListIO.hxx"
50
51 #include "utilities.h"
52
53 // OCCT Includes
54 #include <TColStd_MapOfInteger.hxx>
55
56 // QT Includes
57 #include <qapplication.h>
58 #include <qbuttongroup.h>
59 #include <qgroupbox.h>
60 #include <qlabel.h>
61 #include <qlineedit.h>
62 #include <qlistbox.h>
63 #include <qlistview.h>
64 #include <qpushbutton.h>
65 #include <qradiobutton.h>
66 #include <qcheckbox.h>
67 #include <qlayout.h>
68 #include <qpixmap.h>
69 #include <qheader.h>
70
71 using namespace std;
72
73 //=================================================================================
74 // class    : SMESHGUI_MergeNodesDlg()
75 // purpose  :
76 //=================================================================================
77 SMESHGUI_MergeNodesDlg::SMESHGUI_MergeNodesDlg( SMESHGUI* theModule, const char* name,
78                                                 bool modal, WFlags fl)
79      : QDialog( SMESH::GetDesktop( theModule ), name, modal, WStyle_Customize | WStyle_NormalBorder |
80                 WStyle_Title | WStyle_SysMenu | Qt::WDestructiveClose),
81      mySMESHGUI( theModule ),
82      mySelectionMgr( SMESH::GetSelectionMgr( theModule ) ),
83      myViewWindow( SMESH::GetViewWindow( theModule ) ),
84      mySelector( myViewWindow->GetSelector() )
85 {
86   QPixmap image0 (SMESHGUI::resourceMgr()->loadPixmap("SMESH", tr("ICON_SMESH_MERGE_NODES")));
87   QPixmap image1 (SMESHGUI::resourceMgr()->loadPixmap("SMESH", tr("ICON_SELECT")));
88
89   if (!name)
90     setName("SMESHGUI_MergeNodesDlg");
91   resize(303, 185);
92   setCaption(tr("SMESH_MERGE_NODES"));
93   setSizeGripEnabled(TRUE);
94   SMESHGUI_MergeNodesDlgLayout = new QGridLayout(this);
95   SMESHGUI_MergeNodesDlgLayout->setSpacing(6);
96   SMESHGUI_MergeNodesDlgLayout->setMargin(11);
97
98   /***************************************************************/
99   GroupConstructors = new QButtonGroup(this, "GroupConstructors");
100   GroupConstructors->setSizePolicy(QSizePolicy((QSizePolicy::SizeType)5,
101                                                (QSizePolicy::SizeType)0, 0, 0,
102                                                GroupConstructors->sizePolicy().hasHeightForWidth()));
103   GroupConstructors->setTitle(tr("SMESH_MERGE_NODES" ));
104   GroupConstructors->setExclusive(TRUE);
105   GroupConstructors->setColumnLayout(0, Qt::Vertical);
106   GroupConstructors->layout()->setSpacing(0);
107   GroupConstructors->layout()->setMargin(0);
108   GroupConstructorsLayout = new QGridLayout(GroupConstructors->layout());
109   GroupConstructorsLayout->setAlignment(Qt::AlignTop);
110   GroupConstructorsLayout->setSpacing(6);
111   GroupConstructorsLayout->setMargin(11);
112   QHBoxLayout* RBLayout = new QHBoxLayout(0, 0, 6, "Layout2");
113   RadioButton1= new QRadioButton(GroupConstructors, "RadioButton1");
114   RadioButton1->setText(tr("" ));
115   RadioButton1->setPixmap(image0);
116   RBLayout->addWidget(RadioButton1);
117   GroupConstructorsLayout->addLayout(RBLayout, 0, 0);
118   SMESHGUI_MergeNodesDlgLayout->addWidget(GroupConstructors, 0, 0);
119
120   /***************************************************************/
121   GroupButtons = new QGroupBox(this, "GroupButtons");
122   GroupButtons->setSizePolicy(QSizePolicy((QSizePolicy::SizeType)7,
123                                           (QSizePolicy::SizeType)0, 0, 0,
124                                           GroupButtons->sizePolicy().hasHeightForWidth()));
125   GroupButtons->setGeometry(QRect(10, 10, 281, 48));
126   GroupButtons->setTitle(tr("" ));
127   GroupButtons->setColumnLayout(0, Qt::Vertical);
128   GroupButtons->layout()->setSpacing(0);
129   GroupButtons->layout()->setMargin(0);
130   GroupButtonsLayout = new QGridLayout(GroupButtons->layout());
131   GroupButtonsLayout->setAlignment(Qt::AlignTop);
132   GroupButtonsLayout->setSpacing(6);
133   GroupButtonsLayout->setMargin(11);
134   buttonCancel = new QPushButton(GroupButtons, "buttonCancel");
135   buttonCancel->setText(tr("SMESH_BUT_CLOSE" ));
136   buttonCancel->setAutoDefault(TRUE);
137   GroupButtonsLayout->addWidget(buttonCancel, 0, 3);
138   buttonApply = new QPushButton(GroupButtons, "buttonApply");
139   buttonApply->setText(tr("SMESH_BUT_APPLY" ));
140   buttonApply->setAutoDefault(TRUE);
141   GroupButtonsLayout->addWidget(buttonApply, 0, 1);
142   QSpacerItem* spacer_9 = new QSpacerItem(20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum);
143   GroupButtonsLayout->addItem(spacer_9, 0, 2);
144   buttonOk = new QPushButton(GroupButtons, "buttonOk");
145   buttonOk->setText(tr("SMESH_BUT_OK" ));
146   buttonOk->setAutoDefault(TRUE);
147   buttonOk->setDefault(TRUE);
148   GroupButtonsLayout->addWidget(buttonOk, 0, 0);
149   SMESHGUI_MergeNodesDlgLayout->addWidget(GroupButtons, 4, 0);
150
151   /***************************************************************/
152
153   // Controls for mesh defining
154   GroupMesh = new QGroupBox(this, "GroupMesh");
155   GroupMesh->setTitle(tr("SMESH_MESH"));
156   GroupMesh->setColumnLayout(0, Qt::Vertical);
157   GroupMesh->layout()->setSpacing(0);
158   GroupMesh->layout()->setMargin(0);
159   GroupMeshLayout = new QGridLayout(GroupMesh->layout());
160   GroupMeshLayout->setAlignment(Qt::AlignTop);
161   GroupMeshLayout->setSpacing(6);
162   GroupMeshLayout->setMargin(11);
163
164   TextLabelName = new QLabel(GroupMesh, "TextLabelName");
165   TextLabelName->setText(tr("SMESH_NAME"));
166   GroupMeshLayout->addWidget(TextLabelName, 0, 0);
167
168   SelectMeshButton = new QPushButton(GroupMesh, "SelectMeshButton");
169   SelectMeshButton->setPixmap(image1);
170   GroupMeshLayout->addWidget(SelectMeshButton, 0, 1);
171
172   LineEditMesh = new QLineEdit(GroupMesh, "LineEditMesh");
173   LineEditMesh->setReadOnly(true);
174   GroupMeshLayout->addWidget(LineEditMesh, 0, 2);
175
176   SMESHGUI_MergeNodesDlgLayout->addWidget(GroupMesh, 1, 0);
177
178   // Controls for coincident nodes detecting
179   GroupCoincident = new QGroupBox(this, "GroupCoincident");
180   GroupCoincident->setTitle(tr("COINCIDENT_NODES"));
181   GroupCoincident->setColumnLayout(0, Qt::Vertical);
182   GroupCoincident->layout()->setSpacing(0);
183   GroupCoincident->layout()->setMargin(0);
184   QGridLayout* GroupCoincidentLayout = new QGridLayout(GroupCoincident->layout());
185   GroupCoincidentLayout->setAlignment(Qt::AlignTop);
186   GroupCoincidentLayout->setSpacing(6);
187   GroupCoincidentLayout->setMargin(11);
188
189   TextLabelTolerance = new QLabel(GroupCoincident, "TextLabelTolerance");
190   TextLabelTolerance->setText(tr("SMESH_TOLERANCE"));
191   GroupCoincidentLayout->addWidget(TextLabelTolerance, 0, 0);
192
193   SpinBoxTolerance = new SMESHGUI_SpinBox(GroupCoincident, "SpinBoxTolerance");
194   GroupCoincidentLayout->addWidget(SpinBoxTolerance, 0, 1);
195
196   QPushButton* DetectButton = new QPushButton(GroupCoincident, "DetectButton");
197   DetectButton->setText(tr("DETECT"));
198   GroupCoincidentLayout->addWidget(DetectButton, 0, 2);
199
200   ListCoincident = new QListView(GroupCoincident);
201   ListCoincident->setSorting(-1);
202   ListCoincident->addColumn("Nodes");
203   ListCoincident->header()->hide();
204
205   GroupCoincidentLayout->addMultiCellWidget(ListCoincident, 1, 1, 0, 1);
206
207   SelectAllCB = new QCheckBox(GroupCoincident, "SelectAllCB");
208   SelectAllCB->setText(tr("SELECT_ALL"));
209   GroupCoincidentLayout->addWidget(SelectAllCB, 2, 0);
210
211   SMESHGUI_MergeNodesDlgLayout->addWidget(GroupCoincident, 2, 0);
212
213   // Controls for editing group of nodes
214   GroupEdit = new QGroupBox(this, "GroupEdit");
215   GroupEdit->setTitle(tr("EDIT_GROUP_OF_NODES"));
216   GroupEdit->setColumnLayout(0, Qt::Vertical);
217   GroupEdit->layout()->setSpacing(0);
218   GroupEdit->layout()->setMargin(0);
219   QGridLayout* GroupEditLayout = new QGridLayout(GroupEdit->layout());
220   GroupEditLayout->setAlignment(Qt::AlignTop);
221   GroupEditLayout->setSpacing(6);
222   GroupEditLayout->setMargin(11);
223
224   ListEdit = new QListBox(GroupEdit, "ListEdit");
225   ListEdit->setColumnMode(QListBox::FitToHeight);
226   ListEdit->setSelectionMode(QListBox::Extended);
227   GroupEditLayout->addMultiCellWidget(ListEdit, 0, 2, 0, 0);
228
229   QPushButton* AddButton = new QPushButton(GroupEdit, "AddButton");
230   AddButton->setText(tr("SMESH_BUT_ADD"));
231   GroupEditLayout->addWidget(AddButton, 0, 1);
232
233   QPushButton* RemoveButton = new QPushButton(GroupEdit, "RemoveButton");
234   RemoveButton->setText(tr("SMESH_BUT_REMOVE"));
235   GroupEditLayout->addWidget(RemoveButton, 1, 1);
236
237   QSpacerItem* spacer = new QSpacerItem(20, 200, QSizePolicy::Minimum, QSizePolicy::Expanding);
238   GroupEditLayout->addItem(spacer, 2, 1);
239
240   SMESHGUI_MergeNodesDlgLayout->addWidget(GroupEdit, 3, 0);
241
242   /* Initialisations */
243   SpinBoxTolerance->RangeStepAndValidator(0.0, 999999.999, 0.1, 3);
244   SpinBoxTolerance->SetValue(1e-05);
245
246   RadioButton1->setChecked(TRUE);
247
248   myActor = 0;
249
250   mySMESHGUI = SMESHGUI::GetSMESHGUI();
251   mySMESHGUI->SetActiveDialogBox((QDialog*)this);
252
253   myMeshOrSubMeshFilter = new SMESH_TypeFilter (MESHorSUBMESH);
254
255   /* signals and slots connections */
256   connect(buttonOk, SIGNAL(clicked()),     this, SLOT(ClickOnOk()));
257   connect(buttonCancel, SIGNAL(clicked()), this, SLOT(ClickOnCancel()));
258   connect(buttonApply, SIGNAL(clicked()),  this, SLOT(ClickOnApply()));
259
260   connect(SelectMeshButton, SIGNAL (clicked()), this, SLOT(SetEditCurrentArgument()));
261   connect(DetectButton, SIGNAL (clicked()), this, SLOT(onDetect()));
262   connect(ListCoincident, SIGNAL (selectionChanged()), this, SLOT(onSelectNodesGroup()));
263   connect(ListCoincident, SIGNAL (pressed(QListViewItem*)), this, SLOT(updateControls()));
264   connect(ListCoincident, SIGNAL (currentChanged(QListViewItem*)), this, SLOT(updateControls()));
265   connect(SelectAllCB, SIGNAL(toggled(bool)), this, SLOT(onSelectAll(bool)));
266   connect(ListEdit, SIGNAL (selectionChanged()), this, SLOT(onSelectNodesFromGroup()));
267   connect(AddButton, SIGNAL (clicked()), this, SLOT(onAdd()));
268   connect(RemoveButton, SIGNAL (clicked()), this, SLOT(onRemove()));
269
270   connect(mySMESHGUI, SIGNAL (SignalDeactivateActiveDialog()), this, SLOT(DeactivateActiveDialog()));
271   connect(mySelectionMgr, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument()));
272   /* to close dialog if study change */
273   connect(mySMESHGUI, SIGNAL (SignalCloseAllDialogs()), this, SLOT(ClickOnCancel()));
274
275   /* Move widget on the botton right corner of main widget */
276   int x, y;
277   mySMESHGUI->DefineDlgPosition(this, x, y);
278   this->move(x, y);
279   this->show(); /* displays Dialog */
280
281   resize(0,0);
282   buttonOk->setEnabled(false);
283   buttonApply->setEnabled(false);
284 }
285
286 //=================================================================================
287 // function : ~SMESHGUI_MergeNodesDlg()
288 // purpose  : Destroys the object and frees any allocated resources
289 //=================================================================================
290 SMESHGUI_MergeNodesDlg::~SMESHGUI_MergeNodesDlg()
291 {
292   // no need to delete child widgets, Qt does it all for us
293 }
294
295 //=================================================================================
296 // function : ClickOnApply()
297 // purpose  :
298 //=================================================================================
299 bool SMESHGUI_MergeNodesDlg::ClickOnApply()
300 {
301   if (mySMESHGUI->isActiveStudyLocked() || myMesh->_is_nil())
302     return false;
303
304   try {
305     SMESH::SMESH_MeshEditor_var aMeshEditor = myMesh->GetMeshEditor();
306
307     QApplication::setOverrideCursor(Qt::waitCursor);
308     SMESH::array_of_long_array_var aGroupsOfNodes = new SMESH::array_of_long_array;
309     aGroupsOfNodes->length(ListCoincident->childCount());
310     QListViewItem* item = ListCoincident->firstChild();
311
312     int anArrayNum = 0;
313     while (item) {
314       QStringList aListIds = QStringList("");
315       if (((QCheckListItem*) item)->isOn())
316         aListIds = QStringList::split(" ", item->text(0), false);
317
318       SMESH::long_array_var anIds = new SMESH::long_array;
319       anIds->length(aListIds.count());
320
321       for (int i = 0; i < aListIds.count(); i++)
322         anIds[i] = aListIds[i].toInt();
323
324       aGroupsOfNodes[anArrayNum++] = anIds.inout();
325
326       item = item->itemBelow();
327     }
328
329     aMeshEditor->MergeNodes (aGroupsOfNodes.inout());
330     QApplication::restoreOverrideCursor();
331   } catch(...) {
332   }
333
334   mySelectionMgr->clearSelected();
335   SMESH::UpdateView();
336
337   onDetect();
338   return true;
339 }
340
341 //=================================================================================
342 // function : ClickOnOk()
343 // purpose  :
344 //=================================================================================
345 void SMESHGUI_MergeNodesDlg::ClickOnOk()
346 {
347   if (ClickOnApply())
348     ClickOnCancel();
349 }
350
351 //=================================================================================
352 // function : ClickOnCancel()
353 // purpose  :
354 //=================================================================================
355 void SMESHGUI_MergeNodesDlg::ClickOnCancel()
356 {
357   mySelectionMgr->clearFilters();
358   mySelectionMgr->clearSelected();
359   SMESH::SetPointRepresentation(false);
360   myViewWindow->SetSelectionMode(ActorSelection);
361   disconnect(mySelectionMgr, 0, this, 0);
362   mySMESHGUI->ResetState();
363   reject();
364 }
365
366 //=================================================================================
367 // function : onEditNodesGroup()
368 // purpose  :
369 //=================================================================================
370 void SMESHGUI_MergeNodesDlg::onEditNodesGroup()
371 {
372   if (ListCoincident->childCount() < 1)
373     return;
374
375   QString aNewIds = "";
376
377   QListBoxItem* anItem;
378   for (anItem = ListEdit->firstItem(); anItem != 0; anItem = anItem->next())
379     aNewIds+=QString(" %1").arg(anItem->text());
380
381   ListCoincident->currentItem()->setText(0, aNewIds);
382 }
383
384 //=================================================================================
385 // function : updateControls()
386 // purpose  :
387 //=================================================================================
388 void SMESHGUI_MergeNodesDlg::updateControls()
389 {
390   if (ListCoincident->childCount() < 1) {
391     SMESH::SetPointRepresentation(false);
392     myViewWindow->SetSelectionMode(ActorSelection);
393     return;
394   }
395
396   bool hasChecked = false, hasUnchecked = false;
397
398   QListViewItem* item = ListCoincident->firstChild();
399
400   while (item && (!hasChecked || !hasUnchecked)) {
401     if (((QCheckListItem*) item)->isOn())
402       hasChecked = true;
403     else
404       hasUnchecked = true;
405
406     item = item->itemBelow();
407   }
408
409   if (hasUnchecked)
410     SelectAllCB->setChecked(false);
411
412   bool enable = !(myMesh->_is_nil()) && hasChecked;
413
414   buttonOk->setEnabled(enable);
415   buttonApply->setEnabled(enable);
416 }
417
418 //=================================================================================
419 // function : onDetect()
420 // purpose  :
421 //=================================================================================
422 void SMESHGUI_MergeNodesDlg::onDetect()
423 {
424   if (myMesh->_is_nil())
425     return;
426
427   try {
428     SMESH::SMESH_MeshEditor_var aMeshEditor = myMesh->GetMeshEditor();
429
430     QApplication::setOverrideCursor(Qt::waitCursor);
431     ListCoincident->clear();
432     ListEdit->clear();
433
434     SMESH::array_of_long_array_var aNodeGroups;
435     aMeshEditor->FindCoincidentNodes(SpinBoxTolerance->GetValue(), aNodeGroups);
436
437     for (int i = 0; i < aNodeGroups->length(); i++) {
438       SMESH::long_array& aGroup = aNodeGroups[i];
439
440       QString aNodeIds;
441       for (int j = 0; j < aGroup.length(); j++)
442         aNodeIds+=QString(" %1").arg(aGroup[j]);
443
444       new QCheckListItem (ListCoincident, aNodeIds, QCheckListItem::CheckBox);
445     }
446     QApplication::restoreOverrideCursor();
447   } catch(...) {
448   }
449
450   updateControls();
451 }
452
453 //=================================================================================
454 // function : onSelectNodesGroup()
455 // purpose  :
456 //=================================================================================
457 void SMESHGUI_MergeNodesDlg::onSelectNodesGroup()
458 {
459   if (!myActor)
460     return;
461
462   myEditCurrentArgument = (QWidget*)ListCoincident;
463
464   QListViewItem* aSelectedItem = ListCoincident->selectedItem();
465   if (!aSelectedItem)
466     return;
467
468   QStringList aListId = QStringList::split(" ", aSelectedItem->text(0), false);
469
470   ListEdit->clear();
471   ListEdit->insertStringList(aListId);
472
473   //mySelectionMgr->clearSelected();
474   //mySelectionMgr->AddIObject(myActor->getIO());
475   SALOME_ListIO aList;
476   aList.Append(myActor->getIO());
477   mySelectionMgr->setSelectedObjects(aList, false);
478
479   SMESH::SetPointRepresentation(true);
480   myViewWindow->SetSelectionMode(NodeSelection);
481
482   ListEdit->selectAll(true);
483 }
484
485 //=================================================================================
486 // function : onSelectAll()
487 // purpose  :
488 //=================================================================================
489 void SMESHGUI_MergeNodesDlg::onSelectAll (bool isToggled)
490 {
491   if (isToggled) {
492     int aNbItems = 0;
493     QListViewItem* item = ListCoincident->firstChild();
494     while (item) {
495       aNbItems++;
496       if (!((QCheckListItem*) item)->isOn())
497         ((QCheckListItem*) item)->setOn(true);
498       item = item->itemBelow();
499     }
500
501     if (aNbItems) {
502       buttonOk->setEnabled(true);
503       buttonApply->setEnabled(true);
504     }
505   }
506 }
507
508 //=================================================================================
509 // function : onSelectNodesFromGroup()
510 // purpose  :
511 //=================================================================================
512 void SMESHGUI_MergeNodesDlg::onSelectNodesFromGroup()
513 {
514   if (!myActor)
515     return;
516
517   TColStd_MapOfInteger aIndexes;
518   QListBoxItem* anItem;
519   for (anItem = ListEdit->firstItem(); anItem != 0; anItem = anItem->next()) {
520     if (anItem->isSelected()) {
521       int anId = anItem->text().toInt();
522       aIndexes.Add(anId);
523     }
524   }
525
526   mySelector->AddOrRemoveIndex(myActor->getIO(), aIndexes, false);
527   SALOME_ListIO aList;
528   aList.Append(myActor->getIO());
529   mySelectionMgr->setSelectedObjects(aList);
530 }
531
532 //=================================================================================
533 // function : onAdd()
534 // purpose  :
535 //=================================================================================
536 void SMESHGUI_MergeNodesDlg::onAdd()
537 {
538   if (!myActor)
539     return;
540
541   QString aListStr = "";
542   int aNbNnodes = 0;
543
544   aNbNnodes = SMESH::GetNameOfSelectedNodes(mySelector, myActor->getIO(), aListStr);
545   if (aNbNnodes < 1)
546     return;
547
548   QStringList aNodes = QStringList::split(" ", aListStr);
549   QListBoxItem* anItem = 0;
550
551   for (QStringList::iterator it = aNodes.begin(); it != aNodes.end(); ++it) {
552     anItem = ListEdit->findItem(*it, Qt::ExactMatch);
553     if (!anItem) {
554       anItem = new QListBoxText(*it);
555       ListEdit->insertItem(anItem);
556     }
557     ListEdit->setSelected(anItem, true);
558   }
559
560   onEditNodesGroup();
561 }
562
563 //=================================================================================
564 // function : onRemove()
565 // purpose  :
566 //=================================================================================
567 void SMESHGUI_MergeNodesDlg::onRemove()
568 {
569   if (myEditCurrentArgument != (QWidget*)ListCoincident)
570     return;
571
572   for (int i = ListEdit->count(); i > 0; i--) {
573     if (ListEdit->isSelected(i-1))
574       ListEdit->removeItem(i-1);
575   }
576   onEditNodesGroup();
577 }
578
579 //=================================================================================
580 // function : SetEditCurrentArgument()
581 // purpose  :
582 //=================================================================================
583 void SMESHGUI_MergeNodesDlg::SetEditCurrentArgument()
584 {
585   QPushButton* send = (QPushButton*)sender();
586
587   disconnect(mySelectionMgr, 0, this, 0);
588   mySelectionMgr->clearSelected();
589   mySelectionMgr->clearFilters();
590
591   if (send == SelectMeshButton) {
592     myEditCurrentArgument = (QWidget*)LineEditMesh;
593     SMESH::SetPointRepresentation(false);
594     myViewWindow->SetSelectionMode(ActorSelection);
595     mySelectionMgr->installFilter(myMeshOrSubMeshFilter);
596   }
597
598   myEditCurrentArgument->setFocus();
599   connect(mySelectionMgr, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument()));
600   SelectionIntoArgument();
601 }
602
603 //=================================================================================
604 // function : SelectionIntoArgument()
605 // purpose  : Called when selection as changed or other case
606 //=================================================================================
607 void SMESHGUI_MergeNodesDlg::SelectionIntoArgument()
608 {
609   if (myEditCurrentArgument == (QWidget*)LineEditMesh) {
610     QString aString = "";
611     LineEditMesh->setText(aString);
612
613     ListCoincident->clear();
614     ListEdit->clear();
615
616     int nbSel = SMESH::GetNameOfSelectedIObjects(mySelectionMgr, aString);
617     if (nbSel != 1)
618       return;
619
620     SALOME_ListIO aList;
621     mySelectionMgr->selectedObjects(aList,SVTK_Viewer::Type());
622
623     Handle(SALOME_InteractiveObject) IO = aList.First();
624     myMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(IO);
625     myActor = SMESH::FindActorByEntry(aList.First()->getEntry());
626     if (myMesh->_is_nil() || !myActor)
627       return;
628
629     LineEditMesh->setText(aString);
630   }
631 }
632
633 //=================================================================================
634 // function : DeactivateActiveDialog()
635 // purpose  :
636 //=================================================================================
637 void SMESHGUI_MergeNodesDlg::DeactivateActiveDialog()
638 {
639   if (GroupConstructors->isEnabled()) {
640     GroupConstructors->setEnabled(false);
641     GroupMesh->setEnabled(false);
642     GroupCoincident->setEnabled(false);
643     GroupEdit->setEnabled(false);
644     GroupButtons->setEnabled(false);
645     mySMESHGUI->ResetState();
646     mySMESHGUI->SetActiveDialogBox(0);
647   }
648 }
649
650 //=================================================================================
651 // function : ActivateThisDialog()
652 // purpose  :
653 //=================================================================================
654 void SMESHGUI_MergeNodesDlg::ActivateThisDialog()
655 {
656   /* Emit a signal to deactivate the active dialog */
657   mySMESHGUI->EmitSignalDeactivateDialog();
658   GroupConstructors->setEnabled(true);
659   GroupMesh->setEnabled(true);
660   GroupCoincident->setEnabled(true);
661   GroupEdit->setEnabled(true);
662   GroupButtons->setEnabled(true);
663
664   mySMESHGUI->SetActiveDialogBox((QDialog*)this);
665
666   SelectionIntoArgument();
667 }
668
669 //=================================================================================
670 // function : enterEvent()
671 // purpose  :
672 //=================================================================================
673 void SMESHGUI_MergeNodesDlg::enterEvent (QEvent*)
674 {
675   if (!GroupConstructors->isEnabled())
676     ActivateThisDialog();
677 }
678
679 //=================================================================================
680 // function : closeEvent()
681 // purpose  :
682 //=================================================================================
683 void SMESHGUI_MergeNodesDlg::closeEvent (QCloseEvent*)
684 {
685   /* same than click on cancel button */
686   ClickOnCancel();
687 }
688
689 //=======================================================================
690 //function : hideEvent()
691 //purpose  : caused by ESC key
692 //=======================================================================
693 void SMESHGUI_MergeNodesDlg::hideEvent (QHideEvent*)
694 {
695   if (!isMinimized())
696     ClickOnCancel();
697 }