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 SMESHGUI_Helper( theModule ),
94 mySMESHGUI( theModule ),
95 mySelectionMgr( SMESH::GetSelectionMgr( theModule ) ),
97 mySelectedObject(SMESH::SMESH_IDSource::_nil())
99 QPixmap image0 (SMESH::GetResourceMgr( mySMESHGUI )->loadPixmap("SMESH", tr("ICON_DLG_SMOOTHING")));
100 QPixmap image1 (SMESH::GetResourceMgr( mySMESHGUI )->loadPixmap("SMESH", tr("ICON_SELECT")));
103 setAttribute(Qt::WA_DeleteOnClose, true);
104 setWindowTitle(tr("SMESH_SMOOTHING"));
105 setSizeGripEnabled(true);
107 /***************************************************************/
108 QVBoxLayout* SMESHGUI_SmoothingDlgLayout = new QVBoxLayout(this);
109 SMESHGUI_SmoothingDlgLayout->setSpacing(SPACING);
110 SMESHGUI_SmoothingDlgLayout->setMargin(MARGIN);
112 /***************************************************************/
113 GroupConstructors = new QGroupBox(tr("SMESH_SMOOTHING"), this);
114 QButtonGroup* ButtonGroup = new QButtonGroup(this);
115 QHBoxLayout* GroupConstructorsLayout = new QHBoxLayout(GroupConstructors);
116 GroupConstructorsLayout->setSpacing(SPACING);
117 GroupConstructorsLayout->setMargin(MARGIN);
119 Constructor1 = new QRadioButton(GroupConstructors);
120 Constructor1->setIcon(image0);
121 Constructor1->setChecked(true);
122 GroupConstructorsLayout->addWidget(Constructor1);
123 ButtonGroup->addButton(Constructor1, 0);
125 /***************************************************************/
126 GroupArguments = new QGroupBox(tr("SMESH_ARGUMENTS"), this);
127 QGridLayout* GroupArgumentsLayout = new QGridLayout(GroupArguments);
128 GroupArgumentsLayout->setSpacing(SPACING);
129 GroupArgumentsLayout->setMargin(MARGIN);
131 myIdValidator = new SMESHGUI_IdValidator(this);
133 // Controls for elements selection
134 TextLabelElements = new QLabel(tr("SMESH_ID_ELEMENTS"), GroupArguments);
136 SelectElementsButton = new QPushButton(GroupArguments);
137 SelectElementsButton->setIcon(image1);
139 LineEditElements = new QLineEdit(GroupArguments);
140 LineEditElements->setValidator(myIdValidator);
141 myElemFilterBtn = new QPushButton( tr( "SMESH_BUT_FILTER" ), GroupArguments );
142 connect(myElemFilterBtn, SIGNAL(clicked()), this, SLOT(setElemFilters()));
144 // Control for the whole mesh selection
145 CheckBoxMesh = new QCheckBox(tr("SMESH_SELECT_WHOLE_MESH"), GroupArguments);
147 // Controls for nodes selection
148 TextLabelNodes = new QLabel(tr("FIXED_NODES_IDS"), GroupArguments);
150 SelectNodesButton = new QPushButton(GroupArguments);
151 SelectNodesButton->setIcon(image1);
153 LineEditNodes = new QLineEdit(GroupArguments);
154 LineEditNodes->setValidator(myIdValidator);
155 QPushButton* filterNodeBtn = new QPushButton( tr( "SMESH_BUT_FILTER" ), GroupArguments );
156 connect(filterNodeBtn, SIGNAL(clicked()), this, SLOT(setNodeFilters()));
158 // Controls for method selection
159 TextLabelMethod = new QLabel(tr("METHOD"), GroupArguments);
161 ComboBoxMethod = new QComboBox(GroupArguments);
163 // Controls for iteration limit defining
164 TextLabelLimit = new QLabel(tr("ITERATION_LIMIT"), GroupArguments);
166 SpinBox_IterationLimit = new SalomeApp_IntSpinBox(GroupArguments);
168 // Controls for max. aspect ratio defining
169 TextLabelAspectRatio = new QLabel(tr("MAX_ASPECT_RATIO"), GroupArguments);
171 SpinBox_AspectRatio = new SMESHGUI_SpinBox(GroupArguments);
173 // Check box "Is Parametric"
174 CheckBoxParametric = new QCheckBox( tr("IS_PARAMETRIC"), GroupArguments );
176 GroupArgumentsLayout->addWidget(TextLabelElements, 0, 0);
177 GroupArgumentsLayout->addWidget(SelectElementsButton, 0, 1);
178 GroupArgumentsLayout->addWidget(LineEditElements, 0, 2);
179 GroupArgumentsLayout->addWidget(myElemFilterBtn, 0, 3);
180 GroupArgumentsLayout->addWidget(CheckBoxMesh, 1, 0, 1, 4);
181 GroupArgumentsLayout->addWidget(TextLabelNodes, 2, 0);
182 GroupArgumentsLayout->addWidget(SelectNodesButton, 2, 1);
183 GroupArgumentsLayout->addWidget(LineEditNodes, 2, 2);
184 GroupArgumentsLayout->addWidget(filterNodeBtn, 2, 3);
185 GroupArgumentsLayout->addWidget(TextLabelMethod, 3, 0);
186 GroupArgumentsLayout->addWidget(ComboBoxMethod, 3, 2, 1, 2);
187 GroupArgumentsLayout->addWidget(TextLabelLimit, 4, 0);
188 GroupArgumentsLayout->addWidget(SpinBox_IterationLimit, 4, 2, 1, 2);
189 GroupArgumentsLayout->addWidget(TextLabelAspectRatio, 5, 0);
190 GroupArgumentsLayout->addWidget(SpinBox_AspectRatio, 5, 2, 1, 2);
191 GroupArgumentsLayout->addWidget(CheckBoxParametric, 6, 0, 1, 4);
193 /***************************************************************/
194 GroupButtons = new QGroupBox(this);
195 QHBoxLayout* GroupButtonsLayout = new QHBoxLayout(GroupButtons);
196 GroupButtonsLayout->setSpacing(SPACING);
197 GroupButtonsLayout->setMargin(MARGIN);
199 buttonOk = new QPushButton(tr("SMESH_BUT_APPLY_AND_CLOSE"), GroupButtons);
200 buttonOk->setAutoDefault(true);
201 buttonOk->setDefault(true);
202 buttonApply = new QPushButton(tr("SMESH_BUT_APPLY"), GroupButtons);
203 buttonApply->setAutoDefault(true);
204 buttonCancel = new QPushButton(tr("SMESH_BUT_CLOSE"), GroupButtons);
205 buttonCancel->setAutoDefault(true);
206 buttonHelp = new QPushButton(tr("SMESH_BUT_HELP"), GroupButtons);
207 buttonHelp->setAutoDefault(true);
209 GroupButtonsLayout->addWidget(buttonOk);
210 GroupButtonsLayout->addSpacing(10);
211 GroupButtonsLayout->addWidget(buttonApply);
212 GroupButtonsLayout->addSpacing(10);
213 GroupButtonsLayout->addStretch();
214 GroupButtonsLayout->addWidget(buttonCancel);
215 GroupButtonsLayout->addWidget(buttonHelp);
217 /***************************************************************/
218 SMESHGUI_SmoothingDlgLayout->addWidget(GroupConstructors);
219 SMESHGUI_SmoothingDlgLayout->addWidget(GroupArguments);
220 SMESHGUI_SmoothingDlgLayout->addWidget(GroupButtons);
222 /***************************************************************/
223 /* Initialisations */
224 ComboBoxMethod->addItem(tr("LAPLACIAN"));
225 ComboBoxMethod->addItem(tr("CENTROIDAL"));
227 ComboBoxMethod->setCurrentIndex(0);
229 CheckBoxParametric->setChecked( true );
231 SpinBox_IterationLimit->setRange(1, 999999);
232 SpinBox_IterationLimit->setValue(20);
233 SpinBox_AspectRatio->RangeStepAndValidator(0.0, +999999.999, 0.1, 3);
234 SpinBox_AspectRatio->SetValue(1.1);
236 GroupArguments->show();
238 Constructor1->setChecked(true);
240 mySelector = (SMESH::GetViewWindow( mySMESHGUI ))->GetSelector();
242 mySMESHGUI->SetActiveDialogBox(this);
244 // Costruction of the logical filter for the elements: mesh/sub-mesh/group
245 SMESH_TypeFilter* aMeshOrSubMeshFilter = new SMESH_TypeFilter (MESHorSUBMESH);
246 SMESH_TypeFilter* aSmeshGroupFilter = new SMESH_TypeFilter (GROUP);
248 QList<SUIT_SelectionFilter*> aListOfFilters;
249 if (aMeshOrSubMeshFilter) aListOfFilters.append(aMeshOrSubMeshFilter);
250 if (aSmeshGroupFilter) aListOfFilters.append(aSmeshGroupFilter);
252 myMeshOrSubMeshOrGroupFilter =
253 new SMESH_LogicalFilter (aListOfFilters, SMESH_LogicalFilter::LO_OR);
255 myHelpFileName = "smoothing_page.html";
259 /***************************************************************/
260 // signals and slots connections
261 connect(buttonOk, SIGNAL(clicked()), this, SLOT(ClickOnOk()));
262 connect(buttonCancel, SIGNAL(clicked()), this, SLOT(ClickOnCancel()));
263 connect(buttonApply, SIGNAL(clicked()), this, SLOT(ClickOnApply()));
264 connect(buttonHelp, SIGNAL(clicked()), this, SLOT(ClickOnHelp()));
266 connect(SelectElementsButton, SIGNAL (clicked()), this, SLOT(SetEditCurrentArgument()));
267 connect(SelectNodesButton, SIGNAL (clicked()), this, SLOT(SetEditCurrentArgument()));
268 connect(mySMESHGUI, SIGNAL (SignalDeactivateActiveDialog()), this, SLOT(DeactivateActiveDialog()));
269 connect(mySelectionMgr, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument()));
270 /* to close dialog if study change */
271 connect(mySMESHGUI, SIGNAL (SignalCloseAllDialogs()), this, SLOT(ClickOnCancel()));
272 connect(LineEditElements, SIGNAL(textChanged(const QString&)),
273 SLOT(onTextChange(const QString&)));
274 connect(LineEditNodes, SIGNAL(textChanged(const QString&)),
275 SLOT(onTextChange(const QString&)));
276 connect(CheckBoxMesh, SIGNAL(toggled(bool)),
277 SLOT(onSelectMesh(bool)));
280 //=================================================================================
281 // function : ~SMESHGUI_SmoothingDlg()
282 // purpose : destructor
283 //=================================================================================
284 SMESHGUI_SmoothingDlg::~SMESHGUI_SmoothingDlg()
286 // no need to delete child widgets, Qt does it all for us
287 if ( myFilterDlg != 0 ) {
288 myFilterDlg->setParent( 0 );
293 //=================================================================================
295 // purpose : initialization
296 //=================================================================================
297 void SMESHGUI_SmoothingDlg::Init()
301 // ComboBoxMethod->setCurrentItem(0);
303 // SpinBox_IterationLimit->setValue(20);
304 // SpinBox_AspectRatio->SetValue(1.1);
306 myEditCurrentArgument = LineEditElements;
307 LineEditElements->setFocus();
308 LineEditElements->clear();
309 LineEditNodes->clear();
314 myMesh = SMESH::SMESH_Mesh::_nil();
316 CheckBoxMesh->setChecked(false);
320 //=================================================================================
321 // function : ClickOnApply()
322 // purpose : Called when user presses <Apply> button
323 //=================================================================================
324 bool SMESHGUI_SmoothingDlg::ClickOnApply()
326 if (mySMESHGUI->isActiveStudyLocked())
332 if (myNbOkElements && (myNbOkNodes || LineEditNodes->text().trimmed().isEmpty())) {
333 QStringList aListElementsId = myElementsId.split(" ", QString::SkipEmptyParts);
334 QStringList aListNodesId = LineEditNodes->text().split(" ", QString::SkipEmptyParts);
336 SMESH::long_array_var anElementsId = new SMESH::long_array;
337 SMESH::long_array_var aNodesId = new SMESH::long_array;
339 anElementsId->length(aListElementsId.count());
340 for (int i = 0; i < aListElementsId.count(); i++)
341 anElementsId[i] = aListElementsId[i].toInt();
343 if ( myNbOkNodes && aListNodesId.count() > 0 ) {
344 aNodesId->length(aListNodesId.count());
345 for (int i = 0; i < aListNodesId.count(); i++)
346 aNodesId[i] = aListNodesId[i].toInt();
351 long anIterationLimit = (long)SpinBox_IterationLimit->value();
352 double aMaxAspectRatio = SpinBox_AspectRatio->GetValue();
354 QStringList aParameters;
355 aParameters << SpinBox_IterationLimit->text();
356 aParameters << SpinBox_AspectRatio->text();
358 SMESH::SMESH_MeshEditor::Smooth_Method aMethod = SMESH::SMESH_MeshEditor::LAPLACIAN_SMOOTH;
359 if (ComboBoxMethod->currentIndex() > 0)
360 aMethod = SMESH::SMESH_MeshEditor::CENTROIDAL_SMOOTH;
362 bool aResult = false;
364 SUIT_OverrideCursor aWaitCursor;
365 SMESH::SMESH_MeshEditor_var aMeshEditor = myMesh->GetMeshEditor();
367 if ( CheckBoxParametric->isChecked() ) {
368 if(CheckBoxMesh->isChecked())
369 aResult = aMeshEditor->SmoothParametricObject(mySelectedObject, aNodesId.inout(),
370 anIterationLimit, aMaxAspectRatio, aMethod);
372 aResult = aMeshEditor->SmoothParametric(anElementsId.inout(), aNodesId.inout(),
373 anIterationLimit, aMaxAspectRatio, aMethod);
376 if(CheckBoxMesh->isChecked())
377 aResult = aMeshEditor->SmoothObject(mySelectedObject, aNodesId.inout(),
378 anIterationLimit, aMaxAspectRatio, aMethod);
380 aResult = aMeshEditor->Smooth(anElementsId.inout(), aNodesId.inout(),
381 anIterationLimit, aMaxAspectRatio, aMethod);
384 //asl: myMesh->SetParameters( aParameters.join(":").toLatin1().constData() );
390 Handle(SALOME_InteractiveObject) anIO = myActor->getIO();
394 mySelectionMgr->setSelectedObjects(aList, false);
398 mySelectedObject = SMESH::SMESH_IDSource::_nil();
405 //=================================================================================
406 // function : ClickOnOk()
407 // purpose : Called when user presses <OK> button
408 //=================================================================================
409 void SMESHGUI_SmoothingDlg::ClickOnOk()
415 //=================================================================================
416 // function : ClickOnCancel()
417 // purpose : Called when dialog box is closed
418 //=================================================================================
419 void SMESHGUI_SmoothingDlg::ClickOnCancel()
421 disconnect(mySelectionMgr, 0, this, 0);
422 mySelectionMgr->clearFilters();
423 //mySelectionMgr->clearSelected();
424 if (SMESH::GetCurrentVtkView()) {
425 SMESH::RemoveFilters(); // PAL6938 -- clean all mesh entity filters
426 SMESH::SetPointRepresentation(false);
427 SMESH::SetPickable();
429 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
430 aViewWindow->SetSelectionMode(ActorSelection);
431 mySMESHGUI->ResetState();
435 //=================================================================================
436 // function : ClickOnHelp()
438 //=================================================================================
439 void SMESHGUI_SmoothingDlg::ClickOnHelp()
441 LightApp_Application* app = (LightApp_Application*)(SUIT_Session::session()->activeApplication());
443 app->onHelpContextModule(mySMESHGUI ? app->moduleName(mySMESHGUI->moduleName()) : QString(""), myHelpFileName);
447 platform = "winapplication";
449 platform = "application";
451 SUIT_MessageBox::warning(this, tr("WRN_WARNING"),
452 tr("EXTERNAL_BROWSER_CANNOT_SHOW_PAGE").
453 arg(app->resourceMgr()->stringValue("ExternalBrowser",
455 arg(myHelpFileName));
459 //=======================================================================
460 // function : onTextChange()
462 //=======================================================================
463 void SMESHGUI_SmoothingDlg::onTextChange (const QString& theNewText)
465 QLineEdit* send = (QLineEdit*)sender();
473 if (send == LineEditElements)
475 else if (send == LineEditNodes)
478 buttonOk->setEnabled(false);
479 buttonApply->setEnabled(false);
481 // hilight entered elements/nodes
482 SMDS_Mesh* aMesh = 0;
484 aMesh = myActor->GetObject()->GetMesh();
488 QStringList aListId = theNewText.split(" ", QString::SkipEmptyParts);
490 if (send == LineEditElements) {
491 const Handle(SALOME_InteractiveObject)& anIO = myActor->getIO();
492 TColStd_MapOfInteger newIndices;
493 for (int i = 0; i < aListId.count(); i++) {
494 const SMDS_MeshElement * e = aMesh->FindElement(aListId[ i ].toInt());
496 newIndices.Add(e->GetID());
499 mySelector->AddOrRemoveIndex(anIO, newIndices, false);
500 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
501 aViewWindow->highlight( anIO, true, true );
502 myElementsId = theNewText;
504 } else if (send == LineEditNodes) {
505 TColStd_MapOfInteger newIndices;
507 for (int i = 0; i < aListId.count(); i++) {
508 const SMDS_MeshNode * n = aMesh->FindNode(aListId[ i ].toInt());
510 newIndices.Add(n->GetID());
513 mySelector->AddOrRemoveIndex(myActor->getIO(), newIndices, false);
514 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
515 aViewWindow->highlight( myActor->getIO(), true, true );
519 if (myNbOkElements && (myNbOkNodes || LineEditNodes->text().trimmed().isEmpty())) {
520 buttonOk->setEnabled(true);
521 buttonApply->setEnabled(true);
527 //=================================================================================
528 // function : SelectionIntoArgument()
529 // purpose : Called when selection as changed or other case
530 //=================================================================================
531 void SMESHGUI_SmoothingDlg::SelectionIntoArgument()
536 QString aString = "";
539 if (myEditCurrentArgument == LineEditElements ||
540 myEditCurrentArgument == LineEditNodes) {
541 myEditCurrentArgument->setText(aString);
542 if (myEditCurrentArgument == LineEditElements)
546 buttonOk->setEnabled(false);
547 buttonApply->setEnabled(false);
552 if (!GroupButtons->isEnabled()) // inactive
557 mySelectionMgr->selectedObjects(aList,SVTK_Viewer::Type());
558 int nbSel = aList.Extent();
562 Handle(SALOME_InteractiveObject) IO = aList.First();
563 myMesh = SMESH::GetMeshByIO(IO);
564 if (myMesh->_is_nil())
567 myActor = SMESH::FindActorByObject(myMesh);
573 if (myEditCurrentArgument == LineEditElements) {
576 if (CheckBoxMesh->isChecked()) {
577 SMESH::GetNameOfSelectedIObjects(mySelectionMgr, aString);
579 if (!SMESH::IObjectToInterface<SMESH::SMESH_IDSource>(IO)->_is_nil())
580 mySelectedObject = SMESH::IObjectToInterface<SMESH::SMESH_IDSource>(IO);
584 aNbUnits = SMESH::GetNameOfSelectedElements(mySelector, IO, aString);
585 myElementsId = aString;
589 } else if (myEditCurrentArgument == LineEditNodes && !myMesh->_is_nil() && myActor) {
591 aNbUnits = SMESH::GetNameOfSelectedNodes(mySelector, IO, aString);
596 myEditCurrentArgument->setText(aString);
597 myEditCurrentArgument->repaint();
598 myEditCurrentArgument->setEnabled(false); // to update lineedit IPAL 19809
599 myEditCurrentArgument->setEnabled(true);
603 if (myEditCurrentArgument == LineEditElements)
604 myNbOkElements = true;
605 else if (myEditCurrentArgument == LineEditNodes)
608 if (myNbOkElements && (myNbOkNodes || LineEditNodes->text().trimmed().isEmpty())) {
609 buttonOk->setEnabled(true);
610 buttonApply->setEnabled(true);
614 //=================================================================================
615 // function : SetEditCurrentArgument()
617 //=================================================================================
618 void SMESHGUI_SmoothingDlg::SetEditCurrentArgument()
620 QPushButton* send = (QPushButton*)sender();
622 switch (myConstructorId) {
623 case 0: /* default constructor */
625 disconnect(mySelectionMgr, 0, this, 0);
626 mySelectionMgr->clearSelected();
627 mySelectionMgr->clearFilters();
629 if (send == SelectElementsButton) {
630 myEditCurrentArgument = LineEditElements;
631 SMESH::SetPointRepresentation(false);
632 if (CheckBoxMesh->isChecked()) {
633 // mySelectionMgr->setSelectionModes(ActorSelection);
634 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
635 aViewWindow->SetSelectionMode(ActorSelection);
636 mySelectionMgr->installFilter(myMeshOrSubMeshOrGroupFilter);
638 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
639 aViewWindow->SetSelectionMode(FaceSelection);
641 } else if (send == SelectNodesButton) {
642 LineEditNodes->clear();
643 myEditCurrentArgument = LineEditNodes;
644 SMESH::SetPointRepresentation(true);
645 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI )) {
646 aViewWindow->SetSelectionMode(NodeSelection);
650 myEditCurrentArgument->setFocus();
651 connect(mySelectionMgr, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument()));
652 SelectionIntoArgument();
658 //=================================================================================
659 // function : DeactivateActiveDialog()
660 // purpose : Deactivates this dialog
661 //=================================================================================
662 void SMESHGUI_SmoothingDlg::DeactivateActiveDialog()
664 if (GroupConstructors->isEnabled()) {
665 GroupConstructors->setEnabled(false);
666 GroupArguments->setEnabled(false);
667 GroupButtons->setEnabled(false);
668 mySMESHGUI->ResetState();
669 mySMESHGUI->SetActiveDialogBox(0);
673 //=================================================================================
674 // function : ActivateThisDialog()
675 // purpose : Activates this dialog
676 //=================================================================================
677 void SMESHGUI_SmoothingDlg::ActivateThisDialog()
679 // Emit a signal to deactivate the active dialog
680 mySMESHGUI->EmitSignalDeactivateDialog();
681 GroupConstructors->setEnabled(true);
682 GroupArguments->setEnabled(true);
683 GroupButtons->setEnabled(true);
685 mySMESHGUI->SetActiveDialogBox(this);
686 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
687 aViewWindow->SetSelectionMode(FaceSelection);
688 SelectionIntoArgument();
691 //=================================================================================
692 // function : enterEvent()
693 // purpose : Mouse enter event
694 //=================================================================================
695 void SMESHGUI_SmoothingDlg::enterEvent (QEvent*)
697 if (!GroupConstructors->isEnabled())
698 ActivateThisDialog();
701 //=================================================================================
702 // function : closeEvent()
704 //=================================================================================
705 void SMESHGUI_SmoothingDlg::closeEvent (QCloseEvent*)
707 /* same than click on cancel button */
711 //=======================================================================
712 // function : hideEvent()
713 // purpose : caused by ESC key
714 //=======================================================================
715 void SMESHGUI_SmoothingDlg::hideEvent (QHideEvent*)
721 //=======================================================================
722 // function : onSelectMesh()
724 //=======================================================================
725 void SMESHGUI_SmoothingDlg::onSelectMesh (bool toSelectMesh)
728 TextLabelElements->setText(tr("SMESH_NAME"));
730 TextLabelElements->setText(tr("SMESH_ID_ELEMENTS"));
731 myElemFilterBtn->setEnabled(!toSelectMesh);
733 if (myEditCurrentArgument != LineEditElements &&
734 myEditCurrentArgument != LineEditNodes) {
735 LineEditElements->clear();
736 LineEditNodes->clear();
740 mySelectionMgr->clearFilters();
741 SMESH::SetPointRepresentation(false);
744 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
745 aViewWindow->SetSelectionMode(ActorSelection);
746 // mySelectionMgr->setSelectionModes(ActorSelection);
747 mySelectionMgr->installFilter(myMeshOrSubMeshOrGroupFilter);
748 myEditCurrentArgument->setReadOnly(true);
749 myEditCurrentArgument->setValidator(0);
751 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
752 aViewWindow->SetSelectionMode(myEditCurrentArgument == LineEditElements ? FaceSelection
754 myEditCurrentArgument->setReadOnly(false);
755 LineEditElements->setValidator(myIdValidator);
756 onTextChange(myEditCurrentArgument->text());
759 SelectionIntoArgument();
762 //=================================================================================
763 // function : keyPressEvent()
765 //=================================================================================
766 void SMESHGUI_SmoothingDlg::keyPressEvent( QKeyEvent* e )
768 QDialog::keyPressEvent( e );
769 if ( e->isAccepted() )
772 if ( e->key() == Qt::Key_F1 ) {
778 //=================================================================================
779 // function : setFilters()
780 // purpose : activate filter dialog
781 //=================================================================================
782 void SMESHGUI_SmoothingDlg::setFilters( const bool theIsElem )
784 if(myMesh->_is_nil()) {
785 SUIT_MessageBox::critical(this,
787 tr("NO_MESH_SELECTED"));
793 types.append( SMESH::NODE );
794 types.append( SMESH::ALL );
795 myFilterDlg = new SMESHGUI_FilterDlg( mySMESHGUI, types );
797 myFilterDlg->Init( theIsElem ? SMESH::ALL : SMESH::NODE );
799 myFilterDlg->SetSelection();
800 myFilterDlg->SetMesh( myMesh );
801 myFilterDlg->SetSourceWg( theIsElem ? LineEditElements : LineEditNodes );
806 //=================================================================================
807 // function : setElemFilters()
808 // purpose : SLOT. Called when element "Filter" button pressed.
809 //=================================================================================
810 void SMESHGUI_SmoothingDlg::setElemFilters()
815 //=================================================================================
816 // function : setNodeFilters()
817 // purpose : SLOT. Called when node "Filter" button pressed.
818 //=================================================================================
819 void SMESHGUI_SmoothingDlg::setNodeFilters()
824 //=================================================================================
825 // function : isValid
827 //=================================================================================
828 bool SMESHGUI_SmoothingDlg::isValid()
830 return checkParameters( true, 2, SpinBox_IterationLimit, SpinBox_AspectRatio );