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