Salome HOME
Merging from V3_2_6pre4
[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   SMESHGUI_RevolutionDlgLayout->addWidget(GroupArguments, 1, 0);
294
295   /* Initialisations */
296   SpinBox_X->RangeStepAndValidator(COORD_MIN, COORD_MAX, 10.0, 3);
297   SpinBox_Y->RangeStepAndValidator(COORD_MIN, COORD_MAX, 10.0, 3);
298   SpinBox_Z->RangeStepAndValidator(COORD_MIN, COORD_MAX, 10.0, 3);
299   SpinBox_DX->RangeStepAndValidator(COORD_MIN, COORD_MAX, 10.0, 3);
300   SpinBox_DY->RangeStepAndValidator(COORD_MIN, COORD_MAX, 10.0, 3);
301   SpinBox_DZ->RangeStepAndValidator(COORD_MIN, COORD_MAX, 10.0, 3);
302
303   SpinBox_Angle->RangeStepAndValidator(COORD_MIN, COORD_MAX, 5.0, 3);
304
305   QIntValidator* anIntValidator = new QIntValidator(SpinBox_NbSteps);
306   SpinBox_NbSteps->setValidator(anIntValidator);
307   SpinBox_NbSteps->setRange(1, 999999);
308
309   SpinBox_Tolerance->RangeStepAndValidator(0.0, COORD_MAX, 0.1, 6);
310
311   GroupArguments->show();
312   RadioButton1->setChecked(TRUE);
313
314   mySelector = (SMESH::GetViewWindow( mySMESHGUI ))->GetSelector();
315
316   mySMESHGUI->SetActiveDialogBox((QDialog*)this);
317
318   // Costruction of the logical filter
319   SMESH_TypeFilter* aMeshOrSubMeshFilter = new SMESH_TypeFilter (MESHorSUBMESH);
320   SMESH_TypeFilter* aSmeshGroupFilter    = new SMESH_TypeFilter (GROUP);
321
322   QPtrList<SUIT_SelectionFilter> aListOfFilters;
323   if (aMeshOrSubMeshFilter) aListOfFilters.append(aMeshOrSubMeshFilter);
324   if (aSmeshGroupFilter)    aListOfFilters.append(aSmeshGroupFilter);
325
326   myMeshOrSubMeshOrGroupFilter =
327     new SMESH_LogicalFilter (aListOfFilters, SMESH_LogicalFilter::LO_OR);
328
329   myHelpFileName = "revolution.htm";
330
331   Init();
332
333   /* signals and slots connections */
334   connect(buttonOk, SIGNAL(clicked()),     this, SLOT(ClickOnOk()));
335   connect(buttonCancel, SIGNAL(clicked()), this, SLOT(ClickOnCancel()));
336   connect(buttonApply, SIGNAL(clicked()),  this, SLOT(ClickOnApply()));
337   connect(buttonHelp, SIGNAL(clicked()), this, SLOT(ClickOnHelp()));
338   connect(GroupConstructors, SIGNAL(clicked(int)), SLOT(ConstructorsClicked(int)));
339
340   connect(SelectElementsButton, SIGNAL (clicked()), this, SLOT(SetEditCurrentArgument()));
341   connect(SelectPointButton, SIGNAL (clicked()),    this, SLOT(SetEditCurrentArgument()));
342   connect(SelectVectorButton, SIGNAL (clicked()),   this, SLOT(SetEditCurrentArgument()));
343
344   connect(SpinBox_DX, SIGNAL(valueChanged(double)), this, SLOT(onVectorChanged()));
345   connect(SpinBox_DY, SIGNAL(valueChanged(double)), this, SLOT(onVectorChanged()));
346   connect(SpinBox_DZ, SIGNAL(valueChanged(double)), this, SLOT(onVectorChanged()));
347
348   connect(mySMESHGUI,     SIGNAL(SignalDeactivateActiveDialog()), this, SLOT(DeactivateActiveDialog()));
349   connect(mySelectionMgr, SIGNAL(currentSelectionChanged()),      this, SLOT(SelectionIntoArgument()));
350   /* to close dialog if study change */
351   connect(mySMESHGUI,       SIGNAL(SignalCloseAllDialogs()), this, SLOT(ClickOnCancel()));
352   connect(LineEditElements, SIGNAL(textChanged(const QString&)),   SLOT(onTextChange(const QString&)));
353   connect(CheckBoxMesh,     SIGNAL(toggled(bool)),                 SLOT(onSelectMesh(bool)));
354
355   this->show(); /* displays Dialog */
356
357   ConstructorsClicked(0);
358   SelectionIntoArgument();
359   resize(0,0); // ??
360 }
361
362 //=================================================================================
363 // function : ~SMESHGUI_RevolutionDlg()
364 // purpose  : Destroys the object and frees any allocated resources
365 //=================================================================================
366 SMESHGUI_RevolutionDlg::~SMESHGUI_RevolutionDlg()
367 {
368   // no need to delete child widgets, Qt does it all for us
369 }
370
371 //=================================================================================
372 // function : Init()
373 // purpose  :
374 //=================================================================================
375 void SMESHGUI_RevolutionDlg::Init (bool ResetControls)
376 {
377   myBusy = false;
378
379   myEditCurrentArgument = 0;
380   LineEditElements->clear();
381   myElementsId = "";
382   myNbOkElements = 0;
383
384   myActor = 0;
385   myMesh = SMESH::SMESH_Mesh::_nil();
386
387   if (ResetControls) {
388     SpinBox_X->SetValue(0.0);
389     SpinBox_Y->SetValue(0.0);
390     SpinBox_Z->SetValue(0.0);
391     SpinBox_DX->SetValue(0.0);
392     SpinBox_DY->SetValue(0.0);
393     SpinBox_DZ->SetValue(0.0);
394
395     SpinBox_Angle->SetValue(45);
396     SpinBox_NbSteps->setValue(1);
397     SpinBox_Tolerance->SetValue(1e-05);
398
399     CheckBoxMesh->setChecked(false);
400     onSelectMesh(false);
401   }
402 }
403
404 //=================================================================================
405 // function : ConstructorsClicked()
406 // purpose  : Radio button management
407 //=================================================================================
408 void SMESHGUI_RevolutionDlg::ConstructorsClicked (int constructorId)
409 {
410   disconnect(mySelectionMgr, 0, this, 0);
411
412   Selection_Mode aSelMode = ActorSelection;
413
414   switch (constructorId) {
415   case 0:
416     {
417       GroupArguments->setTitle(tr("REVOLUTION_1D"));
418       aSelMode = EdgeSelection;
419       break;
420     }
421   case 1:
422     {
423       GroupArguments->setTitle(tr("REVOLUTION_2D"));
424       aSelMode = FaceSelection;
425       break;
426     }
427   }
428
429   if (myEditCurrentArgument != (QWidget*)LineEditElements) {
430     SMESH::SetPointRepresentation(false);
431   }
432
433   if (!CheckBoxMesh->isChecked())
434     {
435       if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
436         aViewWindow->SetSelectionMode(aSelMode);
437     }
438
439   myEditCurrentArgument = (QWidget*)LineEditElements;
440   LineEditElements->setFocus();
441
442   if (CheckBoxMesh->isChecked())
443     onSelectMesh(true);
444
445   connect(mySelectionMgr, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument()));
446 }
447
448 //=================================================================================
449 // function : ClickOnApply()
450 // purpose  :
451 //=================================================================================
452 void SMESHGUI_RevolutionDlg::ClickOnApply()
453 {
454   if (mySMESHGUI->isActiveStudyLocked())
455     return;
456
457   if (myNbOkElements && IsAxisOk()) {
458     QStringList aListElementsId = QStringList::split(" ", myElementsId, false);
459
460     SMESH::long_array_var anElementsId = new SMESH::long_array;
461
462     anElementsId->length(aListElementsId.count());
463     for (int i = 0; i < aListElementsId.count(); i++)
464       anElementsId[i] = aListElementsId[i].toInt();
465
466     SMESH::AxisStruct anAxis;
467
468     anAxis.x =  SpinBox_X->GetValue();
469     anAxis.y =  SpinBox_Y->GetValue();
470     anAxis.z =  SpinBox_Z->GetValue();;
471     anAxis.vx = SpinBox_DX->GetValue();
472     anAxis.vy = SpinBox_DY->GetValue();
473     anAxis.vz = SpinBox_DZ->GetValue();
474
475     double anAngle = (SpinBox_Angle->GetValue())*PI/180;
476     long aNbSteps = (long)SpinBox_NbSteps->value();
477     double aTolerance = SpinBox_Tolerance->GetValue();
478
479     try {
480       SMESH::SMESH_MeshEditor_var aMeshEditor = myMesh->GetMeshEditor();
481       QApplication::setOverrideCursor(Qt::waitCursor);
482       aMeshEditor->RotationSweep(anElementsId.inout(), anAxis, anAngle, aNbSteps, aTolerance);
483       QApplication::restoreOverrideCursor();
484     } catch (...) {
485     }
486
487     SMESH::UpdateView();
488     Init(false);
489     ConstructorsClicked(GetConstructorId());
490     SelectionIntoArgument();
491   }
492 }
493
494 //=================================================================================
495 // function : ClickOnOk()
496 // purpose  :
497 //=================================================================================
498 void SMESHGUI_RevolutionDlg::ClickOnOk()
499 {
500   ClickOnApply();
501   ClickOnCancel();
502 }
503
504 //=================================================================================
505 // function : ClickOnCancel()
506 // purpose  :
507 //=================================================================================
508 void SMESHGUI_RevolutionDlg::ClickOnCancel()
509 {
510   disconnect(mySelectionMgr, 0, this, 0);
511   mySelectionMgr->clearFilters();
512   //mySelectionMgr->clearSelected();
513   SMESH::SetPointRepresentation(false);
514   if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
515     aViewWindow->SetSelectionMode(ActorSelection);
516   mySMESHGUI->ResetState();
517   reject();
518 }
519
520 //=================================================================================
521 // function : ClickOnHelp()
522 // purpose  :
523 //=================================================================================
524 void SMESHGUI_RevolutionDlg::ClickOnHelp()
525 {
526   LightApp_Application* app = (LightApp_Application*)(SUIT_Session::session()->activeApplication());
527   if (app) 
528     app->onHelpContextModule(mySMESHGUI ? app->moduleName(mySMESHGUI->moduleName()) : QString(""), myHelpFileName);
529   else {
530                 QString platform;
531 #ifdef WIN32
532                 platform = "winapplication";
533 #else
534                 platform = "application";
535 #endif
536     SUIT_MessageBox::warn1(0, QObject::tr("WRN_WARNING"),
537                            QObject::tr("EXTERNAL_BROWSER_CANNOT_SHOW_PAGE").
538                            arg(app->resourceMgr()->stringValue("ExternalBrowser", platform)).arg(myHelpFileName),
539                            QObject::tr("BUT_OK"));
540   }
541 }
542
543 //=======================================================================
544 // function : onTextChange()
545 // purpose  :
546 //=======================================================================
547 void SMESHGUI_RevolutionDlg::onTextChange (const QString& theNewText)
548 {
549   QLineEdit* send = (QLineEdit*)sender();
550
551   if (myBusy) return;
552   myBusy = true;
553
554   if (send == LineEditElements)
555     myNbOkElements = 0;
556
557   buttonOk->setEnabled(false);
558   buttonApply->setEnabled(false);
559
560   // hilight entered elements
561   SMDS_Mesh* aMesh = 0;
562   if (myActor)
563     aMesh = myActor->GetObject()->GetMesh();
564
565   if (aMesh) {
566     if (send == LineEditElements) {
567       Handle(SALOME_InteractiveObject) anIO = myActor->getIO();
568
569       TColStd_MapOfInteger newIndices;
570
571       QStringList aListId = QStringList::split(" ", theNewText, false);
572       
573       for (int i = 0; i < aListId.count(); i++) {
574         const SMDS_MeshElement * e = aMesh->FindElement(aListId[ i ].toInt());
575         if (e)
576           newIndices.Add(e->GetID());
577         myNbOkElements++;
578       }
579
580       mySelector->AddOrRemoveIndex(myActor->getIO(), newIndices, false);
581       if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
582         aViewWindow->highlight( myActor->getIO(), true, true );
583       
584       myElementsId = theNewText;
585     }
586   }
587
588   if (myNbOkElements && IsAxisOk()) {
589     buttonOk->setEnabled(true);
590     buttonApply->setEnabled(true);
591   }
592
593   myBusy = false;
594 }
595
596 //=================================================================================
597 // function : SelectionIntoArgument()
598 // purpose  : Called when selection as changed or other case
599 //=================================================================================
600 void SMESHGUI_RevolutionDlg::SelectionIntoArgument()
601 {
602   if (myBusy) return;
603
604   // clear
605   myActor = 0;
606   QString aString = "";
607
608   myBusy = true;
609   if (myEditCurrentArgument == (QWidget*)LineEditElements) {
610     LineEditElements->setText(aString);
611     myNbOkElements = 0;
612     buttonOk->setEnabled(false);
613     buttonApply->setEnabled(false);
614   }
615   myBusy = false;
616
617   if (!GroupButtons->isEnabled()) // inactive
618     return;
619
620   // get selected mesh
621   const SALOME_ListIO& aList = mySelector->StoredIObjects();
622
623   int nbSel = aList.Extent();
624   if (nbSel != 1)
625     return;
626
627   Handle(SALOME_InteractiveObject) IO = aList.First();
628   myMesh = SMESH::GetMeshByIO(IO);
629   if (myMesh->_is_nil())
630     return;
631
632   myActor = SMESH::FindActorByObject(myMesh);
633   if (!myActor)
634     myActor = SMESH::FindActorByEntry(IO->getEntry());
635   if (!myActor)
636     return;
637
638   int aNbUnits = 0;
639
640   if (myEditCurrentArgument == (QWidget*)LineEditElements) {
641     myElementsId = "";
642
643     if (CheckBoxMesh->isChecked()) {
644       int aConstructorId = GetConstructorId();
645
646       SMESH::GetNameOfSelectedIObjects(mySelectionMgr, aString);
647
648       if (!SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(IO)->_is_nil()) { //MESH
649         // get IDs from mesh
650         SMDS_Mesh* aSMDSMesh = myActor->GetObject()->GetMesh();
651         if (!aSMDSMesh)
652           return;
653
654         if (aConstructorId == 0) {
655           SMDS_EdgeIteratorPtr anIter = aSMDSMesh->edgesIterator();
656
657           while (anIter->more()) {
658             const SMDS_MeshEdge * edge = anIter->next();
659             if (edge) {
660               myElementsId += QString(" %1").arg(edge->GetID());
661               aNbUnits++;
662             }
663           }
664         } else if (aConstructorId == 1) {
665           SMDS_FaceIteratorPtr anIter = aSMDSMesh->facesIterator();
666           while (anIter->more()) {
667             const SMDS_MeshFace * face = anIter->next();
668             if (face) {
669               myElementsId += QString(" %1").arg(face->GetID());
670               aNbUnits++;
671             }
672           }
673         }
674       } else if (!SMESH::IObjectToInterface<SMESH::SMESH_subMesh>(IO)->_is_nil()) { //SUBMESH
675         // get submesh
676         SMESH::SMESH_subMesh_var aSubMesh = SMESH::IObjectToInterface<SMESH::SMESH_subMesh>(IO);
677
678         // get IDs from submesh
679         SMESH::long_array_var anElementsIds = new SMESH::long_array;
680         if (aConstructorId == 0)
681           anElementsIds = aSubMesh->GetElementsByType(SMESH::EDGE);
682         else if (aConstructorId == 1)
683           anElementsIds = aSubMesh->GetElementsByType(SMESH::FACE);
684
685         for (int i = 0; i < anElementsIds->length(); i++)
686           myElementsId += QString(" %1").arg(anElementsIds[i]);
687         aNbUnits = anElementsIds->length();
688       } else { // GROUP
689         // get smesh group
690         SMESH::SMESH_GroupBase_var aGroup =
691           SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(IO);
692         if (aGroup->_is_nil())
693           return;
694
695         if ((aConstructorId == 0 && aGroup->GetType()!= SMESH::EDGE) ||
696             (aConstructorId == 1 && aGroup->GetType()!= SMESH::FACE))
697           return;
698
699         // get IDs from smesh group
700         SMESH::long_array_var anElementsIds = new SMESH::long_array;
701         anElementsIds = aGroup->GetListOfID();
702         for (int i = 0; i < anElementsIds->length(); i++) {
703           myElementsId += QString(" %1").arg(anElementsIds[i]);
704         }
705         aNbUnits = anElementsIds->length();
706       }
707     } else {
708       aNbUnits = SMESH::GetNameOfSelectedElements(mySelector, IO, aString);
709       myElementsId = aString;
710     }
711
712     if (aNbUnits < 1)
713       return;
714
715     myNbOkElements = true;
716   } else {
717     aNbUnits = SMESH::GetNameOfSelectedNodes(mySelector, IO, aString);
718     if (aNbUnits != 1)
719       return;
720
721     SMDS_Mesh* aMesh =  myActor->GetObject()->GetMesh();
722     if (!aMesh)
723       return;
724
725     const SMDS_MeshNode * n = aMesh->FindNode(aString.toInt());
726     if (!n)
727       return;
728
729     double x = n->X();
730     double y = n->Y();
731     double z = n->Z();
732
733     if (myEditCurrentArgument == (QWidget*)SpinBox_X) {
734       SpinBox_X->SetValue(x);
735       SpinBox_Y->SetValue(y);
736       SpinBox_Z->SetValue(z);
737     } else if (myEditCurrentArgument == (QWidget*)SpinBox_DX) {
738       SpinBox_DX->SetValue(x - SpinBox_X->GetValue());
739       SpinBox_DY->SetValue(y - SpinBox_Y->GetValue());
740       SpinBox_DZ->SetValue(z - SpinBox_Z->GetValue());
741     }
742   }
743
744   myBusy = true;
745   if (myEditCurrentArgument == (QWidget*)LineEditElements)
746     LineEditElements->setText(aString);
747   myBusy = false;
748
749   // OK
750   if (myNbOkElements && IsAxisOk()) {
751     buttonOk->setEnabled(true);
752     buttonApply->setEnabled(true);
753   }
754 }
755
756 //=================================================================================
757 // function : SetEditCurrentArgument()
758 // purpose  :
759 //=================================================================================
760 void SMESHGUI_RevolutionDlg::SetEditCurrentArgument()
761 {
762   QPushButton* send = (QPushButton*)sender();
763
764   disconnect(mySelectionMgr, 0, this, 0);
765   mySelectionMgr->clearSelected();
766   mySelectionMgr->clearFilters();
767
768   if (send == SelectElementsButton) {
769     myEditCurrentArgument = (QWidget*)LineEditElements;
770     SMESH::SetPointRepresentation(false);
771     if (CheckBoxMesh->isChecked()) {
772       if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
773         aViewWindow->SetSelectionMode(ActorSelection);
774       mySelectionMgr->installFilter(myMeshOrSubMeshOrGroupFilter);
775     } else {
776       int aConstructorId = GetConstructorId();
777       if (aConstructorId == 0)
778         {
779           if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
780             aViewWindow->SetSelectionMode(EdgeSelection);
781         }
782       else if (aConstructorId == 1)
783         {
784           if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
785             aViewWindow->SetSelectionMode(FaceSelection);
786         }
787     }
788   } else if (send == SelectPointButton) {
789     myEditCurrentArgument = (QWidget*)SpinBox_X;
790     SMESH::SetPointRepresentation(true);
791     if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
792       aViewWindow->SetSelectionMode(NodeSelection);
793   } else if (send == SelectVectorButton) {
794     myEditCurrentArgument = (QWidget*)SpinBox_DX;
795     SMESH::SetPointRepresentation(true);
796     if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
797       aViewWindow->SetSelectionMode(NodeSelection);
798   } else {
799   }
800
801   myEditCurrentArgument->setFocus();
802   connect(mySelectionMgr, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument()));
803   SelectionIntoArgument();
804 }
805
806 //=================================================================================
807 // function : DeactivateActiveDialog()
808 // purpose  :
809 //=================================================================================
810 void SMESHGUI_RevolutionDlg::DeactivateActiveDialog()
811 {
812   if (GroupConstructors->isEnabled()) {
813     GroupConstructors->setEnabled(false);
814     GroupArguments->setEnabled(false);
815     GroupButtons->setEnabled(false);
816     mySMESHGUI->ResetState();
817     mySMESHGUI->SetActiveDialogBox(0);
818   }
819 }
820
821 //=================================================================================
822 // function : ActivateThisDialog()
823 // purpose  :
824 //=================================================================================
825 void SMESHGUI_RevolutionDlg::ActivateThisDialog()
826 {
827   /* Emit a signal to deactivate the active dialog */
828   mySMESHGUI->EmitSignalDeactivateDialog();
829   GroupConstructors->setEnabled(true);
830   GroupArguments->setEnabled(true);
831   GroupButtons->setEnabled(true);
832
833   mySMESHGUI->SetActiveDialogBox((QDialog*)this);
834
835   ConstructorsClicked(GetConstructorId());
836   SelectionIntoArgument();
837 }
838
839 //=================================================================================
840 // function : enterEvent()
841 // purpose  :
842 //=================================================================================
843 void SMESHGUI_RevolutionDlg::enterEvent (QEvent*)
844 {
845   if (!GroupConstructors->isEnabled())
846     ActivateThisDialog();
847 }
848
849 //=================================================================================
850 // function : closeEvent()
851 // purpose  :
852 //=================================================================================
853 void SMESHGUI_RevolutionDlg::closeEvent (QCloseEvent*)
854 {
855   /* same than click on cancel button */
856   this->ClickOnCancel();
857 }
858
859 //=======================================================================
860 // function : hideEvent()
861 // purpose  : caused by ESC key
862 //=======================================================================
863 void SMESHGUI_RevolutionDlg::hideEvent (QHideEvent*)
864 {
865   if (!isMinimized())
866     ClickOnCancel();
867 }
868
869 //=======================================================================
870 //function : onSelectMesh
871 //purpose  :
872 //=======================================================================
873 void SMESHGUI_RevolutionDlg::onSelectMesh (bool toSelectMesh)
874 {
875   if (toSelectMesh)
876     TextLabelElements->setText(tr("SMESH_NAME"));
877   else
878     TextLabelElements->setText(tr("SMESH_ID_ELEMENTS"));
879
880   if (myEditCurrentArgument != LineEditElements) {
881     LineEditElements->clear();
882     return;
883   }
884
885   mySelectionMgr->clearFilters();
886   SMESH::SetPointRepresentation(false);
887
888   if (toSelectMesh) {
889     if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
890       aViewWindow->SetSelectionMode(ActorSelection);
891     mySelectionMgr->installFilter(myMeshOrSubMeshOrGroupFilter);
892     LineEditElements->setReadOnly(true);
893   } else {
894     int aConstructorId = GetConstructorId();
895     if (aConstructorId == 0)
896       {
897         if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
898           aViewWindow->SetSelectionMode(EdgeSelection);
899       }
900     else if (aConstructorId == 0)
901       {
902         if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
903           aViewWindow->SetSelectionMode(FaceSelection);
904       }
905
906     LineEditElements->setReadOnly(false);
907     onTextChange(LineEditElements->text());
908   }
909
910   SelectionIntoArgument();
911 }
912
913 //=================================================================================
914 // function : GetConstructorId()
915 // purpose  :
916 //=================================================================================
917 int SMESHGUI_RevolutionDlg::GetConstructorId()
918 {
919   if (GroupConstructors != NULL && GroupConstructors->selected() != NULL)
920     return GroupConstructors->id(GroupConstructors->selected());
921   return -1;
922 }
923
924 //=================================================================================
925 // function : IsAxisOk()
926 // purpose  :
927 //=================================================================================
928 bool SMESHGUI_RevolutionDlg::IsAxisOk()
929 {
930   return (SpinBox_DX->GetValue() != 0 ||
931           SpinBox_DY->GetValue() != 0 ||
932           SpinBox_DZ->GetValue() != 0);
933 }
934
935 //=================================================================================
936 // function : onVectorChanged()
937 // purpose  :
938 //=================================================================================
939 void SMESHGUI_RevolutionDlg::onVectorChanged()
940 {
941   if (IsAxisOk()) {
942     buttonOk->setEnabled(true);
943     buttonApply->setEnabled(true);
944   } else {
945     buttonOk->setEnabled(false);
946     buttonApply->setEnabled(false);
947   }
948 }
949
950 //=================================================================================
951 // function : keyPressEvent()
952 // purpose  :
953 //=================================================================================
954 void SMESHGUI_RevolutionDlg::keyPressEvent( QKeyEvent* e )
955 {
956   QDialog::keyPressEvent( e );
957   if ( e->isAccepted() )
958     return;
959
960   if ( e->key() == Key_F1 )
961     {
962       e->accept();
963       ClickOnHelp();
964     }
965 }