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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
24 // File : SMESHGUI_SmoothingDlg.cxx
25 // Author : Michael ZORIN
29 #include "SMESHGUI_SmoothingDlg.h"
32 #include "SMESHGUI_Utils.h"
33 #include "SMESHGUI_VTKUtils.h"
34 #include "SMESHGUI_MeshUtils.h"
35 #include "SMESHGUI_SpinBox.h"
36 #include "SMESHGUI_IdValidator.h"
38 #include "SMESH_Actor.h"
39 #include "SMESH_TypeFilter.hxx"
40 #include "SMESH_NumberFilter.hxx"
41 #include "SMESH_LogicalFilter.hxx"
43 #include "SMDS_Mesh.hxx"
45 #include "SUIT_ResourceMgr.h"
46 #include "SUIT_OverrideCursor.h"
47 #include "SUIT_Desktop.h"
48 #include "SUIT_MessageBox.h"
50 #include "SVTK_ViewModel.h"
51 #include "SVTK_Selector.h"
52 #include "SVTK_ViewWindow.h"
53 #include "SVTK_Selection.h"
54 #include "SALOME_ListIO.hxx"
56 #include "utilities.h"
59 #include <TColStd_MapOfInteger.hxx>
60 #include <TColStd_IndexedMapOfInteger.hxx>
63 #include <qapplication.h>
64 #include <qbuttongroup.h>
65 #include <qgroupbox.h>
67 #include <qlineedit.h>
68 #include <qpushbutton.h>
69 #include <qradiobutton.h>
70 #include <qcombobox.h>
71 #include <qcheckbox.h>
74 #include <qvalidator.h>
78 #include "SALOMEconfig.h"
79 #include CORBA_SERVER_HEADER(SMESH_Group)
83 //=================================================================================
84 // function : SMESHGUI_SmoothingDlg()
85 // purpose : constructor
86 //=================================================================================
87 SMESHGUI_SmoothingDlg::SMESHGUI_SmoothingDlg( SMESHGUI* theModule, const char* name,
88 bool modal, WFlags fl)
89 : QDialog( SMESH::GetDesktop( theModule ), name, modal, WStyle_Customize | WStyle_NormalBorder |
90 WStyle_Title | WStyle_SysMenu | Qt::WDestructiveClose),
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 setName("SMESHGUI_SmoothingDlg");
100 setCaption(tr("SMESH_SMOOTHING"));
101 setSizeGripEnabled(TRUE);
102 SMESHGUI_SmoothingDlgLayout = new QGridLayout(this);
103 SMESHGUI_SmoothingDlgLayout->setSpacing(6);
104 SMESHGUI_SmoothingDlgLayout->setMargin(11);
106 /***************************************************************/
107 GroupConstructors = new QButtonGroup(this, "GroupConstructors");
108 GroupConstructors->setTitle(tr("SMESH_SMOOTHING" ));
109 GroupConstructors->setExclusive(TRUE);
110 GroupConstructors->setColumnLayout(0, Qt::Vertical);
111 GroupConstructors->layout()->setSpacing(0);
112 GroupConstructors->layout()->setMargin(0);
113 GroupConstructorsLayout = new QGridLayout(GroupConstructors->layout());
114 GroupConstructorsLayout->setAlignment(Qt::AlignTop);
115 GroupConstructorsLayout->setSpacing(6);
116 GroupConstructorsLayout->setMargin(11);
117 Constructor1 = new QRadioButton(GroupConstructors, "Constructor1");
118 Constructor1->setText(tr("" ));
119 Constructor1->setPixmap(image0);
120 Constructor1->setChecked(TRUE);
121 Constructor1->setSizePolicy(QSizePolicy((QSizePolicy::SizeType)1,
122 (QSizePolicy::SizeType)0,
123 Constructor1->sizePolicy().hasHeightForWidth()));
124 Constructor1->setMinimumSize(QSize(50, 0));
125 GroupConstructorsLayout->addWidget(Constructor1, 0, 0);
126 QSpacerItem* spacer = new QSpacerItem(20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum);
127 GroupConstructorsLayout->addItem(spacer, 0, 1);
128 SMESHGUI_SmoothingDlgLayout->addWidget(GroupConstructors, 0, 0);
130 /***************************************************************/
131 GroupButtons = new QGroupBox(this, "GroupButtons");
132 GroupButtons->setGeometry(QRect(10, 10, 281, 48));
133 GroupButtons->setTitle(tr(""));
134 GroupButtons->setColumnLayout(0, Qt::Vertical);
135 GroupButtons->layout()->setSpacing(0);
136 GroupButtons->layout()->setMargin(0);
137 GroupButtonsLayout = new QGridLayout(GroupButtons->layout());
138 GroupButtonsLayout->setAlignment(Qt::AlignTop);
139 GroupButtonsLayout->setSpacing(6);
140 GroupButtonsLayout->setMargin(11);
141 buttonCancel = new QPushButton(GroupButtons, "buttonCancel");
142 buttonCancel->setText(tr("SMESH_BUT_CLOSE" ));
143 buttonCancel->setAutoDefault(TRUE);
144 GroupButtonsLayout->addWidget(buttonCancel, 0, 3);
145 buttonApply = new QPushButton(GroupButtons, "buttonApply");
146 buttonApply->setText(tr("SMESH_BUT_APPLY" ));
147 buttonApply->setAutoDefault(TRUE);
148 GroupButtonsLayout->addWidget(buttonApply, 0, 1);
149 QSpacerItem* spacer_9 = new QSpacerItem(20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum);
150 GroupButtonsLayout->addItem(spacer_9, 0, 2);
151 buttonOk = new QPushButton(GroupButtons, "buttonOk");
152 buttonOk->setText(tr("SMESH_BUT_OK" ));
153 buttonOk->setAutoDefault(TRUE);
154 buttonOk->setDefault(TRUE);
155 GroupButtonsLayout->addWidget(buttonOk, 0, 0);
156 SMESHGUI_SmoothingDlgLayout->addWidget(GroupButtons, 2, 0);
158 /***************************************************************/
159 GroupArguments = new QGroupBox(this, "GroupArguments");
160 GroupArguments->setTitle(tr("SMESH_ARGUMENTS"));
161 GroupArguments->setColumnLayout(0, Qt::Vertical);
162 GroupArguments->layout()->setSpacing(0);
163 GroupArguments->layout()->setMargin(0);
164 GroupArgumentsLayout = new QGridLayout(GroupArguments->layout());
165 GroupArgumentsLayout->setAlignment(Qt::AlignTop);
166 GroupArgumentsLayout->setSpacing(6);
167 GroupArgumentsLayout->setMargin(11);
169 // Controls for elements selection
170 TextLabelElements = new QLabel(GroupArguments, "TextLabelElements");
171 TextLabelElements->setText(tr("SMESH_ID_ELEMENTS" ));
172 GroupArgumentsLayout->addWidget(TextLabelElements, 0, 0);
174 SelectElementsButton = new QPushButton(GroupArguments, "SelectElementsButton");
175 SelectElementsButton->setText(tr("" ));
176 SelectElementsButton->setPixmap(image1);
177 SelectElementsButton->setToggleButton(FALSE);
178 GroupArgumentsLayout->addWidget(SelectElementsButton, 0, 1);
180 LineEditElements = new QLineEdit(GroupArguments, "LineEditElements");
181 LineEditElements->setValidator(new SMESHGUI_IdValidator(this, "validator"));
182 GroupArgumentsLayout->addWidget(LineEditElements, 0, 2);
184 // Control for the whole mesh selection
185 CheckBoxMesh = new QCheckBox(GroupArguments, "CheckBoxMesh");
186 CheckBoxMesh->setText(tr("SMESH_SELECT_WHOLE_MESH"));
187 GroupArgumentsLayout->addMultiCellWidget(CheckBoxMesh, 1, 1, 0, 2);
189 // Controls for nodes selection
190 TextLabelNodes = new QLabel(GroupArguments, "TextLabelNodes");
191 TextLabelNodes->setText(tr("FIXED_NODES_IDS"));
192 GroupArgumentsLayout->addWidget(TextLabelNodes, 2, 0);
194 SelectNodesButton = new QPushButton(GroupArguments, "SelectNodesButton");
195 SelectNodesButton->setText(tr("" ));
196 SelectNodesButton->setPixmap(image1);
197 SelectNodesButton->setToggleButton(FALSE);
198 GroupArgumentsLayout->addWidget(SelectNodesButton, 2, 1);
200 LineEditNodes = new QLineEdit(GroupArguments, "LineEditNodes");
201 LineEditNodes->setValidator(new SMESHGUI_IdValidator(this, "validator"));
202 GroupArgumentsLayout->addWidget(LineEditNodes, 2, 2);
204 // Controls for method selection
205 TextLabelMethod = new QLabel(GroupArguments, "TextLabelMethod");
206 TextLabelMethod->setText(tr("METHOD" ));
207 GroupArgumentsLayout->addMultiCellWidget(TextLabelMethod, 3, 3, 0, 1);
209 ComboBoxMethod = new QComboBox(GroupArguments, "ComboBoxMethod");
210 GroupArgumentsLayout->addWidget(ComboBoxMethod, 3, 2);
212 // Controls for iteration limit defining
213 TextLabelLimit = new QLabel(GroupArguments, "TextLabelLimit");
214 TextLabelLimit->setText(tr("ITERATION_LIMIT" ));
215 GroupArgumentsLayout->addMultiCellWidget(TextLabelLimit, 4, 4, 0, 1);
217 SpinBox_IterationLimit = new QSpinBox(GroupArguments, "SpinBox_IterationLimit");
218 GroupArgumentsLayout->addWidget(SpinBox_IterationLimit, 4, 2);
220 // Controls for max. aspect ratio defining
221 TextLabelAspectRatio = new QLabel(GroupArguments, "TextLabelAspectRatio");
222 TextLabelAspectRatio->setText(tr("MAX_ASPECT_RATIO"));
223 GroupArgumentsLayout->addMultiCellWidget(TextLabelAspectRatio, 5, 5, 0, 1);
225 SpinBox_AspectRatio = new SMESHGUI_SpinBox(GroupArguments, "SpinBox_AspectRatio");
226 GroupArgumentsLayout->addWidget(SpinBox_AspectRatio, 5, 2);
228 // Check box "Is Parametric"
229 CheckBoxParametric = new QCheckBox( GroupArguments, "CheckBoxParametric" );
230 CheckBoxParametric->setText( tr( "IS_PARAMETRIC" ) );
231 GroupArgumentsLayout->addMultiCellWidget( CheckBoxParametric, 6, 6, 0, 2 );
234 SMESHGUI_SmoothingDlgLayout->addWidget(GroupArguments, 1, 0);
236 /* Initialisations */
237 ComboBoxMethod->insertItem(tr("LAPLACIAN"));
238 ComboBoxMethod->insertItem(tr("CENTROIDAL"));
240 ComboBoxMethod->setCurrentItem(0);
242 CheckBoxParametric->setChecked( TRUE );
244 QIntValidator* anIntValidator = new QIntValidator(SpinBox_IterationLimit);
245 SpinBox_IterationLimit->setValidator(anIntValidator);
246 SpinBox_IterationLimit->setRange(1, 999999);
247 SpinBox_IterationLimit->setValue(20);
248 SpinBox_AspectRatio->RangeStepAndValidator(0.0, +999999.999, 0.1, 3);
249 SpinBox_AspectRatio->SetValue(1.1);
251 GroupArguments->show();
253 Constructor1->setChecked(TRUE);
255 mySelector = (SMESH::GetViewWindow( mySMESHGUI ))->GetSelector();
257 mySMESHGUI->SetActiveDialogBox(this);
259 // Costruction of the logical filter for the elements: mesh/sub-mesh/group
260 SMESH_TypeFilter* aMeshOrSubMeshFilter = new SMESH_TypeFilter (MESHorSUBMESH);
261 SMESH_TypeFilter* aSmeshGroupFilter = new SMESH_TypeFilter (GROUP);
263 QPtrList<SUIT_SelectionFilter> aListOfFilters;
264 if (aMeshOrSubMeshFilter) aListOfFilters.append(aMeshOrSubMeshFilter);
265 if (aSmeshGroupFilter) aListOfFilters.append(aSmeshGroupFilter);
267 myMeshOrSubMeshOrGroupFilter =
268 new SMESH_LogicalFilter (aListOfFilters, SMESH_LogicalFilter::LO_OR);
272 /***************************************************************/
273 // signals and slots connections
274 connect(buttonOk, SIGNAL(clicked()), this, SLOT(ClickOnOk()));
275 connect(buttonCancel, SIGNAL(clicked()), this, SLOT(ClickOnCancel()));
276 connect(buttonApply, SIGNAL(clicked()), this, SLOT(ClickOnApply()));
277 connect(GroupConstructors, SIGNAL(clicked(int)), SLOT(ConstructorsClicked(int)));
279 connect(SelectElementsButton, SIGNAL (clicked()), this, SLOT(SetEditCurrentArgument()));
280 connect(SelectNodesButton, SIGNAL (clicked()), this, SLOT(SetEditCurrentArgument()));
281 connect(mySMESHGUI, SIGNAL (SignalDeactivateActiveDialog()), this, SLOT(DeactivateActiveDialog()));
282 connect(mySelectionMgr, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument()));
283 /* to close dialog if study change */
284 connect(mySMESHGUI, SIGNAL (SignalCloseAllDialogs()), this, SLOT(ClickOnCancel()));
285 connect(LineEditElements, SIGNAL(textChanged(const QString&)),
286 SLOT(onTextChange(const QString&)));
287 connect(LineEditNodes, SIGNAL(textChanged(const QString&)),
288 SLOT(onTextChange(const QString&)));
289 connect(CheckBoxMesh, SIGNAL(toggled(bool)),
290 SLOT(onSelectMesh(bool)));
292 /***************************************************************/
294 this->show(); // displays Dialog
297 //=================================================================================
298 // function : ~SMESHGUI_SmoothingDlg()
299 // purpose : destructor
300 //=================================================================================
301 SMESHGUI_SmoothingDlg::~SMESHGUI_SmoothingDlg()
303 // no need to delete child widgets, Qt does it all for us
306 //=================================================================================
308 // purpose : initialization
309 //=================================================================================
310 void SMESHGUI_SmoothingDlg::Init()
314 // ComboBoxMethod->setCurrentItem(0);
316 // SpinBox_IterationLimit->setValue(20);
317 // SpinBox_AspectRatio->SetValue(1.1);
319 myEditCurrentArgument = LineEditElements;
320 LineEditElements->setFocus();
321 LineEditElements->clear();
322 LineEditNodes->clear();
327 myMesh = SMESH::SMESH_Mesh::_nil();
329 CheckBoxMesh->setChecked(false);
333 //=================================================================================
334 // function : ConstructorsClicked()
335 // purpose : Radio button management
336 //=================================================================================
337 void SMESHGUI_SmoothingDlg::ConstructorsClicked (int constructorId)
341 //=================================================================================
342 // function : ClickOnApply()
343 // purpose : Called when user presses <Apply> button
344 //=================================================================================
345 void SMESHGUI_SmoothingDlg::ClickOnApply()
347 if (mySMESHGUI->isActiveStudyLocked())
350 if (myNbOkElements &&
351 (myNbOkNodes || LineEditNodes->text().stripWhiteSpace().isEmpty())) {
352 QStringList aListElementsId = QStringList::split(" ", myElementsId, false);
353 QStringList aListNodesId = QStringList::split(" ", LineEditNodes->text(), false);
355 SMESH::long_array_var anElementsId = new SMESH::long_array;
356 SMESH::long_array_var aNodesId = new SMESH::long_array;
358 anElementsId->length(aListElementsId.count());
359 for (int i = 0; i < aListElementsId.count(); i++)
360 anElementsId[i] = aListElementsId[i].toInt();
363 aNodesId->length(aListNodesId.count());
364 for (int i = 0; i < aListNodesId.count(); i++)
365 aNodesId[i] = aListNodesId[i].toInt();
370 long anIterationLimit = (long)SpinBox_IterationLimit->value();
371 double aMaxAspectRatio = SpinBox_AspectRatio->GetValue();
373 SMESH::SMESH_MeshEditor::Smooth_Method aMethod = SMESH::SMESH_MeshEditor::LAPLACIAN_SMOOTH;
374 if (ComboBoxMethod->currentItem() > 0)
375 aMethod = SMESH::SMESH_MeshEditor::CENTROIDAL_SMOOTH;
377 bool aResult = false;
379 SMESH::SMESH_MeshEditor_var aMeshEditor = myMesh->GetMeshEditor();
380 QApplication::setOverrideCursor(Qt::waitCursor);
381 if ( CheckBoxParametric->isChecked() )
382 aResult = aMeshEditor->SmoothParametric(anElementsId.inout(), aNodesId.inout(),
383 anIterationLimit, aMaxAspectRatio, aMethod);
385 aResult = aMeshEditor->Smooth(anElementsId.inout(), aNodesId.inout(),
386 anIterationLimit, aMaxAspectRatio, aMethod);
387 QApplication::restoreOverrideCursor();
392 Handle(SALOME_InteractiveObject) anIO = myActor->getIO();
396 mySelectionMgr->setSelectedObjects(aList, false);
403 //=================================================================================
404 // function : ClickOnOk()
405 // purpose : Called when user presses <OK> button
406 //=================================================================================
407 void SMESHGUI_SmoothingDlg::ClickOnOk()
413 //=================================================================================
414 // function : ClickOnCancel()
415 // purpose : Called when dialog box is closed
416 //=================================================================================
417 void SMESHGUI_SmoothingDlg::ClickOnCancel()
419 disconnect(mySelectionMgr, 0, this, 0);
420 mySelectionMgr->clearFilters();
421 //mySelectionMgr->clearSelected();
422 SMESH::SetPickable(); // ???
423 SMESH::SetPointRepresentation(false);
424 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
425 aViewWindow->SetSelectionMode(ActorSelection);
426 mySMESHGUI->ResetState();
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 = QStringList::split(" ", theNewText, false);
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().stripWhiteSpace().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()
508 QString aString = "";
511 if (myEditCurrentArgument == (QWidget*)LineEditElements) {
512 LineEditElements->setText(aString);
514 buttonOk->setEnabled(false);
515 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, myActor->getIO(), aString);
587 myElementsId = aString;
589 } else if (myEditCurrentArgument == LineEditNodes && !myMesh->_is_nil() && myActor) {
591 aNbUnits = SMESH::GetNameOfSelectedNodes(mySelector, myActor->getIO(), aString);
599 myEditCurrentArgument->setText(aString);
603 if (myEditCurrentArgument == LineEditElements)
604 myNbOkElements = true;
605 else if (myEditCurrentArgument == LineEditNodes)
608 if (myNbOkElements) {
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 mySelectionMgr->installFilter(myMeshOrSubMeshOrGroupFilter);
636 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
637 aViewWindow->SetSelectionMode(CellSelection);
639 } else if (send == SelectNodesButton) {
640 myEditCurrentArgument = LineEditNodes;
641 SMESH::SetPointRepresentation(true);
642 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
643 aViewWindow->SetSelectionMode(NodeSelection);
646 myEditCurrentArgument->setFocus();
647 connect(mySelectionMgr, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument()));
648 SelectionIntoArgument();
654 //=================================================================================
655 // function : DeactivateActiveDialog()
656 // purpose : Deactivates this dialog
657 //=================================================================================
658 void SMESHGUI_SmoothingDlg::DeactivateActiveDialog()
660 if (GroupConstructors->isEnabled()) {
661 GroupConstructors->setEnabled(false);
662 GroupArguments->setEnabled(false);
663 GroupButtons->setEnabled(false);
664 mySMESHGUI->ResetState();
665 mySMESHGUI->SetActiveDialogBox(0);
669 //=================================================================================
670 // function : ActivateThisDialog()
671 // purpose : Activates this dialog
672 //=================================================================================
673 void SMESHGUI_SmoothingDlg::ActivateThisDialog()
675 // Emit a signal to deactivate the active dialog
676 mySMESHGUI->EmitSignalDeactivateDialog();
677 GroupConstructors->setEnabled(true);
678 GroupArguments->setEnabled(true);
679 GroupButtons->setEnabled(true);
681 mySMESHGUI->SetActiveDialogBox(this);
682 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
683 aViewWindow->SetSelectionMode(CellSelection);
684 SelectionIntoArgument();
687 //=================================================================================
688 // function : enterEvent()
689 // purpose : Mouse enter event
690 //=================================================================================
691 void SMESHGUI_SmoothingDlg::enterEvent (QEvent*)
693 if (!GroupConstructors->isEnabled())
694 ActivateThisDialog();
697 //=================================================================================
698 // function : closeEvent()
700 //=================================================================================
701 void SMESHGUI_SmoothingDlg::closeEvent (QCloseEvent*)
703 /* same than click on cancel button */
704 this->ClickOnCancel();
707 //=======================================================================
708 // function : hideEvent()
709 // purpose : caused by ESC key
710 //=======================================================================
711 void SMESHGUI_SmoothingDlg::hideEvent (QHideEvent*)
717 //=======================================================================
718 // function : onSelectMesh()
720 //=======================================================================
721 void SMESHGUI_SmoothingDlg::onSelectMesh (bool toSelectMesh)
724 TextLabelElements->setText(tr("SMESH_NAME"));
726 TextLabelElements->setText(tr("SMESH_ID_ELEMENTS"));
728 if (myEditCurrentArgument != LineEditElements) {
729 LineEditElements->clear();
733 mySelectionMgr->clearFilters();
734 SMESH::SetPointRepresentation(false);
737 mySelectionMgr->setSelectionModes(ActorSelection);
738 mySelectionMgr->installFilter(myMeshOrSubMeshOrGroupFilter);
739 LineEditElements->setReadOnly(true);
741 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
742 aViewWindow->SetSelectionMode(CellSelection);
743 LineEditElements->setReadOnly(false);
744 onTextChange(LineEditElements->text());
747 SelectionIntoArgument();