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 <SalomeApp_IntSpinBox.h>
55 #include <SVTK_ViewModel.h>
56 #include <SVTK_Selector.h>
57 #include <SVTK_ViewWindow.h>
58 #include <SVTK_Selection.h>
59 #include <SALOME_ListIO.hxx>
62 #include <TColStd_MapOfInteger.hxx>
65 #include <QApplication>
69 #include <QPushButton>
70 #include <QRadioButton>
73 #include <QHBoxLayout>
74 #include <QVBoxLayout>
75 #include <QGridLayout>
77 #include <QButtonGroup>
80 #include <SALOMEconfig.h>
81 #include CORBA_SERVER_HEADER(SMESH_Group)
82 #include CORBA_SERVER_HEADER(SMESH_MeshEditor)
87 //=================================================================================
88 // function : SMESHGUI_SmoothingDlg()
89 // purpose : constructor
90 //=================================================================================
91 SMESHGUI_SmoothingDlg::SMESHGUI_SmoothingDlg( SMESHGUI* theModule )
92 : QDialog( SMESH::GetDesktop( theModule ) ),
93 mySMESHGUI( theModule ),
94 mySelectionMgr( SMESH::GetSelectionMgr( theModule ) ),
96 mySelectedObject(SMESH::SMESH_IDSource::_nil())
98 QPixmap image0 (SMESH::GetResourceMgr( mySMESHGUI )->loadPixmap("SMESH", tr("ICON_DLG_SMOOTHING")));
99 QPixmap image1 (SMESH::GetResourceMgr( mySMESHGUI )->loadPixmap("SMESH", tr("ICON_SELECT")));
102 setAttribute(Qt::WA_DeleteOnClose, true);
103 setWindowTitle(tr("SMESH_SMOOTHING"));
104 setSizeGripEnabled(true);
106 /***************************************************************/
107 QVBoxLayout* SMESHGUI_SmoothingDlgLayout = new QVBoxLayout(this);
108 SMESHGUI_SmoothingDlgLayout->setSpacing(SPACING);
109 SMESHGUI_SmoothingDlgLayout->setMargin(MARGIN);
111 /***************************************************************/
112 GroupConstructors = new QGroupBox(tr("SMESH_SMOOTHING"), this);
113 QButtonGroup* ButtonGroup = new QButtonGroup(this);
114 QHBoxLayout* GroupConstructorsLayout = new QHBoxLayout(GroupConstructors);
115 GroupConstructorsLayout->setSpacing(SPACING);
116 GroupConstructorsLayout->setMargin(MARGIN);
118 Constructor1 = new QRadioButton(GroupConstructors);
119 Constructor1->setIcon(image0);
120 Constructor1->setChecked(true);
121 GroupConstructorsLayout->addWidget(Constructor1);
122 ButtonGroup->addButton(Constructor1, 0);
124 /***************************************************************/
125 GroupArguments = new QGroupBox(tr("SMESH_ARGUMENTS"), this);
126 QGridLayout* GroupArgumentsLayout = new QGridLayout(GroupArguments);
127 GroupArgumentsLayout->setSpacing(SPACING);
128 GroupArgumentsLayout->setMargin(MARGIN);
130 myIdValidator = new SMESHGUI_IdValidator(this);
132 // Controls for elements selection
133 TextLabelElements = new QLabel(tr("SMESH_ID_ELEMENTS"), GroupArguments);
135 SelectElementsButton = new QPushButton(GroupArguments);
136 SelectElementsButton->setIcon(image1);
138 LineEditElements = new QLineEdit(GroupArguments);
139 LineEditElements->setValidator(myIdValidator);
140 myElemFilterBtn = new QPushButton( tr( "SMESH_BUT_FILTER" ), GroupArguments );
141 connect(myElemFilterBtn, SIGNAL(clicked()), this, SLOT(setElemFilters()));
143 // Control for the whole mesh selection
144 CheckBoxMesh = new QCheckBox(tr("SMESH_SELECT_WHOLE_MESH"), GroupArguments);
146 // Controls for nodes selection
147 TextLabelNodes = new QLabel(tr("FIXED_NODES_IDS"), GroupArguments);
149 SelectNodesButton = new QPushButton(GroupArguments);
150 SelectNodesButton->setIcon(image1);
152 LineEditNodes = new QLineEdit(GroupArguments);
153 LineEditNodes->setValidator(myIdValidator);
154 QPushButton* filterNodeBtn = new QPushButton( tr( "SMESH_BUT_FILTER" ), GroupArguments );
155 connect(filterNodeBtn, SIGNAL(clicked()), this, SLOT(setNodeFilters()));
157 // Controls for method selection
158 TextLabelMethod = new QLabel(tr("METHOD"), GroupArguments);
160 ComboBoxMethod = new QComboBox(GroupArguments);
162 // Controls for iteration limit defining
163 TextLabelLimit = new QLabel(tr("ITERATION_LIMIT"), GroupArguments);
165 SpinBox_IterationLimit = new SalomeApp_IntSpinBox(GroupArguments);
167 // Controls for max. aspect ratio defining
168 TextLabelAspectRatio = new QLabel(tr("MAX_ASPECT_RATIO"), GroupArguments);
170 SpinBox_AspectRatio = new SMESHGUI_SpinBox(GroupArguments);
172 // Check box "Is Parametric"
173 CheckBoxParametric = new QCheckBox( tr("IS_PARAMETRIC"), GroupArguments );
175 GroupArgumentsLayout->addWidget(TextLabelElements, 0, 0);
176 GroupArgumentsLayout->addWidget(SelectElementsButton, 0, 1);
177 GroupArgumentsLayout->addWidget(LineEditElements, 0, 2);
178 GroupArgumentsLayout->addWidget(myElemFilterBtn, 0, 3);
179 GroupArgumentsLayout->addWidget(CheckBoxMesh, 1, 0, 1, 4);
180 GroupArgumentsLayout->addWidget(TextLabelNodes, 2, 0);
181 GroupArgumentsLayout->addWidget(SelectNodesButton, 2, 1);
182 GroupArgumentsLayout->addWidget(LineEditNodes, 2, 2);
183 GroupArgumentsLayout->addWidget(filterNodeBtn, 2, 3);
184 GroupArgumentsLayout->addWidget(TextLabelMethod, 3, 0);
185 GroupArgumentsLayout->addWidget(ComboBoxMethod, 3, 2, 1, 2);
186 GroupArgumentsLayout->addWidget(TextLabelLimit, 4, 0);
187 GroupArgumentsLayout->addWidget(SpinBox_IterationLimit, 4, 2, 1, 2);
188 GroupArgumentsLayout->addWidget(TextLabelAspectRatio, 5, 0);
189 GroupArgumentsLayout->addWidget(SpinBox_AspectRatio, 5, 2, 1, 2);
190 GroupArgumentsLayout->addWidget(CheckBoxParametric, 6, 0, 1, 4);
192 /***************************************************************/
193 GroupButtons = new QGroupBox(this);
194 QHBoxLayout* GroupButtonsLayout = new QHBoxLayout(GroupButtons);
195 GroupButtonsLayout->setSpacing(SPACING);
196 GroupButtonsLayout->setMargin(MARGIN);
198 buttonOk = new QPushButton(tr("SMESH_BUT_APPLY_AND_CLOSE"), GroupButtons);
199 buttonOk->setAutoDefault(true);
200 buttonOk->setDefault(true);
201 buttonApply = new QPushButton(tr("SMESH_BUT_APPLY"), GroupButtons);
202 buttonApply->setAutoDefault(true);
203 buttonCancel = new QPushButton(tr("SMESH_BUT_CLOSE"), GroupButtons);
204 buttonCancel->setAutoDefault(true);
205 buttonHelp = new QPushButton(tr("SMESH_BUT_HELP"), GroupButtons);
206 buttonHelp->setAutoDefault(true);
208 GroupButtonsLayout->addWidget(buttonOk);
209 GroupButtonsLayout->addSpacing(10);
210 GroupButtonsLayout->addWidget(buttonApply);
211 GroupButtonsLayout->addSpacing(10);
212 GroupButtonsLayout->addStretch();
213 GroupButtonsLayout->addWidget(buttonCancel);
214 GroupButtonsLayout->addWidget(buttonHelp);
216 /***************************************************************/
217 SMESHGUI_SmoothingDlgLayout->addWidget(GroupConstructors);
218 SMESHGUI_SmoothingDlgLayout->addWidget(GroupArguments);
219 SMESHGUI_SmoothingDlgLayout->addWidget(GroupButtons);
221 /***************************************************************/
222 /* Initialisations */
223 ComboBoxMethod->addItem(tr("LAPLACIAN"));
224 ComboBoxMethod->addItem(tr("CENTROIDAL"));
226 ComboBoxMethod->setCurrentIndex(0);
228 CheckBoxParametric->setChecked( true );
230 SpinBox_IterationLimit->setRange(1, 999999);
231 SpinBox_IterationLimit->setValue(20);
232 SpinBox_AspectRatio->RangeStepAndValidator(0.0, +999999.999, 0.1, "parametric_precision");
233 SpinBox_AspectRatio->SetValue(1.1);
235 GroupArguments->show();
237 Constructor1->setChecked(true);
239 mySelector = (SMESH::GetViewWindow( mySMESHGUI ))->GetSelector();
241 mySMESHGUI->SetActiveDialogBox(this);
243 // Costruction of the logical filter for the elements: mesh/sub-mesh/group
244 SMESH_TypeFilter* aMeshOrSubMeshFilter = new SMESH_TypeFilter (MESHorSUBMESH);
245 SMESH_TypeFilter* aSmeshGroupFilter = new SMESH_TypeFilter (GROUP);
247 QList<SUIT_SelectionFilter*> aListOfFilters;
248 if (aMeshOrSubMeshFilter) aListOfFilters.append(aMeshOrSubMeshFilter);
249 if (aSmeshGroupFilter) aListOfFilters.append(aSmeshGroupFilter);
251 myMeshOrSubMeshOrGroupFilter =
252 new SMESH_LogicalFilter (aListOfFilters, SMESH_LogicalFilter::LO_OR);
254 myHelpFileName = "smoothing_page.html";
258 /***************************************************************/
259 // signals and slots connections
260 connect(buttonOk, SIGNAL(clicked()), this, SLOT(ClickOnOk()));
261 connect(buttonCancel, SIGNAL(clicked()), this, SLOT(ClickOnCancel()));
262 connect(buttonApply, SIGNAL(clicked()), this, SLOT(ClickOnApply()));
263 connect(buttonHelp, SIGNAL(clicked()), this, SLOT(ClickOnHelp()));
265 connect(SelectElementsButton, SIGNAL (clicked()), this, SLOT(SetEditCurrentArgument()));
266 connect(SelectNodesButton, SIGNAL (clicked()), this, SLOT(SetEditCurrentArgument()));
267 connect(mySMESHGUI, SIGNAL (SignalDeactivateActiveDialog()), this, SLOT(DeactivateActiveDialog()));
268 connect(mySelectionMgr, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument()));
269 /* to close dialog if study change */
270 connect(mySMESHGUI, SIGNAL (SignalCloseAllDialogs()), this, SLOT(ClickOnCancel()));
271 connect(LineEditElements, SIGNAL(textChanged(const QString&)),
272 SLOT(onTextChange(const QString&)));
273 connect(LineEditNodes, SIGNAL(textChanged(const QString&)),
274 SLOT(onTextChange(const QString&)));
275 connect(CheckBoxMesh, SIGNAL(toggled(bool)),
276 SLOT(onSelectMesh(bool)));
279 //=================================================================================
280 // function : ~SMESHGUI_SmoothingDlg()
281 // purpose : destructor
282 //=================================================================================
283 SMESHGUI_SmoothingDlg::~SMESHGUI_SmoothingDlg()
285 // no need to delete child widgets, Qt does it all for us
286 if ( myFilterDlg != 0 ) {
287 myFilterDlg->setParent( 0 );
292 //=================================================================================
294 // purpose : initialization
295 //=================================================================================
296 void SMESHGUI_SmoothingDlg::Init()
300 // ComboBoxMethod->setCurrentItem(0);
302 // SpinBox_IterationLimit->setValue(20);
303 // SpinBox_AspectRatio->SetValue(1.1);
305 myEditCurrentArgument = LineEditElements;
306 LineEditElements->setFocus();
307 LineEditElements->clear();
308 LineEditNodes->clear();
313 myMesh = SMESH::SMESH_Mesh::_nil();
315 CheckBoxMesh->setChecked(false);
319 //=================================================================================
320 // function : ClickOnApply()
321 // purpose : Called when user presses <Apply> button
322 //=================================================================================
323 bool SMESHGUI_SmoothingDlg::ClickOnApply()
325 if (mySMESHGUI->isActiveStudyLocked())
331 if (myNbOkElements && (myNbOkNodes || LineEditNodes->text().trimmed().isEmpty())) {
332 QStringList aListElementsId = myElementsId.split(" ", QString::SkipEmptyParts);
333 QStringList aListNodesId = LineEditNodes->text().split(" ", QString::SkipEmptyParts);
335 SMESH::long_array_var anElementsId = new SMESH::long_array;
336 SMESH::long_array_var aNodesId = new SMESH::long_array;
338 anElementsId->length(aListElementsId.count());
339 for (int i = 0; i < aListElementsId.count(); i++)
340 anElementsId[i] = aListElementsId[i].toInt();
342 if ( myNbOkNodes && aListNodesId.count() > 0 ) {
343 aNodesId->length(aListNodesId.count());
344 for (int i = 0; i < aListNodesId.count(); i++)
345 aNodesId[i] = aListNodesId[i].toInt();
350 long anIterationLimit = (long)SpinBox_IterationLimit->value();
351 double aMaxAspectRatio = SpinBox_AspectRatio->GetValue();
353 QStringList aParameters;
354 aParameters << SpinBox_IterationLimit->text();
355 aParameters << SpinBox_AspectRatio->text();
357 SMESH::SMESH_MeshEditor::Smooth_Method aMethod = SMESH::SMESH_MeshEditor::LAPLACIAN_SMOOTH;
358 if (ComboBoxMethod->currentIndex() > 0)
359 aMethod = SMESH::SMESH_MeshEditor::CENTROIDAL_SMOOTH;
361 bool aResult = false;
363 SUIT_OverrideCursor aWaitCursor;
364 SMESH::SMESH_MeshEditor_var aMeshEditor = myMesh->GetMeshEditor();
366 if ( CheckBoxParametric->isChecked() ) {
367 if(CheckBoxMesh->isChecked())
368 aResult = aMeshEditor->SmoothParametricObject(mySelectedObject, aNodesId.inout(),
369 anIterationLimit, aMaxAspectRatio, aMethod);
371 aResult = aMeshEditor->SmoothParametric(anElementsId.inout(), aNodesId.inout(),
372 anIterationLimit, aMaxAspectRatio, aMethod);
375 if(CheckBoxMesh->isChecked())
376 aResult = aMeshEditor->SmoothObject(mySelectedObject, aNodesId.inout(),
377 anIterationLimit, aMaxAspectRatio, aMethod);
379 aResult = aMeshEditor->Smooth(anElementsId.inout(), aNodesId.inout(),
380 anIterationLimit, aMaxAspectRatio, aMethod);
383 myMesh->SetParameters( aParameters.join(":").toLatin1().constData() );
390 Handle(SALOME_InteractiveObject) anIO = myActor->getIO();
393 mySelectionMgr->setSelectedObjects(aList, false);
399 mySelectedObject = SMESH::SMESH_IDSource::_nil();
406 //=================================================================================
407 // function : ClickOnOk()
408 // purpose : Called when user presses <OK> button
409 //=================================================================================
410 void SMESHGUI_SmoothingDlg::ClickOnOk()
416 //=================================================================================
417 // function : ClickOnCancel()
418 // purpose : Called when dialog box is closed
419 //=================================================================================
420 void SMESHGUI_SmoothingDlg::ClickOnCancel()
422 disconnect(mySelectionMgr, 0, this, 0);
423 mySelectionMgr->clearFilters();
424 //mySelectionMgr->clearSelected();
425 if (SMESH::GetCurrentVtkView()) {
426 SMESH::RemoveFilters(); // PAL6938 -- clean all mesh entity filters
427 SMESH::SetPointRepresentation(false);
428 SMESH::SetPickable();
430 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
431 aViewWindow->SetSelectionMode(ActorSelection);
432 mySMESHGUI->ResetState();
436 //=================================================================================
437 // function : ClickOnHelp()
439 //=================================================================================
440 void SMESHGUI_SmoothingDlg::ClickOnHelp()
442 LightApp_Application* app = (LightApp_Application*)(SUIT_Session::session()->activeApplication());
444 app->onHelpContextModule(mySMESHGUI ? app->moduleName(mySMESHGUI->moduleName()) : QString(""), myHelpFileName);
448 platform = "winapplication";
450 platform = "application";
452 SUIT_MessageBox::warning(this, tr("WRN_WARNING"),
453 tr("EXTERNAL_BROWSER_CANNOT_SHOW_PAGE").
454 arg(app->resourceMgr()->stringValue("ExternalBrowser",
456 arg(myHelpFileName));
460 //=======================================================================
461 // function : onTextChange()
463 //=======================================================================
464 void SMESHGUI_SmoothingDlg::onTextChange (const QString& theNewText)
466 QLineEdit* send = (QLineEdit*)sender();
474 if (send == LineEditElements)
476 else if (send == LineEditNodes)
479 buttonOk->setEnabled(false);
480 buttonApply->setEnabled(false);
482 // hilight entered elements/nodes
483 SMDS_Mesh* aMesh = 0;
485 aMesh = myActor->GetObject()->GetMesh();
489 QStringList aListId = theNewText.split(" ", QString::SkipEmptyParts);
491 if (send == LineEditElements) {
492 const Handle(SALOME_InteractiveObject)& anIO = myActor->getIO();
493 TColStd_MapOfInteger newIndices;
494 for (int i = 0; i < aListId.count(); i++) {
495 const SMDS_MeshElement * e = aMesh->FindElement(aListId[ i ].toInt());
497 newIndices.Add(e->GetID());
500 mySelector->AddOrRemoveIndex(anIO, newIndices, false);
501 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
502 aViewWindow->highlight( anIO, true, true );
503 myElementsId = theNewText;
505 } else if (send == LineEditNodes) {
506 TColStd_MapOfInteger newIndices;
508 for (int i = 0; i < aListId.count(); i++) {
509 const SMDS_MeshNode * n = aMesh->FindNode(aListId[ i ].toInt());
511 newIndices.Add(n->GetID());
514 mySelector->AddOrRemoveIndex(myActor->getIO(), newIndices, false);
515 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
516 aViewWindow->highlight( myActor->getIO(), true, true );
520 if (myNbOkElements && (myNbOkNodes || LineEditNodes->text().trimmed().isEmpty())) {
521 buttonOk->setEnabled(true);
522 buttonApply->setEnabled(true);
528 //=================================================================================
529 // function : SelectionIntoArgument()
530 // purpose : Called when selection as changed or other case
531 //=================================================================================
532 void SMESHGUI_SmoothingDlg::SelectionIntoArgument()
537 QString aString = "";
540 if (myEditCurrentArgument == LineEditElements ||
541 myEditCurrentArgument == LineEditNodes) {
542 myEditCurrentArgument->setText(aString);
543 if (myEditCurrentArgument == LineEditElements)
547 buttonOk->setEnabled(false);
548 buttonApply->setEnabled(false);
553 if (!GroupButtons->isEnabled()) // inactive
558 mySelectionMgr->selectedObjects(aList,SVTK_Viewer::Type());
559 int nbSel = aList.Extent();
563 Handle(SALOME_InteractiveObject) IO = aList.First();
564 myMesh = SMESH::GetMeshByIO(IO);
565 if (myMesh->_is_nil())
568 myActor = SMESH::FindActorByObject(myMesh);
569 if (!myActor && !CheckBoxMesh->isChecked())
574 if (myEditCurrentArgument == LineEditElements) {
577 if (CheckBoxMesh->isChecked()) {
578 SMESH::GetNameOfSelectedIObjects(mySelectionMgr, aString);
580 if (!SMESH::IObjectToInterface<SMESH::SMESH_IDSource>(IO)->_is_nil())
581 mySelectedObject = SMESH::IObjectToInterface<SMESH::SMESH_IDSource>(IO);
585 aNbUnits = SMESH::GetNameOfSelectedElements(mySelector, IO, aString);
586 myElementsId = aString;
590 } else if (myEditCurrentArgument == LineEditNodes && !myMesh->_is_nil() && myActor) {
592 aNbUnits = SMESH::GetNameOfSelectedNodes(mySelector, IO, aString);
597 myEditCurrentArgument->setText(aString);
598 myEditCurrentArgument->repaint();
599 myEditCurrentArgument->setEnabled(false); // to update lineedit IPAL 19809
600 myEditCurrentArgument->setEnabled(true);
604 if (myEditCurrentArgument == LineEditElements)
605 myNbOkElements = true;
606 else if (myEditCurrentArgument == LineEditNodes)
609 if (myNbOkElements && (myNbOkNodes || LineEditNodes->text().trimmed().isEmpty())) {
610 buttonOk->setEnabled(true);
611 buttonApply->setEnabled(true);
615 //=================================================================================
616 // function : SetEditCurrentArgument()
618 //=================================================================================
619 void SMESHGUI_SmoothingDlg::SetEditCurrentArgument()
621 QPushButton* send = (QPushButton*)sender();
623 switch (myConstructorId) {
624 case 0: /* default constructor */
626 disconnect(mySelectionMgr, 0, this, 0);
627 mySelectionMgr->clearSelected();
628 mySelectionMgr->clearFilters();
630 if (send == SelectElementsButton) {
631 myEditCurrentArgument = LineEditElements;
632 SMESH::SetPointRepresentation(false);
633 if (CheckBoxMesh->isChecked()) {
634 // mySelectionMgr->setSelectionModes(ActorSelection);
635 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
636 aViewWindow->SetSelectionMode(ActorSelection);
637 mySelectionMgr->installFilter(myMeshOrSubMeshOrGroupFilter);
639 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
640 aViewWindow->SetSelectionMode(FaceSelection);
642 } else if (send == SelectNodesButton) {
643 LineEditNodes->clear();
644 myEditCurrentArgument = LineEditNodes;
645 SMESH::SetPointRepresentation(true);
646 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI )) {
647 aViewWindow->SetSelectionMode(NodeSelection);
651 myEditCurrentArgument->setFocus();
652 connect(mySelectionMgr, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument()));
653 SelectionIntoArgument();
659 //=================================================================================
660 // function : DeactivateActiveDialog()
661 // purpose : Deactivates this dialog
662 //=================================================================================
663 void SMESHGUI_SmoothingDlg::DeactivateActiveDialog()
665 if (GroupConstructors->isEnabled()) {
666 GroupConstructors->setEnabled(false);
667 GroupArguments->setEnabled(false);
668 GroupButtons->setEnabled(false);
669 mySMESHGUI->ResetState();
670 mySMESHGUI->SetActiveDialogBox(0);
674 //=================================================================================
675 // function : ActivateThisDialog()
676 // purpose : Activates this dialog
677 //=================================================================================
678 void SMESHGUI_SmoothingDlg::ActivateThisDialog()
680 // Emit a signal to deactivate the active dialog
681 mySMESHGUI->EmitSignalDeactivateDialog();
682 GroupConstructors->setEnabled(true);
683 GroupArguments->setEnabled(true);
684 GroupButtons->setEnabled(true);
686 mySMESHGUI->SetActiveDialogBox(this);
687 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
688 aViewWindow->SetSelectionMode(FaceSelection);
689 SelectionIntoArgument();
692 //=================================================================================
693 // function : enterEvent()
694 // purpose : Mouse enter event
695 //=================================================================================
696 void SMESHGUI_SmoothingDlg::enterEvent (QEvent*)
698 if (!GroupConstructors->isEnabled())
699 ActivateThisDialog();
702 //=================================================================================
703 // function : closeEvent()
705 //=================================================================================
706 void SMESHGUI_SmoothingDlg::closeEvent (QCloseEvent*)
708 /* same than click on cancel button */
712 //=======================================================================
713 // function : hideEvent()
714 // purpose : caused by ESC key
715 //=======================================================================
716 void SMESHGUI_SmoothingDlg::hideEvent (QHideEvent*)
722 //=======================================================================
723 // function : onSelectMesh()
725 //=======================================================================
726 void SMESHGUI_SmoothingDlg::onSelectMesh (bool toSelectMesh)
729 TextLabelElements->setText(tr("SMESH_NAME"));
731 TextLabelElements->setText(tr("SMESH_ID_ELEMENTS"));
732 myElemFilterBtn->setEnabled(!toSelectMesh);
734 if (myEditCurrentArgument != LineEditElements &&
735 myEditCurrentArgument != LineEditNodes) {
736 LineEditElements->clear();
737 LineEditNodes->clear();
741 mySelectionMgr->clearFilters();
742 SMESH::SetPointRepresentation(false);
745 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
746 aViewWindow->SetSelectionMode(ActorSelection);
747 // mySelectionMgr->setSelectionModes(ActorSelection);
748 mySelectionMgr->installFilter(myMeshOrSubMeshOrGroupFilter);
749 myEditCurrentArgument->setReadOnly(true);
750 myEditCurrentArgument->setValidator(0);
752 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
753 aViewWindow->SetSelectionMode(myEditCurrentArgument == LineEditElements ? FaceSelection
755 myEditCurrentArgument->setReadOnly(false);
756 LineEditElements->setValidator(myIdValidator);
757 onTextChange(myEditCurrentArgument->text());
760 SelectionIntoArgument();
763 //=================================================================================
764 // function : keyPressEvent()
766 //=================================================================================
767 void SMESHGUI_SmoothingDlg::keyPressEvent( QKeyEvent* e )
769 QDialog::keyPressEvent( e );
770 if ( e->isAccepted() )
773 if ( e->key() == Qt::Key_F1 ) {
779 //=================================================================================
780 // function : setFilters()
781 // purpose : activate filter dialog
782 //=================================================================================
783 void SMESHGUI_SmoothingDlg::setFilters( const bool theIsElem )
785 if(myMesh->_is_nil()) {
786 SUIT_MessageBox::critical(this,
788 tr("NO_MESH_SELECTED"));
794 types.append( SMESH::NODE );
795 types.append( SMESH::ALL );
796 myFilterDlg = new SMESHGUI_FilterDlg( mySMESHGUI, types );
798 myFilterDlg->Init( theIsElem ? SMESH::ALL : SMESH::NODE );
800 myFilterDlg->SetSelection();
801 myFilterDlg->SetMesh( myMesh );
802 myFilterDlg->SetSourceWg( theIsElem ? LineEditElements : LineEditNodes );
807 //=================================================================================
808 // function : setElemFilters()
809 // purpose : SLOT. Called when element "Filter" button pressed.
810 //=================================================================================
811 void SMESHGUI_SmoothingDlg::setElemFilters()
816 //=================================================================================
817 // function : setNodeFilters()
818 // purpose : SLOT. Called when node "Filter" button pressed.
819 //=================================================================================
820 void SMESHGUI_SmoothingDlg::setNodeFilters()
825 //=================================================================================
826 // function : isValid
828 //=================================================================================
829 bool SMESHGUI_SmoothingDlg::isValid()
833 ok = SpinBox_IterationLimit->isValid( msg, true ) && ok;
834 ok = SpinBox_AspectRatio->isValid( msg, true ) && ok;
837 QString str( tr( "SMESH_INCORRECT_INPUT" ) );
838 if ( !msg.isEmpty() )
840 SUIT_MessageBox::critical( this, tr( "SMESH_ERROR" ), str );