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