]> SALOME platform Git repositories - modules/smesh.git/blob - src/SMESHGUI/SMESHGUI_RevolutionDlg.cxx
Salome HOME
ec665bcf753250a6357ec5c3722c5e7bb250c2e0
[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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org 
21 //
22 //
23 //
24 //  File   : SMESHGUI_RevolutionDlg.cxx
25 //  Author : Michael ZORIN
26 //  Module : SMESH
27 //  $Header: 
28
29 #include "SMESHGUI_RevolutionDlg.h"
30 #include "SMESHGUI.h"
31 #include "SMESHGUI_SpinBox.h"
32 #include "SMESHGUI_Utils.h"
33 #include "SMESHGUI_VTKUtils.h"
34 #include "SMESHGUI_IdValidator.h"
35 #include "SMESH_Actor.h"
36 #include "SMDS_Mesh.hxx"
37
38 #include "QAD_Application.h"
39 #include "QAD_Desktop.h"
40 #include "QAD_MessageBox.h"
41 #include "utilities.h"
42
43 // QT Includes
44 #include <qapplication.h>
45 #include <qbuttongroup.h>
46 #include <qgroupbox.h>
47 #include <qlabel.h>
48 #include <qlineedit.h>
49 #include <qpushbutton.h>
50 #include <qradiobutton.h>
51 #include <qlayout.h>
52 #include <qspinbox.h> 
53 #include <qvalidator.h>
54 #include <qpixmap.h>
55
56 using namespace std;
57
58 //=================================================================================
59 // class    : SMESHGUI_RevolutionDlg()
60 // purpose  : 
61 //=================================================================================
62 SMESHGUI_RevolutionDlg::SMESHGUI_RevolutionDlg( QWidget* parent, const char* name, SALOME_Selection* Sel,
63                                               bool modal, WFlags fl )
64   : QDialog( parent, name, modal, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu |
65              Qt::WDestructiveClose)
66 {
67   QPixmap image0(QAD_Desktop::getResourceManager()->loadPixmap( "SMESH",tr("ICON_DLG_EDGE")));
68   QPixmap image1(QAD_Desktop::getResourceManager()->loadPixmap( "SMESH",tr("ICON_DLG_TRIANGLE")));
69   QPixmap image2(QAD_Desktop::getResourceManager()->loadPixmap( "SMESH",tr("ICON_SELECT")));
70
71   if ( !name )
72     setName( "SMESHGUI_RevolutionDlg" );
73   resize( 303, 185 ); 
74   setCaption( tr( "REVOLUTION_AROUND_AXIS" ) );
75   setSizeGripEnabled( TRUE );
76   SMESHGUI_RevolutionDlgLayout = new QGridLayout( this ); 
77   SMESHGUI_RevolutionDlgLayout->setSpacing( 6 );
78   SMESHGUI_RevolutionDlgLayout->setMargin( 11 );
79
80   /***************************************************************/
81   GroupConstructors = new QButtonGroup( this, "GroupConstructors" );
82   GroupConstructors->setTitle( tr( "SMESH_REVOLUTION"  ) );
83   GroupConstructors->setExclusive( TRUE );
84   GroupConstructors->setColumnLayout(0, Qt::Vertical );
85   GroupConstructors->layout()->setSpacing( 0 );
86   GroupConstructors->layout()->setMargin( 0 );
87   GroupConstructorsLayout = new QGridLayout( GroupConstructors->layout() );
88   GroupConstructorsLayout->setAlignment( Qt::AlignTop );
89   GroupConstructorsLayout->setSpacing( 6 );
90   GroupConstructorsLayout->setMargin( 11 );
91   RadioButton1= new QRadioButton( GroupConstructors, "RadioButton1" );
92   RadioButton1->setText( tr( ""  ) );
93   RadioButton1->setPixmap( image0 );
94   GroupConstructorsLayout->addWidget( RadioButton1, 0, 0 );
95   RadioButton2= new QRadioButton( GroupConstructors, "RadioButton2" );
96   RadioButton2->setText( tr( ""  ) );
97   RadioButton2->setPixmap( image1 );
98   GroupConstructorsLayout->addWidget( RadioButton2, 0, 2 );
99   SMESHGUI_RevolutionDlgLayout->addWidget( GroupConstructors, 0, 0 );
100   
101   /***************************************************************/
102   GroupButtons = new QGroupBox( this, "GroupButtons" );
103   GroupButtons->setGeometry( QRect( 10, 10, 281, 48 ) ); 
104   GroupButtons->setTitle( tr( ""  ) );
105   GroupButtons->setColumnLayout(0, Qt::Vertical );
106   GroupButtons->layout()->setSpacing( 0 );
107   GroupButtons->layout()->setMargin( 0 );
108   GroupButtonsLayout = new QGridLayout( GroupButtons->layout() );
109   GroupButtonsLayout->setAlignment( Qt::AlignTop );
110   GroupButtonsLayout->setSpacing( 6 );
111   GroupButtonsLayout->setMargin( 11 );
112   buttonCancel = new QPushButton( GroupButtons, "buttonCancel" );
113   buttonCancel->setText( tr( "SMESH_BUT_CLOSE"  ) );
114   buttonCancel->setAutoDefault( TRUE );
115   GroupButtonsLayout->addWidget( buttonCancel, 0, 3 );
116   buttonApply = new QPushButton( GroupButtons, "buttonApply" );
117   buttonApply->setText( tr( "SMESH_BUT_APPLY"  ) );
118   buttonApply->setAutoDefault( TRUE );
119   GroupButtonsLayout->addWidget( buttonApply, 0, 1 );
120   QSpacerItem* spacer_9 = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum );
121   GroupButtonsLayout->addItem( spacer_9, 0, 2 );
122   buttonOk = new QPushButton( GroupButtons, "buttonOk" );
123   buttonOk->setText( tr( "SMESH_BUT_OK"  ) );
124   buttonOk->setAutoDefault( TRUE );
125   buttonOk->setDefault( TRUE );
126   GroupButtonsLayout->addWidget( buttonOk, 0, 0 );
127   SMESHGUI_RevolutionDlgLayout->addWidget( GroupButtons, 2, 0 );
128
129   /***************************************************************/
130   GroupArguments = new QGroupBox( this, "GroupArguments" );
131   GroupArguments->setTitle( tr( "REVOLUTION_1D"  ) );
132   GroupArguments->setColumnLayout(0, Qt::Vertical );
133   GroupArguments->layout()->setSpacing( 0 );
134   GroupArguments->layout()->setMargin( 0 );
135   GroupArgumentsLayout = new QGridLayout( GroupArguments->layout() );
136   GroupArgumentsLayout->setAlignment( Qt::AlignTop );
137   GroupArgumentsLayout->setSpacing( 6 );
138   GroupArgumentsLayout->setMargin( 11 );
139
140   // Controls for elements selection
141   TextLabelElements  = new QLabel( GroupArguments, "TextLabelElements" );
142   TextLabelElements->setText( tr( "SMESH_ID_ELEMENTS"  ) );
143   GroupArgumentsLayout->addWidget( TextLabelElements, 0, 0 );
144
145   SelectElementsButton  = new QPushButton( GroupArguments, "SelectElementsButton" );
146   SelectElementsButton->setText( tr( ""  ) );
147   SelectElementsButton->setPixmap( image2 );
148   SelectElementsButton->setToggleButton( FALSE );
149   GroupArgumentsLayout->addWidget( SelectElementsButton, 0, 1 );
150
151   LineEditElements  = new QLineEdit( GroupArguments, "LineEditElements" );
152   LineEditElements->setValidator( new SMESHGUI_IdValidator( this, "validator" ));
153   GroupArgumentsLayout->addWidget( LineEditElements, 0, 2 );
154
155   // Controls for axis defining
156   GroupAxis = new QGroupBox( GroupArguments, "GroupAxis" );
157   GroupAxis->setTitle( tr( "SMESH_AXIS" ) );
158   GroupAxis->setColumnLayout(0, Qt::Vertical );
159   GroupAxis->layout()->setSpacing( 0 );
160   GroupAxis->layout()->setMargin( 0 );
161   QGridLayout* GroupAxisLayout = new QGridLayout( GroupAxis->layout() );
162   GroupAxisLayout->setAlignment( Qt::AlignTop );
163   GroupAxisLayout->setSpacing( 6 );
164   GroupAxisLayout->setMargin( 11 );
165   
166   TextLabelPoint = new QLabel( GroupAxis, "TextLabelPoint" );
167   TextLabelPoint->setText( tr( "SMESH_POINT" ) );
168   GroupAxisLayout->addWidget( TextLabelPoint, 0, 0 );
169
170   SelectPointButton  = new QPushButton( GroupAxis, "SelectPointButton" );
171   SelectPointButton->setPixmap( image2 );
172   GroupAxisLayout->addWidget( SelectPointButton, 0, 1 );
173   
174   TextLabelX = new QLabel( GroupAxis, "TextLabelX" );
175   TextLabelX->setText( tr( "SMESH_X" ) );
176   GroupAxisLayout->addWidget( TextLabelX, 0, 2 );
177
178   SpinBox_X = new SMESHGUI_SpinBox( GroupAxis, "SpinBox_X");
179   GroupAxisLayout->addWidget( SpinBox_X, 0, 3 );
180   
181   TextLabelY = new QLabel( GroupAxis, "TextLabelY" );
182   TextLabelY->setText( tr( "SMESH_Y" ) );
183   GroupAxisLayout->addWidget( TextLabelY, 0, 4 );
184
185   SpinBox_Y = new SMESHGUI_SpinBox( GroupAxis, "SpinBox_Y");
186   GroupAxisLayout->addWidget( SpinBox_Y, 0, 5 );
187
188   TextLabelZ = new QLabel( GroupAxis, "TextLabelZ" );
189   TextLabelZ->setText( tr( "SMESH_Z" ) );
190   GroupAxisLayout->addWidget( TextLabelZ, 0, 6 );
191   
192   SpinBox_Z = new SMESHGUI_SpinBox( GroupAxis, "SpinBox_Z");
193   GroupAxisLayout->addWidget( SpinBox_Z, 0, 7 );
194
195   TextLabelVector = new QLabel( GroupAxis, "TextLabelVector" );
196   TextLabelVector->setText( tr( "SMESH_VECTOR" ) );
197   GroupAxisLayout->addWidget( TextLabelVector, 1, 0 );
198   
199   SelectVectorButton = new QPushButton( GroupAxis, "SelectVectorButton" );
200   SelectVectorButton->setPixmap( image2 );
201   GroupAxisLayout->addWidget( SelectVectorButton, 1, 1 );
202   
203   TextLabelDX = new QLabel( GroupAxis, "TextLabelDX" );
204   TextLabelDX->setText( tr( "SMESH_DX" ) );
205   GroupAxisLayout->addWidget( TextLabelDX, 1, 2 );
206
207   SpinBox_DX = new SMESHGUI_SpinBox( GroupAxis, "SpinBox_DX");
208   GroupAxisLayout->addWidget( SpinBox_DX, 1, 3 );
209   
210   TextLabelDY = new QLabel( GroupAxis, "TextLabelDY" );
211   TextLabelDY->setText( tr( "SMESH_DY" ) );
212   GroupAxisLayout->addWidget( TextLabelDY, 1, 4 );
213
214   SpinBox_DY = new SMESHGUI_SpinBox( GroupAxis, "SpinBox_DY");
215   GroupAxisLayout->addWidget( SpinBox_DY, 1, 5 );
216
217   TextLabelDZ = new QLabel( GroupAxis, "TextLabelDZ" );
218   TextLabelDZ->setText( tr( "SMESH_DZ" ) );
219   GroupAxisLayout->addWidget( TextLabelDZ, 1, 6 );
220   
221   SpinBox_DZ = new SMESHGUI_SpinBox( GroupAxis, "SpinBox_DZ");
222   GroupAxisLayout->addWidget( SpinBox_DZ, 1, 7 );
223
224   GroupArgumentsLayout->addMultiCellWidget( GroupAxis, 1, 1, 0, 3 );
225     
226   // Controls for angle defining
227   TextLabelAngle = new QLabel( GroupArguments, "TextLabelAngle" );
228   TextLabelAngle->setText( tr( "SMESH_ANGLE"  ) );
229   GroupArgumentsLayout->addMultiCellWidget( TextLabelAngle, 2, 2, 0, 1 );
230
231   SpinBox_Angle = new SMESHGUI_SpinBox(GroupArguments, "SpinBox_Angle");
232   GroupArgumentsLayout->addWidget( SpinBox_Angle, 2, 2 );
233   
234   // Controls for nb. steps defining
235   TextLabelNbSteps = new QLabel( GroupArguments, "TextLabelNbSteps" );
236   TextLabelNbSteps->setText( tr( "SMESH_NUMBEROFSTEPS"  ) );
237   GroupArgumentsLayout->addMultiCellWidget( TextLabelNbSteps, 3, 3, 0, 1 );
238
239   SpinBox_NbSteps = new QSpinBox(GroupArguments, "SpinBox_NbSteps");
240   GroupArgumentsLayout->addWidget( SpinBox_NbSteps, 3, 2 );
241   
242   // Controls for tolerance defining
243   TextLabelTolerance = new QLabel( GroupArguments, "TextLabelTolerance" );
244   TextLabelTolerance->setText( tr( "SMESH_TOLERANCE" ) );
245   GroupArgumentsLayout->addMultiCellWidget( TextLabelTolerance, 4, 4, 0, 1 );
246
247   SpinBox_Tolerance = new SMESHGUI_SpinBox(GroupArguments, "SpinBox_Tolerance");
248   GroupArgumentsLayout->addWidget( SpinBox_Tolerance, 4, 2 );
249
250   SMESHGUI_RevolutionDlgLayout->addWidget( GroupArguments, 1, 0 );
251   
252   /* Initialisations */
253   SpinBox_X->RangeStepAndValidator( -999999.999, +999999.999, 10.0, 3 );
254   SpinBox_Y->RangeStepAndValidator( -999999.999, +999999.999, 10.0, 3 );
255   SpinBox_Z->RangeStepAndValidator( -999999.999, +999999.999, 10.0, 3 );
256   SpinBox_DX->RangeStepAndValidator( -999999.999, +999999.999, 10.0, 3 );
257   SpinBox_DY->RangeStepAndValidator( -999999.999, +999999.999, 10.0, 3 );
258   SpinBox_DZ->RangeStepAndValidator( -999999.999, +999999.999, 10.0, 3 );
259
260   SpinBox_Angle->RangeStepAndValidator( -999999.999, +999999.999, 5.0, 3 );
261   
262   QIntValidator* anIntValidator = new QIntValidator(SpinBox_NbSteps);
263   SpinBox_NbSteps->setValidator(anIntValidator);
264   SpinBox_NbSteps->setRange( 1, 999999 );
265   
266   SpinBox_Tolerance->RangeStepAndValidator( 0.0, +999999.999, 0.1, 6 );
267  
268   GroupArguments->show();
269   RadioButton1->setChecked( TRUE );
270   mySelection = Sel;  
271
272   mySMESHGUI  = SMESHGUI::GetSMESHGUI() ;
273   mySMESHGUI->SetActiveDialogBox( (QDialog*)this ) ;
274     
275   Init();
276   /* signals and slots connections */
277   connect( buttonOk, SIGNAL( clicked() ),     this, SLOT( ClickOnOk() ) );
278   connect( buttonCancel, SIGNAL( clicked() ), this, SLOT( ClickOnCancel() ) ) ;
279   connect( buttonApply, SIGNAL( clicked() ), this, SLOT(ClickOnApply() ) );
280   connect( GroupConstructors, SIGNAL(clicked(int) ), SLOT( ConstructorsClicked(int) ) );
281   
282   connect( SelectElementsButton, SIGNAL (clicked() ),   this, SLOT( SetEditCurrentArgument() ) ) ;
283   connect( SelectPointButton, SIGNAL (clicked() ),   this, SLOT( SetEditCurrentArgument() ) ) ;
284   connect( SelectVectorButton, SIGNAL (clicked() ),   this, SLOT( SetEditCurrentArgument() ) ) ;
285
286   connect( SpinBox_DX, SIGNAL( valueChanged( double )), this, SLOT(onVectorChanged() ) );
287   connect( SpinBox_DY, SIGNAL( valueChanged( double )), this, SLOT(onVectorChanged() ) );
288   connect( SpinBox_DZ, SIGNAL( valueChanged( double )), this, SLOT(onVectorChanged() ) );
289
290   connect( mySMESHGUI, SIGNAL ( SignalDeactivateActiveDialog() ), this, SLOT( DeactivateActiveDialog() ) ) ;
291   connect( mySelection, SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) );
292   /* to close dialog if study change */
293   connect( mySMESHGUI, SIGNAL ( SignalCloseAllDialogs() ), this, SLOT( ClickOnCancel() ) ) ;
294   connect( LineEditElements, SIGNAL( textChanged( const QString& )),
295            SLOT( onTextChange( const QString& )));
296   
297   /* Move widget on the botton right corner of main widget */
298   int x, y ;
299   mySMESHGUI->DefineDlgPosition( this, x, y ) ;
300   this->move( x, y ) ;
301   this->show() ; /* displays Dialog */
302
303   ConstructorsClicked(0);
304 }
305
306 //=================================================================================
307 // function : ~SMESHGUI_RevolutionDlg()
308 // purpose  : Destroys the object and frees any allocated resources
309 //=================================================================================
310 SMESHGUI_RevolutionDlg::~SMESHGUI_RevolutionDlg()
311 {
312   // no need to delete child widgets, Qt does it all for us
313 }
314
315
316 //=================================================================================
317 // function : Init()
318 // purpose  :
319 //=================================================================================
320 void SMESHGUI_RevolutionDlg::Init()
321 {
322   myBusy = false;    
323
324   SpinBox_X->SetValue(0.0);
325   SpinBox_Y->SetValue(0.0);
326   SpinBox_Z->SetValue(0.0);
327   SpinBox_DX->SetValue(0.0);
328   SpinBox_DY->SetValue(0.0);
329   SpinBox_DZ->SetValue(0.0);
330
331   SpinBox_Angle->SetValue(45);
332   SpinBox_NbSteps->setValue(1);
333   SpinBox_Tolerance->SetValue(1e-05);
334   
335   myEditCurrentArgument = (QWidget*)LineEditElements;
336   LineEditElements->setFocus();
337   myNbOkElements = 0 ;
338   myActor     = 0;
339   myMesh = SMESH::SMESH_Mesh::_nil();
340     
341   SelectionIntoArgument();
342 }
343
344
345 //=================================================================================
346 // function : ConstructorsClicked()
347 // purpose  : Radio button management
348 //=================================================================================
349 void SMESHGUI_RevolutionDlg::ConstructorsClicked(int constructorId)
350 {
351   disconnect(mySelection, 0, this, 0);
352   mySelection->ClearIObjects();
353   mySelection->ClearFilters();
354   myNbOkElements = 0 ;
355   myEditCurrentArgument = (QWidget*)LineEditElements;
356   LineEditElements->setText("");
357   LineEditElements->setFocus();
358   
359   switch(constructorId)
360     { 
361     case 0 :
362       {
363         GroupArguments->setTitle( tr( "REVOLUTION_1D" ) );
364         QAD_Application::getDesktop()->SetSelectionMode( EdgeSelection, true );
365         break;
366       }
367     case 1 :
368       { 
369         GroupArguments->setTitle( tr( "REVOLUTION_2D" ) );
370         QAD_Application::getDesktop()->SetSelectionMode( FaceSelection, true );
371         break;
372       }
373     }
374   connect(mySelection, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument()));
375 }
376
377
378 //=================================================================================
379 // function : ClickOnApply()
380 // purpose  :
381 //=================================================================================
382 void SMESHGUI_RevolutionDlg::ClickOnApply()
383 {
384   if (mySMESHGUI->ActiveStudyLocked())
385     return;
386   
387   if ( myNbOkElements  && IsAxisOk())
388     {
389       QStringList aListElementsId = QStringList::split( " ", LineEditElements->text(), false);
390       
391       SMESH::long_array_var anElementsId = new SMESH::long_array;
392       
393       anElementsId->length( aListElementsId.count() );
394       for ( int i = 0; i < aListElementsId.count(); i++ )
395         anElementsId[i] = aListElementsId[i].toInt();
396       
397       SMESH::AxisStruct anAxis;
398       
399       anAxis.x =  SpinBox_X->GetValue();
400       anAxis.y =  SpinBox_Y->GetValue();
401       anAxis.z =  SpinBox_Z->GetValue();;
402       anAxis.vx = SpinBox_DX->GetValue();
403       anAxis.vy = SpinBox_DY->GetValue();
404       anAxis.vz = SpinBox_DZ->GetValue();
405
406       double anAngle = (SpinBox_Angle->GetValue())*PI/180; 
407       long aNbSteps = (long)SpinBox_NbSteps->value();
408       double aTolerance = SpinBox_Tolerance->GetValue();
409
410       try
411         {
412           SMESH::SMESH_MeshEditor_var aMeshEditor = myMesh->GetMeshEditor();
413           QApplication::setOverrideCursor(Qt::waitCursor);
414           aMeshEditor->RotationSweep(anElementsId.inout(), anAxis, anAngle, aNbSteps, aTolerance);
415           QApplication::restoreOverrideCursor();
416         }
417       catch( ... )
418         {
419         }
420       
421       mySelection->ClearIObjects();
422       SMESH::UpdateView();
423       Init();
424     }
425 }
426
427 //=================================================================================
428 // function : ClickOnOk()
429 // purpose  :
430 //=================================================================================
431 void SMESHGUI_RevolutionDlg::ClickOnOk()
432 {
433   this->ClickOnApply() ;
434   this->ClickOnCancel() ;
435 }
436
437         
438 //=================================================================================
439 // function : ClickOnCancel()
440 // purpose  :
441 //=================================================================================
442 void SMESHGUI_RevolutionDlg::ClickOnCancel()
443 {
444   mySelection->ClearFilters();
445   mySelection->ClearIObjects();
446   SMESH::SetPointRepresentation(false);
447   QAD_Application::getDesktop()->SetSelectionMode( ActorSelection );
448   disconnect( mySelection, 0, this, 0 );
449   mySMESHGUI->ResetState() ;
450   reject() ;
451 }
452
453 //=======================================================================
454 //function : onTextChange
455 //purpose  : 
456 //=======================================================================
457
458 void SMESHGUI_RevolutionDlg::onTextChange(const QString& theNewText)
459 {
460   QLineEdit* send = (QLineEdit*)sender();
461
462   if ( myBusy ) return;
463   myBusy = true;
464   
465   if (send == LineEditElements)
466     myNbOkElements = 0;
467   
468   buttonOk->setEnabled( false );
469   buttonApply->setEnabled( false );
470   
471   // hilight entered elements
472   SMDS_Mesh* aMesh = 0;
473   if ( myActor )
474     aMesh = myActor->GetObject()->GetMesh();
475   
476   if ( aMesh ) {
477     
478     mySelection->ClearIObjects();
479     mySelection->AddIObject( myActor->getIO() );
480     
481     QStringList aListId = QStringList::split( " ", theNewText, false);
482     
483     if (send == LineEditElements) {
484       for ( int i = 0; i < aListId.count(); i++ ) {
485         const SMDS_MeshElement * e = aMesh->FindElement( aListId[ i ].toInt() );
486         if ( e ) {
487           if ( !mySelection->IsIndexSelected( myActor->getIO(), e->GetID() ))
488             mySelection->AddOrRemoveIndex (myActor->getIO(), e->GetID(), true);
489           myNbOkElements++;
490         }
491       }
492     }
493   }
494   
495   if ( myNbOkElements &&  IsAxisOk() ) {
496     buttonOk->setEnabled( true );
497     buttonApply->setEnabled( true );
498   }
499   
500   myBusy = false;
501 }
502
503 //=================================================================================
504 // function : SelectionIntoArgument()
505 // purpose  : Called when selection as changed or other case
506 //=================================================================================
507 void SMESHGUI_RevolutionDlg::SelectionIntoArgument()
508 {
509   if ( myBusy ) return;
510   
511   // clear
512   
513   myActor = 0;
514   QString aString = "";
515
516   myBusy = true;
517   if (myEditCurrentArgument == (QWidget*)LineEditElements)
518     LineEditElements->setText( aString );
519   myBusy = false;
520   
521   if ( !GroupButtons->isEnabled() ) // inactive
522     return;
523   
524   // get selected mesh
525   int nbSel = mySelection->IObjectCount();
526   if(nbSel != 1)
527     return;
528   
529   Handle(SALOME_InteractiveObject) IO = mySelection->firstIObject();
530   myMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(IO) ;
531   myActor = SMESH::FindActorByEntry( mySelection->firstIObject()->getEntry() );
532   
533   if (myMesh->_is_nil() || !myActor)
534     return;
535   
536   int aNbUnits = 0;
537
538   if (myEditCurrentArgument == (QWidget*)LineEditElements)
539     {
540       buttonOk->setEnabled( false );
541       buttonApply->setEnabled( false );
542
543       // get selected elements
544       aNbUnits = SMESH::GetNameOfSelectedElements(mySelection, aString);
545       if(aNbUnits < 1) 
546         return ;
547       LineEditElements->setText( aString );
548     }
549   else 
550     {
551       aNbUnits = SMESH::GetNameOfSelectedNodes(mySelection, aString);
552       if(aNbUnits != 1)
553         return;
554       
555       SMDS_Mesh* aMesh =  myActor->GetObject()->GetMesh();
556       if (!aMesh)
557         return;
558
559       const SMDS_MeshNode * n = aMesh->FindNode( aString.toInt() );
560       if ( !n )
561         return;
562       
563       double x = n->X();
564       double y = n->Y();
565       double z = n->Z();
566
567       if (myEditCurrentArgument == (QWidget*)SpinBox_X)
568         {
569           SpinBox_X->SetValue(x);
570           SpinBox_Y->SetValue(y);
571           SpinBox_Z->SetValue(z);
572         }
573       else if (myEditCurrentArgument == (QWidget*)SpinBox_DX)
574         {
575           SpinBox_DX->SetValue(x - SpinBox_X->GetValue());
576           SpinBox_DY->SetValue(y - SpinBox_Y->GetValue());
577           SpinBox_DZ->SetValue(z - SpinBox_Z->GetValue());
578         }
579     }
580   
581   // OK
582   if (myEditCurrentArgument == (QWidget*)LineEditElements)
583     myNbOkElements = true;
584   
585   if(myNbOkElements && IsAxisOk())
586     {
587       buttonOk->setEnabled( true );
588       buttonApply->setEnabled( true );
589     }
590 }
591
592
593 //=================================================================================
594 // function : SetEditCurrentArgument()
595 // purpose  :
596 //=================================================================================
597 void SMESHGUI_RevolutionDlg::SetEditCurrentArgument()
598 {
599   QPushButton* send = (QPushButton*)sender();
600   disconnect( mySelection, 0, this, 0 );
601   mySelection->ClearIObjects();
602   mySelection->ClearFilters();
603   
604   if(send == SelectElementsButton) {
605     myEditCurrentArgument = (QWidget*)LineEditElements;
606     SMESH::SetPointRepresentation(false);
607     int aConstructorId = GetConstructorId();
608     if (aConstructorId == 0)
609       QAD_Application::getDesktop()->SetSelectionMode( EdgeSelection, true );
610     else if (aConstructorId == 1)
611       QAD_Application::getDesktop()->SetSelectionMode( FaceSelection, true );
612   }
613   else if (send == SelectPointButton)
614     {
615       myEditCurrentArgument = (QWidget*)SpinBox_X;
616       SMESH::SetPointRepresentation(true);
617       QAD_Application::getDesktop()->SetSelectionMode( NodeSelection, true );
618     }
619   else if (send == SelectVectorButton)
620     {
621       myEditCurrentArgument = (QWidget*)SpinBox_DX;
622       SMESH::SetPointRepresentation(true);
623       QAD_Application::getDesktop()->SetSelectionMode( NodeSelection, true );
624     }
625   
626   myEditCurrentArgument->setFocus();
627   connect( mySelection, SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) );
628   SelectionIntoArgument() ;
629 }
630
631 //=================================================================================
632 // function : DeactivateActiveDialog()
633 // purpose  :
634 //=================================================================================
635 void SMESHGUI_RevolutionDlg::DeactivateActiveDialog()
636 {
637   if ( GroupConstructors->isEnabled() ) {
638     GroupConstructors->setEnabled(false) ;
639     GroupArguments->setEnabled(false) ;
640     GroupButtons->setEnabled(false) ;
641     mySMESHGUI->ResetState() ;    
642     mySMESHGUI->SetActiveDialogBox(0) ;
643   }
644   return ;
645 }
646
647
648 //=================================================================================
649 // function : ActivateThisDialog()
650 // purpose  :
651 //=================================================================================
652 void SMESHGUI_RevolutionDlg::ActivateThisDialog()
653 {
654   /* Emit a signal to deactivate the active dialog */
655   mySMESHGUI->EmitSignalDeactivateDialog() ;   
656   GroupConstructors->setEnabled(true) ;
657   GroupArguments->setEnabled(true) ;
658   GroupButtons->setEnabled(true) ;
659   
660   mySMESHGUI->SetActiveDialogBox( (QDialog*)this ) ;
661
662   ConstructorsClicked(GetConstructorId());
663   SelectionIntoArgument();
664 }
665
666
667 //=================================================================================
668 // function : enterEvent()
669 // purpose  :
670 //=================================================================================
671 void SMESHGUI_RevolutionDlg::enterEvent(QEvent* e)
672 {
673   if ( GroupConstructors->isEnabled() )
674     return ;  
675   ActivateThisDialog() ;
676   return ;
677 }
678
679
680 //=================================================================================
681 // function : closeEvent()
682 // purpose  :
683 //=================================================================================
684 void SMESHGUI_RevolutionDlg::closeEvent( QCloseEvent* e )
685 {
686   /* same than click on cancel button */
687   this->ClickOnCancel() ;
688   return ;
689 }
690
691
692 //=======================================================================
693 //function : hideEvent
694 //purpose  : caused by ESC key
695 //=======================================================================
696
697 void SMESHGUI_RevolutionDlg::hideEvent ( QHideEvent * e )
698 {
699   if ( !isMinimized() )
700     ClickOnCancel();
701 }
702
703
704 //=================================================================================
705 // function : GetConstructorId()
706 // purpose  : 
707 //=================================================================================
708 int SMESHGUI_RevolutionDlg::GetConstructorId()
709
710   if ( GroupConstructors != NULL && GroupConstructors->selected() != NULL )
711     return GroupConstructors->id( GroupConstructors->selected() );
712   return -1;
713 }
714
715
716 //=================================================================================
717 // function : IsAxisOk()
718 // purpose  : 
719 //=================================================================================
720 bool SMESHGUI_RevolutionDlg::IsAxisOk()
721 {
722   return (SpinBox_DX->GetValue() != 0 || 
723           SpinBox_DY->GetValue() != 0 ||
724           SpinBox_DZ->GetValue() != 0); 
725 }
726
727
728 //=================================================================================
729 // function : onVectorChanged()
730 // purpose  : 
731 //=================================================================================
732 void SMESHGUI_RevolutionDlg::onVectorChanged()
733 {
734   if (IsAxisOk())
735     {
736       buttonOk->setEnabled( true );
737       buttonApply->setEnabled( true );
738     }
739   else
740     {
741       buttonOk->setEnabled( false );
742       buttonApply->setEnabled( false );
743     }
744 }
745