Salome HOME
f85e4eade0ae701c196507e88233cc9a8fb8759f
[modules/smesh.git] / src / SMESHGUI / SMESHGUI_RevolutionDlg.cxx
1 // Copyright (C) 2007-2012  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   : SMESHGUI_PreviewDlg( 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   LineEditElements->setMaxLength(-1);
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   myPreviewCheckBox = 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(myPreviewCheckBox,    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 (SMESH::MESHorSUBMESH);
305   SMESH_TypeFilter* aSmeshGroupFilter    = new SMESH_TypeFilter (SMESH::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
355   //To Connect preview check box
356   connectPreviewControl();
357
358   connect(SpinBox_Angle, SIGNAL(textChanged(const QString&)), this, SLOT(onAngleTextChange(const QString&)));
359
360   ConstructorsClicked(0);
361   SelectionIntoArgument();
362 }
363
364 //=================================================================================
365 // function : ~SMESHGUI_RevolutionDlg()
366 // purpose  : Destroys the object and frees any allocated resources
367 //=================================================================================
368 SMESHGUI_RevolutionDlg::~SMESHGUI_RevolutionDlg()
369 {
370   delete mySimulation;
371   if ( myFilterDlg ) {
372     myFilterDlg->setParent( 0 );
373     delete myFilterDlg;
374     myFilterDlg = 0;
375   }
376 }
377
378 //=================================================================================
379 // function : Init()
380 // purpose  :
381 //=================================================================================
382 void SMESHGUI_RevolutionDlg::Init (bool ResetControls)
383 {
384   myBusy = false;
385
386   myEditCurrentArgument = 0;
387   LineEditElements->clear();
388   myElementsId = "";
389   myNbOkElements = 0;
390   myIDs.clear();
391
392   myActor = 0;
393   myMesh = SMESH::SMESH_Mesh::_nil();
394
395   if (ResetControls) {
396     SpinBox_X->SetValue(0.0);
397     SpinBox_Y->SetValue(0.0);
398     SpinBox_Z->SetValue(0.0);
399     SpinBox_DX->SetValue(0.0);
400     SpinBox_DY->SetValue(0.0);
401     SpinBox_DZ->SetValue(0.0);
402
403     SpinBox_Angle->SetValue(45);
404     SpinBox_NbSteps->setValue(1);
405     SpinBox_Tolerance->SetValue(1e-05);
406
407     CheckBoxMesh->setChecked(false);
408     onSelectMesh(false);
409     myPreviewCheckBox->setChecked(false);
410     onDisplaySimulation(false);
411   }
412 }
413
414 //=================================================================================
415 // function : ConstructorsClicked()
416 // purpose  : Radio button management
417 //=================================================================================
418 void SMESHGUI_RevolutionDlg::ConstructorsClicked (int constructorId)
419 {
420   disconnect(mySelectionMgr, 0, this, 0);
421
422   /*  SALOME_ListIO io;
423   mySelectionMgr->selectedObjects( io );
424   SALOME_ListIO aList;
425   mySelectionMgr->setSelectedObjects( aList );*/
426
427   buttonApply->setEnabled(false);
428   buttonOk->setEnabled(false);
429   mySimulation->SetVisibility(false);
430
431   Selection_Mode aSelMode = ActorSelection;
432
433   switch (constructorId) {
434   case 0:
435     {
436       GroupArguments->setTitle(tr("REVOLUTION_1D"));
437       aSelMode = EdgeSelection;
438       break;
439     }
440   case 1:
441     {
442       GroupArguments->setTitle(tr("REVOLUTION_2D"));
443       aSelMode = FaceSelection;
444       break;
445     }
446   }
447
448   if (myEditCurrentArgument != (QWidget*)LineEditElements) {
449     SMESH::SetPointRepresentation(false);
450   }
451
452   if (!CheckBoxMesh->isChecked())
453     {
454       LineEditElements->clear();
455       myIDs.clear();
456       myNbOkElements = 0;
457       if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
458         aViewWindow->SetSelectionMode(aSelMode);
459     }
460
461   myEditCurrentArgument = (QWidget*)LineEditElements;
462   LineEditElements->setFocus();
463
464   if (CheckBoxMesh->isChecked())
465     onSelectMesh(true);
466
467   connect(mySelectionMgr, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument()));
468   //  mySelectionMgr->setSelectedObjects( io );
469 }
470
471 //=================================================================================
472 // function : ClickOnApply()
473 // purpose  :
474 //=================================================================================
475 bool SMESHGUI_RevolutionDlg::ClickOnApply()
476 {
477   if (mySMESHGUI->isActiveStudyLocked())
478     return false;
479
480   if (!isValid())
481     return false;
482
483   if (myNbOkElements && IsAxisOk()) {
484     QStringList aListElementsId = myElementsId.split(" ", QString::SkipEmptyParts);
485
486     SMESH::long_array_var anElementsId = new SMESH::long_array;
487
488     anElementsId->length(aListElementsId.count());
489     for (int i = 0; i < aListElementsId.count(); i++)
490       anElementsId[i] = aListElementsId[i].toInt();
491
492     SMESH::AxisStruct anAxis;
493
494     anAxis.x =  SpinBox_X->GetValue();
495     anAxis.y =  SpinBox_Y->GetValue();
496     anAxis.z =  SpinBox_Z->GetValue();;
497     anAxis.vx = SpinBox_DX->GetValue();
498     anAxis.vy = SpinBox_DY->GetValue();
499     anAxis.vz = SpinBox_DZ->GetValue();
500
501     double anAngle = (SpinBox_Angle->GetValue())*M_PI/180.;
502     long aNbSteps = (long)SpinBox_NbSteps->value();
503     double aTolerance = SpinBox_Tolerance->GetValue();
504
505     if ( GroupAngle->checkedId() == 1 )
506       anAngle = anAngle/aNbSteps;
507
508     QStringList aParameters;
509     aParameters << SpinBox_X->text();
510     aParameters << SpinBox_Y->text();
511     aParameters << SpinBox_Z->text();
512     aParameters << SpinBox_DX->text();
513     aParameters << SpinBox_DY->text();
514     aParameters << SpinBox_DZ->text();
515     aParameters << SpinBox_Angle->text();
516     aParameters << SpinBox_NbSteps->text();
517     aParameters << SpinBox_Tolerance->text();
518
519     try {
520       SUIT_OverrideCursor aWaitCursor;
521       SMESH::SMESH_MeshEditor_var aMeshEditor = myMesh->GetMeshEditor();
522       
523       myMesh->SetParameters( aParameters.join(":").toLatin1().constData() );
524
525       if ( MakeGroupsCheck->isEnabled() && MakeGroupsCheck->isChecked() ) {
526         if( CheckBoxMesh->isChecked() ) {
527           if( GetConstructorId() == 0 )
528             SMESH::ListOfGroups_var groups = 
529               aMeshEditor->RotationSweepObject1DMakeGroups(mySelectedObject, anAxis,
530                                                            anAngle, aNbSteps, aTolerance);
531           else
532             SMESH::ListOfGroups_var groups = 
533               aMeshEditor->RotationSweepObject2DMakeGroups(mySelectedObject, anAxis,
534                                                            anAngle, aNbSteps, aTolerance);
535         }
536         else
537           SMESH::ListOfGroups_var groups = 
538             aMeshEditor->RotationSweepMakeGroups(anElementsId.inout(), anAxis,
539                                                  anAngle, aNbSteps, aTolerance);
540       }
541       else {
542         if( CheckBoxMesh->isChecked() ) {
543           if( GetConstructorId() == 0 )
544             aMeshEditor->RotationSweepObject1D(mySelectedObject, anAxis, anAngle, aNbSteps, aTolerance);
545           else
546             aMeshEditor->RotationSweepObject2D(mySelectedObject, anAxis, anAngle, aNbSteps, aTolerance);
547         }
548         else
549           aMeshEditor->RotationSweep(anElementsId.inout(), anAxis, anAngle, aNbSteps, aTolerance);
550       }
551
552     } catch (...) {
553     }
554
555     SMESH::UpdateView();
556     SMESH::Update(myIO, SMESH::eDisplay);
557     if ( MakeGroupsCheck->isEnabled() && MakeGroupsCheck->isChecked() )
558       mySMESHGUI->updateObjBrowser(true); // new groups may appear
559     Init(false);
560     ConstructorsClicked(GetConstructorId());
561     mySelectedObject = SMESH::SMESH_IDSource::_nil();
562     SelectionIntoArgument();
563
564     SMESHGUI::Modified();
565   }
566
567   return true;
568 }
569
570 //=================================================================================
571 // function : ClickOnOk()
572 // purpose  :
573 //=================================================================================
574 void SMESHGUI_RevolutionDlg::ClickOnOk()
575 {
576   if( ClickOnApply() )
577     ClickOnCancel();
578 }
579
580 //=================================================================================
581 // function : ClickOnCancel()
582 // purpose  :
583 //=================================================================================
584 void SMESHGUI_RevolutionDlg::ClickOnCancel()
585 {
586   reject();
587 }
588
589 void SMESHGUI_RevolutionDlg::reject()
590 {
591   close();
592 }
593
594 //=================================================================================
595 // function : ClickOnHelp()
596 // purpose  :
597 //=================================================================================
598 void SMESHGUI_RevolutionDlg::ClickOnHelp()
599 {
600   LightApp_Application* app = (LightApp_Application*)(SUIT_Session::session()->activeApplication());
601   if (app) 
602     app->onHelpContextModule(mySMESHGUI ? app->moduleName(mySMESHGUI->moduleName()) : QString(""), myHelpFileName);
603   else {
604     QString platform;
605 #ifdef WIN32
606     platform = "winapplication";
607 #else
608     platform = "application";
609 #endif
610     SUIT_MessageBox::warning(this, tr("WRN_WARNING"),
611                              tr("EXTERNAL_BROWSER_CANNOT_SHOW_PAGE").
612                              arg(app->resourceMgr()->stringValue("ExternalBrowser", 
613                                                                  platform)).
614                              arg(myHelpFileName));
615   }
616 }
617
618 //=======================================================================
619 // function : onAngleTextChange()
620 // purpose  :
621 //=======================================================================
622 void SMESHGUI_RevolutionDlg::onAngleTextChange (const QString& theNewText)
623 {
624   bool isNumber;
625   SpinBox_Angle->text().toDouble( &isNumber );
626   if( !isNumber )
627     RadioButton3->setChecked( true );
628   RadioButton4->setEnabled( isNumber );
629 }
630
631 //=======================================================================
632 // function : onTextChange()
633 // purpose  :
634 //=======================================================================
635 void SMESHGUI_RevolutionDlg::onTextChange (const QString& theNewText)
636 {
637   QLineEdit* send = (QLineEdit*)sender();
638
639   if (myBusy) return;
640   myBusy = true;
641
642   if (send == LineEditElements)
643     myNbOkElements = 0;
644
645   buttonOk->setEnabled(false);
646   buttonApply->setEnabled(false);
647
648   // hilight entered elements
649   SMDS_Mesh* aMesh = 0;
650   if (myActor)
651     aMesh = myActor->GetObject()->GetMesh();
652
653   if (aMesh) {
654     if (send == LineEditElements) {
655       Handle(SALOME_InteractiveObject) anIO = myActor->getIO();
656
657       TColStd_MapOfInteger newIndices;
658
659       QStringList aListId = theNewText.split(" ", QString::SkipEmptyParts);
660       
661       for (int i = 0; i < aListId.count(); i++) {
662         const SMDS_MeshElement * e = aMesh->FindElement(aListId[ i ].toInt());
663         if (e)
664           newIndices.Add(e->GetID());
665         myNbOkElements++;
666       }
667
668       mySelector->AddOrRemoveIndex(myActor->getIO(), newIndices, false);
669       if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
670         aViewWindow->highlight( myActor->getIO(), true, true );
671       
672       myElementsId = theNewText;
673     }
674   }
675
676   if (myNbOkElements && IsAxisOk()) {
677     buttonOk->setEnabled(true);
678     buttonApply->setEnabled(true);
679   }
680   onDisplaySimulation(true);
681
682   myBusy = false;
683 }
684
685 //=================================================================================
686 // function : SelectionIntoArgument()
687 // purpose  : Called when selection as changed or other case
688 //=================================================================================
689 void SMESHGUI_RevolutionDlg::SelectionIntoArgument()
690 {
691   if (myBusy) return;
692
693   // clear
694   QString aString = "";
695
696   myBusy = true;
697   if (myEditCurrentArgument == (QWidget*)LineEditElements) {
698     LineEditElements->setText(aString);
699     myNbOkElements = 0;
700     buttonOk->setEnabled(false);
701     buttonApply->setEnabled(false);
702   }
703   myBusy = false;
704
705   if (!GroupButtons->isEnabled()) // inactive
706     return;
707
708   // get selected mesh
709   const SALOME_ListIO& aList = mySelector->StoredIObjects();
710
711   int nbSel = aList.Extent();
712   if (nbSel != 1) 
713     return;
714
715   Handle(SALOME_InteractiveObject) IO = aList.First();
716   SMESH::SMESH_Mesh_var aMeshVar = SMESH::GetMeshByIO(IO);
717   if (aMeshVar->_is_nil())
718     return;
719
720   SMESH_Actor* anActor = SMESH::FindActorByObject(aMeshVar);
721   if (!anActor)
722     anActor = SMESH::FindActorByEntry(IO->getEntry());
723   if (!anActor && !CheckBoxMesh->isChecked())
724     return;
725
726   int aNbUnits = 0;
727
728   if (myEditCurrentArgument == (QWidget*)LineEditElements) {
729     myElementsId = "";
730     myMesh = aMeshVar;
731     myActor = anActor;
732     myIO = IO;
733
734     // MakeGroups is available if there are groups
735     if ( myMesh->NbGroups() == 0 ) {
736       MakeGroupsCheck->setChecked(false);
737       MakeGroupsCheck->setEnabled(false);
738     } else {
739       MakeGroupsCheck->setEnabled(true);
740     }
741
742     if (CheckBoxMesh->isChecked()) {
743       SMESH::GetNameOfSelectedIObjects(mySelectionMgr, aString);
744
745       if (!SMESH::IObjectToInterface<SMESH::SMESH_IDSource>(IO)->_is_nil())
746         mySelectedObject = SMESH::IObjectToInterface<SMESH::SMESH_IDSource>(IO);
747       else
748         return;
749     } else {
750       aNbUnits = SMESH::GetNameOfSelectedElements(mySelector, IO, aString);
751       myElementsId = aString;
752       if (aNbUnits < 1)
753         return;
754     }
755     myNbOkElements = true;
756   } else {
757
758     SMDS_Mesh* aMesh = anActor->GetObject()->GetMesh();
759     if (!aMesh)
760       return;
761
762     bool isNodeSelected = (myEditCurrentArgument == (QWidget*)SpinBox_X ||
763                            (myEditCurrentArgument == (QWidget*)SpinBox_DX && 
764                             myVectorDefinition==POINT_SELECT));
765
766     bool isFaceSelected = (myEditCurrentArgument == (QWidget*)SpinBox_DX && 
767                            myVectorDefinition==FACE_SELECT);
768
769     if(isNodeSelected) {
770       aNbUnits = SMESH::GetNameOfSelectedNodes(mySelector, IO, aString);
771     }
772     else if(isFaceSelected){
773       aNbUnits = SMESH::GetNameOfSelectedElements(mySelector, IO, aString);
774     }
775     
776     if (aNbUnits != 1)
777       return;
778
779     if(isNodeSelected) {
780       const SMDS_MeshNode * n = aMesh->FindNode(aString.toInt());
781       if (!n)
782         return;
783
784       double x = n->X();
785       double y = n->Y();
786       double z = n->Z();
787
788       if (myEditCurrentArgument == (QWidget*)SpinBox_X) {
789         SpinBox_X->SetValue(x);
790         SpinBox_Y->SetValue(y);
791         SpinBox_Z->SetValue(z);
792       } else if (myEditCurrentArgument == (QWidget*)SpinBox_DX) {
793         SpinBox_DX->SetValue(x - SpinBox_X->GetValue());
794         SpinBox_DY->SetValue(y - SpinBox_Y->GetValue());
795         SpinBox_DZ->SetValue(z - SpinBox_Z->GetValue());
796       }
797     }
798     else if(isFaceSelected){
799       const SMDS_MeshFace* face = dynamic_cast<const SMDS_MeshFace*>(aMesh->FindElement(aString.toInt()));
800       if (!face)
801         return;
802       
803       gp_XYZ aNormale = SMESH::getNormale(face);
804       SpinBox_DX->SetValue(aNormale.X());
805       SpinBox_DY->SetValue(aNormale.Y());
806       SpinBox_DZ->SetValue(aNormale.Z());
807       
808     }
809   }
810
811   myBusy = true;
812   if (myEditCurrentArgument == (QWidget*)LineEditElements)
813     LineEditElements->setText(aString);
814   myBusy = false;
815
816   // OK
817   if (myNbOkElements && IsAxisOk()) {
818     buttonOk->setEnabled(true);
819     buttonApply->setEnabled(true);
820   }
821
822   onDisplaySimulation(true);
823 }
824
825 //=================================================================================
826 // function : SetEditCurrentArgument()
827 // purpose  :
828 //=================================================================================
829 void SMESHGUI_RevolutionDlg::SetEditCurrentArgument()
830 {
831   QPushButton* send = (QPushButton*)sender();
832
833   disconnect(mySelectionMgr, 0, this, 0);
834   mySelectionMgr->clearSelected();
835   mySelectionMgr->clearFilters();
836
837   if (send == SelectElementsButton) {
838     mySimulation->SetVisibility(false);
839     myEditCurrentArgument = (QWidget*)LineEditElements;
840     SMESH::SetPointRepresentation(false);
841     if (CheckBoxMesh->isChecked()) {
842       if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
843         aViewWindow->SetSelectionMode(ActorSelection);
844       mySelectionMgr->installFilter(myMeshOrSubMeshOrGroupFilter);
845     } else {
846       int aConstructorId = GetConstructorId();
847       if (aConstructorId == 0)
848         {
849           if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
850             aViewWindow->SetSelectionMode(EdgeSelection);
851         }
852       else if (aConstructorId == 1)
853         {
854           if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
855             aViewWindow->SetSelectionMode(FaceSelection);
856         }
857     }
858   } else if (send == SelectPointButton) {
859     myEditCurrentArgument = (QWidget*)SpinBox_X;
860     SMESH::SetPointRepresentation(true);
861     if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
862       aViewWindow->SetSelectionMode(NodeSelection);
863   }
864
865   myEditCurrentArgument->setFocus();
866   connect(mySelectionMgr, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument()));
867   SelectionIntoArgument();
868 }
869
870 //=================================================================================
871 // function : DeactivateActiveDialog()
872 // purpose  :
873 //=================================================================================
874 void SMESHGUI_RevolutionDlg::DeactivateActiveDialog()
875 {
876   if (ConstructorsBox->isEnabled()) {
877     ConstructorsBox->setEnabled(false);
878     GroupArguments->setEnabled(false);
879     GroupButtons->setEnabled(false);
880     mySMESHGUI->ResetState();
881     mySMESHGUI->SetActiveDialogBox(0);
882   }
883 }
884
885 //=================================================================================
886 // function : ActivateThisDialog()
887 // purpose  :
888 //=================================================================================
889 void SMESHGUI_RevolutionDlg::ActivateThisDialog()
890 {
891   /* Emit a signal to deactivate the active dialog */
892   mySMESHGUI->EmitSignalDeactivateDialog();
893   ConstructorsBox->setEnabled(true);
894   GroupArguments->setEnabled(true);
895   GroupButtons->setEnabled(true);
896
897   mySMESHGUI->SetActiveDialogBox((QDialog*)this);
898
899   ConstructorsClicked(GetConstructorId());
900   SelectionIntoArgument();
901 }
902
903 //=================================================================================
904 // function : enterEvent()
905 // purpose  :
906 //=================================================================================
907 void SMESHGUI_RevolutionDlg::enterEvent (QEvent*)
908 {
909   if (!ConstructorsBox->isEnabled())
910     ActivateThisDialog();
911 }
912
913 //=================================================================================
914 // function : closeEvent()
915 // purpose  :
916 //=================================================================================
917 void SMESHGUI_RevolutionDlg::closeEvent (QCloseEvent*)
918 {
919   /* same than click on cancel button */
920   disconnect(mySelectionMgr, 0, this, 0);
921   mySelectionMgr->clearFilters();
922   //mySelectionMgr->clearSelected();
923   if (SMESH::GetCurrentVtkView()) {
924     SMESH::RemoveFilters(); // PAL6938 -- clean all mesh entity filters
925     SMESH::SetPointRepresentation(false);
926   }
927   if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
928     aViewWindow->SetSelectionMode(ActorSelection);
929   mySMESHGUI->ResetState();
930 }
931
932 //=======================================================================
933 //function : onSelectMesh
934 //purpose  :
935 //=======================================================================
936 void SMESHGUI_RevolutionDlg::onSelectMesh (bool toSelectMesh)
937 {
938   if (toSelectMesh) {
939     myIDs = LineEditElements->text();
940     TextLabelElements->setText(tr("SMESH_NAME"));
941   }
942   else
943     TextLabelElements->setText(tr("SMESH_ID_ELEMENTS"));
944   myFilterBtn->setEnabled(!toSelectMesh);
945
946   if (myEditCurrentArgument != LineEditElements) {
947     LineEditElements->clear();
948     mySimulation->SetVisibility(false);
949     return;
950   }
951
952   mySelectionMgr->clearFilters();
953   SMESH::SetPointRepresentation(false);
954
955   if (toSelectMesh) {
956     if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
957       aViewWindow->SetSelectionMode(ActorSelection);
958     mySelectionMgr->installFilter(myMeshOrSubMeshOrGroupFilter);
959     LineEditElements->setReadOnly(true);
960     LineEditElements->setValidator(0);
961   } else {
962     int aConstructorId = GetConstructorId();
963     if (aConstructorId == 0)
964       {
965         if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
966           aViewWindow->SetSelectionMode(EdgeSelection);
967       }
968     else if (aConstructorId == 1)
969       {
970         if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
971           aViewWindow->SetSelectionMode(FaceSelection);
972       }
973
974     LineEditElements->setReadOnly(false);
975     LineEditElements->setValidator(myIdValidator);
976     onTextChange(LineEditElements->text());
977     mySimulation->SetVisibility(false);
978   }
979
980   SelectionIntoArgument();
981
982   if (!toSelectMesh)
983     LineEditElements->setText( myIDs );
984 }
985
986 //=================================================================================
987 // function : GetConstructorId()
988 // purpose  :
989 //=================================================================================
990 int SMESHGUI_RevolutionDlg::GetConstructorId()
991 {
992   return GroupConstructors->checkedId();
993 }
994
995 //=================================================================================
996 // function : IsAxisOk()
997 // purpose  :
998 //=================================================================================
999 bool SMESHGUI_RevolutionDlg::IsAxisOk()
1000 {
1001   return (SpinBox_DX->GetValue() != 0 ||
1002           SpinBox_DY->GetValue() != 0 ||
1003           SpinBox_DZ->GetValue() != 0);
1004 }
1005
1006 //=================================================================================
1007 // function : onVectorChanged()
1008 // purpose  :
1009 //=================================================================================
1010 void SMESHGUI_RevolutionDlg::onVectorChanged()
1011 {
1012   if (IsAxisOk()) {
1013     buttonOk->setEnabled(true);
1014     buttonApply->setEnabled(true);
1015   } else {
1016     buttonOk->setEnabled(false);
1017     buttonApply->setEnabled(false);
1018   }
1019   onDisplaySimulation(true);
1020 }
1021
1022 //=================================================================================
1023 // function : keyPressEvent()
1024 // purpose  :
1025 //=================================================================================
1026 void SMESHGUI_RevolutionDlg::keyPressEvent( QKeyEvent* e )
1027 {
1028   QDialog::keyPressEvent( e );
1029   if ( e->isAccepted() )
1030     return;
1031
1032   if ( e->key() == Qt::Key_F1 ) {
1033     e->accept();
1034     ClickOnHelp();
1035   }
1036 }
1037
1038 //=================================================================================
1039 // function : onDisplaySimulation()
1040 // purpose  : Show/Hide preview
1041 //=================================================================================
1042 void SMESHGUI_RevolutionDlg::onDisplaySimulation(bool toDisplayPreview)
1043 {
1044   if (myPreviewCheckBox->isChecked() && toDisplayPreview)
1045   {
1046     //display preview
1047     if (myNbOkElements && IsAxisOk())
1048     {
1049       QStringList aListElementsId = myElementsId.split(" ", QString::SkipEmptyParts);
1050       
1051       SMESH::long_array_var anElementsId = new SMESH::long_array;
1052       
1053       anElementsId->length(aListElementsId.count());
1054       for (int i = 0; i < aListElementsId.count(); i++)
1055         anElementsId[i] = aListElementsId[i].toInt();
1056       
1057       SMESH::AxisStruct anAxis;
1058       
1059       anAxis.x =  SpinBox_X->GetValue();
1060       anAxis.y =  SpinBox_Y->GetValue();
1061       anAxis.z =  SpinBox_Z->GetValue();
1062       anAxis.vx = SpinBox_DX->GetValue();
1063       anAxis.vy = SpinBox_DY->GetValue();
1064       anAxis.vz = SpinBox_DZ->GetValue();
1065
1066       double anAngle = (SpinBox_Angle->GetValue())*M_PI/180.;
1067       long aNbSteps = (long)SpinBox_NbSteps->value();
1068       double aTolerance = SpinBox_Tolerance->GetValue();
1069       
1070       if (GroupAngle->checkedId() == 1)
1071         anAngle = anAngle/aNbSteps;
1072       
1073       try {
1074         SUIT_OverrideCursor aWaitCursor;
1075         SMESH::SMESH_MeshEditor_var aMeshEditor = myMesh->GetMeshEditPreviewer();
1076         if( CheckBoxMesh->isChecked() ) {
1077           if( GetConstructorId() == 0 )
1078             aMeshEditor->RotationSweepObject1D(mySelectedObject, anAxis,
1079                                                anAngle, aNbSteps, aTolerance);
1080           else
1081             aMeshEditor->RotationSweepObject2D(mySelectedObject, anAxis,
1082                                                anAngle, aNbSteps, aTolerance);
1083         }
1084         else
1085           aMeshEditor->RotationSweep(anElementsId.inout(), 
1086                                      anAxis, 
1087                                      anAngle, 
1088                                      aNbSteps, 
1089                                      aTolerance);
1090         SMESH::MeshPreviewStruct_var aMeshPreviewStruct = aMeshEditor->GetPreviewData();
1091         mySimulation->SetData(aMeshPreviewStruct._retn());
1092       } catch (...) {}
1093     }
1094     else
1095     {
1096       mySimulation->SetVisibility(false);
1097     }
1098   }
1099   else
1100   {
1101     //erase preview
1102     mySimulation->SetVisibility(false);
1103   }
1104 }
1105
1106 //=================================================================================
1107 // function : onSelectVectorButton()
1108 // purpose  : [slot]
1109 //=================================================================================
1110 void SMESHGUI_RevolutionDlg::onSelectVectorButton(){
1111   if(SelectVectorMenu) {
1112     SelectVectorMenu->exec( QCursor::pos() );
1113   }
1114 }
1115
1116 //=================================================================================
1117 // function : onSelectVectorMenu()
1118 // purpose  : [slot]
1119 //=================================================================================
1120 void SMESHGUI_RevolutionDlg::onSelectVectorMenu( QAction* action){
1121   if(!action)
1122     return;
1123
1124   disconnect(mySelectionMgr, 0, this, 0);
1125
1126   switch(myMenuActions[action]) {
1127   case POINT_SELECT: 
1128     SMESH::SetPointRepresentation(true);
1129     if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
1130       aViewWindow->SetSelectionMode(NodeSelection);
1131     break;
1132     
1133   case FACE_SELECT: 
1134     SMESH::SetPointRepresentation(false);
1135     if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
1136       aViewWindow->SetSelectionMode(FaceSelection);
1137     break;
1138   }
1139
1140   myVectorDefinition = myMenuActions[action];
1141   myEditCurrentArgument = (QWidget*)SpinBox_DX;
1142   myEditCurrentArgument->setFocus();
1143   connect(mySelectionMgr, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument()));
1144   SelectionIntoArgument();
1145 }
1146
1147 //=================================================================================
1148 // function : setFilters()
1149 // purpose  : SLOT. Called when "Filter" button pressed.
1150 //=================================================================================
1151 void SMESHGUI_RevolutionDlg::setFilters()
1152 {
1153   if(myMesh->_is_nil()) {
1154     SUIT_MessageBox::critical(this,
1155                               tr("SMESH_ERROR"),
1156                               tr("NO_MESH_SELECTED"));
1157    return;
1158   }
1159   if ( !myFilterDlg )
1160   {
1161     QList<int> types;  
1162     types.append( SMESH::EDGE );
1163     types.append( SMESH::FACE );
1164     myFilterDlg = new SMESHGUI_FilterDlg( mySMESHGUI, types );
1165   }
1166   myFilterDlg->Init( GetConstructorId() ? SMESH::FACE : SMESH::EDGE );
1167
1168   myFilterDlg->SetSelection();
1169   myFilterDlg->SetMesh( myMesh );
1170   myFilterDlg->SetSourceWg( LineEditElements );
1171
1172   myFilterDlg->show();
1173 }
1174
1175 //=================================================================================
1176 // function : isValid
1177 // purpose  :
1178 //=================================================================================
1179 bool SMESHGUI_RevolutionDlg::isValid()
1180 {
1181   QString msg;
1182   bool ok = true;
1183   ok = SpinBox_X->isValid( msg, true ) && ok;
1184   ok = SpinBox_Y->isValid( msg, true ) && ok;
1185   ok = SpinBox_Z->isValid( msg, true ) && ok;
1186   ok = SpinBox_DX->isValid( msg, true ) && ok;
1187   ok = SpinBox_DY->isValid( msg, true ) && ok;
1188   ok = SpinBox_DZ->isValid( msg, true ) && ok;
1189   ok = SpinBox_Angle->isValid( msg, true ) && ok;
1190   ok = SpinBox_NbSteps->isValid( msg, true ) && ok;
1191   ok = SpinBox_Tolerance->isValid( msg, true ) && ok;
1192
1193   if( !ok ) {
1194     QString str( tr( "SMESH_INCORRECT_INPUT" ) );
1195     if ( !msg.isEmpty() )
1196       str += "\n" + msg;
1197     SUIT_MessageBox::critical( this, tr( "SMESH_ERROR" ), str );
1198     return false;
1199   }
1200   return true;
1201 }