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, 3);
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() );
389 Handle(SALOME_InteractiveObject) anIO = myActor->getIO();
393 mySelectionMgr->setSelectedObjects(aList, false);
397 mySelectedObject = SMESH::SMESH_IDSource::_nil();
404 //=================================================================================
405 // function : ClickOnOk()
406 // purpose : Called when user presses <OK> button
407 //=================================================================================
408 void SMESHGUI_SmoothingDlg::ClickOnOk()
414 //=================================================================================
415 // function : ClickOnCancel()
416 // purpose : Called when dialog box is closed
417 //=================================================================================
418 void SMESHGUI_SmoothingDlg::ClickOnCancel()
420 disconnect(mySelectionMgr, 0, this, 0);
421 mySelectionMgr->clearFilters();
422 //mySelectionMgr->clearSelected();
423 if (SMESH::GetCurrentVtkView()) {
424 SMESH::RemoveFilters(); // PAL6938 -- clean all mesh entity filters
425 SMESH::SetPointRepresentation(false);
426 SMESH::SetPickable();
428 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
429 aViewWindow->SetSelectionMode(ActorSelection);
430 mySMESHGUI->ResetState();
434 //=================================================================================
435 // function : ClickOnHelp()
437 //=================================================================================
438 void SMESHGUI_SmoothingDlg::ClickOnHelp()
440 LightApp_Application* app = (LightApp_Application*)(SUIT_Session::session()->activeApplication());
442 app->onHelpContextModule(mySMESHGUI ? app->moduleName(mySMESHGUI->moduleName()) : QString(""), myHelpFileName);
446 platform = "winapplication";
448 platform = "application";
450 SUIT_MessageBox::warning(this, tr("WRN_WARNING"),
451 tr("EXTERNAL_BROWSER_CANNOT_SHOW_PAGE").
452 arg(app->resourceMgr()->stringValue("ExternalBrowser",
454 arg(myHelpFileName));
458 //=======================================================================
459 // function : onTextChange()
461 //=======================================================================
462 void SMESHGUI_SmoothingDlg::onTextChange (const QString& theNewText)
464 QLineEdit* send = (QLineEdit*)sender();
472 if (send == LineEditElements)
474 else if (send == LineEditNodes)
477 buttonOk->setEnabled(false);
478 buttonApply->setEnabled(false);
480 // hilight entered elements/nodes
481 SMDS_Mesh* aMesh = 0;
483 aMesh = myActor->GetObject()->GetMesh();
487 QStringList aListId = theNewText.split(" ", QString::SkipEmptyParts);
489 if (send == LineEditElements) {
490 const Handle(SALOME_InteractiveObject)& anIO = myActor->getIO();
491 TColStd_MapOfInteger newIndices;
492 for (int i = 0; i < aListId.count(); i++) {
493 const SMDS_MeshElement * e = aMesh->FindElement(aListId[ i ].toInt());
495 newIndices.Add(e->GetID());
498 mySelector->AddOrRemoveIndex(anIO, newIndices, false);
499 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
500 aViewWindow->highlight( anIO, true, true );
501 myElementsId = theNewText;
503 } else if (send == LineEditNodes) {
504 TColStd_MapOfInteger newIndices;
506 for (int i = 0; i < aListId.count(); i++) {
507 const SMDS_MeshNode * n = aMesh->FindNode(aListId[ i ].toInt());
509 newIndices.Add(n->GetID());
512 mySelector->AddOrRemoveIndex(myActor->getIO(), newIndices, false);
513 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
514 aViewWindow->highlight( myActor->getIO(), true, true );
518 if (myNbOkElements && (myNbOkNodes || LineEditNodes->text().trimmed().isEmpty())) {
519 buttonOk->setEnabled(true);
520 buttonApply->setEnabled(true);
526 //=================================================================================
527 // function : SelectionIntoArgument()
528 // purpose : Called when selection as changed or other case
529 //=================================================================================
530 void SMESHGUI_SmoothingDlg::SelectionIntoArgument()
535 QString aString = "";
538 if (myEditCurrentArgument == LineEditElements ||
539 myEditCurrentArgument == LineEditNodes) {
540 myEditCurrentArgument->setText(aString);
541 if (myEditCurrentArgument == LineEditElements)
545 buttonOk->setEnabled(false);
546 buttonApply->setEnabled(false);
551 if (!GroupButtons->isEnabled()) // inactive
556 mySelectionMgr->selectedObjects(aList,SVTK_Viewer::Type());
557 int nbSel = aList.Extent();
561 Handle(SALOME_InteractiveObject) IO = aList.First();
562 myMesh = SMESH::GetMeshByIO(IO);
563 if (myMesh->_is_nil())
566 myActor = SMESH::FindActorByObject(myMesh);
572 if (myEditCurrentArgument == LineEditElements) {
575 if (CheckBoxMesh->isChecked()) {
576 SMESH::GetNameOfSelectedIObjects(mySelectionMgr, aString);
578 if (!SMESH::IObjectToInterface<SMESH::SMESH_IDSource>(IO)->_is_nil())
579 mySelectedObject = SMESH::IObjectToInterface<SMESH::SMESH_IDSource>(IO);
583 aNbUnits = SMESH::GetNameOfSelectedElements(mySelector, IO, aString);
584 myElementsId = aString;
588 } else if (myEditCurrentArgument == LineEditNodes && !myMesh->_is_nil() && myActor) {
590 aNbUnits = SMESH::GetNameOfSelectedNodes(mySelector, IO, aString);
595 myEditCurrentArgument->setText(aString);
596 myEditCurrentArgument->repaint();
597 myEditCurrentArgument->setEnabled(false); // to update lineedit IPAL 19809
598 myEditCurrentArgument->setEnabled(true);
602 if (myEditCurrentArgument == LineEditElements)
603 myNbOkElements = true;
604 else if (myEditCurrentArgument == LineEditNodes)
607 if (myNbOkElements && (myNbOkNodes || LineEditNodes->text().trimmed().isEmpty())) {
608 buttonOk->setEnabled(true);
609 buttonApply->setEnabled(true);
613 //=================================================================================
614 // function : SetEditCurrentArgument()
616 //=================================================================================
617 void SMESHGUI_SmoothingDlg::SetEditCurrentArgument()
619 QPushButton* send = (QPushButton*)sender();
621 switch (myConstructorId) {
622 case 0: /* default constructor */
624 disconnect(mySelectionMgr, 0, this, 0);
625 mySelectionMgr->clearSelected();
626 mySelectionMgr->clearFilters();
628 if (send == SelectElementsButton) {
629 myEditCurrentArgument = LineEditElements;
630 SMESH::SetPointRepresentation(false);
631 if (CheckBoxMesh->isChecked()) {
632 // mySelectionMgr->setSelectionModes(ActorSelection);
633 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
634 aViewWindow->SetSelectionMode(ActorSelection);
635 mySelectionMgr->installFilter(myMeshOrSubMeshOrGroupFilter);
637 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
638 aViewWindow->SetSelectionMode(FaceSelection);
640 } else if (send == SelectNodesButton) {
641 LineEditNodes->clear();
642 myEditCurrentArgument = LineEditNodes;
643 SMESH::SetPointRepresentation(true);
644 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI )) {
645 aViewWindow->SetSelectionMode(NodeSelection);
649 myEditCurrentArgument->setFocus();
650 connect(mySelectionMgr, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument()));
651 SelectionIntoArgument();
657 //=================================================================================
658 // function : DeactivateActiveDialog()
659 // purpose : Deactivates this dialog
660 //=================================================================================
661 void SMESHGUI_SmoothingDlg::DeactivateActiveDialog()
663 if (GroupConstructors->isEnabled()) {
664 GroupConstructors->setEnabled(false);
665 GroupArguments->setEnabled(false);
666 GroupButtons->setEnabled(false);
667 mySMESHGUI->ResetState();
668 mySMESHGUI->SetActiveDialogBox(0);
672 //=================================================================================
673 // function : ActivateThisDialog()
674 // purpose : Activates this dialog
675 //=================================================================================
676 void SMESHGUI_SmoothingDlg::ActivateThisDialog()
678 // Emit a signal to deactivate the active dialog
679 mySMESHGUI->EmitSignalDeactivateDialog();
680 GroupConstructors->setEnabled(true);
681 GroupArguments->setEnabled(true);
682 GroupButtons->setEnabled(true);
684 mySMESHGUI->SetActiveDialogBox(this);
685 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
686 aViewWindow->SetSelectionMode(FaceSelection);
687 SelectionIntoArgument();
690 //=================================================================================
691 // function : enterEvent()
692 // purpose : Mouse enter event
693 //=================================================================================
694 void SMESHGUI_SmoothingDlg::enterEvent (QEvent*)
696 if (!GroupConstructors->isEnabled())
697 ActivateThisDialog();
700 //=================================================================================
701 // function : closeEvent()
703 //=================================================================================
704 void SMESHGUI_SmoothingDlg::closeEvent (QCloseEvent*)
706 /* same than click on cancel button */
710 //=======================================================================
711 // function : hideEvent()
712 // purpose : caused by ESC key
713 //=======================================================================
714 void SMESHGUI_SmoothingDlg::hideEvent (QHideEvent*)
720 //=======================================================================
721 // function : onSelectMesh()
723 //=======================================================================
724 void SMESHGUI_SmoothingDlg::onSelectMesh (bool toSelectMesh)
727 TextLabelElements->setText(tr("SMESH_NAME"));
729 TextLabelElements->setText(tr("SMESH_ID_ELEMENTS"));
730 myElemFilterBtn->setEnabled(!toSelectMesh);
732 if (myEditCurrentArgument != LineEditElements &&
733 myEditCurrentArgument != LineEditNodes) {
734 LineEditElements->clear();
735 LineEditNodes->clear();
739 mySelectionMgr->clearFilters();
740 SMESH::SetPointRepresentation(false);
743 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
744 aViewWindow->SetSelectionMode(ActorSelection);
745 // mySelectionMgr->setSelectionModes(ActorSelection);
746 mySelectionMgr->installFilter(myMeshOrSubMeshOrGroupFilter);
747 myEditCurrentArgument->setReadOnly(true);
748 myEditCurrentArgument->setValidator(0);
750 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
751 aViewWindow->SetSelectionMode(myEditCurrentArgument == LineEditElements ? FaceSelection
753 myEditCurrentArgument->setReadOnly(false);
754 LineEditElements->setValidator(myIdValidator);
755 onTextChange(myEditCurrentArgument->text());
758 SelectionIntoArgument();
761 //=================================================================================
762 // function : keyPressEvent()
764 //=================================================================================
765 void SMESHGUI_SmoothingDlg::keyPressEvent( QKeyEvent* e )
767 QDialog::keyPressEvent( e );
768 if ( e->isAccepted() )
771 if ( e->key() == Qt::Key_F1 ) {
777 //=================================================================================
778 // function : setFilters()
779 // purpose : activate filter dialog
780 //=================================================================================
781 void SMESHGUI_SmoothingDlg::setFilters( const bool theIsElem )
783 if(myMesh->_is_nil()) {
784 SUIT_MessageBox::critical(this,
786 tr("NO_MESH_SELECTED"));
792 types.append( SMESH::NODE );
793 types.append( SMESH::ALL );
794 myFilterDlg = new SMESHGUI_FilterDlg( mySMESHGUI, types );
796 myFilterDlg->Init( theIsElem ? SMESH::ALL : SMESH::NODE );
798 myFilterDlg->SetSelection();
799 myFilterDlg->SetMesh( myMesh );
800 myFilterDlg->SetSourceWg( theIsElem ? LineEditElements : LineEditNodes );
805 //=================================================================================
806 // function : setElemFilters()
807 // purpose : SLOT. Called when element "Filter" button pressed.
808 //=================================================================================
809 void SMESHGUI_SmoothingDlg::setElemFilters()
814 //=================================================================================
815 // function : setNodeFilters()
816 // purpose : SLOT. Called when node "Filter" button pressed.
817 //=================================================================================
818 void SMESHGUI_SmoothingDlg::setNodeFilters()
823 //=================================================================================
824 // function : isValid
826 //=================================================================================
827 bool SMESHGUI_SmoothingDlg::isValid()
831 ok = SpinBox_IterationLimit->isValid( msg, true ) && ok;
832 ok = SpinBox_AspectRatio->isValid( msg, true ) && ok;
835 QString str( tr( "SMESH_INCORRECT_INPUT" ) );
836 if ( !msg.isEmpty() )
838 SUIT_MessageBox::critical( this, tr( "SMESH_ERROR" ), str );