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"
36 #include <SMESH_Actor.h>
37 #include <SMESH_TypeFilter.hxx>
38 #include <SMESH_LogicalFilter.hxx>
40 #include <SMDS_Mesh.hxx>
42 // SALOME GUI includes
43 #include <SUIT_ResourceMgr.h>
44 #include <SUIT_OverrideCursor.h>
45 #include <SUIT_Desktop.h>
46 #include <SUIT_Session.h>
47 #include <SUIT_MessageBox.h>
49 #include <LightApp_Application.h>
50 #include <LightApp_SelectionMgr.h>
52 #include <SVTK_ViewModel.h>
53 #include <SVTK_Selector.h>
54 #include <SVTK_ViewWindow.h>
55 #include <SVTK_Selection.h>
56 #include <SALOME_ListIO.hxx>
59 #include <TColStd_MapOfInteger.hxx>
62 #include <QApplication>
66 #include <QPushButton>
67 #include <QRadioButton>
71 #include <QHBoxLayout>
72 #include <QVBoxLayout>
73 #include <QGridLayout>
75 #include <QButtonGroup>
78 #include <SALOMEconfig.h>
79 #include CORBA_SERVER_HEADER(SMESH_Group)
80 #include CORBA_SERVER_HEADER(SMESH_MeshEditor)
85 //=================================================================================
86 // function : SMESHGUI_SmoothingDlg()
87 // purpose : constructor
88 //=================================================================================
89 SMESHGUI_SmoothingDlg::SMESHGUI_SmoothingDlg( SMESHGUI* theModule )
90 : QDialog( SMESH::GetDesktop( theModule ) ),
91 mySMESHGUI( theModule ),
92 mySelectionMgr( SMESH::GetSelectionMgr( theModule ) )
94 QPixmap image0 (SMESH::GetResourceMgr( mySMESHGUI )->loadPixmap("SMESH", tr("ICON_DLG_SMOOTHING")));
95 QPixmap image1 (SMESH::GetResourceMgr( mySMESHGUI )->loadPixmap("SMESH", tr("ICON_SELECT")));
98 setAttribute(Qt::WA_DeleteOnClose, true);
99 setWindowTitle(tr("SMESH_SMOOTHING"));
100 setSizeGripEnabled(true);
102 /***************************************************************/
103 QVBoxLayout* SMESHGUI_SmoothingDlgLayout = new QVBoxLayout(this);
104 SMESHGUI_SmoothingDlgLayout->setSpacing(SPACING);
105 SMESHGUI_SmoothingDlgLayout->setMargin(MARGIN);
107 /***************************************************************/
108 GroupConstructors = new QGroupBox(tr("SMESH_SMOOTHING"), this);
109 QButtonGroup* ButtonGroup = new QButtonGroup(this);
110 QHBoxLayout* GroupConstructorsLayout = new QHBoxLayout(GroupConstructors);
111 GroupConstructorsLayout->setSpacing(SPACING);
112 GroupConstructorsLayout->setMargin(MARGIN);
114 Constructor1 = new QRadioButton(GroupConstructors);
115 Constructor1->setIcon(image0);
116 Constructor1->setChecked(true);
117 GroupConstructorsLayout->addWidget(Constructor1);
118 ButtonGroup->addButton(Constructor1, 0);
120 /***************************************************************/
121 GroupArguments = new QGroupBox(tr("SMESH_ARGUMENTS"), this);
122 QGridLayout* GroupArgumentsLayout = new QGridLayout(GroupArguments);
123 GroupArgumentsLayout->setSpacing(SPACING);
124 GroupArgumentsLayout->setMargin(MARGIN);
126 myIdValidator = new SMESHGUI_IdValidator(this);
128 // Controls for elements selection
129 TextLabelElements = new QLabel(tr("SMESH_ID_ELEMENTS"), GroupArguments);
131 SelectElementsButton = new QPushButton(GroupArguments);
132 SelectElementsButton->setIcon(image1);
134 LineEditElements = new QLineEdit(GroupArguments);
135 LineEditElements->setValidator(myIdValidator);
137 // Control for the whole mesh selection
138 CheckBoxMesh = new QCheckBox(tr("SMESH_SELECT_WHOLE_MESH"), GroupArguments);
140 // Controls for nodes selection
141 TextLabelNodes = new QLabel(tr("FIXED_NODES_IDS"), GroupArguments);
143 SelectNodesButton = new QPushButton(GroupArguments);
144 SelectNodesButton->setIcon(image1);
146 LineEditNodes = new QLineEdit(GroupArguments);
147 LineEditNodes->setValidator(myIdValidator);
149 // Controls for method selection
150 TextLabelMethod = new QLabel(tr("METHOD"), GroupArguments);
152 ComboBoxMethod = new QComboBox(GroupArguments);
154 // Controls for iteration limit defining
155 TextLabelLimit = new QLabel(tr("ITERATION_LIMIT"), GroupArguments);
157 SpinBox_IterationLimit = new QSpinBox(GroupArguments);
159 // Controls for max. aspect ratio defining
160 TextLabelAspectRatio = new QLabel(tr("MAX_ASPECT_RATIO"), GroupArguments);
162 SpinBox_AspectRatio = new SMESHGUI_SpinBox(GroupArguments);
164 // Check box "Is Parametric"
165 CheckBoxParametric = new QCheckBox( tr("IS_PARAMETRIC"), GroupArguments );
167 GroupArgumentsLayout->addWidget(TextLabelElements, 0, 0);
168 GroupArgumentsLayout->addWidget(SelectElementsButton, 0, 1);
169 GroupArgumentsLayout->addWidget(LineEditElements, 0, 2);
170 GroupArgumentsLayout->addWidget(CheckBoxMesh, 1, 0, 1, 3);
171 GroupArgumentsLayout->addWidget(TextLabelNodes, 2, 0);
172 GroupArgumentsLayout->addWidget(SelectNodesButton, 2, 1);
173 GroupArgumentsLayout->addWidget(LineEditNodes, 2, 2);
174 GroupArgumentsLayout->addWidget(TextLabelMethod, 3, 0);
175 GroupArgumentsLayout->addWidget(ComboBoxMethod, 3, 2);
176 GroupArgumentsLayout->addWidget(TextLabelLimit, 4, 0);
177 GroupArgumentsLayout->addWidget(SpinBox_IterationLimit, 4, 2);
178 GroupArgumentsLayout->addWidget(TextLabelAspectRatio, 5, 0);
179 GroupArgumentsLayout->addWidget(SpinBox_AspectRatio, 5, 2);
180 GroupArgumentsLayout->addWidget(CheckBoxParametric, 6, 0, 1, 3);
182 /***************************************************************/
183 GroupButtons = new QGroupBox(this);
184 QHBoxLayout* GroupButtonsLayout = new QHBoxLayout(GroupButtons);
185 GroupButtonsLayout->setSpacing(SPACING);
186 GroupButtonsLayout->setMargin(MARGIN);
188 buttonOk = new QPushButton(tr("SMESH_BUT_APPLY_AND_CLOSE"), GroupButtons);
189 buttonOk->setAutoDefault(true);
190 buttonOk->setDefault(true);
191 buttonApply = new QPushButton(tr("SMESH_BUT_APPLY"), GroupButtons);
192 buttonApply->setAutoDefault(true);
193 buttonCancel = new QPushButton(tr("SMESH_BUT_CLOSE"), GroupButtons);
194 buttonCancel->setAutoDefault(true);
195 buttonHelp = new QPushButton(tr("SMESH_BUT_HELP"), GroupButtons);
196 buttonHelp->setAutoDefault(true);
198 GroupButtonsLayout->addWidget(buttonOk);
199 GroupButtonsLayout->addSpacing(10);
200 GroupButtonsLayout->addWidget(buttonApply);
201 GroupButtonsLayout->addSpacing(10);
202 GroupButtonsLayout->addStretch();
203 GroupButtonsLayout->addWidget(buttonCancel);
204 GroupButtonsLayout->addWidget(buttonHelp);
206 /***************************************************************/
207 SMESHGUI_SmoothingDlgLayout->addWidget(GroupConstructors);
208 SMESHGUI_SmoothingDlgLayout->addWidget(GroupArguments);
209 SMESHGUI_SmoothingDlgLayout->addWidget(GroupButtons);
211 /***************************************************************/
212 /* Initialisations */
213 ComboBoxMethod->addItem(tr("LAPLACIAN"));
214 ComboBoxMethod->addItem(tr("CENTROIDAL"));
216 ComboBoxMethod->setCurrentIndex(0);
218 CheckBoxParametric->setChecked( true );
220 SpinBox_IterationLimit->setRange(1, 999999);
221 SpinBox_IterationLimit->setValue(20);
222 SpinBox_AspectRatio->RangeStepAndValidator(0.0, +999999.999, 0.1, 3);
223 SpinBox_AspectRatio->SetValue(1.1);
225 GroupArguments->show();
227 Constructor1->setChecked(true);
229 mySelector = (SMESH::GetViewWindow( mySMESHGUI ))->GetSelector();
231 mySMESHGUI->SetActiveDialogBox(this);
233 // Costruction of the logical filter for the elements: mesh/sub-mesh/group
234 SMESH_TypeFilter* aMeshOrSubMeshFilter = new SMESH_TypeFilter (MESHorSUBMESH);
235 SMESH_TypeFilter* aSmeshGroupFilter = new SMESH_TypeFilter (GROUP);
237 QList<SUIT_SelectionFilter*> aListOfFilters;
238 if (aMeshOrSubMeshFilter) aListOfFilters.append(aMeshOrSubMeshFilter);
239 if (aSmeshGroupFilter) aListOfFilters.append(aSmeshGroupFilter);
241 myMeshOrSubMeshOrGroupFilter =
242 new SMESH_LogicalFilter (aListOfFilters, SMESH_LogicalFilter::LO_OR);
244 myHelpFileName = "smoothing_page.html";
248 /***************************************************************/
249 // signals and slots connections
250 connect(buttonOk, SIGNAL(clicked()), this, SLOT(ClickOnOk()));
251 connect(buttonCancel, SIGNAL(clicked()), this, SLOT(ClickOnCancel()));
252 connect(buttonApply, SIGNAL(clicked()), this, SLOT(ClickOnApply()));
253 connect(buttonHelp, SIGNAL(clicked()), this, SLOT(ClickOnHelp()));
255 connect(SelectElementsButton, SIGNAL (clicked()), this, SLOT(SetEditCurrentArgument()));
256 connect(SelectNodesButton, SIGNAL (clicked()), this, SLOT(SetEditCurrentArgument()));
257 connect(mySMESHGUI, SIGNAL (SignalDeactivateActiveDialog()), this, SLOT(DeactivateActiveDialog()));
258 connect(mySelectionMgr, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument()));
259 /* to close dialog if study change */
260 connect(mySMESHGUI, SIGNAL (SignalCloseAllDialogs()), this, SLOT(ClickOnCancel()));
261 connect(LineEditElements, SIGNAL(textChanged(const QString&)),
262 SLOT(onTextChange(const QString&)));
263 connect(LineEditNodes, SIGNAL(textChanged(const QString&)),
264 SLOT(onTextChange(const QString&)));
265 connect(CheckBoxMesh, SIGNAL(toggled(bool)),
266 SLOT(onSelectMesh(bool)));
269 //=================================================================================
270 // function : ~SMESHGUI_SmoothingDlg()
271 // purpose : destructor
272 //=================================================================================
273 SMESHGUI_SmoothingDlg::~SMESHGUI_SmoothingDlg()
275 // no need to delete child widgets, Qt does it all for us
278 //=================================================================================
280 // purpose : initialization
281 //=================================================================================
282 void SMESHGUI_SmoothingDlg::Init()
286 // ComboBoxMethod->setCurrentItem(0);
288 // SpinBox_IterationLimit->setValue(20);
289 // SpinBox_AspectRatio->SetValue(1.1);
291 myEditCurrentArgument = LineEditElements;
292 LineEditElements->setFocus();
293 LineEditElements->clear();
294 LineEditNodes->clear();
299 myMesh = SMESH::SMESH_Mesh::_nil();
301 CheckBoxMesh->setChecked(false);
305 //=================================================================================
306 // function : ClickOnApply()
307 // purpose : Called when user presses <Apply> button
308 //=================================================================================
309 void SMESHGUI_SmoothingDlg::ClickOnApply()
311 if (mySMESHGUI->isActiveStudyLocked())
314 if (myNbOkElements && (myNbOkNodes || LineEditNodes->text().trimmed().isEmpty())) {
315 QStringList aListElementsId = myElementsId.split(" ", QString::SkipEmptyParts);
316 QStringList aListNodesId = LineEditNodes->text().split(" ", QString::SkipEmptyParts);
318 SMESH::long_array_var anElementsId = new SMESH::long_array;
319 SMESH::long_array_var aNodesId = new SMESH::long_array;
321 anElementsId->length(aListElementsId.count());
322 for (int i = 0; i < aListElementsId.count(); i++)
323 anElementsId[i] = aListElementsId[i].toInt();
325 if ( myNbOkNodes && aListNodesId.count() > 0 ) {
326 aNodesId->length(aListNodesId.count());
327 for (int i = 0; i < aListNodesId.count(); i++)
328 aNodesId[i] = aListNodesId[i].toInt();
333 long anIterationLimit = (long)SpinBox_IterationLimit->value();
334 double aMaxAspectRatio = SpinBox_AspectRatio->GetValue();
336 SMESH::SMESH_MeshEditor::Smooth_Method aMethod = SMESH::SMESH_MeshEditor::LAPLACIAN_SMOOTH;
337 if (ComboBoxMethod->currentIndex() > 0)
338 aMethod = SMESH::SMESH_MeshEditor::CENTROIDAL_SMOOTH;
340 bool aResult = false;
342 SUIT_OverrideCursor aWaitCursor;
343 SMESH::SMESH_MeshEditor_var aMeshEditor = myMesh->GetMeshEditor();
345 if ( CheckBoxParametric->isChecked() )
346 aResult = aMeshEditor->SmoothParametric(anElementsId.inout(), aNodesId.inout(),
347 anIterationLimit, aMaxAspectRatio, aMethod);
349 aResult = aMeshEditor->Smooth(anElementsId.inout(), aNodesId.inout(),
350 anIterationLimit, aMaxAspectRatio, aMethod);
355 Handle(SALOME_InteractiveObject) anIO = myActor->getIO();
359 mySelectionMgr->setSelectedObjects(aList, false);
366 //=================================================================================
367 // function : ClickOnOk()
368 // purpose : Called when user presses <OK> button
369 //=================================================================================
370 void SMESHGUI_SmoothingDlg::ClickOnOk()
376 //=================================================================================
377 // function : ClickOnCancel()
378 // purpose : Called when dialog box is closed
379 //=================================================================================
380 void SMESHGUI_SmoothingDlg::ClickOnCancel()
382 disconnect(mySelectionMgr, 0, this, 0);
383 mySelectionMgr->clearFilters();
384 //mySelectionMgr->clearSelected();
385 SMESH::SetPickable(); // ???
386 SMESH::SetPointRepresentation(false);
387 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
388 aViewWindow->SetSelectionMode(ActorSelection);
389 mySMESHGUI->ResetState();
393 //=================================================================================
394 // function : ClickOnHelp()
396 //=================================================================================
397 void SMESHGUI_SmoothingDlg::ClickOnHelp()
399 LightApp_Application* app = (LightApp_Application*)(SUIT_Session::session()->activeApplication());
401 app->onHelpContextModule(mySMESHGUI ? app->moduleName(mySMESHGUI->moduleName()) : QString(""), myHelpFileName);
405 platform = "winapplication";
407 platform = "application";
409 SUIT_MessageBox::warning(this, tr("WRN_WARNING"),
410 tr("EXTERNAL_BROWSER_CANNOT_SHOW_PAGE").
411 arg(app->resourceMgr()->stringValue("ExternalBrowser",
413 arg(myHelpFileName));
417 //=======================================================================
418 // function : onTextChange()
420 //=======================================================================
421 void SMESHGUI_SmoothingDlg::onTextChange (const QString& theNewText)
423 QLineEdit* send = (QLineEdit*)sender();
431 if (send == LineEditElements)
433 else if (send == LineEditNodes)
436 buttonOk->setEnabled(false);
437 buttonApply->setEnabled(false);
439 // hilight entered elements/nodes
440 SMDS_Mesh* aMesh = 0;
442 aMesh = myActor->GetObject()->GetMesh();
446 QStringList aListId = theNewText.split(" ", QString::SkipEmptyParts);
448 if (send == LineEditElements) {
449 const Handle(SALOME_InteractiveObject)& anIO = myActor->getIO();
450 TColStd_MapOfInteger newIndices;
451 for (int i = 0; i < aListId.count(); i++) {
452 const SMDS_MeshElement * e = aMesh->FindElement(aListId[ i ].toInt());
454 newIndices.Add(e->GetID());
457 mySelector->AddOrRemoveIndex(anIO, newIndices, false);
458 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
459 aViewWindow->highlight( anIO, true, true );
460 myElementsId = theNewText;
462 } else if (send == LineEditNodes) {
463 TColStd_MapOfInteger newIndices;
465 for (int i = 0; i < aListId.count(); i++) {
466 const SMDS_MeshNode * n = aMesh->FindNode(aListId[ i ].toInt());
468 newIndices.Add(n->GetID());
471 mySelector->AddOrRemoveIndex(myActor->getIO(), newIndices, false);
472 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
473 aViewWindow->highlight( myActor->getIO(), true, true );
477 if (myNbOkElements && (myNbOkNodes || LineEditNodes->text().trimmed().isEmpty())) {
478 buttonOk->setEnabled(true);
479 buttonApply->setEnabled(true);
485 //=================================================================================
486 // function : SelectionIntoArgument()
487 // purpose : Called when selection as changed or other case
488 //=================================================================================
489 void SMESHGUI_SmoothingDlg::SelectionIntoArgument()
494 QString aString = "";
497 if (myEditCurrentArgument == (QWidget*)LineEditElements) {
498 LineEditElements->setText(aString);
500 buttonOk->setEnabled(false);
501 buttonApply->setEnabled(false);
506 if (!GroupButtons->isEnabled()) // inactive
511 mySelectionMgr->selectedObjects(aList,SVTK_Viewer::Type());
512 int nbSel = aList.Extent();
516 Handle(SALOME_InteractiveObject) IO = aList.First();
517 myMesh = SMESH::GetMeshByIO(IO);
518 if (myMesh->_is_nil())
521 myActor = SMESH::FindActorByObject(myMesh);
527 if (myEditCurrentArgument == LineEditElements) {
530 if (CheckBoxMesh->isChecked()) {
531 SMESH::GetNameOfSelectedIObjects(mySelectionMgr, aString);
533 if (!SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(IO)->_is_nil()) { //MESH
535 SMDS_Mesh* aSMDSMesh = myActor->GetObject()->GetMesh();
539 for (int i = aSMDSMesh->MinElementID(); i <= aSMDSMesh->MaxElementID(); i++ ) {
540 const SMDS_MeshElement * e = aSMDSMesh->FindElement(i);
542 myElementsId += QString(" %1").arg(i);
546 } else if (!SMESH::IObjectToInterface<SMESH::SMESH_subMesh>(IO)->_is_nil()) { //SUBMESH
548 SMESH::SMESH_subMesh_var aSubMesh = SMESH::IObjectToInterface<SMESH::SMESH_subMesh>(IO);
550 // get IDs from submesh
551 SMESH::long_array_var anElementsIds = new SMESH::long_array;
552 anElementsIds = aSubMesh->GetElementsId();
553 for (int i = 0; i < anElementsIds->length(); i++) {
554 myElementsId += QString(" %1").arg(anElementsIds[i]);
556 aNbUnits = anElementsIds->length();
559 SMESH::SMESH_GroupBase_var aGroup =
560 SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(IO);
561 if (aGroup->_is_nil())
564 // get IDs from smesh group
565 SMESH::long_array_var anElementsIds = new SMESH::long_array;
566 anElementsIds = aGroup->GetListOfID();
567 for (int i = 0; i < anElementsIds->length(); i++) {
568 myElementsId += QString(" %1").arg(anElementsIds[i]);
570 aNbUnits = anElementsIds->length();
573 aNbUnits = SMESH::GetNameOfSelectedElements(mySelector, IO, aString);
574 myElementsId = aString;
576 } else if (myEditCurrentArgument == LineEditNodes && !myMesh->_is_nil() && myActor) {
578 aNbUnits = SMESH::GetNameOfSelectedNodes(mySelector, IO, aString);
586 myEditCurrentArgument->setText(aString);
587 myEditCurrentArgument->repaint();
588 myEditCurrentArgument->setEnabled(false); // to update lineedit IPAL 19809
589 myEditCurrentArgument->setEnabled(true);
593 if (myEditCurrentArgument == LineEditElements)
594 myNbOkElements = true;
595 else if (myEditCurrentArgument == LineEditNodes)
598 if (myNbOkElements && (myNbOkNodes || LineEditNodes->text().trimmed().isEmpty())) {
599 buttonOk->setEnabled(true);
600 buttonApply->setEnabled(true);
604 //=================================================================================
605 // function : SetEditCurrentArgument()
607 //=================================================================================
608 void SMESHGUI_SmoothingDlg::SetEditCurrentArgument()
610 QPushButton* send = (QPushButton*)sender();
612 switch (myConstructorId) {
613 case 0: /* default constructor */
615 disconnect(mySelectionMgr, 0, this, 0);
616 mySelectionMgr->clearSelected();
617 mySelectionMgr->clearFilters();
619 if (send == SelectElementsButton) {
620 myEditCurrentArgument = LineEditElements;
621 SMESH::SetPointRepresentation(false);
622 if (CheckBoxMesh->isChecked()) {
623 // mySelectionMgr->setSelectionModes(ActorSelection);
624 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
625 aViewWindow->SetSelectionMode(ActorSelection);
626 mySelectionMgr->installFilter(myMeshOrSubMeshOrGroupFilter);
628 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
629 aViewWindow->SetSelectionMode(FaceSelection);
631 } else if (send == SelectNodesButton) {
632 LineEditNodes->clear();
633 myEditCurrentArgument = LineEditNodes;
634 SMESH::SetPointRepresentation(true);
635 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI )) {
636 aViewWindow->SetSelectionMode(NodeSelection);
640 myEditCurrentArgument->setFocus();
641 connect(mySelectionMgr, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument()));
642 SelectionIntoArgument();
648 //=================================================================================
649 // function : DeactivateActiveDialog()
650 // purpose : Deactivates this dialog
651 //=================================================================================
652 void SMESHGUI_SmoothingDlg::DeactivateActiveDialog()
654 if (GroupConstructors->isEnabled()) {
655 GroupConstructors->setEnabled(false);
656 GroupArguments->setEnabled(false);
657 GroupButtons->setEnabled(false);
658 mySMESHGUI->ResetState();
659 mySMESHGUI->SetActiveDialogBox(0);
663 //=================================================================================
664 // function : ActivateThisDialog()
665 // purpose : Activates this dialog
666 //=================================================================================
667 void SMESHGUI_SmoothingDlg::ActivateThisDialog()
669 // Emit a signal to deactivate the active dialog
670 mySMESHGUI->EmitSignalDeactivateDialog();
671 GroupConstructors->setEnabled(true);
672 GroupArguments->setEnabled(true);
673 GroupButtons->setEnabled(true);
675 mySMESHGUI->SetActiveDialogBox(this);
676 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
677 aViewWindow->SetSelectionMode(FaceSelection);
678 SelectionIntoArgument();
681 //=================================================================================
682 // function : enterEvent()
683 // purpose : Mouse enter event
684 //=================================================================================
685 void SMESHGUI_SmoothingDlg::enterEvent (QEvent*)
687 if (!GroupConstructors->isEnabled())
688 ActivateThisDialog();
691 //=================================================================================
692 // function : closeEvent()
694 //=================================================================================
695 void SMESHGUI_SmoothingDlg::closeEvent (QCloseEvent*)
697 /* same than click on cancel button */
701 //=======================================================================
702 // function : hideEvent()
703 // purpose : caused by ESC key
704 //=======================================================================
705 void SMESHGUI_SmoothingDlg::hideEvent (QHideEvent*)
711 //=======================================================================
712 // function : onSelectMesh()
714 //=======================================================================
715 void SMESHGUI_SmoothingDlg::onSelectMesh (bool toSelectMesh)
718 TextLabelElements->setText(tr("SMESH_NAME"));
720 TextLabelElements->setText(tr("SMESH_ID_ELEMENTS"));
722 if (myEditCurrentArgument != LineEditElements) {
723 LineEditElements->clear();
727 mySelectionMgr->clearFilters();
728 SMESH::SetPointRepresentation(false);
731 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
732 aViewWindow->SetSelectionMode(ActorSelection);
733 // mySelectionMgr->setSelectionModes(ActorSelection);
734 mySelectionMgr->installFilter(myMeshOrSubMeshOrGroupFilter);
735 LineEditElements->setReadOnly(true);
736 LineEditElements->setValidator(0);
738 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
739 aViewWindow->SetSelectionMode(FaceSelection);
740 LineEditElements->setReadOnly(false);
741 LineEditElements->setValidator(myIdValidator);
742 onTextChange(LineEditElements->text());
745 SelectionIntoArgument();
748 //=================================================================================
749 // function : keyPressEvent()
751 //=================================================================================
752 void SMESHGUI_SmoothingDlg::keyPressEvent( QKeyEvent* e )
754 QDialog::keyPressEvent( e );
755 if ( e->isAccepted() )
758 if ( e->key() == Qt::Key_F1 ) {