1 // Copyright (C) 2007-2015 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, or (at your option) any later version.
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
23 // SMESH SMESHGUI : GUI for SMESH component
24 // File : SMESHGUI_SmoothingDlg.cxx
25 // Author : Michael ZORIN, Open CASCADE S.A.S.
28 #include "SMESHGUI_SmoothingDlg.h"
31 #include "SMESHGUI_Utils.h"
32 #include "SMESHGUI_VTKUtils.h"
33 #include "SMESHGUI_MeshUtils.h"
34 #include "SMESHGUI_SpinBox.h"
35 #include "SMESHGUI_IdValidator.h"
36 #include "SMESHGUI_FilterDlg.h"
38 #include <SMESH_Actor.h>
39 #include <SMESH_TypeFilter.hxx>
40 #include <SMESH_LogicalFilter.hxx>
42 #include <SMDS_Mesh.hxx>
44 // SALOME GUI includes
45 #include <SUIT_ResourceMgr.h>
46 #include <SUIT_OverrideCursor.h>
47 #include <SUIT_Desktop.h>
48 #include <SUIT_Session.h>
49 #include <SUIT_MessageBox.h>
51 #include <LightApp_Application.h>
52 #include <LightApp_SelectionMgr.h>
54 #include <SalomeApp_IntSpinBox.h>
56 #include <SVTK_ViewModel.h>
57 #include <SVTK_Selector.h>
58 #include <SVTK_ViewWindow.h>
59 #include <SVTK_Selection.h>
60 #include <SALOME_ListIO.hxx>
63 #include <TColStd_MapOfInteger.hxx>
66 #include <QApplication>
70 #include <QPushButton>
71 #include <QRadioButton>
74 #include <QHBoxLayout>
75 #include <QVBoxLayout>
76 #include <QGridLayout>
78 #include <QButtonGroup>
81 #include <SALOMEconfig.h>
82 #include CORBA_SERVER_HEADER(SMESH_Group)
83 #include CORBA_SERVER_HEADER(SMESH_MeshEditor)
90 \brief Simple 'busy state' flag locker.
97 //! Constructor. Sets passed boolean flag to \c true.
98 BusyLocker( bool& busy ) : myBusy( busy ) { myBusy = true; }
99 //! Destructor. Clear external boolean flag passed as parameter to the constructor to \c false.
100 ~BusyLocker() { myBusy = false; }
102 bool& myBusy; //! External 'busy state' boolean flag
106 //=================================================================================
107 // function : SMESHGUI_SmoothingDlg()
108 // purpose : constructor
109 //=================================================================================
110 SMESHGUI_SmoothingDlg::SMESHGUI_SmoothingDlg( SMESHGUI* theModule )
111 : QDialog( SMESH::GetDesktop( theModule ) ),
112 mySMESHGUI( theModule ),
113 mySelectionMgr( SMESH::GetSelectionMgr( theModule ) ),
115 mySelectedObject(SMESH::SMESH_IDSource::_nil())
117 QPixmap image0 (SMESH::GetResourceMgr( mySMESHGUI )->loadPixmap("SMESH", tr("ICON_DLG_SMOOTHING")));
118 QPixmap image1 (SMESH::GetResourceMgr( mySMESHGUI )->loadPixmap("SMESH", tr("ICON_SELECT")));
121 setAttribute(Qt::WA_DeleteOnClose, true);
122 setWindowTitle(tr("SMESH_SMOOTHING"));
123 setSizeGripEnabled(true);
125 /***************************************************************/
126 QVBoxLayout* SMESHGUI_SmoothingDlgLayout = new QVBoxLayout(this);
127 SMESHGUI_SmoothingDlgLayout->setSpacing(SPACING);
128 SMESHGUI_SmoothingDlgLayout->setMargin(MARGIN);
130 /***************************************************************/
131 GroupConstructors = new QGroupBox(tr("SMESH_SMOOTHING"), this);
132 QButtonGroup* ButtonGroup = new QButtonGroup(this);
133 QHBoxLayout* GroupConstructorsLayout = new QHBoxLayout(GroupConstructors);
134 GroupConstructorsLayout->setSpacing(SPACING);
135 GroupConstructorsLayout->setMargin(MARGIN);
137 Constructor1 = new QRadioButton(GroupConstructors);
138 Constructor1->setIcon(image0);
139 Constructor1->setChecked(true);
140 GroupConstructorsLayout->addWidget(Constructor1);
141 ButtonGroup->addButton(Constructor1, 0);
143 /***************************************************************/
144 GroupArguments = new QGroupBox(tr("SMESH_ARGUMENTS"), this);
145 QGridLayout* GroupArgumentsLayout = new QGridLayout(GroupArguments);
146 GroupArgumentsLayout->setSpacing(SPACING);
147 GroupArgumentsLayout->setMargin(MARGIN);
149 myIdValidator = new SMESHGUI_IdValidator(this);
151 // Controls for elements selection
152 TextLabelElements = new QLabel(tr("SMESH_ID_ELEMENTS"), GroupArguments);
154 SelectElementsButton = new QPushButton(GroupArguments);
155 SelectElementsButton->setIcon(image1);
157 LineEditElements = new QLineEdit(GroupArguments);
158 LineEditElements->setValidator(myIdValidator);
159 LineEditElements->setMaxLength(-1);
160 myElemFilterBtn = new QPushButton( tr( "SMESH_BUT_FILTER" ), GroupArguments );
161 connect(myElemFilterBtn, SIGNAL(clicked()), this, SLOT(setElemFilters()));
163 // Control for the whole mesh selection
164 CheckBoxMesh = new QCheckBox(tr("SMESH_SELECT_WHOLE_MESH"), GroupArguments);
166 // Controls for nodes selection
167 TextLabelNodes = new QLabel(tr("FIXED_NODES_IDS"), GroupArguments);
169 SelectNodesButton = new QPushButton(GroupArguments);
170 SelectNodesButton->setIcon(image1);
172 LineEditNodes = new QLineEdit(GroupArguments);
173 LineEditNodes->setValidator(myIdValidator);
174 LineEditNodes->setMaxLength(-1);
175 QPushButton* filterNodeBtn = new QPushButton( tr( "SMESH_BUT_FILTER" ), GroupArguments );
176 connect(filterNodeBtn, SIGNAL(clicked()), this, SLOT(setNodeFilters()));
178 // Controls for method selection
179 TextLabelMethod = new QLabel(tr("METHOD"), GroupArguments);
181 ComboBoxMethod = new QComboBox(GroupArguments);
183 // Controls for iteration limit defining
184 TextLabelLimit = new QLabel(tr("ITERATION_LIMIT"), GroupArguments);
186 SpinBox_IterationLimit = new SalomeApp_IntSpinBox(GroupArguments);
188 // Controls for max. aspect ratio defining
189 TextLabelAspectRatio = new QLabel(tr("MAX_ASPECT_RATIO"), GroupArguments);
191 SpinBox_AspectRatio = new SMESHGUI_SpinBox(GroupArguments);
193 // Check box "Is Parametric"
194 CheckBoxParametric = new QCheckBox( tr("IS_PARAMETRIC"), GroupArguments );
196 GroupArgumentsLayout->addWidget(TextLabelElements, 0, 0);
197 GroupArgumentsLayout->addWidget(SelectElementsButton, 0, 1);
198 GroupArgumentsLayout->addWidget(LineEditElements, 0, 2);
199 GroupArgumentsLayout->addWidget(myElemFilterBtn, 0, 3);
200 GroupArgumentsLayout->addWidget(CheckBoxMesh, 1, 0, 1, 4);
201 GroupArgumentsLayout->addWidget(TextLabelNodes, 2, 0);
202 GroupArgumentsLayout->addWidget(SelectNodesButton, 2, 1);
203 GroupArgumentsLayout->addWidget(LineEditNodes, 2, 2);
204 GroupArgumentsLayout->addWidget(filterNodeBtn, 2, 3);
205 GroupArgumentsLayout->addWidget(TextLabelMethod, 3, 0);
206 GroupArgumentsLayout->addWidget(ComboBoxMethod, 3, 2, 1, 2);
207 GroupArgumentsLayout->addWidget(TextLabelLimit, 4, 0);
208 GroupArgumentsLayout->addWidget(SpinBox_IterationLimit, 4, 2, 1, 2);
209 GroupArgumentsLayout->addWidget(TextLabelAspectRatio, 5, 0);
210 GroupArgumentsLayout->addWidget(SpinBox_AspectRatio, 5, 2, 1, 2);
211 GroupArgumentsLayout->addWidget(CheckBoxParametric, 6, 0, 1, 4);
213 /***************************************************************/
214 GroupButtons = new QGroupBox(this);
215 QHBoxLayout* GroupButtonsLayout = new QHBoxLayout(GroupButtons);
216 GroupButtonsLayout->setSpacing(SPACING);
217 GroupButtonsLayout->setMargin(MARGIN);
219 buttonOk = new QPushButton(tr("SMESH_BUT_APPLY_AND_CLOSE"), GroupButtons);
220 buttonOk->setAutoDefault(true);
221 buttonOk->setDefault(true);
222 buttonApply = new QPushButton(tr("SMESH_BUT_APPLY"), GroupButtons);
223 buttonApply->setAutoDefault(true);
224 buttonCancel = new QPushButton(tr("SMESH_BUT_CLOSE"), GroupButtons);
225 buttonCancel->setAutoDefault(true);
226 buttonHelp = new QPushButton(tr("SMESH_BUT_HELP"), GroupButtons);
227 buttonHelp->setAutoDefault(true);
229 GroupButtonsLayout->addWidget(buttonOk);
230 GroupButtonsLayout->addSpacing(10);
231 GroupButtonsLayout->addWidget(buttonApply);
232 GroupButtonsLayout->addSpacing(10);
233 GroupButtonsLayout->addStretch();
234 GroupButtonsLayout->addWidget(buttonCancel);
235 GroupButtonsLayout->addWidget(buttonHelp);
237 /***************************************************************/
238 SMESHGUI_SmoothingDlgLayout->addWidget(GroupConstructors);
239 SMESHGUI_SmoothingDlgLayout->addWidget(GroupArguments);
240 SMESHGUI_SmoothingDlgLayout->addWidget(GroupButtons);
242 /***************************************************************/
243 /* Initialisations */
244 ComboBoxMethod->addItem(tr("LAPLACIAN"));
245 ComboBoxMethod->addItem(tr("CENTROIDAL"));
247 ComboBoxMethod->setCurrentIndex(0);
249 CheckBoxParametric->setChecked( true );
251 SpinBox_IterationLimit->setRange(1, 999999);
252 SpinBox_IterationLimit->setValue(20);
253 SpinBox_AspectRatio->RangeStepAndValidator(0.0, +999999.999, 0.1, "parametric_precision");
254 SpinBox_AspectRatio->SetValue(1.1);
256 GroupArguments->show();
258 Constructor1->setChecked(true);
260 mySelector = (SMESH::GetViewWindow( mySMESHGUI ))->GetSelector();
262 mySMESHGUI->SetActiveDialogBox(this);
264 // Costruction of the logical filter for the elements: mesh/sub-mesh/group
265 QList<SUIT_SelectionFilter*> aListOfFilters;
266 aListOfFilters << new SMESH_TypeFilter(SMESH::MESHorSUBMESH) << new SMESH_TypeFilter(SMESH::GROUP);
268 myMeshOrSubMeshOrGroupFilter =
269 new SMESH_LogicalFilter (aListOfFilters, SMESH_LogicalFilter::LO_OR);
271 myHelpFileName = "smoothing_page.html";
275 /***************************************************************/
276 // signals and slots connections
277 connect(buttonOk, SIGNAL(clicked()), this, SLOT(ClickOnOk()));
278 connect(buttonCancel, SIGNAL(clicked()), this, SLOT(reject()));
279 connect(buttonApply, SIGNAL(clicked()), this, SLOT(ClickOnApply()));
280 connect(buttonHelp, SIGNAL(clicked()), this, SLOT(ClickOnHelp()));
282 connect(SelectElementsButton, SIGNAL (clicked()), this, SLOT(SetEditCurrentArgument()));
283 connect(SelectNodesButton, SIGNAL (clicked()), this, SLOT(SetEditCurrentArgument()));
284 connect(mySMESHGUI, SIGNAL (SignalDeactivateActiveDialog()), this, SLOT(DeactivateActiveDialog()));
285 connect(mySelectionMgr, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument()));
286 /* to close dialog if study change */
287 connect(mySMESHGUI, SIGNAL (SignalCloseAllDialogs()), this, SLOT(reject()));
288 connect(mySMESHGUI, SIGNAL (SignalActivatedViewManager()), this, SLOT(onOpenView()));
289 connect(mySMESHGUI, SIGNAL (SignalCloseView()), this, SLOT(onCloseView()));
290 connect(LineEditElements, SIGNAL(textChanged(const QString&)),
291 SLOT(onTextChange(const QString&)));
292 connect(LineEditNodes, SIGNAL(textChanged(const QString&)),
293 SLOT(onTextChange(const QString&)));
294 connect(CheckBoxMesh, SIGNAL(toggled(bool)),
295 SLOT(onSelectMesh(bool)));
298 //=================================================================================
299 // function : ~SMESHGUI_SmoothingDlg()
300 // purpose : destructor
301 //=================================================================================
302 SMESHGUI_SmoothingDlg::~SMESHGUI_SmoothingDlg()
304 // no need to delete child widgets, Qt does it all for us
305 if ( myFilterDlg != 0 ) {
306 myFilterDlg->setParent( 0 );
311 //=================================================================================
313 // purpose : initialization
314 //=================================================================================
315 void SMESHGUI_SmoothingDlg::Init()
319 // ComboBoxMethod->setCurrentItem(0);
321 // SpinBox_IterationLimit->setValue(20);
322 // SpinBox_AspectRatio->SetValue(1.1);
324 myEditCurrentArgument = LineEditElements;
325 LineEditElements->setFocus();
326 LineEditElements->clear();
327 LineEditNodes->clear();
332 myMesh = SMESH::SMESH_Mesh::_nil();
334 CheckBoxMesh->setChecked(false);
338 //=================================================================================
339 // function : ClickOnApply()
340 // purpose : Called when user presses <Apply> button
341 //=================================================================================
342 bool SMESHGUI_SmoothingDlg::ClickOnApply()
344 if (mySMESHGUI->isActiveStudyLocked())
350 if (myNbOkElements && (myNbOkNodes || LineEditNodes->text().trimmed().isEmpty())) {
351 QStringList aListElementsId = LineEditElements->text().split(" ", QString::SkipEmptyParts);
352 QStringList aListNodesId = LineEditNodes->text().split(" ", QString::SkipEmptyParts);
354 SMESH::long_array_var anElementsId = new SMESH::long_array;
355 SMESH::long_array_var aNodesId = new SMESH::long_array;
357 anElementsId->length(aListElementsId.count());
358 for (int i = 0; i < aListElementsId.count(); i++)
359 anElementsId[i] = aListElementsId[i].toInt();
361 if ( myNbOkNodes && aListNodesId.count() > 0 ) {
362 aNodesId->length(aListNodesId.count());
363 for (int i = 0; i < aListNodesId.count(); i++)
364 aNodesId[i] = aListNodesId[i].toInt();
369 long anIterationLimit = (long)SpinBox_IterationLimit->value();
370 double aMaxAspectRatio = SpinBox_AspectRatio->GetValue();
372 QStringList aParameters;
373 aParameters << SpinBox_IterationLimit->text();
374 aParameters << SpinBox_AspectRatio->text();
376 SMESH::SMESH_MeshEditor::Smooth_Method aMethod = SMESH::SMESH_MeshEditor::LAPLACIAN_SMOOTH;
377 if (ComboBoxMethod->currentIndex() > 0)
378 aMethod = SMESH::SMESH_MeshEditor::CENTROIDAL_SMOOTH;
380 bool aResult = false;
382 SUIT_OverrideCursor aWaitCursor;
383 SMESH::SMESH_MeshEditor_var aMeshEditor = myMesh->GetMeshEditor();
385 myMesh->SetParameters( aParameters.join(":").toLatin1().constData() );
387 if ( CheckBoxParametric->isChecked() ) {
388 if(CheckBoxMesh->isChecked())
389 aResult = aMeshEditor->SmoothParametricObject(mySelectedObject, aNodesId.inout(),
390 anIterationLimit, aMaxAspectRatio, aMethod);
392 aResult = aMeshEditor->SmoothParametric(anElementsId.inout(), aNodesId.inout(),
393 anIterationLimit, aMaxAspectRatio, aMethod);
396 if(CheckBoxMesh->isChecked())
397 aResult = aMeshEditor->SmoothObject(mySelectedObject, aNodesId.inout(),
398 anIterationLimit, aMaxAspectRatio, aMethod);
400 aResult = aMeshEditor->Smooth(anElementsId.inout(), aNodesId.inout(),
401 anIterationLimit, aMaxAspectRatio, aMethod);
408 SMESH::Update(myIO, SMESH::eDisplay);
409 SMESHGUI::Modified();
412 mySelectedObject = SMESH::SMESH_IDSource::_nil();
419 //=================================================================================
420 // function : ClickOnOk()
421 // purpose : Called when user presses <OK> button
422 //=================================================================================
423 void SMESHGUI_SmoothingDlg::ClickOnOk()
429 //=================================================================================
430 // function : reject()
431 // purpose : Called when dialog box is closed
432 //=================================================================================
433 void SMESHGUI_SmoothingDlg::reject()
435 disconnect(mySelectionMgr, 0, this, 0);
436 mySelectionMgr->clearFilters();
437 //mySelectionMgr->clearSelected();
438 if (SMESH::GetCurrentVtkView()) {
439 SMESH::RemoveFilters(); // PAL6938 -- clean all mesh entity filters
440 SMESH::SetPointRepresentation(false);
441 SMESH::SetPickable();
443 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
444 aViewWindow->SetSelectionMode(ActorSelection);
445 mySMESHGUI->ResetState();
449 //=================================================================================
450 // function : onOpenView()
452 //=================================================================================
453 void SMESHGUI_SmoothingDlg::onOpenView()
456 SMESH::SetPointRepresentation(false);
459 mySelector = SMESH::GetViewWindow( mySMESHGUI )->GetSelector();
460 ActivateThisDialog();
464 //=================================================================================
465 // function : onCloseView()
467 //=================================================================================
468 void SMESHGUI_SmoothingDlg::onCloseView()
470 DeactivateActiveDialog();
474 //=================================================================================
475 // function : ClickOnHelp()
477 //=================================================================================
478 void SMESHGUI_SmoothingDlg::ClickOnHelp()
480 LightApp_Application* app = (LightApp_Application*)(SUIT_Session::session()->activeApplication());
482 app->onHelpContextModule(mySMESHGUI ? app->moduleName(mySMESHGUI->moduleName()) : QString(""), myHelpFileName);
486 platform = "winapplication";
488 platform = "application";
490 SUIT_MessageBox::warning(this, tr("WRN_WARNING"),
491 tr("EXTERNAL_BROWSER_CANNOT_SHOW_PAGE").
492 arg(app->resourceMgr()->stringValue("ExternalBrowser",
494 arg(myHelpFileName));
498 //=======================================================================
499 // function : onTextChange()
501 //=======================================================================
502 void SMESHGUI_SmoothingDlg::onTextChange (const QString& theNewText)
504 QLineEdit* send = (QLineEdit*)sender();
507 if (myBusy || myIO.IsNull()) return;
510 BusyLocker lock( myBusy );
512 if (send == LineEditElements)
514 else if (send == LineEditNodes)
517 buttonOk->setEnabled(false);
518 buttonApply->setEnabled(false);
520 // hilight entered elements/nodes
521 SMDS_Mesh* aMesh = myActor ? myActor->GetObject()->GetMesh() : 0;
522 QStringList aListId = theNewText.split(" ", QString::SkipEmptyParts);
524 if (send == LineEditElements) {
525 TColStd_MapOfInteger newIndices;
526 for (int i = 0; i < aListId.count(); i++) {
527 int id = aListId[ i ].toInt();
529 bool validId = aMesh ? ( aMesh->FindElement( id ) != 0 ) : ( myMesh->GetElementType( id, true ) != SMESH::EDGE );
531 newIndices.Add( id );
533 myNbOkElements = newIndices.Extent();
534 mySelector->AddOrRemoveIndex(myIO, newIndices, false);
535 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
536 aViewWindow->highlight( myIO, true, true );
539 else if (send == LineEditNodes) {
540 TColStd_MapOfInteger newIndices;
541 for (int i = 0; i < aListId.count(); i++) {
542 int id = aListId[ i ].toInt();
544 bool validId = aMesh ? ( aMesh->FindNode( id ) != 0 ) : ( myMesh->GetElementType( id, false ) != SMESH::EDGE );
546 newIndices.Add( id );
548 myNbOkNodes = newIndices.Extent();
549 mySelector->AddOrRemoveIndex(myIO, newIndices, false);
550 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
551 aViewWindow->highlight( myIO, true, true );
555 if (myNbOkElements && (myNbOkNodes || LineEditNodes->text().trimmed().isEmpty())) {
556 buttonOk->setEnabled(true);
557 buttonApply->setEnabled(true);
561 //=================================================================================
562 // function : SelectionIntoArgument()
563 // purpose : Called when selection as changed or other case
564 //=================================================================================
565 void SMESHGUI_SmoothingDlg::SelectionIntoArgument()
570 QString aString = "";
573 BusyLocker lock( myBusy );
575 if (myEditCurrentArgument == LineEditElements ||
576 myEditCurrentArgument == LineEditNodes) {
577 myEditCurrentArgument->setText(aString);
578 if (myEditCurrentArgument == LineEditElements) {
586 buttonOk->setEnabled(false);
587 buttonApply->setEnabled(false);
590 if (!GroupButtons->isEnabled()) // inactive
595 mySelectionMgr->selectedObjects(aList);
596 int nbSel = aList.Extent();
600 Handle(SALOME_InteractiveObject) IO = aList.First();
602 if (myEditCurrentArgument == LineEditElements) {
603 myMesh = SMESH::GetMeshByIO(IO);
604 if (myMesh->_is_nil())
607 myActor = SMESH::FindActorByObject(myMesh);
609 if (CheckBoxMesh->isChecked()) {
610 SMESH::GetNameOfSelectedIObjects(mySelectionMgr, aString);
612 SMESH::SMESH_IDSource_var obj = SMESH::IObjectToInterface<SMESH::SMESH_IDSource>( myIO );
613 if ( !CORBA::is_nil( obj ) )
614 mySelectedObject = obj;
617 myNbOkElements = true;
619 // get indices of selected elements
620 TColStd_IndexedMapOfInteger aMapIndex;
621 mySelector->GetIndex(IO,aMapIndex);
622 myNbOkElements = aMapIndex.Extent();
624 if (myNbOkElements < 1)
627 QStringList elements;
628 for ( int i = 0; i < myNbOkElements; ++i )
629 elements << QString::number( aMapIndex( i+1 ) );
630 aString = elements.join(" ");
632 } else if (myEditCurrentArgument == LineEditNodes && !myMesh->_is_nil() && myIO->isSame(IO) )
634 myNbOkNodes = SMESH::GetNameOfSelectedNodes(mySelector, IO, aString);
637 myEditCurrentArgument->setText(aString);
638 myEditCurrentArgument->repaint();
639 myEditCurrentArgument->setEnabled(false); // to update lineedit IPAL 19809
640 myEditCurrentArgument->setEnabled(true);
642 if (myNbOkElements && (myNbOkNodes || LineEditNodes->text().trimmed().isEmpty())) {
643 buttonOk->setEnabled(true);
644 buttonApply->setEnabled(true);
648 //=================================================================================
649 // function : SetEditCurrentArgument()
651 //=================================================================================
652 void SMESHGUI_SmoothingDlg::SetEditCurrentArgument()
654 QPushButton* send = (QPushButton*)sender();
656 switch (myConstructorId) {
657 case 0: /* default constructor */
659 disconnect(mySelectionMgr, 0, this, 0);
660 mySelectionMgr->clearSelected();
661 mySelectionMgr->clearFilters();
663 if (send == SelectElementsButton) {
664 myEditCurrentArgument = LineEditElements;
665 SMESH::SetPointRepresentation(false);
666 if (CheckBoxMesh->isChecked()) {
667 // mySelectionMgr->setSelectionModes(ActorSelection);
668 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
669 aViewWindow->SetSelectionMode(ActorSelection);
670 mySelectionMgr->installFilter(myMeshOrSubMeshOrGroupFilter);
672 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
673 aViewWindow->SetSelectionMode(FaceSelection);
675 } else if (send == SelectNodesButton) {
676 LineEditNodes->clear();
677 myEditCurrentArgument = LineEditNodes;
678 SMESH::SetPointRepresentation(true);
679 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI )) {
680 aViewWindow->SetSelectionMode(NodeSelection);
684 myEditCurrentArgument->setFocus();
685 connect(mySelectionMgr, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument()));
686 SelectionIntoArgument();
692 //=================================================================================
693 // function : DeactivateActiveDialog()
694 // purpose : Deactivates this dialog
695 //=================================================================================
696 void SMESHGUI_SmoothingDlg::DeactivateActiveDialog()
698 if (GroupConstructors->isEnabled()) {
699 GroupConstructors->setEnabled(false);
700 GroupArguments->setEnabled(false);
701 GroupButtons->setEnabled(false);
702 mySMESHGUI->ResetState();
703 mySMESHGUI->SetActiveDialogBox(0);
707 //=================================================================================
708 // function : ActivateThisDialog()
709 // purpose : Activates this dialog
710 //=================================================================================
711 void SMESHGUI_SmoothingDlg::ActivateThisDialog()
713 // Emit a signal to deactivate the active dialog
714 mySMESHGUI->EmitSignalDeactivateDialog();
715 GroupConstructors->setEnabled(true);
716 GroupArguments->setEnabled(true);
717 GroupButtons->setEnabled(true);
719 mySMESHGUI->SetActiveDialogBox(this);
720 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
721 aViewWindow->SetSelectionMode(FaceSelection);
722 SelectionIntoArgument();
725 //=================================================================================
726 // function : enterEvent()
727 // purpose : Mouse enter event
728 //=================================================================================
729 void SMESHGUI_SmoothingDlg::enterEvent (QEvent*)
731 if (!GroupConstructors->isEnabled()) {
732 SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI );
733 if ( aViewWindow && !mySelector) {
734 mySelector = aViewWindow->GetSelector();
736 ActivateThisDialog();
740 //=======================================================================
741 // function : onSelectMesh()
743 //=======================================================================
744 void SMESHGUI_SmoothingDlg::onSelectMesh (bool toSelectMesh)
747 TextLabelElements->setText(tr("SMESH_NAME"));
749 TextLabelElements->setText(tr("SMESH_ID_ELEMENTS"));
750 myElemFilterBtn->setEnabled(!toSelectMesh);
752 if (myEditCurrentArgument != LineEditElements &&
753 myEditCurrentArgument != LineEditNodes) {
754 LineEditElements->clear();
755 LineEditNodes->clear();
759 mySelectionMgr->clearFilters();
760 SMESH::SetPointRepresentation(false);
763 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
764 aViewWindow->SetSelectionMode(ActorSelection);
765 // mySelectionMgr->setSelectionModes(ActorSelection);
766 mySelectionMgr->installFilter(myMeshOrSubMeshOrGroupFilter);
767 myEditCurrentArgument->setReadOnly(true);
768 myEditCurrentArgument->setValidator(0);
770 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
771 aViewWindow->SetSelectionMode(myEditCurrentArgument == LineEditElements ? FaceSelection
773 myEditCurrentArgument->setReadOnly(false);
774 LineEditElements->setValidator(myIdValidator);
775 onTextChange(myEditCurrentArgument->text());
778 SelectionIntoArgument();
781 //=================================================================================
782 // function : keyPressEvent()
784 //=================================================================================
785 void SMESHGUI_SmoothingDlg::keyPressEvent( QKeyEvent* e )
787 QDialog::keyPressEvent( e );
788 if ( e->isAccepted() )
791 if ( e->key() == Qt::Key_F1 ) {
797 //=================================================================================
798 // function : setFilters()
799 // purpose : activate filter dialog
800 //=================================================================================
801 void SMESHGUI_SmoothingDlg::setFilters( const bool theIsElem )
803 if(myMesh->_is_nil()) {
804 SUIT_MessageBox::critical(this,
806 tr("NO_MESH_SELECTED"));
812 types.append( SMESH::NODE );
813 types.append( SMESH::ALL );
814 myFilterDlg = new SMESHGUI_FilterDlg( mySMESHGUI, types );
816 myFilterDlg->Init( theIsElem ? SMESH::ALL : SMESH::NODE );
818 myFilterDlg->SetSelection();
819 myFilterDlg->SetMesh( myMesh );
820 myFilterDlg->SetSourceWg( theIsElem ? LineEditElements : LineEditNodes );
825 //=================================================================================
826 // function : setElemFilters()
827 // purpose : SLOT. Called when element "Filter" button pressed.
828 //=================================================================================
829 void SMESHGUI_SmoothingDlg::setElemFilters()
834 //=================================================================================
835 // function : setNodeFilters()
836 // purpose : SLOT. Called when node "Filter" button pressed.
837 //=================================================================================
838 void SMESHGUI_SmoothingDlg::setNodeFilters()
843 //=================================================================================
844 // function : isValid
846 //=================================================================================
847 bool SMESHGUI_SmoothingDlg::isValid()
851 ok = SpinBox_IterationLimit->isValid( msg, true ) && ok;
852 ok = SpinBox_AspectRatio->isValid( msg, true ) && ok;
855 QString str( tr( "SMESH_INCORRECT_INPUT" ) );
856 if ( !msg.isEmpty() )
858 SUIT_MessageBox::critical( this, tr( "SMESH_ERROR" ), str );