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