Salome HOME
7fddebc3620f33b193c7b485901abbe17d514cd5
[modules/smesh.git] / src / SMESHGUI / SMESHGUI_RevolutionDlg.cxx
1 // Copyright (C) 2007-2011  CEA/DEN, EDF R&D, OPEN CASCADE
2 //
3 // Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
5 //
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.
10 //
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.
15 //
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
19 //
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21
22 // SMESH SMESHGUI : GUI for SMESH component
23 // File   : SMESHGUI_RevolutionDlg.cxx
24 // Author : Michael ZORIN, Open CASCADE S.A.S.
25 // SMESH includes
26
27 #include "SMESHGUI_RevolutionDlg.h"
28
29 #include "SMESHGUI.h"
30 #include "SMESHGUI_SpinBox.h"
31 #include "SMESHGUI_Utils.h"
32 #include "SMESHGUI_VTKUtils.h"
33 #include "SMESHGUI_MeshUtils.h"
34 #include "SMESHGUI_IdValidator.h"
35 #include "SMESHGUI_MeshEditPreview.h"
36 #include "SMESHGUI_FilterDlg.h"
37
38 #include <SMESH_Actor.h>
39 #include <SMESH_TypeFilter.hxx>
40 #include <SMESH_LogicalFilter.hxx>
41 #include <SMDS_Mesh.hxx>
42
43 // SALOME GUI includes
44 #include <SUIT_ResourceMgr.h>
45 #include <SUIT_Session.h>
46 #include <SUIT_MessageBox.h>
47 #include <SUIT_Desktop.h>
48 #include <SUIT_OverrideCursor.h>
49
50 #include <LightApp_Application.h>
51 #include <LightApp_SelectionMgr.h>
52 #include <SalomeApp_Application.h>
53 #include <SalomeApp_IntSpinBox.h>
54
55 #include <SVTK_ViewWindow.h>
56 #include <SVTK_Selector.h>
57 #include <SALOME_ListIO.hxx>
58 #include <VTKViewer_CellLocationsArray.h>
59
60 // OCCT includes
61 #include <TColStd_MapOfInteger.hxx>
62
63 // Qt includes
64 #include <QApplication>
65 #include <QButtonGroup>
66 #include <QGroupBox>
67 #include <QLabel>
68 #include <QLineEdit>
69 #include <QPushButton>
70 #include <QRadioButton>
71 #include <QCheckBox>
72 #include <QHBoxLayout>
73 #include <QVBoxLayout>
74 #include <QGridLayout>
75 #include <QKeyEvent>
76 #include <QMenu>
77
78 // IDL includes
79 #include <SALOMEconfig.h>
80 #include CORBA_SERVER_HEADER(SMESH_Group)
81 #include CORBA_SERVER_HEADER(SMESH_MeshEditor)
82
83 #define SPACING 6
84 #define MARGIN  11
85
86 //=================================================================================
87 // class    : SMESHGUI_RevolutionDlg()
88 // purpose  :
89 //=================================================================================
90 SMESHGUI_RevolutionDlg::SMESHGUI_RevolutionDlg( SMESHGUI* theModule )
91   : SMESHGUI_PreviewDlg( theModule ),
92     mySelectionMgr( SMESH::GetSelectionMgr( theModule ) ),
93     myVectorDefinition(NONE_SELECT),
94     myFilterDlg( 0 ),
95     mySelectedObject(SMESH::SMESH_IDSource::_nil()),
96     myActor(0)
97 {
98   mySimulation = new SMESHGUI_MeshEditPreview(SMESH::GetViewWindow( mySMESHGUI ));
99
100   SUIT_ResourceMgr* mgr = SMESH::GetResourceMgr( mySMESHGUI );
101   QPixmap image0 ( mgr->loadPixmap("SMESH", tr("ICON_DLG_EDGE")));
102   QPixmap image1 ( mgr->loadPixmap("SMESH", tr("ICON_DLG_TRIANGLE")));
103   QPixmap image2 ( mgr->loadPixmap("SMESH", tr("ICON_SELECT")));
104
105   setModal(false);
106   setAttribute(Qt::WA_DeleteOnClose, true);
107   setWindowTitle(tr("REVOLUTION_AROUND_AXIS"));
108   setSizeGripEnabled(true);
109   
110   QVBoxLayout* SMESHGUI_RevolutionDlgLayout = new QVBoxLayout(this);
111   SMESHGUI_RevolutionDlgLayout->setSpacing(SPACING);
112   SMESHGUI_RevolutionDlgLayout->setMargin(MARGIN);
113
114   /***************************************************************/
115   ConstructorsBox = new QGroupBox(tr("SMESH_REVOLUTION"), this);
116   GroupConstructors = new QButtonGroup(this);
117   QHBoxLayout* ConstructorsBoxLayout = new QHBoxLayout(ConstructorsBox);
118   ConstructorsBoxLayout->setSpacing(SPACING);
119   ConstructorsBoxLayout->setMargin(MARGIN);
120
121   RadioButton1 = new QRadioButton(ConstructorsBox);
122   RadioButton1->setIcon(image0);
123   RadioButton2 = new QRadioButton(ConstructorsBox);
124   RadioButton2->setIcon(image1);
125
126   ConstructorsBoxLayout->addWidget(RadioButton1);
127   ConstructorsBoxLayout->addWidget(RadioButton2);
128   GroupConstructors->addButton(RadioButton1, 0);
129   GroupConstructors->addButton(RadioButton2, 1);
130
131   /***************************************************************/
132   GroupArguments = new QGroupBox(tr("REVOLUTION_1D"), this);
133   QGridLayout* GroupArgumentsLayout = new QGridLayout(GroupArguments);
134   GroupArgumentsLayout->setSpacing(SPACING);
135   GroupArgumentsLayout->setMargin(MARGIN);
136
137   myIdValidator = new SMESHGUI_IdValidator(this);
138
139   // Controls for elements selection
140   TextLabelElements = new QLabel(tr("SMESH_ID_ELEMENTS"), GroupArguments);
141
142   SelectElementsButton = new QPushButton(GroupArguments);
143   SelectElementsButton->setIcon(image2);
144
145   LineEditElements  = new QLineEdit(GroupArguments);
146   LineEditElements->setValidator(myIdValidator);
147   LineEditElements->setMaxLength(-1);
148   myFilterBtn = new QPushButton( tr( "SMESH_BUT_FILTER" ), GroupArguments );
149   connect(myFilterBtn,   SIGNAL(clicked()), this, SLOT(setFilters()));
150
151   // Control for the whole mesh selection
152   CheckBoxMesh = new QCheckBox(tr("SMESH_SELECT_WHOLE_MESH"), GroupArguments);
153
154   // Controls for axis defining
155   GroupAxis = new QGroupBox(tr("SMESH_AXIS"), GroupArguments);
156   QGridLayout* GroupAxisLayout = new QGridLayout(GroupAxis);
157   GroupAxisLayout->setSpacing(SPACING);
158   GroupAxisLayout->setMargin(MARGIN);
159
160   TextLabelPoint = new QLabel(tr("SMESH_POINT"), GroupAxis);
161   SelectPointButton  = new QPushButton(GroupAxis);
162   SelectPointButton->setIcon(image2);
163
164   TextLabelX = new QLabel(tr("SMESH_X"), GroupAxis);
165   SpinBox_X = new SMESHGUI_SpinBox(GroupAxis);
166
167   TextLabelY = new QLabel(tr("SMESH_Y"), GroupAxis);
168   SpinBox_Y = new SMESHGUI_SpinBox(GroupAxis);
169
170   TextLabelZ = new QLabel(tr("SMESH_Z"), GroupAxis);
171   SpinBox_Z = new SMESHGUI_SpinBox(GroupAxis);
172
173   TextLabelVector = new QLabel(tr("SMESH_VECTOR"), GroupAxis);
174   SelectVectorButton = new QPushButton(GroupAxis);
175   SelectVectorButton->setIcon(image2);
176
177   TextLabelDX = new QLabel(tr("SMESH_DX"), GroupAxis);
178   SpinBox_DX = new SMESHGUI_SpinBox(GroupAxis);
179
180   TextLabelDY = new QLabel(tr("SMESH_DY"), GroupAxis);
181   SpinBox_DY = new SMESHGUI_SpinBox(GroupAxis);
182
183   TextLabelDZ = new QLabel(tr("SMESH_DZ"), GroupAxis);
184   SpinBox_DZ = new SMESHGUI_SpinBox(GroupAxis);
185
186   GroupAxisLayout->addWidget(TextLabelPoint,     0, 0);
187   GroupAxisLayout->addWidget(SelectPointButton,  0, 1);
188   GroupAxisLayout->addWidget(TextLabelX,         0, 2);
189   GroupAxisLayout->addWidget(SpinBox_X,          0, 3);
190   GroupAxisLayout->addWidget(TextLabelY,         0, 4);
191   GroupAxisLayout->addWidget(SpinBox_Y,          0, 5);
192   GroupAxisLayout->addWidget(TextLabelZ,         0, 6);
193   GroupAxisLayout->addWidget(SpinBox_Z,          0, 7);
194   GroupAxisLayout->addWidget(TextLabelVector,    1, 0);
195   GroupAxisLayout->addWidget(SelectVectorButton, 1, 1);
196   GroupAxisLayout->addWidget(TextLabelDX,        1, 2);
197   GroupAxisLayout->addWidget(SpinBox_DX,         1, 3);
198   GroupAxisLayout->addWidget(TextLabelDY,        1, 4);
199   GroupAxisLayout->addWidget(SpinBox_DY,         1, 5);
200   GroupAxisLayout->addWidget(TextLabelDZ,        1, 6);
201   GroupAxisLayout->addWidget(SpinBox_DZ,         1, 7);
202
203   // Controls for angle defining & number of steps defining
204   GroupAngleBox = new QGroupBox(tr("SMESH_ANGLE"), GroupArguments);
205   GroupAngle = new QButtonGroup(GroupAngleBox);
206   QGridLayout* GroupAngleLayout = new QGridLayout(GroupAngleBox);
207   GroupAngleLayout->setSpacing(6);
208   GroupAngleLayout->setMargin(11);
209
210   RadioButton3 = new QRadioButton(tr("ANGLE_BY_STEP"), GroupAngleBox);
211   RadioButton4 = new QRadioButton(tr("TOTAL_ANGLE"),   GroupAngleBox);
212   GroupAngle->addButton(RadioButton3, 0);
213   GroupAngle->addButton(RadioButton4, 1);
214
215   TextLabelAngle = new QLabel(tr("SMESH_ANGLE"), GroupAngleBox);
216   SpinBox_Angle = new SMESHGUI_SpinBox(GroupAngleBox);
217
218   TextLabelNbSteps = new QLabel(tr("SMESH_NUMBEROFSTEPS"), GroupAngleBox);
219   SpinBox_NbSteps = new SalomeApp_IntSpinBox(GroupAngleBox);
220
221   GroupAngleLayout->addWidget(RadioButton3,     0, 0);
222   GroupAngleLayout->addWidget(RadioButton4,     0, 1);
223   GroupAngleLayout->addWidget(TextLabelAngle,   1, 0);
224   GroupAngleLayout->addWidget(SpinBox_Angle,    1, 1);
225   GroupAngleLayout->addWidget(TextLabelNbSteps, 2, 0);
226   GroupAngleLayout->addWidget(SpinBox_NbSteps,  2, 1);
227
228   // Controls for tolerance defining
229   TextLabelTolerance = new QLabel(tr("SMESH_TOLERANCE"), GroupArguments);
230   SpinBox_Tolerance = new SMESHGUI_SpinBox(GroupArguments);
231
232   // Control for mesh preview
233   myPreviewCheckBox = new QCheckBox(tr("PREVIEW"), GroupArguments);
234
235   // CheckBox for groups generation
236   MakeGroupsCheck = new QCheckBox(tr("SMESH_MAKE_GROUPS"), GroupArguments);
237   MakeGroupsCheck->setChecked(true);
238
239   GroupArgumentsLayout->addWidget(TextLabelElements,    0, 0);
240   GroupArgumentsLayout->addWidget(SelectElementsButton, 0, 1);
241   GroupArgumentsLayout->addWidget(LineEditElements,     0, 2);
242   GroupArgumentsLayout->addWidget(myFilterBtn,          0, 3);
243   GroupArgumentsLayout->addWidget(CheckBoxMesh,         1, 0, 1, 4);
244   GroupArgumentsLayout->addWidget(GroupAxis,            2, 0, 1, 4);
245   GroupArgumentsLayout->addWidget(GroupAngleBox,        3, 0, 1, 4);
246   GroupArgumentsLayout->addWidget(TextLabelTolerance,   4, 0, 1, 2);
247   GroupArgumentsLayout->addWidget(SpinBox_Tolerance,    4, 2, 1, 2);
248   GroupArgumentsLayout->addWidget(myPreviewCheckBox,    5, 0, 1, 4);
249   GroupArgumentsLayout->addWidget(MakeGroupsCheck,      6, 0, 1, 4);
250
251   /***************************************************************/
252   GroupButtons = new QGroupBox(this);
253   QHBoxLayout* GroupButtonsLayout = new QHBoxLayout(GroupButtons);
254   GroupButtonsLayout->setSpacing(SPACING);
255   GroupButtonsLayout->setMargin(MARGIN);
256   
257   buttonOk = new QPushButton(tr("SMESH_BUT_APPLY_AND_CLOSE"), GroupButtons);
258   buttonOk->setAutoDefault(true);
259   buttonOk->setDefault(true);
260   buttonApply = new QPushButton(tr("SMESH_BUT_APPLY"), GroupButtons);
261   buttonApply->setAutoDefault(true);
262   buttonCancel = new QPushButton(tr("SMESH_BUT_CLOSE"), GroupButtons);
263   buttonCancel->setAutoDefault(true);
264   buttonHelp = new QPushButton(tr("SMESH_BUT_HELP"), GroupButtons);
265   buttonHelp->setAutoDefault(true);
266
267   GroupButtonsLayout->addWidget(buttonOk);
268   GroupButtonsLayout->addSpacing(10);
269   GroupButtonsLayout->addWidget(buttonApply);
270   GroupButtonsLayout->addSpacing(10);
271   GroupButtonsLayout->addStretch();
272   GroupButtonsLayout->addWidget(buttonCancel);
273   GroupButtonsLayout->addWidget(buttonHelp);
274
275   /***************************************************************/
276   SMESHGUI_RevolutionDlgLayout->addWidget(ConstructorsBox);
277   SMESHGUI_RevolutionDlgLayout->addWidget(GroupArguments);
278   SMESHGUI_RevolutionDlgLayout->addWidget(GroupButtons);
279
280   /* Initialisations */
281   SpinBox_X->RangeStepAndValidator(COORD_MIN, COORD_MAX, 10.0, "length_precision");
282   SpinBox_Y->RangeStepAndValidator(COORD_MIN, COORD_MAX, 10.0, "length_precision");
283   SpinBox_Z->RangeStepAndValidator(COORD_MIN, COORD_MAX, 10.0, "length_precision");
284   SpinBox_DX->RangeStepAndValidator(COORD_MIN, COORD_MAX, 10.0, "length_precision");
285   SpinBox_DY->RangeStepAndValidator(COORD_MIN, COORD_MAX, 10.0, "length_precision");
286   SpinBox_DZ->RangeStepAndValidator(COORD_MIN, COORD_MAX, 10.0, "length_precision");
287
288   RadioButton3->setChecked(true);
289
290   SpinBox_Angle->RangeStepAndValidator(COORD_MIN, COORD_MAX, 5.0, "angle_precision");
291
292   SpinBox_NbSteps->setRange(1, 999999);
293
294   SpinBox_Tolerance->RangeStepAndValidator(0.0, COORD_MAX, 0.00001, "len_tol_precision");
295
296   RadioButton1->setChecked(true);
297
298   mySelector = (SMESH::GetViewWindow( mySMESHGUI ))->GetSelector();
299
300   mySMESHGUI->SetActiveDialogBox((QDialog*)this);
301
302   // Costruction of the logical filter
303   SMESH_TypeFilter* aMeshOrSubMeshFilter = new SMESH_TypeFilter (MESHorSUBMESH);
304   SMESH_TypeFilter* aSmeshGroupFilter    = new SMESH_TypeFilter (GROUP);
305
306   QList<SUIT_SelectionFilter*> aListOfFilters;
307   if (aMeshOrSubMeshFilter) aListOfFilters.append(aMeshOrSubMeshFilter);
308   if (aSmeshGroupFilter)    aListOfFilters.append(aSmeshGroupFilter);
309
310   myMeshOrSubMeshOrGroupFilter =
311     new SMESH_LogicalFilter (aListOfFilters, SMESH_LogicalFilter::LO_OR);
312
313   myHelpFileName = "revolution_page.html";
314
315   Init();
316
317   /*Create menu to vector selection*/
318   SelectVectorMenu = new QMenu(this);
319   myMenuActions[SelectVectorMenu->addAction( tr( "MEN_POINT_SELECT" ) )] = POINT_SELECT;
320   myMenuActions[SelectVectorMenu->addAction( tr( "MEN_FACE_SELECT" ) )] = FACE_SELECT;
321   connect( SelectVectorMenu, SIGNAL( triggered( QAction* ) ), SLOT( onSelectVectorMenu( QAction* ) ) );
322
323   /* signals and slots connections */
324   connect(buttonOk,     SIGNAL(clicked()), this, SLOT(ClickOnOk()));
325   connect(buttonCancel, SIGNAL(clicked()), this, SLOT(ClickOnCancel()));
326   connect(buttonApply,  SIGNAL(clicked()), this, SLOT(ClickOnApply()));
327   connect(buttonHelp,   SIGNAL(clicked()), this, SLOT(ClickOnHelp()));
328   connect(GroupConstructors, SIGNAL(buttonClicked(int)), SLOT(ConstructorsClicked(int)));
329
330   connect(SelectElementsButton, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
331   connect(SelectPointButton,    SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
332   connect(SelectVectorButton,   SIGNAL(clicked()), this, SLOT(onSelectVectorButton()));
333
334   connect(SpinBox_X,  SIGNAL(valueChanged(double)), this, SLOT(toDisplaySimulation()));
335   connect(SpinBox_Y,  SIGNAL(valueChanged(double)), this, SLOT(toDisplaySimulation()));
336   connect(SpinBox_Z,  SIGNAL(valueChanged(double)), this, SLOT(toDisplaySimulation()));
337
338   connect(SpinBox_DX, SIGNAL(valueChanged(double)), this, SLOT(onVectorChanged()));
339   connect(SpinBox_DY, SIGNAL(valueChanged(double)), this, SLOT(onVectorChanged()));
340   connect(SpinBox_DZ, SIGNAL(valueChanged(double)), this, SLOT(onVectorChanged()));
341
342   connect(mySMESHGUI,     SIGNAL(SignalDeactivateActiveDialog()), this, SLOT(DeactivateActiveDialog()));
343   connect(mySelectionMgr, SIGNAL(currentSelectionChanged()),      this, SLOT(SelectionIntoArgument()));
344   /* to close dialog if study change */
345   connect(mySMESHGUI,       SIGNAL(SignalCloseAllDialogs()), this, SLOT(ClickOnCancel()));
346   connect(LineEditElements, SIGNAL(textChanged(const QString&)),   SLOT(onTextChange(const QString&)));
347   connect(CheckBoxMesh,     SIGNAL(toggled(bool)),                 SLOT(onSelectMesh(bool)));
348
349   connect(GroupAngle,        SIGNAL(buttonClicked(int)),   this, SLOT(toDisplaySimulation()));
350   connect(SpinBox_Angle,     SIGNAL(valueChanged(double)), this, SLOT(toDisplaySimulation()));
351   connect(SpinBox_NbSteps,   SIGNAL(valueChanged(int)),    this, SLOT(toDisplaySimulation()));
352   connect(SpinBox_Tolerance, SIGNAL(valueChanged(double)), this, SLOT(toDisplaySimulation()));
353
354   //To Connect preview check box
355   connectPreviewControl();
356
357   connect(SpinBox_Angle, SIGNAL(textChanged(const QString&)), this, SLOT(onAngleTextChange(const QString&)));
358
359   ConstructorsClicked(0);
360   SelectionIntoArgument();
361 }
362
363 //=================================================================================
364 // function : ~SMESHGUI_RevolutionDlg()
365 // purpose  : Destroys the object and frees any allocated resources
366 //=================================================================================
367 SMESHGUI_RevolutionDlg::~SMESHGUI_RevolutionDlg()
368 {
369   delete mySimulation;
370   if ( myFilterDlg ) {
371     myFilterDlg->setParent( 0 );
372     delete myFilterDlg;
373     myFilterDlg = 0;
374   }
375 }
376
377 //=================================================================================
378 // function : Init()
379 // purpose  :
380 //=================================================================================
381 void SMESHGUI_RevolutionDlg::Init (bool ResetControls)
382 {
383   myBusy = false;
384
385   myEditCurrentArgument = 0;
386   LineEditElements->clear();
387   myElementsId = "";
388   myNbOkElements = 0;
389   myIDs.clear();
390
391   myActor = 0;
392   myMesh = SMESH::SMESH_Mesh::_nil();
393
394   if (ResetControls) {
395     SpinBox_X->SetValue(0.0);
396     SpinBox_Y->SetValue(0.0);
397     SpinBox_Z->SetValue(0.0);
398     SpinBox_DX->SetValue(0.0);
399     SpinBox_DY->SetValue(0.0);
400     SpinBox_DZ->SetValue(0.0);
401
402     SpinBox_Angle->SetValue(45);
403     SpinBox_NbSteps->setValue(1);
404     SpinBox_Tolerance->SetValue(1e-05);
405
406     CheckBoxMesh->setChecked(false);
407     onSelectMesh(false);
408     myPreviewCheckBox->setChecked(false);
409     onDisplaySimulation(false);
410   }
411 }
412
413 //=================================================================================
414 // function : ConstructorsClicked()
415 // purpose  : Radio button management
416 //=================================================================================
417 void SMESHGUI_RevolutionDlg::ConstructorsClicked (int constructorId)
418 {
419   disconnect(mySelectionMgr, 0, this, 0);
420
421   /*  SALOME_ListIO io;
422   mySelectionMgr->selectedObjects( io );
423   SALOME_ListIO aList;
424   mySelectionMgr->setSelectedObjects( aList );*/
425
426   buttonApply->setEnabled(false);
427   buttonOk->setEnabled(false);
428   mySimulation->SetVisibility(false);
429
430   Selection_Mode aSelMode = ActorSelection;
431
432   switch (constructorId) {
433   case 0:
434     {
435       GroupArguments->setTitle(tr("REVOLUTION_1D"));
436       aSelMode = EdgeSelection;
437       break;
438     }
439   case 1:
440     {
441       GroupArguments->setTitle(tr("REVOLUTION_2D"));
442       aSelMode = FaceSelection;
443       break;
444     }
445   }
446
447   if (myEditCurrentArgument != (QWidget*)LineEditElements) {
448     SMESH::SetPointRepresentation(false);
449   }
450
451   if (!CheckBoxMesh->isChecked())
452     {
453       LineEditElements->clear();
454       myIDs.clear();
455       myNbOkElements = 0;
456       if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
457         aViewWindow->SetSelectionMode(aSelMode);
458     }
459
460   myEditCurrentArgument = (QWidget*)LineEditElements;
461   LineEditElements->setFocus();
462
463   if (CheckBoxMesh->isChecked())
464     onSelectMesh(true);
465
466   connect(mySelectionMgr, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument()));
467   //  mySelectionMgr->setSelectedObjects( io );
468 }
469
470 //=================================================================================
471 // function : ClickOnApply()
472 // purpose  :
473 //=================================================================================
474 bool SMESHGUI_RevolutionDlg::ClickOnApply()
475 {
476   if (mySMESHGUI->isActiveStudyLocked())
477     return false;
478
479   if (!isValid())
480     return false;
481
482   if (myNbOkElements && IsAxisOk()) {
483     QStringList aListElementsId = myElementsId.split(" ", QString::SkipEmptyParts);
484
485     SMESH::long_array_var anElementsId = new SMESH::long_array;
486
487     anElementsId->length(aListElementsId.count());
488     for (int i = 0; i < aListElementsId.count(); i++)
489       anElementsId[i] = aListElementsId[i].toInt();
490
491     SMESH::AxisStruct anAxis;
492
493     anAxis.x =  SpinBox_X->GetValue();
494     anAxis.y =  SpinBox_Y->GetValue();
495     anAxis.z =  SpinBox_Z->GetValue();;
496     anAxis.vx = SpinBox_DX->GetValue();
497     anAxis.vy = SpinBox_DY->GetValue();
498     anAxis.vz = SpinBox_DZ->GetValue();
499
500     double anAngle = (SpinBox_Angle->GetValue())*M_PI/180.;
501     long aNbSteps = (long)SpinBox_NbSteps->value();
502     double aTolerance = SpinBox_Tolerance->GetValue();
503
504     if ( GroupAngle->checkedId() == 1 )
505       anAngle = anAngle/aNbSteps;
506
507     QStringList aParameters;
508     aParameters << SpinBox_X->text();
509     aParameters << SpinBox_Y->text();
510     aParameters << SpinBox_Z->text();
511     aParameters << SpinBox_DX->text();
512     aParameters << SpinBox_DY->text();
513     aParameters << SpinBox_DZ->text();
514     aParameters << SpinBox_Angle->text();
515     aParameters << SpinBox_NbSteps->text();
516     aParameters << SpinBox_Tolerance->text();
517
518     try {
519       SUIT_OverrideCursor aWaitCursor;
520       SMESH::SMESH_MeshEditor_var aMeshEditor = myMesh->GetMeshEditor();
521       
522       myMesh->SetParameters( aParameters.join(":").toLatin1().constData() );
523
524       if ( MakeGroupsCheck->isEnabled() && MakeGroupsCheck->isChecked() ) {
525         if( CheckBoxMesh->isChecked() ) {
526           if( GetConstructorId() == 0 )
527             SMESH::ListOfGroups_var groups = 
528               aMeshEditor->RotationSweepObject1DMakeGroups(mySelectedObject, anAxis,
529                                                            anAngle, aNbSteps, aTolerance);
530           else
531             SMESH::ListOfGroups_var groups = 
532               aMeshEditor->RotationSweepObject2DMakeGroups(mySelectedObject, anAxis,
533                                                            anAngle, aNbSteps, aTolerance);
534         }
535         else
536           SMESH::ListOfGroups_var groups = 
537             aMeshEditor->RotationSweepMakeGroups(anElementsId.inout(), anAxis,
538                                                  anAngle, aNbSteps, aTolerance);
539       }
540       else {
541         if( CheckBoxMesh->isChecked() ) {
542           if( GetConstructorId() == 0 )
543             aMeshEditor->RotationSweepObject1D(mySelectedObject, anAxis, anAngle, aNbSteps, aTolerance);
544           else
545             aMeshEditor->RotationSweepObject2D(mySelectedObject, anAxis, anAngle, aNbSteps, aTolerance);
546         }
547         else
548           aMeshEditor->RotationSweep(anElementsId.inout(), anAxis, anAngle, aNbSteps, aTolerance);
549       }
550
551     } catch (...) {
552     }
553
554     SMESH::UpdateView();
555     SMESH::Update(myIO, SMESH::eDisplay);
556     if ( MakeGroupsCheck->isEnabled() && MakeGroupsCheck->isChecked() )
557       mySMESHGUI->updateObjBrowser(true); // new groups may appear
558     Init(false);
559     ConstructorsClicked(GetConstructorId());
560     mySelectedObject = SMESH::SMESH_IDSource::_nil();
561     SelectionIntoArgument();
562
563     SMESHGUI::Modified();
564   }
565
566   return true;
567 }
568
569 //=================================================================================
570 // function : ClickOnOk()
571 // purpose  :
572 //=================================================================================
573 void SMESHGUI_RevolutionDlg::ClickOnOk()
574 {
575   if( ClickOnApply() )
576     ClickOnCancel();
577 }
578
579 //=================================================================================
580 // function : ClickOnCancel()
581 // purpose  :
582 //=================================================================================
583 void SMESHGUI_RevolutionDlg::ClickOnCancel()
584 {
585   reject();
586 }
587
588 void SMESHGUI_RevolutionDlg::reject()
589 {
590   close();
591 }
592
593 //=================================================================================
594 // function : ClickOnHelp()
595 // purpose  :
596 //=================================================================================
597 void SMESHGUI_RevolutionDlg::ClickOnHelp()
598 {
599   LightApp_Application* app = (LightApp_Application*)(SUIT_Session::session()->activeApplication());
600   if (app) 
601     app->onHelpContextModule(mySMESHGUI ? app->moduleName(mySMESHGUI->moduleName()) : QString(""), myHelpFileName);
602   else {
603     QString platform;
604 #ifdef WIN32
605     platform = "winapplication";
606 #else
607     platform = "application";
608 #endif
609     SUIT_MessageBox::warning(this, tr("WRN_WARNING"),
610                              tr("EXTERNAL_BROWSER_CANNOT_SHOW_PAGE").
611                              arg(app->resourceMgr()->stringValue("ExternalBrowser", 
612                                                                  platform)).
613                              arg(myHelpFileName));
614   }
615 }
616
617 //=======================================================================
618 // function : onAngleTextChange()
619 // purpose  :
620 //=======================================================================
621 void SMESHGUI_RevolutionDlg::onAngleTextChange (const QString& theNewText)
622 {
623   bool isNumber;
624   SpinBox_Angle->text().toDouble( &isNumber );
625   if( !isNumber )
626     RadioButton3->setChecked( true );
627   RadioButton4->setEnabled( isNumber );
628 }
629
630 //=======================================================================
631 // function : onTextChange()
632 // purpose  :
633 //=======================================================================
634 void SMESHGUI_RevolutionDlg::onTextChange (const QString& theNewText)
635 {
636   QLineEdit* send = (QLineEdit*)sender();
637
638   if (myBusy) return;
639   myBusy = true;
640
641   if (send == LineEditElements)
642     myNbOkElements = 0;
643
644   buttonOk->setEnabled(false);
645   buttonApply->setEnabled(false);
646
647   // hilight entered elements
648   SMDS_Mesh* aMesh = 0;
649   if (myActor)
650     aMesh = myActor->GetObject()->GetMesh();
651
652   if (aMesh) {
653     if (send == LineEditElements) {
654       Handle(SALOME_InteractiveObject) anIO = myActor->getIO();
655
656       TColStd_MapOfInteger newIndices;
657
658       QStringList aListId = theNewText.split(" ", QString::SkipEmptyParts);
659       
660       for (int i = 0; i < aListId.count(); i++) {
661         const SMDS_MeshElement * e = aMesh->FindElement(aListId[ i ].toInt());
662         if (e)
663           newIndices.Add(e->GetID());
664         myNbOkElements++;
665       }
666
667       mySelector->AddOrRemoveIndex(myActor->getIO(), newIndices, false);
668       if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
669         aViewWindow->highlight( myActor->getIO(), true, true );
670       
671       myElementsId = theNewText;
672     }
673   }
674
675   if (myNbOkElements && IsAxisOk()) {
676     buttonOk->setEnabled(true);
677     buttonApply->setEnabled(true);
678   }
679   onDisplaySimulation(true);
680
681   myBusy = false;
682 }
683
684 //=================================================================================
685 // function : SelectionIntoArgument()
686 // purpose  : Called when selection as changed or other case
687 //=================================================================================
688 void SMESHGUI_RevolutionDlg::SelectionIntoArgument()
689 {
690   if (myBusy) return;
691
692   // clear
693   QString aString = "";
694
695   myBusy = true;
696   if (myEditCurrentArgument == (QWidget*)LineEditElements) {
697     LineEditElements->setText(aString);
698     myNbOkElements = 0;
699     buttonOk->setEnabled(false);
700     buttonApply->setEnabled(false);
701   }
702   myBusy = false;
703
704   if (!GroupButtons->isEnabled()) // inactive
705     return;
706
707   // get selected mesh
708   const SALOME_ListIO& aList = mySelector->StoredIObjects();
709
710   int nbSel = aList.Extent();
711   if (nbSel != 1) 
712     return;
713
714   Handle(SALOME_InteractiveObject) IO = aList.First();
715   SMESH::SMESH_Mesh_var aMeshVar = SMESH::GetMeshByIO(IO);
716   if (aMeshVar->_is_nil())
717     return;
718
719   SMESH_Actor* anActor = SMESH::FindActorByObject(aMeshVar);
720   if (!anActor)
721     anActor = SMESH::FindActorByEntry(IO->getEntry());
722   if (!anActor && !CheckBoxMesh->isChecked())
723     return;
724
725   int aNbUnits = 0;
726
727   if (myEditCurrentArgument == (QWidget*)LineEditElements) {
728     myElementsId = "";
729     myMesh = aMeshVar;
730     myActor = anActor;
731     myIO = IO;
732
733     // MakeGroups is available if there are groups
734     if ( myMesh->NbGroups() == 0 ) {
735       MakeGroupsCheck->setChecked(false);
736       MakeGroupsCheck->setEnabled(false);
737     } else {
738       MakeGroupsCheck->setEnabled(true);
739     }
740
741     if (CheckBoxMesh->isChecked()) {
742       SMESH::GetNameOfSelectedIObjects(mySelectionMgr, aString);
743
744       if (!SMESH::IObjectToInterface<SMESH::SMESH_IDSource>(IO)->_is_nil())
745         mySelectedObject = SMESH::IObjectToInterface<SMESH::SMESH_IDSource>(IO);
746       else
747         return;
748     } else {
749       aNbUnits = SMESH::GetNameOfSelectedElements(mySelector, IO, aString);
750       myElementsId = aString;
751       if (aNbUnits < 1)
752         return;
753     }
754     myNbOkElements = true;
755   } else {
756
757     SMDS_Mesh* aMesh = anActor->GetObject()->GetMesh();
758     if (!aMesh)
759       return;
760
761     bool isNodeSelected = (myEditCurrentArgument == (QWidget*)SpinBox_X ||
762                            (myEditCurrentArgument == (QWidget*)SpinBox_DX && 
763                             myVectorDefinition==POINT_SELECT));
764
765     bool isFaceSelected = (myEditCurrentArgument == (QWidget*)SpinBox_DX && 
766                            myVectorDefinition==FACE_SELECT);
767
768     if(isNodeSelected) {
769       aNbUnits = SMESH::GetNameOfSelectedNodes(mySelector, IO, aString);
770     }
771     else if(isFaceSelected){
772       aNbUnits = SMESH::GetNameOfSelectedElements(mySelector, IO, aString);
773     }
774     
775     if (aNbUnits != 1)
776       return;
777
778     if(isNodeSelected) {
779       const SMDS_MeshNode * n = aMesh->FindNode(aString.toInt());
780       if (!n)
781         return;
782
783       double x = n->X();
784       double y = n->Y();
785       double z = n->Z();
786
787       if (myEditCurrentArgument == (QWidget*)SpinBox_X) {
788         SpinBox_X->SetValue(x);
789         SpinBox_Y->SetValue(y);
790         SpinBox_Z->SetValue(z);
791       } else if (myEditCurrentArgument == (QWidget*)SpinBox_DX) {
792         SpinBox_DX->SetValue(x - SpinBox_X->GetValue());
793         SpinBox_DY->SetValue(y - SpinBox_Y->GetValue());
794         SpinBox_DZ->SetValue(z - SpinBox_Z->GetValue());
795       }
796     }
797     else if(isFaceSelected){
798       const SMDS_MeshFace* face = dynamic_cast<const SMDS_MeshFace*>(aMesh->FindElement(aString.toInt()));
799       if (!face)
800         return;
801       
802       gp_XYZ aNormale = SMESH::getNormale(face);
803       SpinBox_DX->SetValue(aNormale.X());
804       SpinBox_DY->SetValue(aNormale.Y());
805       SpinBox_DZ->SetValue(aNormale.Z());
806       
807     }
808   }
809
810   myBusy = true;
811   if (myEditCurrentArgument == (QWidget*)LineEditElements)
812     LineEditElements->setText(aString);
813   myBusy = false;
814
815   // OK
816   if (myNbOkElements && IsAxisOk()) {
817     buttonOk->setEnabled(true);
818     buttonApply->setEnabled(true);
819   }
820
821   onDisplaySimulation(true);
822 }
823
824 //=================================================================================
825 // function : SetEditCurrentArgument()
826 // purpose  :
827 //=================================================================================
828 void SMESHGUI_RevolutionDlg::SetEditCurrentArgument()
829 {
830   QPushButton* send = (QPushButton*)sender();
831
832   disconnect(mySelectionMgr, 0, this, 0);
833   mySelectionMgr->clearSelected();
834   mySelectionMgr->clearFilters();
835
836   if (send == SelectElementsButton) {
837     mySimulation->SetVisibility(false);
838     myEditCurrentArgument = (QWidget*)LineEditElements;
839     SMESH::SetPointRepresentation(false);
840     if (CheckBoxMesh->isChecked()) {
841       if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
842         aViewWindow->SetSelectionMode(ActorSelection);
843       mySelectionMgr->installFilter(myMeshOrSubMeshOrGroupFilter);
844     } else {
845       int aConstructorId = GetConstructorId();
846       if (aConstructorId == 0)
847         {
848           if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
849             aViewWindow->SetSelectionMode(EdgeSelection);
850         }
851       else if (aConstructorId == 1)
852         {
853           if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
854             aViewWindow->SetSelectionMode(FaceSelection);
855         }
856     }
857   } else if (send == SelectPointButton) {
858     myEditCurrentArgument = (QWidget*)SpinBox_X;
859     SMESH::SetPointRepresentation(true);
860     if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
861       aViewWindow->SetSelectionMode(NodeSelection);
862   }
863
864   myEditCurrentArgument->setFocus();
865   connect(mySelectionMgr, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument()));
866   SelectionIntoArgument();
867 }
868
869 //=================================================================================
870 // function : DeactivateActiveDialog()
871 // purpose  :
872 //=================================================================================
873 void SMESHGUI_RevolutionDlg::DeactivateActiveDialog()
874 {
875   if (ConstructorsBox->isEnabled()) {
876     ConstructorsBox->setEnabled(false);
877     GroupArguments->setEnabled(false);
878     GroupButtons->setEnabled(false);
879     mySMESHGUI->ResetState();
880     mySMESHGUI->SetActiveDialogBox(0);
881   }
882 }
883
884 //=================================================================================
885 // function : ActivateThisDialog()
886 // purpose  :
887 //=================================================================================
888 void SMESHGUI_RevolutionDlg::ActivateThisDialog()
889 {
890   /* Emit a signal to deactivate the active dialog */
891   mySMESHGUI->EmitSignalDeactivateDialog();
892   ConstructorsBox->setEnabled(true);
893   GroupArguments->setEnabled(true);
894   GroupButtons->setEnabled(true);
895
896   mySMESHGUI->SetActiveDialogBox((QDialog*)this);
897
898   ConstructorsClicked(GetConstructorId());
899   SelectionIntoArgument();
900 }
901
902 //=================================================================================
903 // function : enterEvent()
904 // purpose  :
905 //=================================================================================
906 void SMESHGUI_RevolutionDlg::enterEvent (QEvent*)
907 {
908   if (!ConstructorsBox->isEnabled())
909     ActivateThisDialog();
910 }
911
912 //=================================================================================
913 // function : closeEvent()
914 // purpose  :
915 //=================================================================================
916 void SMESHGUI_RevolutionDlg::closeEvent (QCloseEvent*)
917 {
918   /* same than click on cancel button */
919   disconnect(mySelectionMgr, 0, this, 0);
920   mySelectionMgr->clearFilters();
921   //mySelectionMgr->clearSelected();
922   if (SMESH::GetCurrentVtkView()) {
923     SMESH::RemoveFilters(); // PAL6938 -- clean all mesh entity filters
924     SMESH::SetPointRepresentation(false);
925   }
926   if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
927     aViewWindow->SetSelectionMode(ActorSelection);
928   mySMESHGUI->ResetState();
929 }
930
931 //=======================================================================
932 //function : onSelectMesh
933 //purpose  :
934 //=======================================================================
935 void SMESHGUI_RevolutionDlg::onSelectMesh (bool toSelectMesh)
936 {
937   if (toSelectMesh) {
938     myIDs = LineEditElements->text();
939     TextLabelElements->setText(tr("SMESH_NAME"));
940   }
941   else
942     TextLabelElements->setText(tr("SMESH_ID_ELEMENTS"));
943   myFilterBtn->setEnabled(!toSelectMesh);
944
945   if (myEditCurrentArgument != LineEditElements) {
946     LineEditElements->clear();
947     mySimulation->SetVisibility(false);
948     return;
949   }
950
951   mySelectionMgr->clearFilters();
952   SMESH::SetPointRepresentation(false);
953
954   if (toSelectMesh) {
955     if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
956       aViewWindow->SetSelectionMode(ActorSelection);
957     mySelectionMgr->installFilter(myMeshOrSubMeshOrGroupFilter);
958     LineEditElements->setReadOnly(true);
959     LineEditElements->setValidator(0);
960   } else {
961     int aConstructorId = GetConstructorId();
962     if (aConstructorId == 0)
963       {
964         if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
965           aViewWindow->SetSelectionMode(EdgeSelection);
966       }
967     else if (aConstructorId == 1)
968       {
969         if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
970           aViewWindow->SetSelectionMode(FaceSelection);
971       }
972
973     LineEditElements->setReadOnly(false);
974     LineEditElements->setValidator(myIdValidator);
975     onTextChange(LineEditElements->text());
976     mySimulation->SetVisibility(false);
977   }
978
979   SelectionIntoArgument();
980
981   if (!toSelectMesh)
982     LineEditElements->setText( myIDs );
983 }
984
985 //=================================================================================
986 // function : GetConstructorId()
987 // purpose  :
988 //=================================================================================
989 int SMESHGUI_RevolutionDlg::GetConstructorId()
990 {
991   return GroupConstructors->checkedId();
992 }
993
994 //=================================================================================
995 // function : IsAxisOk()
996 // purpose  :
997 //=================================================================================
998 bool SMESHGUI_RevolutionDlg::IsAxisOk()
999 {
1000   return (SpinBox_DX->GetValue() != 0 ||
1001           SpinBox_DY->GetValue() != 0 ||
1002           SpinBox_DZ->GetValue() != 0);
1003 }
1004
1005 //=================================================================================
1006 // function : onVectorChanged()
1007 // purpose  :
1008 //=================================================================================
1009 void SMESHGUI_RevolutionDlg::onVectorChanged()
1010 {
1011   if (IsAxisOk()) {
1012     buttonOk->setEnabled(true);
1013     buttonApply->setEnabled(true);
1014   } else {
1015     buttonOk->setEnabled(false);
1016     buttonApply->setEnabled(false);
1017   }
1018   onDisplaySimulation(true);
1019 }
1020
1021 //=================================================================================
1022 // function : keyPressEvent()
1023 // purpose  :
1024 //=================================================================================
1025 void SMESHGUI_RevolutionDlg::keyPressEvent( QKeyEvent* e )
1026 {
1027   QDialog::keyPressEvent( e );
1028   if ( e->isAccepted() )
1029     return;
1030
1031   if ( e->key() == Qt::Key_F1 ) {
1032     e->accept();
1033     ClickOnHelp();
1034   }
1035 }
1036
1037 //=================================================================================
1038 // function : onDisplaySimulation()
1039 // purpose  : Show/Hide preview
1040 //=================================================================================
1041 void SMESHGUI_RevolutionDlg::onDisplaySimulation(bool toDisplayPreview)
1042 {
1043   if (myPreviewCheckBox->isChecked() && toDisplayPreview)
1044   {
1045     //display preview
1046     if (myNbOkElements && IsAxisOk())
1047     {
1048       QStringList aListElementsId = myElementsId.split(" ", QString::SkipEmptyParts);
1049       
1050       SMESH::long_array_var anElementsId = new SMESH::long_array;
1051       
1052       anElementsId->length(aListElementsId.count());
1053       for (int i = 0; i < aListElementsId.count(); i++)
1054         anElementsId[i] = aListElementsId[i].toInt();
1055       
1056       SMESH::AxisStruct anAxis;
1057       
1058       anAxis.x =  SpinBox_X->GetValue();
1059       anAxis.y =  SpinBox_Y->GetValue();
1060       anAxis.z =  SpinBox_Z->GetValue();
1061       anAxis.vx = SpinBox_DX->GetValue();
1062       anAxis.vy = SpinBox_DY->GetValue();
1063       anAxis.vz = SpinBox_DZ->GetValue();
1064
1065       double anAngle = (SpinBox_Angle->GetValue())*M_PI/180.;
1066       long aNbSteps = (long)SpinBox_NbSteps->value();
1067       double aTolerance = SpinBox_Tolerance->GetValue();
1068       
1069       if (GroupAngle->checkedId() == 1)
1070         anAngle = anAngle/aNbSteps;
1071       
1072       try {
1073         SUIT_OverrideCursor aWaitCursor;
1074         SMESH::SMESH_MeshEditor_var aMeshEditor = myMesh->GetMeshEditPreviewer();
1075         if( CheckBoxMesh->isChecked() ) {
1076           if( GetConstructorId() == 0 )
1077             aMeshEditor->RotationSweepObject1D(mySelectedObject, anAxis,
1078                                                anAngle, aNbSteps, aTolerance);
1079           else
1080             aMeshEditor->RotationSweepObject2D(mySelectedObject, anAxis,
1081                                                anAngle, aNbSteps, aTolerance);
1082         }
1083         else
1084           aMeshEditor->RotationSweep(anElementsId.inout(), 
1085                                      anAxis, 
1086                                      anAngle, 
1087                                      aNbSteps, 
1088                                      aTolerance);
1089         SMESH::MeshPreviewStruct_var aMeshPreviewStruct = aMeshEditor->GetPreviewData();
1090         mySimulation->SetData(aMeshPreviewStruct._retn());
1091       } catch (...) {}
1092     }
1093     else
1094     {
1095       mySimulation->SetVisibility(false);
1096     }
1097   }
1098   else
1099   {
1100     //erase preview
1101     mySimulation->SetVisibility(false);
1102   }
1103 }
1104
1105 //=================================================================================
1106 // function : onSelectVectorButton()
1107 // purpose  : [slot]
1108 //=================================================================================
1109 void SMESHGUI_RevolutionDlg::onSelectVectorButton(){
1110   if(SelectVectorMenu) {
1111     SelectVectorMenu->exec( QCursor::pos() );
1112   }
1113 }
1114
1115 //=================================================================================
1116 // function : onSelectVectorMenu()
1117 // purpose  : [slot]
1118 //=================================================================================
1119 void SMESHGUI_RevolutionDlg::onSelectVectorMenu( QAction* action){
1120   if(!action)
1121     return;
1122
1123   disconnect(mySelectionMgr, 0, this, 0);
1124
1125   switch(myMenuActions[action]) {
1126   case POINT_SELECT: 
1127     SMESH::SetPointRepresentation(true);
1128     if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
1129       aViewWindow->SetSelectionMode(NodeSelection);
1130     break;
1131     
1132   case FACE_SELECT: 
1133     SMESH::SetPointRepresentation(false);
1134     if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
1135       aViewWindow->SetSelectionMode(FaceSelection);
1136     break;
1137   }
1138
1139   myVectorDefinition = myMenuActions[action];
1140   myEditCurrentArgument = (QWidget*)SpinBox_DX;
1141   myEditCurrentArgument->setFocus();
1142   connect(mySelectionMgr, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument()));
1143   SelectionIntoArgument();
1144 }
1145
1146 //=================================================================================
1147 // function : setFilters()
1148 // purpose  : SLOT. Called when "Filter" button pressed.
1149 //=================================================================================
1150 void SMESHGUI_RevolutionDlg::setFilters()
1151 {
1152   if(myMesh->_is_nil()) {
1153     SUIT_MessageBox::critical(this,
1154                               tr("SMESH_ERROR"),
1155                               tr("NO_MESH_SELECTED"));
1156    return;
1157   }
1158   if ( !myFilterDlg )
1159   {
1160     QList<int> types;  
1161     types.append( SMESH::EDGE );
1162     types.append( SMESH::FACE );
1163     myFilterDlg = new SMESHGUI_FilterDlg( mySMESHGUI, types );
1164   }
1165   myFilterDlg->Init( GetConstructorId() ? SMESH::FACE : SMESH::EDGE );
1166
1167   myFilterDlg->SetSelection();
1168   myFilterDlg->SetMesh( myMesh );
1169   myFilterDlg->SetSourceWg( LineEditElements );
1170
1171   myFilterDlg->show();
1172 }
1173
1174 //=================================================================================
1175 // function : isValid
1176 // purpose  :
1177 //=================================================================================
1178 bool SMESHGUI_RevolutionDlg::isValid()
1179 {
1180   QString msg;
1181   bool ok = true;
1182   ok = SpinBox_X->isValid( msg, true ) && ok;
1183   ok = SpinBox_Y->isValid( msg, true ) && ok;
1184   ok = SpinBox_Z->isValid( msg, true ) && ok;
1185   ok = SpinBox_DX->isValid( msg, true ) && ok;
1186   ok = SpinBox_DY->isValid( msg, true ) && ok;
1187   ok = SpinBox_DZ->isValid( msg, true ) && ok;
1188   ok = SpinBox_Angle->isValid( msg, true ) && ok;
1189   ok = SpinBox_NbSteps->isValid( msg, true ) && ok;
1190   ok = SpinBox_Tolerance->isValid( msg, true ) && ok;
1191
1192   if( !ok ) {
1193     QString str( tr( "SMESH_INCORRECT_INPUT" ) );
1194     if ( !msg.isEmpty() )
1195       str += "\n" + msg;
1196     SUIT_MessageBox::critical( this, tr( "SMESH_ERROR" ), str );
1197     return false;
1198   }
1199   return true;
1200 }