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