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