1 // Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 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
22 // SMESH SMESHGUI : GUI for SMESH component
23 // File : SMESHGUI_SmoothingDlg.cxx
24 // Author : Michael ZORIN, Open CASCADE S.A.S.
27 #include "SMESHGUI_SmoothingDlg.h"
30 #include "SMESHGUI_Utils.h"
31 #include "SMESHGUI_VTKUtils.h"
32 #include "SMESHGUI_MeshUtils.h"
33 #include "SMESHGUI_SpinBox.h"
34 #include "SMESHGUI_IdValidator.h"
35 #include "SMESHGUI_FilterDlg.h"
37 #include <SMESH_Actor.h>
38 #include <SMESH_TypeFilter.hxx>
39 #include <SMESH_LogicalFilter.hxx>
41 #include <SMDS_Mesh.hxx>
43 // SALOME GUI includes
44 #include <SUIT_ResourceMgr.h>
45 #include <SUIT_OverrideCursor.h>
46 #include <SUIT_Desktop.h>
47 #include <SUIT_Session.h>
48 #include <SUIT_MessageBox.h>
50 #include <LightApp_Application.h>
51 #include <LightApp_SelectionMgr.h>
53 #include <SVTK_ViewModel.h>
54 #include <SVTK_Selector.h>
55 #include <SVTK_ViewWindow.h>
56 #include <SVTK_Selection.h>
57 #include <SALOME_ListIO.hxx>
60 #include <TColStd_MapOfInteger.hxx>
63 #include <QApplication>
67 #include <QPushButton>
68 #include <QRadioButton>
72 #include <QHBoxLayout>
73 #include <QVBoxLayout>
74 #include <QGridLayout>
76 #include <QButtonGroup>
79 #include <SALOMEconfig.h>
80 #include CORBA_SERVER_HEADER(SMESH_Group)
81 #include CORBA_SERVER_HEADER(SMESH_MeshEditor)
86 //=================================================================================
87 // function : SMESHGUI_SmoothingDlg()
88 // purpose : constructor
89 //=================================================================================
90 SMESHGUI_SmoothingDlg::SMESHGUI_SmoothingDlg( SMESHGUI* theModule )
91 : QDialog( SMESH::GetDesktop( theModule ) ),
92 mySMESHGUI( theModule ),
93 mySelectionMgr( SMESH::GetSelectionMgr( theModule ) ),
96 QPixmap image0 (SMESH::GetResourceMgr( mySMESHGUI )->loadPixmap("SMESH", tr("ICON_DLG_SMOOTHING")));
97 QPixmap image1 (SMESH::GetResourceMgr( mySMESHGUI )->loadPixmap("SMESH", tr("ICON_SELECT")));
100 setAttribute(Qt::WA_DeleteOnClose, true);
101 setWindowTitle(tr("SMESH_SMOOTHING"));
102 setSizeGripEnabled(true);
104 /***************************************************************/
105 QVBoxLayout* SMESHGUI_SmoothingDlgLayout = new QVBoxLayout(this);
106 SMESHGUI_SmoothingDlgLayout->setSpacing(SPACING);
107 SMESHGUI_SmoothingDlgLayout->setMargin(MARGIN);
109 /***************************************************************/
110 GroupConstructors = new QGroupBox(tr("SMESH_SMOOTHING"), this);
111 QButtonGroup* ButtonGroup = new QButtonGroup(this);
112 QHBoxLayout* GroupConstructorsLayout = new QHBoxLayout(GroupConstructors);
113 GroupConstructorsLayout->setSpacing(SPACING);
114 GroupConstructorsLayout->setMargin(MARGIN);
116 Constructor1 = new QRadioButton(GroupConstructors);
117 Constructor1->setIcon(image0);
118 Constructor1->setChecked(true);
119 GroupConstructorsLayout->addWidget(Constructor1);
120 ButtonGroup->addButton(Constructor1, 0);
122 /***************************************************************/
123 GroupArguments = new QGroupBox(tr("SMESH_ARGUMENTS"), this);
124 QGridLayout* GroupArgumentsLayout = new QGridLayout(GroupArguments);
125 GroupArgumentsLayout->setSpacing(SPACING);
126 GroupArgumentsLayout->setMargin(MARGIN);
128 myIdValidator = new SMESHGUI_IdValidator(this);
130 // Controls for elements selection
131 TextLabelElements = new QLabel(tr("SMESH_ID_ELEMENTS"), GroupArguments);
133 SelectElementsButton = new QPushButton(GroupArguments);
134 SelectElementsButton->setIcon(image1);
136 LineEditElements = new QLineEdit(GroupArguments);
137 LineEditElements->setValidator(myIdValidator);
138 QPushButton* filterElemBtn = new QPushButton( tr( "SMESH_BUT_FILTER" ), GroupArguments );
139 connect(filterElemBtn, SIGNAL(clicked()), this, SLOT(setElemFilters()));
141 // Control for the whole mesh selection
142 CheckBoxMesh = new QCheckBox(tr("SMESH_SELECT_WHOLE_MESH"), GroupArguments);
144 // Controls for nodes selection
145 TextLabelNodes = new QLabel(tr("FIXED_NODES_IDS"), GroupArguments);
147 SelectNodesButton = new QPushButton(GroupArguments);
148 SelectNodesButton->setIcon(image1);
150 LineEditNodes = new QLineEdit(GroupArguments);
151 LineEditNodes->setValidator(myIdValidator);
152 QPushButton* filterNodeBtn = new QPushButton( tr( "SMESH_BUT_FILTER" ), GroupArguments );
153 connect(filterNodeBtn, SIGNAL(clicked()), this, SLOT(setNodeFilters()));
155 // Controls for method selection
156 TextLabelMethod = new QLabel(tr("METHOD"), GroupArguments);
158 ComboBoxMethod = new QComboBox(GroupArguments);
160 // Controls for iteration limit defining
161 TextLabelLimit = new QLabel(tr("ITERATION_LIMIT"), GroupArguments);
163 SpinBox_IterationLimit = new QSpinBox(GroupArguments);
165 // Controls for max. aspect ratio defining
166 TextLabelAspectRatio = new QLabel(tr("MAX_ASPECT_RATIO"), GroupArguments);
168 SpinBox_AspectRatio = new SMESHGUI_SpinBox(GroupArguments);
170 // Check box "Is Parametric"
171 CheckBoxParametric = new QCheckBox( tr("IS_PARAMETRIC"), GroupArguments );
173 GroupArgumentsLayout->addWidget(TextLabelElements, 0, 0);
174 GroupArgumentsLayout->addWidget(SelectElementsButton, 0, 1);
175 GroupArgumentsLayout->addWidget(LineEditElements, 0, 2);
176 GroupArgumentsLayout->addWidget(filterElemBtn, 0, 3);
177 GroupArgumentsLayout->addWidget(CheckBoxMesh, 1, 0, 1, 4);
178 GroupArgumentsLayout->addWidget(TextLabelNodes, 2, 0);
179 GroupArgumentsLayout->addWidget(SelectNodesButton, 2, 1);
180 GroupArgumentsLayout->addWidget(LineEditNodes, 2, 2);
181 GroupArgumentsLayout->addWidget(filterNodeBtn, 2, 3);
182 GroupArgumentsLayout->addWidget(TextLabelMethod, 3, 0);
183 GroupArgumentsLayout->addWidget(ComboBoxMethod, 3, 2, 1, 2);
184 GroupArgumentsLayout->addWidget(TextLabelLimit, 4, 0);
185 GroupArgumentsLayout->addWidget(SpinBox_IterationLimit, 4, 2, 1, 2);
186 GroupArgumentsLayout->addWidget(TextLabelAspectRatio, 5, 0);
187 GroupArgumentsLayout->addWidget(SpinBox_AspectRatio, 5, 2, 1, 2);
188 GroupArgumentsLayout->addWidget(CheckBoxParametric, 6, 0, 1, 4);
190 /***************************************************************/
191 GroupButtons = new QGroupBox(this);
192 QHBoxLayout* GroupButtonsLayout = new QHBoxLayout(GroupButtons);
193 GroupButtonsLayout->setSpacing(SPACING);
194 GroupButtonsLayout->setMargin(MARGIN);
196 buttonOk = new QPushButton(tr("SMESH_BUT_APPLY_AND_CLOSE"), GroupButtons);
197 buttonOk->setAutoDefault(true);
198 buttonOk->setDefault(true);
199 buttonApply = new QPushButton(tr("SMESH_BUT_APPLY"), GroupButtons);
200 buttonApply->setAutoDefault(true);
201 buttonCancel = new QPushButton(tr("SMESH_BUT_CLOSE"), GroupButtons);
202 buttonCancel->setAutoDefault(true);
203 buttonHelp = new QPushButton(tr("SMESH_BUT_HELP"), GroupButtons);
204 buttonHelp->setAutoDefault(true);
206 GroupButtonsLayout->addWidget(buttonOk);
207 GroupButtonsLayout->addSpacing(10);
208 GroupButtonsLayout->addWidget(buttonApply);
209 GroupButtonsLayout->addSpacing(10);
210 GroupButtonsLayout->addStretch();
211 GroupButtonsLayout->addWidget(buttonCancel);
212 GroupButtonsLayout->addWidget(buttonHelp);
214 /***************************************************************/
215 SMESHGUI_SmoothingDlgLayout->addWidget(GroupConstructors);
216 SMESHGUI_SmoothingDlgLayout->addWidget(GroupArguments);
217 SMESHGUI_SmoothingDlgLayout->addWidget(GroupButtons);
219 /***************************************************************/
220 /* Initialisations */
221 ComboBoxMethod->addItem(tr("LAPLACIAN"));
222 ComboBoxMethod->addItem(tr("CENTROIDAL"));
224 ComboBoxMethod->setCurrentIndex(0);
226 CheckBoxParametric->setChecked( true );
228 SpinBox_IterationLimit->setRange(1, 999999);
229 SpinBox_IterationLimit->setValue(20);
230 SpinBox_AspectRatio->RangeStepAndValidator(0.0, +999999.999, 0.1, 3);
231 SpinBox_AspectRatio->SetValue(1.1);
233 GroupArguments->show();
235 Constructor1->setChecked(true);
237 mySelector = (SMESH::GetViewWindow( mySMESHGUI ))->GetSelector();
239 mySMESHGUI->SetActiveDialogBox(this);
241 // Costruction of the logical filter for the elements: mesh/sub-mesh/group
242 SMESH_TypeFilter* aMeshOrSubMeshFilter = new SMESH_TypeFilter (MESHorSUBMESH);
243 SMESH_TypeFilter* aSmeshGroupFilter = new SMESH_TypeFilter (GROUP);
245 QList<SUIT_SelectionFilter*> aListOfFilters;
246 if (aMeshOrSubMeshFilter) aListOfFilters.append(aMeshOrSubMeshFilter);
247 if (aSmeshGroupFilter) aListOfFilters.append(aSmeshGroupFilter);
249 myMeshOrSubMeshOrGroupFilter =
250 new SMESH_LogicalFilter (aListOfFilters, SMESH_LogicalFilter::LO_OR);
252 myHelpFileName = "smoothing_page.html";
256 /***************************************************************/
257 // signals and slots connections
258 connect(buttonOk, SIGNAL(clicked()), this, SLOT(ClickOnOk()));
259 connect(buttonCancel, SIGNAL(clicked()), this, SLOT(ClickOnCancel()));
260 connect(buttonApply, SIGNAL(clicked()), this, SLOT(ClickOnApply()));
261 connect(buttonHelp, SIGNAL(clicked()), this, SLOT(ClickOnHelp()));
263 connect(SelectElementsButton, SIGNAL (clicked()), this, SLOT(SetEditCurrentArgument()));
264 connect(SelectNodesButton, SIGNAL (clicked()), this, SLOT(SetEditCurrentArgument()));
265 connect(mySMESHGUI, SIGNAL (SignalDeactivateActiveDialog()), this, SLOT(DeactivateActiveDialog()));
266 connect(mySelectionMgr, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument()));
267 /* to close dialog if study change */
268 connect(mySMESHGUI, SIGNAL (SignalCloseAllDialogs()), this, SLOT(ClickOnCancel()));
269 connect(LineEditElements, SIGNAL(textChanged(const QString&)),
270 SLOT(onTextChange(const QString&)));
271 connect(LineEditNodes, SIGNAL(textChanged(const QString&)),
272 SLOT(onTextChange(const QString&)));
273 connect(CheckBoxMesh, SIGNAL(toggled(bool)),
274 SLOT(onSelectMesh(bool)));
277 //=================================================================================
278 // function : ~SMESHGUI_SmoothingDlg()
279 // purpose : destructor
280 //=================================================================================
281 SMESHGUI_SmoothingDlg::~SMESHGUI_SmoothingDlg()
283 // no need to delete child widgets, Qt does it all for us
284 if ( myFilterDlg != 0 ) {
285 myFilterDlg->setParent( 0 );
290 //=================================================================================
292 // purpose : initialization
293 //=================================================================================
294 void SMESHGUI_SmoothingDlg::Init()
298 // ComboBoxMethod->setCurrentItem(0);
300 // SpinBox_IterationLimit->setValue(20);
301 // SpinBox_AspectRatio->SetValue(1.1);
303 myEditCurrentArgument = LineEditElements;
304 LineEditElements->setFocus();
305 LineEditElements->clear();
306 LineEditNodes->clear();
311 myMesh = SMESH::SMESH_Mesh::_nil();
313 CheckBoxMesh->setChecked(false);
317 //=================================================================================
318 // function : ClickOnApply()
319 // purpose : Called when user presses <Apply> button
320 //=================================================================================
321 void SMESHGUI_SmoothingDlg::ClickOnApply()
323 if (mySMESHGUI->isActiveStudyLocked())
326 if (myNbOkElements && (myNbOkNodes || LineEditNodes->text().trimmed().isEmpty())) {
327 QStringList aListElementsId = myElementsId.split(" ", QString::SkipEmptyParts);
328 QStringList aListNodesId = LineEditNodes->text().split(" ", QString::SkipEmptyParts);
330 SMESH::long_array_var anElementsId = new SMESH::long_array;
331 SMESH::long_array_var aNodesId = new SMESH::long_array;
333 anElementsId->length(aListElementsId.count());
334 for (int i = 0; i < aListElementsId.count(); i++)
335 anElementsId[i] = aListElementsId[i].toInt();
337 if ( myNbOkNodes && aListNodesId.count() > 0 ) {
338 aNodesId->length(aListNodesId.count());
339 for (int i = 0; i < aListNodesId.count(); i++)
340 aNodesId[i] = aListNodesId[i].toInt();
345 long anIterationLimit = (long)SpinBox_IterationLimit->value();
346 double aMaxAspectRatio = SpinBox_AspectRatio->GetValue();
348 SMESH::SMESH_MeshEditor::Smooth_Method aMethod = SMESH::SMESH_MeshEditor::LAPLACIAN_SMOOTH;
349 if (ComboBoxMethod->currentIndex() > 0)
350 aMethod = SMESH::SMESH_MeshEditor::CENTROIDAL_SMOOTH;
352 bool aResult = false;
354 SUIT_OverrideCursor aWaitCursor;
355 SMESH::SMESH_MeshEditor_var aMeshEditor = myMesh->GetMeshEditor();
357 if ( CheckBoxParametric->isChecked() )
358 aResult = aMeshEditor->SmoothParametric(anElementsId.inout(), aNodesId.inout(),
359 anIterationLimit, aMaxAspectRatio, aMethod);
361 aResult = aMeshEditor->Smooth(anElementsId.inout(), aNodesId.inout(),
362 anIterationLimit, aMaxAspectRatio, aMethod);
367 Handle(SALOME_InteractiveObject) anIO = myActor->getIO();
371 mySelectionMgr->setSelectedObjects(aList, false);
378 //=================================================================================
379 // function : ClickOnOk()
380 // purpose : Called when user presses <OK> button
381 //=================================================================================
382 void SMESHGUI_SmoothingDlg::ClickOnOk()
388 //=================================================================================
389 // function : ClickOnCancel()
390 // purpose : Called when dialog box is closed
391 //=================================================================================
392 void SMESHGUI_SmoothingDlg::ClickOnCancel()
394 disconnect(mySelectionMgr, 0, this, 0);
395 mySelectionMgr->clearFilters();
396 //mySelectionMgr->clearSelected();
397 if (SMESH::GetCurrentVtkView()) {
398 SMESH::RemoveFilters(); // PAL6938 -- clean all mesh entity filters
399 SMESH::SetPointRepresentation(false);
400 SMESH::SetPickable();
402 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
403 aViewWindow->SetSelectionMode(ActorSelection);
404 mySMESHGUI->ResetState();
408 //=================================================================================
409 // function : ClickOnHelp()
411 //=================================================================================
412 void SMESHGUI_SmoothingDlg::ClickOnHelp()
414 LightApp_Application* app = (LightApp_Application*)(SUIT_Session::session()->activeApplication());
416 app->onHelpContextModule(mySMESHGUI ? app->moduleName(mySMESHGUI->moduleName()) : QString(""), myHelpFileName);
420 platform = "winapplication";
422 platform = "application";
424 SUIT_MessageBox::warning(this, tr("WRN_WARNING"),
425 tr("EXTERNAL_BROWSER_CANNOT_SHOW_PAGE").
426 arg(app->resourceMgr()->stringValue("ExternalBrowser",
428 arg(myHelpFileName));
432 //=======================================================================
433 // function : onTextChange()
435 //=======================================================================
436 void SMESHGUI_SmoothingDlg::onTextChange (const QString& theNewText)
438 QLineEdit* send = (QLineEdit*)sender();
446 if (send == LineEditElements)
448 else if (send == LineEditNodes)
451 buttonOk->setEnabled(false);
452 buttonApply->setEnabled(false);
454 // hilight entered elements/nodes
455 SMDS_Mesh* aMesh = 0;
457 aMesh = myActor->GetObject()->GetMesh();
461 QStringList aListId = theNewText.split(" ", QString::SkipEmptyParts);
463 if (send == LineEditElements) {
464 const Handle(SALOME_InteractiveObject)& anIO = myActor->getIO();
465 TColStd_MapOfInteger newIndices;
466 for (int i = 0; i < aListId.count(); i++) {
467 const SMDS_MeshElement * e = aMesh->FindElement(aListId[ i ].toInt());
469 newIndices.Add(e->GetID());
472 mySelector->AddOrRemoveIndex(anIO, newIndices, false);
473 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
474 aViewWindow->highlight( anIO, true, true );
475 myElementsId = theNewText;
477 } else if (send == LineEditNodes) {
478 TColStd_MapOfInteger newIndices;
480 for (int i = 0; i < aListId.count(); i++) {
481 const SMDS_MeshNode * n = aMesh->FindNode(aListId[ i ].toInt());
483 newIndices.Add(n->GetID());
486 mySelector->AddOrRemoveIndex(myActor->getIO(), newIndices, false);
487 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
488 aViewWindow->highlight( myActor->getIO(), true, true );
492 if (myNbOkElements && (myNbOkNodes || LineEditNodes->text().trimmed().isEmpty())) {
493 buttonOk->setEnabled(true);
494 buttonApply->setEnabled(true);
500 //=================================================================================
501 // function : SelectionIntoArgument()
502 // purpose : Called when selection as changed or other case
503 //=================================================================================
504 void SMESHGUI_SmoothingDlg::SelectionIntoArgument()
509 QString aString = "";
512 if (myEditCurrentArgument == LineEditElements ||
513 myEditCurrentArgument == LineEditNodes) {
514 myEditCurrentArgument->setText(aString);
515 if (myEditCurrentArgument == LineEditElements)
519 buttonOk->setEnabled(false);
520 buttonApply->setEnabled(false);
525 if (!GroupButtons->isEnabled()) // inactive
530 mySelectionMgr->selectedObjects(aList,SVTK_Viewer::Type());
531 int nbSel = aList.Extent();
535 Handle(SALOME_InteractiveObject) IO = aList.First();
536 myMesh = SMESH::GetMeshByIO(IO);
537 if (myMesh->_is_nil())
540 myActor = SMESH::FindActorByObject(myMesh);
546 if (myEditCurrentArgument == LineEditElements) {
549 if (CheckBoxMesh->isChecked()) {
550 SMESH::GetNameOfSelectedIObjects(mySelectionMgr, aString);
552 if (!SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(IO)->_is_nil()) { //MESH
554 SMDS_Mesh* aSMDSMesh = myActor->GetObject()->GetMesh();
558 for (int i = aSMDSMesh->MinElementID(); i <= aSMDSMesh->MaxElementID(); i++ ) {
559 const SMDS_MeshElement * e = aSMDSMesh->FindElement(i);
561 myElementsId += QString(" %1").arg(i);
565 } else if (!SMESH::IObjectToInterface<SMESH::SMESH_subMesh>(IO)->_is_nil()) { //SUBMESH
567 SMESH::SMESH_subMesh_var aSubMesh = SMESH::IObjectToInterface<SMESH::SMESH_subMesh>(IO);
569 // get IDs from submesh
570 SMESH::long_array_var anElementsIds = new SMESH::long_array;
571 anElementsIds = aSubMesh->GetElementsId();
572 for (int i = 0; i < anElementsIds->length(); i++) {
573 myElementsId += QString(" %1").arg(anElementsIds[i]);
575 aNbUnits = anElementsIds->length();
578 SMESH::SMESH_GroupBase_var aGroup =
579 SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(IO);
580 if (aGroup->_is_nil())
583 // get IDs from smesh group
584 SMESH::long_array_var anElementsIds = new SMESH::long_array;
585 anElementsIds = aGroup->GetListOfID();
586 for (int i = 0; i < anElementsIds->length(); i++) {
587 myElementsId += QString(" %1").arg(anElementsIds[i]);
589 aNbUnits = anElementsIds->length();
592 aNbUnits = SMESH::GetNameOfSelectedElements(mySelector, IO, aString);
593 myElementsId = aString;
595 } else if (myEditCurrentArgument == LineEditNodes && !myMesh->_is_nil() && myActor) {
597 aNbUnits = SMESH::GetNameOfSelectedNodes(mySelector, IO, aString);
605 myEditCurrentArgument->setText(aString);
606 myEditCurrentArgument->repaint();
607 myEditCurrentArgument->setEnabled(false); // to update lineedit IPAL 19809
608 myEditCurrentArgument->setEnabled(true);
612 if (myEditCurrentArgument == LineEditElements)
613 myNbOkElements = aNbUnits;
614 else if (myEditCurrentArgument == LineEditNodes)
615 myNbOkNodes = aNbUnits;
617 if (myNbOkElements && (myNbOkNodes || LineEditNodes->text().trimmed().isEmpty())) {
618 buttonOk->setEnabled(true);
619 buttonApply->setEnabled(true);
623 //=================================================================================
624 // function : SetEditCurrentArgument()
626 //=================================================================================
627 void SMESHGUI_SmoothingDlg::SetEditCurrentArgument()
629 QPushButton* send = (QPushButton*)sender();
631 switch (myConstructorId) {
632 case 0: /* default constructor */
634 disconnect(mySelectionMgr, 0, this, 0);
635 mySelectionMgr->clearSelected();
636 mySelectionMgr->clearFilters();
638 if (send == SelectElementsButton) {
639 myEditCurrentArgument = LineEditElements;
640 SMESH::SetPointRepresentation(false);
641 if (CheckBoxMesh->isChecked()) {
642 // mySelectionMgr->setSelectionModes(ActorSelection);
643 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
644 aViewWindow->SetSelectionMode(ActorSelection);
645 mySelectionMgr->installFilter(myMeshOrSubMeshOrGroupFilter);
647 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
648 aViewWindow->SetSelectionMode(FaceSelection);
650 } else if (send == SelectNodesButton) {
651 LineEditNodes->clear();
652 myEditCurrentArgument = LineEditNodes;
653 SMESH::SetPointRepresentation(true);
654 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI )) {
655 aViewWindow->SetSelectionMode(NodeSelection);
659 myEditCurrentArgument->setFocus();
660 connect(mySelectionMgr, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument()));
661 SelectionIntoArgument();
667 //=================================================================================
668 // function : DeactivateActiveDialog()
669 // purpose : Deactivates this dialog
670 //=================================================================================
671 void SMESHGUI_SmoothingDlg::DeactivateActiveDialog()
673 if (GroupConstructors->isEnabled()) {
674 GroupConstructors->setEnabled(false);
675 GroupArguments->setEnabled(false);
676 GroupButtons->setEnabled(false);
677 mySMESHGUI->ResetState();
678 mySMESHGUI->SetActiveDialogBox(0);
682 //=================================================================================
683 // function : ActivateThisDialog()
684 // purpose : Activates this dialog
685 //=================================================================================
686 void SMESHGUI_SmoothingDlg::ActivateThisDialog()
688 // Emit a signal to deactivate the active dialog
689 mySMESHGUI->EmitSignalDeactivateDialog();
690 GroupConstructors->setEnabled(true);
691 GroupArguments->setEnabled(true);
692 GroupButtons->setEnabled(true);
694 mySMESHGUI->SetActiveDialogBox(this);
695 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
696 aViewWindow->SetSelectionMode(FaceSelection);
697 SelectionIntoArgument();
700 //=================================================================================
701 // function : enterEvent()
702 // purpose : Mouse enter event
703 //=================================================================================
704 void SMESHGUI_SmoothingDlg::enterEvent (QEvent*)
706 if (!GroupConstructors->isEnabled())
707 ActivateThisDialog();
710 //=================================================================================
711 // function : closeEvent()
713 //=================================================================================
714 void SMESHGUI_SmoothingDlg::closeEvent (QCloseEvent*)
716 /* same than click on cancel button */
720 //=======================================================================
721 // function : hideEvent()
722 // purpose : caused by ESC key
723 //=======================================================================
724 void SMESHGUI_SmoothingDlg::hideEvent (QHideEvent*)
730 //=======================================================================
731 // function : onSelectMesh()
733 //=======================================================================
734 void SMESHGUI_SmoothingDlg::onSelectMesh (bool toSelectMesh)
737 TextLabelElements->setText(tr("SMESH_NAME"));
739 TextLabelElements->setText(tr("SMESH_ID_ELEMENTS"));
741 if (myEditCurrentArgument != LineEditElements &&
742 myEditCurrentArgument != LineEditNodes) {
743 LineEditElements->clear();
744 LineEditNodes->clear();
748 mySelectionMgr->clearFilters();
749 SMESH::SetPointRepresentation(false);
752 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
753 aViewWindow->SetSelectionMode(ActorSelection);
754 // mySelectionMgr->setSelectionModes(ActorSelection);
755 mySelectionMgr->installFilter(myMeshOrSubMeshOrGroupFilter);
756 myEditCurrentArgument->setReadOnly(true);
757 myEditCurrentArgument->setValidator(0);
759 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
760 aViewWindow->SetSelectionMode(myEditCurrentArgument == LineEditElements ? FaceSelection
762 myEditCurrentArgument->setReadOnly(false);
763 LineEditElements->setValidator(myIdValidator);
764 onTextChange(myEditCurrentArgument->text());
767 SelectionIntoArgument();
770 //=================================================================================
771 // function : keyPressEvent()
773 //=================================================================================
774 void SMESHGUI_SmoothingDlg::keyPressEvent( QKeyEvent* e )
776 QDialog::keyPressEvent( e );
777 if ( e->isAccepted() )
780 if ( e->key() == Qt::Key_F1 ) {
786 //=================================================================================
787 // function : setFilters()
788 // purpose : activate filter dialog
789 //=================================================================================
790 void SMESHGUI_SmoothingDlg::setFilters( const bool theIsElem )
795 types.append( SMESH::NODE );
796 types.append( SMESH::ALL );
797 myFilterDlg = new SMESHGUI_FilterDlg( mySMESHGUI, types );
799 myFilterDlg->Init( theIsElem ? SMESH::ALL : SMESH::NODE );
801 myFilterDlg->SetSelection();
802 myFilterDlg->SetMesh( myMesh );
803 myFilterDlg->SetSourceWg( theIsElem ? LineEditElements : LineEditNodes );
808 //=================================================================================
809 // function : setElemFilters()
810 // purpose : SLOT. Called when element "Filter" button pressed.
811 //=================================================================================
812 void SMESHGUI_SmoothingDlg::setElemFilters()
817 //=================================================================================
818 // function : setNodeFilters()
819 // purpose : SLOT. Called when node "Filter" button pressed.
820 //=================================================================================
821 void SMESHGUI_SmoothingDlg::setNodeFilters()