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