1 // SMESH SMESHGUI : GUI for SMESH component
3 // Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
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.
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.
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
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
24 // File : SMESHGUI_MergeNodesDlg.cxx
25 // Author : Michael ZORIN
29 #include "SMESHGUI_MergeNodesDlg.h"
32 #include "SMESHGUI_Utils.h"
33 #include "SMESHGUI_VTKUtils.h"
34 #include "SMESHGUI_IdValidator.h"
35 #include "SMESHGUI_SpinBox.h"
37 #include "SMESH_Actor.h"
38 #include "SMESH_TypeFilter.hxx"
39 #include "SMESH_LogicalFilter.hxx"
40 #include "SMESHGUI_MeshUtils.h"
41 #include "SMDS_Mesh.hxx"
45 #include "SUIT_ResourceMgr.h"
46 #include "SUIT_Session.h"
47 #include "SUIT_MessageBox.h"
49 #include "LightApp_Application.h"
51 #include "SVTK_ViewModel.h"
52 #include "SVTK_ViewWindow.h"
53 #include "SVTK_Selector.h"
54 #include "SVTK_Selection.h"
55 #include "SALOME_ListIO.hxx"
57 #include "utilities.h"
60 #include <TColStd_MapOfInteger.hxx>
63 #include <qapplication.h>
64 #include <qbuttongroup.h>
65 #include <qgroupbox.h>
67 #include <qlineedit.h>
69 #include <qlistview.h>
70 #include <qpushbutton.h>
71 #include <qradiobutton.h>
72 #include <qcheckbox.h>
78 #include CORBA_SERVER_HEADER(SMESH_Group)
82 //=================================================================================
83 // class : SMESHGUI_MergeNodesDlg()
85 //=================================================================================
86 SMESHGUI_MergeNodesDlg::SMESHGUI_MergeNodesDlg( SMESHGUI* theModule, const char* name,
87 bool modal, WFlags fl)
88 : QDialog( SMESH::GetDesktop( theModule ), name, modal, WStyle_Customize | WStyle_NormalBorder |
89 WStyle_Title | WStyle_SysMenu | Qt::WDestructiveClose),
90 mySMESHGUI( theModule ),
91 mySelectionMgr( SMESH::GetSelectionMgr( theModule ) )
93 QPixmap image0 (SMESH::GetResourceMgr( mySMESHGUI )->loadPixmap("SMESH", tr("ICON_SMESH_MERGE_NODES")));
94 QPixmap image1 (SMESH::GetResourceMgr( mySMESHGUI )->loadPixmap("SMESH", tr("ICON_SELECT")));
97 setName("SMESHGUI_MergeNodesDlg");
99 setCaption(tr("SMESH_MERGE_NODES"));
100 setSizeGripEnabled(TRUE);
101 SMESHGUI_MergeNodesDlgLayout = new QGridLayout(this);
102 SMESHGUI_MergeNodesDlgLayout->setSpacing(6);
103 SMESHGUI_MergeNodesDlgLayout->setMargin(11);
105 /***************************************************************/
106 GroupConstructors = new QButtonGroup(this, "GroupConstructors");
107 GroupConstructors->setSizePolicy(QSizePolicy((QSizePolicy::SizeType)5,
108 (QSizePolicy::SizeType)0, 0, 0,
109 GroupConstructors->sizePolicy().hasHeightForWidth()));
110 GroupConstructors->setTitle(tr("SMESH_MERGE_NODES" ));
111 GroupConstructors->setExclusive(TRUE);
112 GroupConstructors->setColumnLayout(0, Qt::Vertical);
113 GroupConstructors->layout()->setSpacing(0);
114 GroupConstructors->layout()->setMargin(0);
115 GroupConstructorsLayout = new QGridLayout(GroupConstructors->layout());
116 GroupConstructorsLayout->setAlignment(Qt::AlignTop);
117 GroupConstructorsLayout->setSpacing(6);
118 GroupConstructorsLayout->setMargin(11);
119 QHBoxLayout* RBLayout = new QHBoxLayout(0, 0, 6, "Layout2");
120 RadioButton1= new QRadioButton(GroupConstructors, "RadioButton1");
121 RadioButton1->setText(tr("" ));
122 RadioButton1->setPixmap(image0);
123 RBLayout->addWidget(RadioButton1);
124 GroupConstructorsLayout->addLayout(RBLayout, 0, 0);
125 SMESHGUI_MergeNodesDlgLayout->addWidget(GroupConstructors, 0, 0);
127 /***************************************************************/
128 GroupButtons = new QGroupBox(this, "GroupButtons");
129 GroupButtons->setSizePolicy(QSizePolicy((QSizePolicy::SizeType)7,
130 (QSizePolicy::SizeType)0, 0, 0,
131 GroupButtons->sizePolicy().hasHeightForWidth()));
132 GroupButtons->setGeometry(QRect(10, 10, 281, 48));
133 GroupButtons->setTitle(tr("" ));
134 GroupButtons->setColumnLayout(0, Qt::Vertical);
135 GroupButtons->layout()->setSpacing(0);
136 GroupButtons->layout()->setMargin(0);
137 GroupButtonsLayout = new QGridLayout(GroupButtons->layout());
138 GroupButtonsLayout->setAlignment(Qt::AlignTop);
139 GroupButtonsLayout->setSpacing(6);
140 GroupButtonsLayout->setMargin(11);
141 buttonHelp = new QPushButton(GroupButtons, "buttonHelp");
142 buttonHelp->setText(tr("SMESH_BUT_HELP" ));
143 buttonHelp->setAutoDefault(TRUE);
144 GroupButtonsLayout->addWidget(buttonHelp, 0, 4);
145 buttonCancel = new QPushButton(GroupButtons, "buttonCancel");
146 buttonCancel->setText(tr("SMESH_BUT_CLOSE" ));
147 buttonCancel->setAutoDefault(TRUE);
148 GroupButtonsLayout->addWidget(buttonCancel, 0, 3);
149 buttonApply = new QPushButton(GroupButtons, "buttonApply");
150 buttonApply->setText(tr("SMESH_BUT_APPLY" ));
151 buttonApply->setAutoDefault(TRUE);
152 GroupButtonsLayout->addWidget(buttonApply, 0, 1);
153 QSpacerItem* spacer_9 = new QSpacerItem(20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum);
154 GroupButtonsLayout->addItem(spacer_9, 0, 2);
155 buttonOk = new QPushButton(GroupButtons, "buttonOk");
156 buttonOk->setText(tr("SMESH_BUT_OK" ));
157 buttonOk->setAutoDefault(TRUE);
158 buttonOk->setDefault(TRUE);
159 GroupButtonsLayout->addWidget(buttonOk, 0, 0);
160 SMESHGUI_MergeNodesDlgLayout->addWidget(GroupButtons, 4, 0);
162 /***************************************************************/
164 // Controls for mesh defining
165 GroupMesh = new QGroupBox(this, "GroupMesh");
166 GroupMesh->setTitle(tr("SMESH_SELECT_WHOLE_MESH"));
167 GroupMesh->setColumnLayout(0, Qt::Vertical);
168 GroupMesh->layout()->setSpacing(0);
169 GroupMesh->layout()->setMargin(0);
170 GroupMeshLayout = new QGridLayout(GroupMesh->layout());
171 GroupMeshLayout->setAlignment(Qt::AlignTop);
172 GroupMeshLayout->setSpacing(6);
173 GroupMeshLayout->setMargin(11);
175 TextLabelName = new QLabel(GroupMesh, "TextLabelName");
176 TextLabelName->setText(tr("SMESH_NAME"));
177 GroupMeshLayout->addWidget(TextLabelName, 0, 0);
179 SelectMeshButton = new QPushButton(GroupMesh, "SelectMeshButton");
180 SelectMeshButton->setPixmap(image1);
181 GroupMeshLayout->addWidget(SelectMeshButton, 0, 1);
183 LineEditMesh = new QLineEdit(GroupMesh, "LineEditMesh");
184 LineEditMesh->setReadOnly(true);
185 GroupMeshLayout->addWidget(LineEditMesh, 0, 2);
187 SMESHGUI_MergeNodesDlgLayout->addWidget(GroupMesh, 1, 0);
189 // Controls for coincident nodes detecting
190 GroupCoincident = new QGroupBox(this, "GroupCoincident");
191 GroupCoincident->setTitle(tr("COINCIDENT_NODES"));
192 GroupCoincident->setColumnLayout(0, Qt::Vertical);
193 GroupCoincident->layout()->setSpacing(0);
194 GroupCoincident->layout()->setMargin(0);
195 QGridLayout* GroupCoincidentLayout = new QGridLayout(GroupCoincident->layout());
196 GroupCoincidentLayout->setAlignment(Qt::AlignTop);
197 GroupCoincidentLayout->setSpacing(6);
198 GroupCoincidentLayout->setMargin(11);
200 TextLabelTolerance = new QLabel(GroupCoincident, "TextLabelTolerance");
201 TextLabelTolerance->setText(tr("SMESH_TOLERANCE"));
202 GroupCoincidentLayout->addWidget(TextLabelTolerance, 0, 0);
204 SpinBoxTolerance = new SMESHGUI_SpinBox(GroupCoincident, "SpinBoxTolerance");
205 GroupCoincidentLayout->addWidget(SpinBoxTolerance, 0, 1);
207 QPushButton* DetectButton = new QPushButton(GroupCoincident, "DetectButton");
208 DetectButton->setText(tr("DETECT"));
209 GroupCoincidentLayout->addWidget(DetectButton, 0, 2);
211 ListCoincident = new QListView(GroupCoincident);
212 ListCoincident->setSorting(-1);
213 ListCoincident->addColumn("Nodes");
214 ListCoincident->header()->hide();
216 GroupCoincidentLayout->addMultiCellWidget(ListCoincident, 1, 1, 0, 1);
218 SelectAllCB = new QCheckBox(GroupCoincident, "SelectAllCB");
219 SelectAllCB->setText(tr("SELECT_ALL"));
220 GroupCoincidentLayout->addWidget(SelectAllCB, 2, 0);
222 SMESHGUI_MergeNodesDlgLayout->addWidget(GroupCoincident, 2, 0);
224 // Controls for editing group of nodes
225 GroupEdit = new QGroupBox(this, "GroupEdit");
226 GroupEdit->setTitle(tr("EDIT_GROUP_OF_NODES"));
227 GroupEdit->setColumnLayout(0, Qt::Vertical);
228 GroupEdit->layout()->setSpacing(0);
229 GroupEdit->layout()->setMargin(0);
230 QGridLayout* GroupEditLayout = new QGridLayout(GroupEdit->layout());
231 GroupEditLayout->setAlignment(Qt::AlignTop);
232 GroupEditLayout->setSpacing(6);
233 GroupEditLayout->setMargin(11);
235 ListEdit = new QListBox(GroupEdit, "ListEdit");
236 ListEdit->setColumnMode(QListBox::FitToHeight);
237 ListEdit->setSelectionMode(QListBox::Extended);
238 GroupEditLayout->addMultiCellWidget(ListEdit, 0, 2, 0, 0);
240 QPushButton* AddButton = new QPushButton(GroupEdit, "AddButton");
241 AddButton->setText(tr("SMESH_BUT_ADD"));
242 GroupEditLayout->addWidget(AddButton, 0, 1);
244 QPushButton* RemoveButton = new QPushButton(GroupEdit, "RemoveButton");
245 RemoveButton->setText(tr("SMESH_BUT_REMOVE"));
246 GroupEditLayout->addWidget(RemoveButton, 1, 1);
248 QSpacerItem* spacer = new QSpacerItem(20, 200, QSizePolicy::Minimum, QSizePolicy::Expanding);
249 GroupEditLayout->addItem(spacer, 2, 1);
251 SMESHGUI_MergeNodesDlgLayout->addWidget(GroupEdit, 3, 0);
253 /* Initialisations */
254 SpinBoxTolerance->RangeStepAndValidator(0.0, COORD_MAX, 0.1, 3);
255 SpinBoxTolerance->SetValue(1e-05);
257 RadioButton1->setChecked(TRUE);
259 myEditCurrentArgument = (QWidget*)LineEditMesh;
262 mySubMeshOrGroup = SMESH::SMESH_subMesh::_nil();
264 mySelector = (SMESH::GetViewWindow( mySMESHGUI ))->GetSelector();
266 mySMESHGUI->SetActiveDialogBox((QDialog*)this);
268 // Costruction of the logical filter
269 SMESH_TypeFilter* aMeshOrSubMeshFilter = new SMESH_TypeFilter (MESHorSUBMESH);
270 SMESH_TypeFilter* aSmeshGroupFilter = new SMESH_TypeFilter (GROUP);
272 QPtrList<SUIT_SelectionFilter> aListOfFilters;
273 if (aMeshOrSubMeshFilter) aListOfFilters.append(aMeshOrSubMeshFilter);
274 if (aSmeshGroupFilter) aListOfFilters.append(aSmeshGroupFilter);
276 myMeshOrSubMeshOrGroupFilter =
277 new SMESH_LogicalFilter (aListOfFilters, SMESH_LogicalFilter::LO_OR);
279 //myMeshOrSubMeshFilter = new SMESH_TypeFilter (MESHorSUBMESH);
281 /* signals and slots connections */
282 connect(buttonOk, SIGNAL(clicked()), this, SLOT(ClickOnOk()));
283 connect(buttonCancel, SIGNAL(clicked()), this, SLOT(ClickOnCancel()));
284 connect(buttonApply, SIGNAL(clicked()), this, SLOT(ClickOnApply()));
285 connect(buttonHelp, SIGNAL(clicked()), this, SLOT(ClickOnHelp()));
287 connect(SelectMeshButton, SIGNAL (clicked()), this, SLOT(SetEditCurrentArgument()));
288 connect(DetectButton, SIGNAL (clicked()), this, SLOT(onDetect()));
289 connect(ListCoincident, SIGNAL (selectionChanged()), this, SLOT(onSelectNodesGroup()));
290 connect(ListCoincident, SIGNAL (pressed(QListViewItem*)), this, SLOT(updateControls()));
291 connect(ListCoincident, SIGNAL (currentChanged(QListViewItem*)), this, SLOT(updateControls()));
292 connect(SelectAllCB, SIGNAL(toggled(bool)), this, SLOT(onSelectAll(bool)));
293 connect(ListEdit, SIGNAL (selectionChanged()), this, SLOT(onSelectNodesFromGroup()));
294 connect(AddButton, SIGNAL (clicked()), this, SLOT(onAdd()));
295 connect(RemoveButton, SIGNAL (clicked()), this, SLOT(onRemove()));
297 connect(mySMESHGUI, SIGNAL (SignalDeactivateActiveDialog()), this, SLOT(DeactivateActiveDialog()));
298 connect(mySelectionMgr, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument()));
299 /* to close dialog if study change */
300 connect(mySMESHGUI, SIGNAL (SignalCloseAllDialogs()), this, SLOT(ClickOnCancel()));
302 this->show(); /* displays Dialog */
305 buttonOk->setEnabled(false);
306 buttonApply->setEnabled(false);
308 // Init Mesh field from selection
309 SelectionIntoArgument();
311 myHelpFileName = "merging_nodes_page.html";
314 //=================================================================================
315 // function : ~SMESHGUI_MergeNodesDlg()
316 // purpose : Destroys the object and frees any allocated resources
317 //=================================================================================
318 SMESHGUI_MergeNodesDlg::~SMESHGUI_MergeNodesDlg()
320 // no need to delete child widgets, Qt does it all for us
323 //=================================================================================
324 // function : ClickOnApply()
326 //=================================================================================
327 bool SMESHGUI_MergeNodesDlg::ClickOnApply()
329 if (mySMESHGUI->isActiveStudyLocked() || myMesh->_is_nil())
333 SMESH::SMESH_MeshEditor_var aMeshEditor = myMesh->GetMeshEditor();
335 QApplication::setOverrideCursor(Qt::waitCursor);
336 SMESH::array_of_long_array_var aGroupsOfNodes = new SMESH::array_of_long_array;
337 aGroupsOfNodes->length(ListCoincident->childCount());
338 QListViewItem* item = ListCoincident->firstChild();
342 QStringList aListIds = QStringList("");
343 if (((QCheckListItem*) item)->isOn())
344 aListIds = QStringList::split(" ", item->text(0), false);
346 SMESH::long_array_var anIds = new SMESH::long_array;
347 anIds->length(aListIds.count());
349 for (int i = 0; i < aListIds.count(); i++)
350 anIds[i] = aListIds[i].toInt();
352 aGroupsOfNodes[anArrayNum++] = anIds.inout();
354 item = item->itemBelow();
357 aMeshEditor->MergeNodes (aGroupsOfNodes.inout());
358 QApplication::restoreOverrideCursor();
362 //mySelectionMgr->clearSelected();
369 //=================================================================================
370 // function : ClickOnOk()
372 //=================================================================================
373 void SMESHGUI_MergeNodesDlg::ClickOnOk()
379 //=================================================================================
380 // function : ClickOnCancel()
382 //=================================================================================
383 void SMESHGUI_MergeNodesDlg::ClickOnCancel()
385 mySelectionMgr->clearFilters();
386 //mySelectionMgr->clearSelected();
387 SMESH::SetPointRepresentation(false);
388 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
389 aViewWindow->SetSelectionMode(ActorSelection);
390 disconnect(mySelectionMgr, 0, this, 0);
391 mySMESHGUI->ResetState();
395 //=================================================================================
396 // function : ClickOnHelp()
398 //=================================================================================
399 void SMESHGUI_MergeNodesDlg::ClickOnHelp()
401 LightApp_Application* app = (LightApp_Application*)(SUIT_Session::session()->activeApplication());
403 app->onHelpContextModule(mySMESHGUI ? app->moduleName(mySMESHGUI->moduleName()) : QString(""), myHelpFileName);
407 platform = "winapplication";
409 platform = "application";
411 SUIT_MessageBox::warn1(0, QObject::tr("WRN_WARNING"),
412 QObject::tr("EXTERNAL_BROWSER_CANNOT_SHOW_PAGE").
413 arg(app->resourceMgr()->stringValue("ExternalBrowser", platform)).arg(myHelpFileName),
414 QObject::tr("BUT_OK"));
418 //=================================================================================
419 // function : onEditNodesGroup()
421 //=================================================================================
422 void SMESHGUI_MergeNodesDlg::onEditNodesGroup()
424 if (ListCoincident->childCount() < 1)
427 QString aNewIds = "";
429 QListBoxItem* anItem;
430 for (anItem = ListEdit->firstItem(); anItem != 0; anItem = anItem->next())
431 aNewIds+=QString(" %1").arg(anItem->text());
433 ListCoincident->currentItem()->setText(0, aNewIds);
436 //=================================================================================
437 // function : updateControls()
439 //=================================================================================
440 void SMESHGUI_MergeNodesDlg::updateControls()
442 if (ListCoincident->childCount() < 1) {
443 SMESH::SetPointRepresentation(false);
444 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
445 aViewWindow->SetSelectionMode(ActorSelection);
449 bool hasChecked = false, hasUnchecked = false;
451 QListViewItem* item = ListCoincident->firstChild();
453 while (item && (!hasChecked || !hasUnchecked)) {
454 if (((QCheckListItem*) item)->isOn())
459 item = item->itemBelow();
463 SelectAllCB->setChecked(false);
465 bool enable = !(myMesh->_is_nil()) && hasChecked;
467 buttonOk->setEnabled(enable);
468 buttonApply->setEnabled(enable);
471 //=================================================================================
472 // function : onDetect()
474 //=================================================================================
475 void SMESHGUI_MergeNodesDlg::onDetect()
477 if (myMesh->_is_nil())
481 SMESH::SMESH_MeshEditor_var aMeshEditor = myMesh->GetMeshEditor();
483 QApplication::setOverrideCursor(Qt::waitCursor);
484 ListCoincident->clear();
487 SMESH::array_of_long_array_var aNodeGroups;
488 if(!mySubMeshOrGroup->_is_nil())
489 aMeshEditor->FindCoincidentNodesOnPart(mySubMeshOrGroup, SpinBoxTolerance->GetValue(), aNodeGroups);
491 aMeshEditor->FindCoincidentNodes(SpinBoxTolerance->GetValue(), aNodeGroups);
493 for (int i = 0; i < aNodeGroups->length(); i++) {
494 SMESH::long_array& aGroup = aNodeGroups[i];
497 for (int j = 0; j < aGroup.length(); j++)
498 aNodeIds+=QString(" %1").arg(aGroup[j]);
500 new QCheckListItem (ListCoincident, aNodeIds, QCheckListItem::CheckBox);
502 QApplication::restoreOverrideCursor();
509 //=================================================================================
510 // function : onSelectNodesGroup()
512 //=================================================================================
513 void SMESHGUI_MergeNodesDlg::onSelectNodesGroup()
518 myEditCurrentArgument = (QWidget*)ListCoincident;
520 QListViewItem* aSelectedItem = ListCoincident->selectedItem();
524 QStringList aListId = QStringList::split(" ", aSelectedItem->text(0), false);
527 ListEdit->insertStringList(aListId);
529 //mySelectionMgr->clearSelected();
530 //mySelectionMgr->AddIObject(myActor->getIO());
532 aList.Append(myActor->getIO());
533 mySelectionMgr->setSelectedObjects(aList, false);
535 SMESH::SetPointRepresentation(true);
536 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
537 aViewWindow->SetSelectionMode(NodeSelection);
539 ListEdit->selectAll(true);
542 //=================================================================================
543 // function : onSelectAll()
545 //=================================================================================
546 void SMESHGUI_MergeNodesDlg::onSelectAll (bool isToggled)
550 QListViewItem* item = ListCoincident->firstChild();
553 if (!((QCheckListItem*) item)->isOn())
554 ((QCheckListItem*) item)->setOn(true);
555 item = item->itemBelow();
559 buttonOk->setEnabled(true);
560 buttonApply->setEnabled(true);
565 //=================================================================================
566 // function : onSelectNodesFromGroup()
568 //=================================================================================
569 void SMESHGUI_MergeNodesDlg::onSelectNodesFromGroup()
574 TColStd_MapOfInteger aIndexes;
575 QListBoxItem* anItem;
576 for (anItem = ListEdit->firstItem(); anItem != 0; anItem = anItem->next()) {
577 if (anItem->isSelected()) {
578 int anId = anItem->text().toInt();
583 mySelector->AddOrRemoveIndex(myActor->getIO(), aIndexes, false);
585 aList.Append(myActor->getIO());
586 mySelectionMgr->setSelectedObjects(aList);
589 //=================================================================================
590 // function : onAdd()
592 //=================================================================================
593 void SMESHGUI_MergeNodesDlg::onAdd()
598 QString aListStr = "";
601 aNbNnodes = SMESH::GetNameOfSelectedNodes(mySelector, myActor->getIO(), aListStr);
605 QStringList aNodes = QStringList::split(" ", aListStr);
606 QListBoxItem* anItem = 0;
608 for (QStringList::iterator it = aNodes.begin(); it != aNodes.end(); ++it) {
609 anItem = ListEdit->findItem(*it, Qt::ExactMatch);
611 anItem = new QListBoxText(*it);
612 ListEdit->insertItem(anItem);
614 ListEdit->setSelected(anItem, true);
620 //=================================================================================
621 // function : onRemove()
623 //=================================================================================
624 void SMESHGUI_MergeNodesDlg::onRemove()
626 if (myEditCurrentArgument != (QWidget*)ListCoincident)
629 for (int i = ListEdit->count(); i > 0; i--) {
630 if (ListEdit->isSelected(i-1))
631 ListEdit->removeItem(i-1);
636 //=================================================================================
637 // function : SetEditCurrentArgument()
639 //=================================================================================
640 void SMESHGUI_MergeNodesDlg::SetEditCurrentArgument()
642 QPushButton* send = (QPushButton*)sender();
644 disconnect(mySelectionMgr, 0, this, 0);
645 mySelectionMgr->clearSelected();
646 mySelectionMgr->clearFilters();
648 if (send == SelectMeshButton) {
649 myEditCurrentArgument = (QWidget*)LineEditMesh;
650 SMESH::SetPointRepresentation(false);
651 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
652 aViewWindow->SetSelectionMode(ActorSelection);
653 mySelectionMgr->installFilter(myMeshOrSubMeshOrGroupFilter);
656 myEditCurrentArgument->setFocus();
657 connect(mySelectionMgr, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument()));
658 SelectionIntoArgument();
661 //=================================================================================
662 // function : SelectionIntoArgument()
663 // purpose : Called when selection as changed or other case
664 //=================================================================================
665 void SMESHGUI_MergeNodesDlg::SelectionIntoArgument()
667 if (myEditCurrentArgument == (QWidget*)LineEditMesh) {
668 QString aString = "";
669 LineEditMesh->setText(aString);
671 ListCoincident->clear();
675 int nbSel = SMESH::GetNameOfSelectedIObjects(mySelectionMgr, aString);
680 mySelectionMgr->selectedObjects(aList,SVTK_Viewer::Type());
682 Handle(SALOME_InteractiveObject) IO = aList.First();
683 myMesh = SMESH::GetMeshByIO(IO);
685 if (myMesh->_is_nil())
688 myActor = SMESH::FindActorByEntry(IO->getEntry());
690 myActor = SMESH::FindActorByObject(myMesh);
694 mySubMeshOrGroup = SMESH::SMESH_IDSource::_nil();
696 if ((!SMESH::IObjectToInterface<SMESH::SMESH_subMesh>(IO)->_is_nil() || //SUBMESH OR GROUP
697 !SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(IO)->_is_nil()) &&
698 !SMESH::IObjectToInterface<SMESH::SMESH_IDSource>(IO)->_is_nil())
699 mySubMeshOrGroup = SMESH::IObjectToInterface<SMESH::SMESH_IDSource>(IO);
701 LineEditMesh->setText(aString);
705 //=================================================================================
706 // function : DeactivateActiveDialog()
708 //=================================================================================
709 void SMESHGUI_MergeNodesDlg::DeactivateActiveDialog()
711 if (GroupConstructors->isEnabled()) {
712 GroupConstructors->setEnabled(false);
713 GroupMesh->setEnabled(false);
714 GroupCoincident->setEnabled(false);
715 GroupEdit->setEnabled(false);
716 GroupButtons->setEnabled(false);
717 mySMESHGUI->ResetState();
718 mySMESHGUI->SetActiveDialogBox(0);
722 //=================================================================================
723 // function : ActivateThisDialog()
725 //=================================================================================
726 void SMESHGUI_MergeNodesDlg::ActivateThisDialog()
728 /* Emit a signal to deactivate the active dialog */
729 mySMESHGUI->EmitSignalDeactivateDialog();
730 GroupConstructors->setEnabled(true);
731 GroupMesh->setEnabled(true);
732 GroupCoincident->setEnabled(true);
733 GroupEdit->setEnabled(true);
734 GroupButtons->setEnabled(true);
736 mySMESHGUI->SetActiveDialogBox((QDialog*)this);
738 SelectionIntoArgument();
741 //=================================================================================
742 // function : enterEvent()
744 //=================================================================================
745 void SMESHGUI_MergeNodesDlg::enterEvent (QEvent*)
747 if (!GroupConstructors->isEnabled())
748 ActivateThisDialog();
751 //=================================================================================
752 // function : closeEvent()
754 //=================================================================================
755 void SMESHGUI_MergeNodesDlg::closeEvent (QCloseEvent*)
757 /* same than click on cancel button */
761 //=======================================================================
762 //function : hideEvent()
763 //purpose : caused by ESC key
764 //=======================================================================
765 void SMESHGUI_MergeNodesDlg::hideEvent (QHideEvent*)
771 //=================================================================================
772 // function : keyPressEvent()
774 //=================================================================================
775 void SMESHGUI_MergeNodesDlg::keyPressEvent( QKeyEvent* e )
777 QDialog::keyPressEvent( e );
778 if ( e->isAccepted() )
781 if ( e->key() == Key_F1 )