1 // SMESH SMESHGUI : GUI for SMESH component
3 // Copyright (C) 2003 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 // File : SMESHGUI_SmoothingDlg.cxx
23 // 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 <SalomeApp_IntSpinBox.h>
54 #include <SVTK_ViewModel.h>
55 #include <SVTK_Selector.h>
56 #include <SVTK_ViewWindow.h>
57 #include <SVTK_Selection.h>
58 #include <SALOME_ListIO.hxx>
61 #include <TColStd_MapOfInteger.hxx>
64 #include <QApplication>
68 #include <QPushButton>
69 #include <QRadioButton>
72 #include <QHBoxLayout>
73 #include <QVBoxLayout>
74 #include <QGridLayout>
76 #include <QButtonGroup>
79 #include <SALOMEconfig.h>
80 #include CORBA_SERVER_HEADER(SMESH_Group)
81 #include CORBA_SERVER_HEADER(SMESH_MeshEditor)
86 //=================================================================================
87 // function : SMESHGUI_SmoothingDlg()
88 // purpose : constructor
89 //=================================================================================
90 SMESHGUI_SmoothingDlg::SMESHGUI_SmoothingDlg( SMESHGUI* theModule )
91 : QDialog( SMESH::GetDesktop( theModule ) ),
92 mySMESHGUI( theModule ),
93 mySelectionMgr( SMESH::GetSelectionMgr( theModule ) )
95 QPixmap image0 (SMESH::GetResourceMgr( mySMESHGUI )->loadPixmap("SMESH", tr("ICON_DLG_SMOOTHING")));
96 QPixmap image1 (SMESH::GetResourceMgr( mySMESHGUI )->loadPixmap("SMESH", tr("ICON_SELECT")));
99 setAttribute(Qt::WA_DeleteOnClose, true);
100 setWindowTitle(tr("SMESH_SMOOTHING"));
101 setSizeGripEnabled(true);
103 /***************************************************************/
104 QVBoxLayout* SMESHGUI_SmoothingDlgLayout = new QVBoxLayout(this);
105 SMESHGUI_SmoothingDlgLayout->setSpacing(SPACING);
106 SMESHGUI_SmoothingDlgLayout->setMargin(MARGIN);
108 /***************************************************************/
109 GroupConstructors = new QGroupBox(tr("SMESH_SMOOTHING"), this);
110 QButtonGroup* ButtonGroup = new QButtonGroup(this);
111 QHBoxLayout* GroupConstructorsLayout = new QHBoxLayout(GroupConstructors);
112 GroupConstructorsLayout->setSpacing(SPACING);
113 GroupConstructorsLayout->setMargin(MARGIN);
115 Constructor1 = new QRadioButton(GroupConstructors);
116 Constructor1->setIcon(image0);
117 Constructor1->setChecked(true);
118 GroupConstructorsLayout->addWidget(Constructor1);
119 ButtonGroup->addButton(Constructor1, 0);
121 /***************************************************************/
122 GroupArguments = new QGroupBox(tr("SMESH_ARGUMENTS"), this);
123 QGridLayout* GroupArgumentsLayout = new QGridLayout(GroupArguments);
124 GroupArgumentsLayout->setSpacing(SPACING);
125 GroupArgumentsLayout->setMargin(MARGIN);
127 myIdValidator = new SMESHGUI_IdValidator(this);
129 // Controls for elements selection
130 TextLabelElements = new QLabel(tr("SMESH_ID_ELEMENTS"), GroupArguments);
132 SelectElementsButton = new QPushButton(GroupArguments);
133 SelectElementsButton->setIcon(image1);
135 LineEditElements = new QLineEdit(GroupArguments);
136 LineEditElements->setValidator(myIdValidator);
138 // Control for the whole mesh selection
139 CheckBoxMesh = new QCheckBox(tr("SMESH_SELECT_WHOLE_MESH"), GroupArguments);
141 // Controls for nodes selection
142 TextLabelNodes = new QLabel(tr("FIXED_NODES_IDS"), GroupArguments);
144 SelectNodesButton = new QPushButton(GroupArguments);
145 SelectNodesButton->setIcon(image1);
147 LineEditNodes = new QLineEdit(GroupArguments);
148 LineEditNodes->setValidator(myIdValidator);
150 // Controls for method selection
151 TextLabelMethod = new QLabel(tr("METHOD"), GroupArguments);
153 ComboBoxMethod = new QComboBox(GroupArguments);
155 // Controls for iteration limit defining
156 TextLabelLimit = new QLabel(tr("ITERATION_LIMIT"), GroupArguments);
158 SpinBox_IterationLimit = new SalomeApp_IntSpinBox(GroupArguments);
160 // Controls for max. aspect ratio defining
161 TextLabelAspectRatio = new QLabel(tr("MAX_ASPECT_RATIO"), GroupArguments);
163 SpinBox_AspectRatio = new SMESHGUI_SpinBox(GroupArguments);
165 // Check box "Is Parametric"
166 CheckBoxParametric = new QCheckBox( tr("IS_PARAMETRIC"), GroupArguments );
168 GroupArgumentsLayout->addWidget(TextLabelElements, 0, 0);
169 GroupArgumentsLayout->addWidget(SelectElementsButton, 0, 1);
170 GroupArgumentsLayout->addWidget(LineEditElements, 0, 2);
171 GroupArgumentsLayout->addWidget(CheckBoxMesh, 1, 0, 1, 3);
172 GroupArgumentsLayout->addWidget(TextLabelNodes, 2, 0);
173 GroupArgumentsLayout->addWidget(SelectNodesButton, 2, 1);
174 GroupArgumentsLayout->addWidget(LineEditNodes, 2, 2);
175 GroupArgumentsLayout->addWidget(TextLabelMethod, 3, 0);
176 GroupArgumentsLayout->addWidget(ComboBoxMethod, 3, 2);
177 GroupArgumentsLayout->addWidget(TextLabelLimit, 4, 0);
178 GroupArgumentsLayout->addWidget(SpinBox_IterationLimit, 4, 2);
179 GroupArgumentsLayout->addWidget(TextLabelAspectRatio, 5, 0);
180 GroupArgumentsLayout->addWidget(SpinBox_AspectRatio, 5, 2);
181 GroupArgumentsLayout->addWidget(CheckBoxParametric, 6, 0, 1, 3);
183 /***************************************************************/
184 GroupButtons = new QGroupBox(this);
185 QHBoxLayout* GroupButtonsLayout = new QHBoxLayout(GroupButtons);
186 GroupButtonsLayout->setSpacing(SPACING);
187 GroupButtonsLayout->setMargin(MARGIN);
189 buttonOk = new QPushButton(tr("SMESH_BUT_APPLY_AND_CLOSE"), GroupButtons);
190 buttonOk->setAutoDefault(true);
191 buttonOk->setDefault(true);
192 buttonApply = new QPushButton(tr("SMESH_BUT_APPLY"), GroupButtons);
193 buttonApply->setAutoDefault(true);
194 buttonCancel = new QPushButton(tr("SMESH_BUT_CLOSE"), GroupButtons);
195 buttonCancel->setAutoDefault(true);
196 buttonHelp = new QPushButton(tr("SMESH_BUT_HELP"), GroupButtons);
197 buttonHelp->setAutoDefault(true);
199 GroupButtonsLayout->addWidget(buttonOk);
200 GroupButtonsLayout->addSpacing(10);
201 GroupButtonsLayout->addWidget(buttonApply);
202 GroupButtonsLayout->addSpacing(10);
203 GroupButtonsLayout->addStretch();
204 GroupButtonsLayout->addWidget(buttonCancel);
205 GroupButtonsLayout->addWidget(buttonHelp);
207 /***************************************************************/
208 SMESHGUI_SmoothingDlgLayout->addWidget(GroupConstructors);
209 SMESHGUI_SmoothingDlgLayout->addWidget(GroupArguments);
210 SMESHGUI_SmoothingDlgLayout->addWidget(GroupButtons);
212 /***************************************************************/
213 /* Initialisations */
214 ComboBoxMethod->addItem(tr("LAPLACIAN"));
215 ComboBoxMethod->addItem(tr("CENTROIDAL"));
217 ComboBoxMethod->setCurrentIndex(0);
219 CheckBoxParametric->setChecked( true );
221 SpinBox_IterationLimit->setRange(1, 999999);
222 SpinBox_IterationLimit->setValue(20);
223 SpinBox_AspectRatio->RangeStepAndValidator(0.0, +999999.999, 0.1, 3);
224 SpinBox_AspectRatio->SetValue(1.1);
226 GroupArguments->show();
228 Constructor1->setChecked(true);
230 mySelector = (SMESH::GetViewWindow( mySMESHGUI ))->GetSelector();
232 mySMESHGUI->SetActiveDialogBox(this);
234 // Costruction of the logical filter for the elements: mesh/sub-mesh/group
235 SMESH_TypeFilter* aMeshOrSubMeshFilter = new SMESH_TypeFilter (MESHorSUBMESH);
236 SMESH_TypeFilter* aSmeshGroupFilter = new SMESH_TypeFilter (GROUP);
238 QList<SUIT_SelectionFilter*> aListOfFilters;
239 if (aMeshOrSubMeshFilter) aListOfFilters.append(aMeshOrSubMeshFilter);
240 if (aSmeshGroupFilter) aListOfFilters.append(aSmeshGroupFilter);
242 myMeshOrSubMeshOrGroupFilter =
243 new SMESH_LogicalFilter (aListOfFilters, SMESH_LogicalFilter::LO_OR);
245 myHelpFileName = "smoothing_page.html";
249 /***************************************************************/
250 // signals and slots connections
251 connect(buttonOk, SIGNAL(clicked()), this, SLOT(ClickOnOk()));
252 connect(buttonCancel, SIGNAL(clicked()), this, SLOT(ClickOnCancel()));
253 connect(buttonApply, SIGNAL(clicked()), this, SLOT(ClickOnApply()));
254 connect(buttonHelp, SIGNAL(clicked()), this, SLOT(ClickOnHelp()));
256 connect(SelectElementsButton, SIGNAL (clicked()), this, SLOT(SetEditCurrentArgument()));
257 connect(SelectNodesButton, SIGNAL (clicked()), this, SLOT(SetEditCurrentArgument()));
258 connect(mySMESHGUI, SIGNAL (SignalDeactivateActiveDialog()), this, SLOT(DeactivateActiveDialog()));
259 connect(mySelectionMgr, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument()));
260 /* to close dialog if study change */
261 connect(mySMESHGUI, SIGNAL (SignalCloseAllDialogs()), this, SLOT(ClickOnCancel()));
262 connect(LineEditElements, SIGNAL(textChanged(const QString&)),
263 SLOT(onTextChange(const QString&)));
264 connect(LineEditNodes, SIGNAL(textChanged(const QString&)),
265 SLOT(onTextChange(const QString&)));
266 connect(CheckBoxMesh, SIGNAL(toggled(bool)),
267 SLOT(onSelectMesh(bool)));
270 //=================================================================================
271 // function : ~SMESHGUI_SmoothingDlg()
272 // purpose : destructor
273 //=================================================================================
274 SMESHGUI_SmoothingDlg::~SMESHGUI_SmoothingDlg()
276 // no need to delete child widgets, Qt does it all for us
279 //=================================================================================
281 // purpose : initialization
282 //=================================================================================
283 void SMESHGUI_SmoothingDlg::Init()
287 // ComboBoxMethod->setCurrentItem(0);
289 // SpinBox_IterationLimit->setValue(20);
290 // SpinBox_AspectRatio->SetValue(1.1);
292 myEditCurrentArgument = LineEditElements;
293 LineEditElements->setFocus();
294 LineEditElements->clear();
295 LineEditNodes->clear();
300 myMesh = SMESH::SMESH_Mesh::_nil();
302 CheckBoxMesh->setChecked(false);
306 //=================================================================================
307 // function : ClickOnApply()
308 // purpose : Called when user presses <Apply> button
309 //=================================================================================
310 bool SMESHGUI_SmoothingDlg::ClickOnApply()
312 if (mySMESHGUI->isActiveStudyLocked())
318 if (myNbOkElements && (myNbOkNodes || LineEditNodes->text().trimmed().isEmpty())) {
319 QStringList aListElementsId = myElementsId.split(" ", QString::SkipEmptyParts);
320 QStringList aListNodesId = LineEditNodes->text().split(" ", QString::SkipEmptyParts);
322 SMESH::long_array_var anElementsId = new SMESH::long_array;
323 SMESH::long_array_var aNodesId = new SMESH::long_array;
325 anElementsId->length(aListElementsId.count());
326 for (int i = 0; i < aListElementsId.count(); i++)
327 anElementsId[i] = aListElementsId[i].toInt();
329 if ( myNbOkNodes && aListNodesId.count() > 0 ) {
330 aNodesId->length(aListNodesId.count());
331 for (int i = 0; i < aListNodesId.count(); i++)
332 aNodesId[i] = aListNodesId[i].toInt();
337 long anIterationLimit = (long)SpinBox_IterationLimit->value();
338 double aMaxAspectRatio = SpinBox_AspectRatio->GetValue();
340 QStringList aParameters;
341 aParameters << SpinBox_IterationLimit->text();
342 aParameters << SpinBox_AspectRatio->text();
344 SMESH::SMESH_MeshEditor::Smooth_Method aMethod = SMESH::SMESH_MeshEditor::LAPLACIAN_SMOOTH;
345 if (ComboBoxMethod->currentIndex() > 0)
346 aMethod = SMESH::SMESH_MeshEditor::CENTROIDAL_SMOOTH;
348 bool aResult = false;
350 SUIT_OverrideCursor aWaitCursor;
351 SMESH::SMESH_MeshEditor_var aMeshEditor = myMesh->GetMeshEditor();
353 if ( CheckBoxParametric->isChecked() )
354 aResult = aMeshEditor->SmoothParametric(anElementsId.inout(), aNodesId.inout(),
355 anIterationLimit, aMaxAspectRatio, aMethod);
357 aResult = aMeshEditor->Smooth(anElementsId.inout(), aNodesId.inout(),
358 anIterationLimit, aMaxAspectRatio, aMethod);
360 myMesh->SetParameters( SMESHGUI::JoinObjectParameters(aParameters) );
366 Handle(SALOME_InteractiveObject) anIO = myActor->getIO();
370 mySelectionMgr->setSelectedObjects(aList, false);
379 //=================================================================================
380 // function : ClickOnOk()
381 // purpose : Called when user presses <OK> button
382 //=================================================================================
383 void SMESHGUI_SmoothingDlg::ClickOnOk()
389 //=================================================================================
390 // function : ClickOnCancel()
391 // purpose : Called when dialog box is closed
392 //=================================================================================
393 void SMESHGUI_SmoothingDlg::ClickOnCancel()
395 disconnect(mySelectionMgr, 0, this, 0);
396 mySelectionMgr->clearFilters();
397 //mySelectionMgr->clearSelected();
398 SMESH::SetPickable(); // ???
399 SMESH::SetPointRepresentation(false);
400 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
401 aViewWindow->SetSelectionMode(ActorSelection);
402 mySMESHGUI->ResetState();
406 //=================================================================================
407 // function : ClickOnHelp()
409 //=================================================================================
410 void SMESHGUI_SmoothingDlg::ClickOnHelp()
412 LightApp_Application* app = (LightApp_Application*)(SUIT_Session::session()->activeApplication());
414 app->onHelpContextModule(mySMESHGUI ? app->moduleName(mySMESHGUI->moduleName()) : QString(""), myHelpFileName);
418 platform = "winapplication";
420 platform = "application";
422 SUIT_MessageBox::warning(this, tr("WRN_WARNING"),
423 tr("EXTERNAL_BROWSER_CANNOT_SHOW_PAGE").
424 arg(app->resourceMgr()->stringValue("ExternalBrowser",
426 arg(myHelpFileName));
430 //=======================================================================
431 // function : onTextChange()
433 //=======================================================================
434 void SMESHGUI_SmoothingDlg::onTextChange (const QString& theNewText)
436 QLineEdit* send = (QLineEdit*)sender();
444 if (send == LineEditElements)
446 else if (send == LineEditNodes)
449 buttonOk->setEnabled(false);
450 buttonApply->setEnabled(false);
452 // hilight entered elements/nodes
453 SMDS_Mesh* aMesh = 0;
455 aMesh = myActor->GetObject()->GetMesh();
459 QStringList aListId = theNewText.split(" ", QString::SkipEmptyParts);
461 if (send == LineEditElements) {
462 const Handle(SALOME_InteractiveObject)& anIO = myActor->getIO();
463 TColStd_MapOfInteger newIndices;
464 for (int i = 0; i < aListId.count(); i++) {
465 const SMDS_MeshElement * e = aMesh->FindElement(aListId[ i ].toInt());
467 newIndices.Add(e->GetID());
470 mySelector->AddOrRemoveIndex(anIO, newIndices, false);
471 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
472 aViewWindow->highlight( anIO, true, true );
473 myElementsId = theNewText;
475 } else if (send == LineEditNodes) {
476 TColStd_MapOfInteger newIndices;
478 for (int i = 0; i < aListId.count(); i++) {
479 const SMDS_MeshNode * n = aMesh->FindNode(aListId[ i ].toInt());
481 newIndices.Add(n->GetID());
484 mySelector->AddOrRemoveIndex(myActor->getIO(), newIndices, false);
485 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
486 aViewWindow->highlight( myActor->getIO(), true, true );
490 if (myNbOkElements && (myNbOkNodes || LineEditNodes->text().trimmed().isEmpty())) {
491 buttonOk->setEnabled(true);
492 buttonApply->setEnabled(true);
498 //=================================================================================
499 // function : SelectionIntoArgument()
500 // purpose : Called when selection as changed or other case
501 //=================================================================================
502 void SMESHGUI_SmoothingDlg::SelectionIntoArgument()
507 QString aString = "";
510 if (myEditCurrentArgument == (QWidget*)LineEditElements) {
511 LineEditElements->setText(aString);
513 buttonOk->setEnabled(false);
514 buttonApply->setEnabled(false);
519 if (!GroupButtons->isEnabled()) // inactive
524 mySelectionMgr->selectedObjects(aList,SVTK_Viewer::Type());
525 int nbSel = aList.Extent();
529 Handle(SALOME_InteractiveObject) IO = aList.First();
530 myMesh = SMESH::GetMeshByIO(IO);
531 if (myMesh->_is_nil())
534 myActor = SMESH::FindActorByObject(myMesh);
540 if (myEditCurrentArgument == LineEditElements) {
543 if (CheckBoxMesh->isChecked()) {
544 SMESH::GetNameOfSelectedIObjects(mySelectionMgr, aString);
546 if (!SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(IO)->_is_nil()) { //MESH
548 SMDS_Mesh* aSMDSMesh = myActor->GetObject()->GetMesh();
552 for (int i = aSMDSMesh->MinElementID(); i <= aSMDSMesh->MaxElementID(); i++ ) {
553 const SMDS_MeshElement * e = aSMDSMesh->FindElement(i);
555 myElementsId += QString(" %1").arg(i);
559 } else if (!SMESH::IObjectToInterface<SMESH::SMESH_subMesh>(IO)->_is_nil()) { //SUBMESH
561 SMESH::SMESH_subMesh_var aSubMesh = SMESH::IObjectToInterface<SMESH::SMESH_subMesh>(IO);
563 // get IDs from submesh
564 SMESH::long_array_var anElementsIds = new SMESH::long_array;
565 anElementsIds = aSubMesh->GetElementsId();
566 for (int i = 0; i < anElementsIds->length(); i++) {
567 myElementsId += QString(" %1").arg(anElementsIds[i]);
569 aNbUnits = anElementsIds->length();
572 SMESH::SMESH_GroupBase_var aGroup =
573 SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(IO);
574 if (aGroup->_is_nil())
577 // get IDs from smesh group
578 SMESH::long_array_var anElementsIds = new SMESH::long_array;
579 anElementsIds = aGroup->GetListOfID();
580 for (int i = 0; i < anElementsIds->length(); i++) {
581 myElementsId += QString(" %1").arg(anElementsIds[i]);
583 aNbUnits = anElementsIds->length();
586 aNbUnits = SMESH::GetNameOfSelectedElements(mySelector, IO, aString);
587 myElementsId = aString;
589 } else if (myEditCurrentArgument == LineEditNodes && !myMesh->_is_nil() && myActor) {
591 aNbUnits = SMESH::GetNameOfSelectedNodes(mySelector, IO, aString);
599 myEditCurrentArgument->setText(aString);
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"));
732 if (myEditCurrentArgument != LineEditElements) {
733 LineEditElements->clear();
737 mySelectionMgr->clearFilters();
738 SMESH::SetPointRepresentation(false);
741 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
742 aViewWindow->SetSelectionMode(ActorSelection);
743 // mySelectionMgr->setSelectionModes(ActorSelection);
744 mySelectionMgr->installFilter(myMeshOrSubMeshOrGroupFilter);
745 LineEditElements->setReadOnly(true);
746 LineEditElements->setValidator(0);
748 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
749 aViewWindow->SetSelectionMode(FaceSelection);
750 LineEditElements->setReadOnly(false);
751 LineEditElements->setValidator(myIdValidator);
752 onTextChange(LineEditElements->text());
755 SelectionIntoArgument();
758 //=================================================================================
759 // function : keyPressEvent()
761 //=================================================================================
762 void SMESHGUI_SmoothingDlg::keyPressEvent( QKeyEvent* e )
764 QDialog::keyPressEvent( e );
765 if ( e->isAccepted() )
768 if ( e->key() == Qt::Key_F1 ) {
774 //=================================================================================
775 // function : isValid
777 //=================================================================================
778 bool SMESHGUI_SmoothingDlg::isValid()
782 ok = SpinBox_IterationLimit->isValid( msg, true ) && ok;
783 ok = SpinBox_AspectRatio->isValid( msg, true ) && ok;
786 QString str( tr( "SMESH_INCORRECT_INPUT" ) );
787 if ( !msg.isEmpty() )
789 SUIT_MessageBox::critical( this, tr( "SMESH_ERROR" ), str );