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