Salome HOME
NRI : First integration.
[modules/geom.git] / src / GEOMGUI / GeometryGUI_CylinderDlg.cxx
1 using namespace std;
2 //  File      : GeometryGUI_CylinderDlg.cxx
3 //  Created   :
4 //  Author    : Lucien PIGNOLONI
5 //  Project   : SALOME
6 //  Module    : GeometryGUI
7 //  Copyright : OPEN CASCADE
8 //  $Header$
9
10 #include "GeometryGUI_CylinderDlg.h"
11
12 #include "GeometryGUI.h"
13 #include "QAD_Application.h"
14 #include "QAD_Desktop.h"
15 #include "QAD_Config.h"
16 #include "utilities.h"
17
18 #include <BRepAdaptor_Curve.hxx>
19
20 #include <qbuttongroup.h>
21 #include <qgroupbox.h>
22 #include <qlabel.h>
23 #include <qlineedit.h>
24 #include <qpushbutton.h>
25 #include <qradiobutton.h>
26 #include <qlayout.h>
27 #include <qvariant.h>
28 #include <qtooltip.h>
29 #include <qwhatsthis.h>
30 #include <qimage.h>
31 #include <qpixmap.h>
32
33 //=================================================================================
34 // class    : GeometryGUI_CylinderDlg()
35 // purpose  : Constructs a GeometryGUI_CylinderDlg which is a child of 'parent', with the 
36 //            name 'name' and widget flags set to 'f'.
37 //            The dialog will by default be modeless, unless you set 'modal' to
38 //            TRUE to construct a modal dialog.
39 //=================================================================================
40 GeometryGUI_CylinderDlg::GeometryGUI_CylinderDlg( QWidget* parent, const char* name, SALOME_Selection* Sel, bool modal, WFlags fl )
41     : QDialog( parent, name, modal, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu )
42 {
43     QPixmap image0(QAD_Desktop::getResourceManager()->loadPixmap( "GeometryGUI",tr("ICON_DLG_CYLINDER_PV")));
44     QPixmap image1(QAD_Desktop::getResourceManager()->loadPixmap( "GeometryGUI",tr("ICON_SELECT")));
45     QPixmap image2(QAD_Desktop::getResourceManager()->loadPixmap( "GeometryGUI",tr("ICON_DLG_CYLINDER_DXYZ")));
46     
47     if ( !name )
48       setName( "GeometryGUI_CylinderDlg" );
49     resize( 303, 281 ); 
50     setCaption( tr( "GEOM_CYLINDER_TITLE"  ) );
51     setSizeGripEnabled( TRUE );
52     GeometryGUI_CylinderDlgLayout = new QGridLayout( this ); 
53     GeometryGUI_CylinderDlgLayout->setSpacing( 6 );
54     GeometryGUI_CylinderDlgLayout->setMargin( 11 );
55
56     /***************************************************************/
57     GroupButtons = new QGroupBox( this, "GroupButtons" );
58     GroupButtons->setGeometry( QRect( 10, 10, 281, 48 ) ); 
59     GroupButtons->setTitle( tr( ""  ) );
60     GroupButtons->setColumnLayout(0, Qt::Vertical );
61     GroupButtons->layout()->setSpacing( 0 );
62     GroupButtons->layout()->setMargin( 0 );
63     GroupButtonsLayout = new QGridLayout( GroupButtons->layout() );
64     GroupButtonsLayout->setAlignment( Qt::AlignTop );
65     GroupButtonsLayout->setSpacing( 6 );
66     GroupButtonsLayout->setMargin( 11 );
67     buttonCancel = new QPushButton( GroupButtons, "buttonCancel" );
68     buttonCancel->setText( tr( "GEOM_BUT_CLOSE"  ) );
69     buttonCancel->setAutoDefault( TRUE );
70     GroupButtonsLayout->addWidget( buttonCancel, 0, 3 );
71     buttonApply = new QPushButton( GroupButtons, "buttonApply" );
72     buttonApply->setText( tr( "GEOM_BUT_APPLY"  ) );
73     buttonApply->setAutoDefault( TRUE );
74     GroupButtonsLayout->addWidget( buttonApply, 0, 1 );
75     QSpacerItem* spacer = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum );
76     GroupButtonsLayout->addItem( spacer, 0, 2 );
77     buttonOk = new QPushButton( GroupButtons, "buttonOk" );
78     buttonOk->setText( tr( "GEOM_BUT_OK"  ) );
79     buttonOk->setAutoDefault( TRUE );
80     buttonOk->setDefault( TRUE );
81     GroupButtonsLayout->addWidget( buttonOk, 0, 0 );
82     GeometryGUI_CylinderDlgLayout->addWidget( GroupButtons, 2, 0 );
83
84     /***************************************************************/
85     GroupConstructors = new QButtonGroup( this, "GroupConstructors" );
86     GroupConstructors->setTitle( tr( "GEOM_CYLINDER"  ) );
87     GroupConstructors->setExclusive( TRUE );
88     GroupConstructors->setColumnLayout(0, Qt::Vertical );
89     GroupConstructors->layout()->setSpacing( 0 );
90     GroupConstructors->layout()->setMargin( 0 );
91     GroupConstructorsLayout = new QGridLayout( GroupConstructors->layout() );
92     GroupConstructorsLayout->setAlignment( Qt::AlignTop );
93     GroupConstructorsLayout->setSpacing( 6 );
94     GroupConstructorsLayout->setMargin( 11 );
95     QSpacerItem* spacer_2 = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum );
96     GroupConstructorsLayout->addItem( spacer_2, 0, 1 );
97     Constructor1 = new QRadioButton( GroupConstructors, "Constructor1" );
98     Constructor1->setText( tr( ""  ) );
99     Constructor1->setPixmap( image0 );
100     Constructor1->setChecked( TRUE );
101     Constructor1->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)3, (QSizePolicy::SizeType)0, Constructor1->sizePolicy().hasHeightForWidth() ) );
102     Constructor1->setMinimumSize( QSize( 50, 0 ) );
103     GroupConstructorsLayout->addWidget( Constructor1, 0, 0 );
104     Constructor2 = new QRadioButton( GroupConstructors, "Constructor2" );
105     Constructor2->setText( tr( ""  ) );
106     Constructor2->setMinimumSize( QSize( 50, 0 ) );
107     Constructor2->setPixmap( image2 );
108     Constructor2->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)3, (QSizePolicy::SizeType)0, Constructor1->sizePolicy().hasHeightForWidth() ) );
109     GroupConstructorsLayout->addWidget( Constructor2, 0, 2 );
110     QSpacerItem* spacer_3 = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum );
111     GroupConstructorsLayout->addItem( spacer_3, 0, 3 );
112     GeometryGUI_CylinderDlgLayout->addWidget( GroupConstructors, 0, 0 );
113     
114     /***************************************************************/
115     GroupC1 = new QGroupBox( this, "GroupC1" );
116     GroupC1->setTitle( tr( "GEOM_ARGUMENTS"  ) );
117     GroupC1->setColumnLayout(0, Qt::Vertical );
118     GroupC1->layout()->setSpacing( 0 );
119     GroupC1->layout()->setMargin( 0 );
120     GroupC1Layout = new QGridLayout( GroupC1->layout() );
121     GroupC1Layout->setAlignment( Qt::AlignTop );
122     GroupC1Layout->setSpacing( 6 );
123     GroupC1Layout->setMargin( 11 );
124     SelectButtonC1A1 = new QPushButton( GroupC1, "SelectButtonC1A1" );
125     SelectButtonC1A1->setText( tr( ""  ) );
126     SelectButtonC1A1->setPixmap( image1 );
127     GroupC1Layout->addWidget( SelectButtonC1A1, 0, 1 );
128     LineEditC1A1 = new QLineEdit( GroupC1, "LineEditC1A1" );
129     LineEditC1A1->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)3, (QSizePolicy::SizeType)0, LineEditC1A1->sizePolicy().hasHeightForWidth() ) );
130     GroupC1Layout->addWidget( LineEditC1A1, 0, 2 );
131     TextLabelC1A1 = new QLabel( GroupC1, "TextLabelC1A1" );
132     TextLabelC1A1->setText( tr( "GEOM_BASE_POINT"  ) );
133     TextLabelC1A1->setMinimumSize( QSize( 50, 0 ) );
134     TextLabelC1A1->setFrameShape( QLabel::NoFrame );
135     TextLabelC1A1->setFrameShadow( QLabel::Plain );
136     GroupC1Layout->addWidget( TextLabelC1A1, 0, 0 );
137     SelectButtonC1A2 = new QPushButton( GroupC1, "SelectButtonC1A2" );
138     SelectButtonC1A2->setText( tr( ""  ) );
139     SelectButtonC1A2->setMinimumSize( QSize( 0, 0 ) );
140     SelectButtonC1A2->setPixmap( image1 );
141     GroupC1Layout->addWidget( SelectButtonC1A2, 1, 1 );
142     LineEditC1A2 = new QLineEdit( GroupC1, "LineEditC1A2" );
143     LineEditC1A2->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)3, (QSizePolicy::SizeType)0, LineEditC1A2->sizePolicy().hasHeightForWidth() ) );
144     GroupC1Layout->addWidget( LineEditC1A2, 1, 2 );
145     TextLabelC1A2 = new QLabel( GroupC1, "TextLabelC1A2" );
146     TextLabelC1A2->setText( tr( "GEOM_VECTOR"  ) );
147     TextLabelC1A2->setMinimumSize( QSize( 50, 0 ) );
148     TextLabelC1A2->setFrameShape( QLabel::NoFrame );
149     TextLabelC1A2->setFrameShadow( QLabel::Plain );
150     GroupC1Layout->addWidget( TextLabelC1A2, 1, 0 );
151     TextLabelC1A3 = new QLabel( GroupC1, "TextLabelC1A3" );
152     TextLabelC1A3->setText( tr( "GEOM_RADIUS"  ) );
153     TextLabelC1A3->setMinimumSize( QSize( 50, 0 ) );
154     TextLabelC1A3->setFrameShape( QLabel::NoFrame );
155     TextLabelC1A3->setFrameShadow( QLabel::Plain );
156     GroupC1Layout->addWidget( TextLabelC1A3, 2, 0 );
157  
158     SpinBox_C1A3 = new GeometryGUI_SpinBox( GroupC1, "GeomSpinBox_C1A3" ) ;
159     GroupC1Layout->addWidget( SpinBox_C1A3, 2, 2 ) ;
160     
161     TextLabelC1A4 = new QLabel( GroupC1, "TextLabelC1A4" );
162     TextLabelC1A4->setText( tr( "GEOM_HEIGHT"  ) );
163     TextLabelC1A4->setMinimumSize( QSize( 50, 0 ) );
164     TextLabelC1A4->setFrameShape( QLabel::NoFrame );
165     TextLabelC1A4->setFrameShadow( QLabel::Plain );
166     GroupC1Layout->addWidget( TextLabelC1A4, 3, 0 );
167
168     SpinBox_C1A4 = new GeometryGUI_SpinBox( GroupC1, "GeomSpinBox_C1A4" ) ;
169     GroupC1Layout->addWidget( SpinBox_C1A4, 3, 2 );
170     
171     GeometryGUI_CylinderDlgLayout->addWidget( GroupC1, 1, 0 );
172
173     /***************************************************************/
174     GroupC2 = new QGroupBox( this, "GroupC2" );
175     GroupC2->setTitle( tr( "GEOM_BOX_OBJ"  ) );
176     GroupC2->setColumnLayout(0, Qt::Vertical );
177     GroupC2->layout()->setSpacing( 0 );
178     GroupC2->layout()->setMargin( 0 );
179     GroupC2Layout = new QGridLayout( GroupC2->layout() );
180     GroupC2Layout->setAlignment( Qt::AlignTop );
181     GroupC2Layout->setSpacing( 6 );
182     GroupC2Layout->setMargin( 11 );
183     TextLabel_Height = new QLabel(GroupC2 , "TextLabel_Height" );
184     TextLabel_Height->setText( tr( "GEOM_HEIGHT"  ) );
185     GroupC2Layout->addWidget( TextLabel_Height, 1, 0 );
186     TextLabel_Radius = new QLabel( GroupC2, "TextLabel_Radius" );
187     TextLabel_Radius->setText( tr( "GEOM_RADIUS"  ) );
188     GroupC2Layout->addWidget( TextLabel_Radius, 0, 0 );
189
190     SpinBox_Height = new GeometryGUI_SpinBox( GroupC2, "GeomSpinBox_Height" ) ;
191     SpinBox_Height->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)3, (QSizePolicy::SizeType)0, SpinBox_Height->sizePolicy().hasHeightForWidth() ) );
192     GroupC2Layout->addWidget( SpinBox_Height, 1, 1 ) ;
193
194     SpinBox_Radius = new GeometryGUI_SpinBox( GroupC2, "GeomSpinBox_Radius" ) ;
195     SpinBox_Radius->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)3, (QSizePolicy::SizeType)0, SpinBox_Radius->sizePolicy().hasHeightForWidth() ) );
196     GroupC2Layout->addWidget( SpinBox_Radius, 0, 1 ) ;
197
198     QSpacerItem* spacer1 = new QSpacerItem( 20, 62, QSizePolicy::Minimum, QSizePolicy::Fixed );
199     GroupC2Layout->addItem( spacer1 );
200
201     GeometryGUI_CylinderDlgLayout->addWidget(GroupC2 , 1, 0 );
202     /***************************************************************/
203
204     Init(Sel) ; /* Initialisations */
205 }
206
207
208 //=================================================================================
209 // function : ~GeometryGUI_CylinderDlg()
210 // purpose  : Destroys the object and frees any allocated resources
211 //=================================================================================
212 GeometryGUI_CylinderDlg::~GeometryGUI_CylinderDlg()
213 {
214     // no need to delete child widgets, Qt does it all for us
215 }
216
217
218 //=================================================================================
219 // function : Init()
220 // purpose  :
221 //=================================================================================
222 void GeometryGUI_CylinderDlg::Init( SALOME_Selection* Sel )
223 {
224
225   /* Get setting of step value from file configuration */
226   double step ;
227   QString St = QAD_CONFIG->getSetting( "Geometry:SettingsGeomStep" );
228   step = St.toDouble() ;
229
230   /* min, max, step and decimals for spin boxes & initial values */
231   /* First constructor : radius */
232   SpinBox_C1A3->RangeStepAndValidator( 0.001, 999.999, step, 3 ) ;
233   /* First constructor : algebric height */
234   SpinBox_C1A4->RangeStepAndValidator( -999.999, 999.999, step, 3 ) ;
235   /* Second constructor : radius */
236   SpinBox_Radius->RangeStepAndValidator( 0.001, 999.999, step, 3 ) ;
237   /* Second constructor : algebric height */
238   SpinBox_Height->RangeStepAndValidator( -999.999, 999.999, step, 3 ) ;
239
240   GroupC1->show();
241   GroupC2->hide();
242   myConstructorId = 0 ;
243   Constructor1->setChecked( TRUE );
244   myEditCurrentArgument = LineEditC1A1 ;        
245   mySelection = Sel;
246   myGeomGUI = GeometryGUI::GetGeometryGUI() ;
247
248   SpinBox_C1A3->SetValue( 100.0 ) ;  
249   SpinBox_C1A4->SetValue( 300.0 ) ;
250   SpinBox_Radius->SetValue( 100.0 ) ;  
251   SpinBox_Height->SetValue( 300.0 ) ;  
252   myRadius = 100.0 ;
253   myHeight = 300.0 ;
254
255   myOkRadius = true ;
256   myOkHeight = true ;  
257   myOkPoint1 = false ;
258   myOkDir    = false ;
259
260   mySimulationTopoDs.Nullify() ;
261   myGeomGUI->SetActiveDialogBox( (QDialog*)this ) ;
262
263   // TODO : previous selection into argument ?
264
265   /* Filter definitions */
266   Engines::Component_var comp = QAD_Application::getDesktop()->getEngine("FactoryServer", "Geometry");
267   myGeom = GEOM::GEOM_Gen::_narrow(comp);  
268   myEdgeFilter   = new GEOM_EdgeFilter( StdSelect_Line, myGeom );
269   myVertexFilter = new GEOM_ShapeTypeFilter( TopAbs_VERTEX, myGeom );
270
271   /* first filter used */
272   mySelection->AddFilter(myVertexFilter) ;
273
274   /* signals and slots connections */
275   connect( buttonOk, SIGNAL( clicked() ),     this, SLOT( ClickOnOk() ) );
276   connect( buttonCancel, SIGNAL( clicked() ), this, SLOT( ClickOnCancel() ) ) ;
277   connect( buttonApply,  SIGNAL( clicked() ), this, SLOT(ClickOnApply() ) );
278   connect( GroupConstructors, SIGNAL(clicked(int) ), SLOT( ConstructorsClicked(int) ) );  
279   connect( SelectButtonC1A1, SIGNAL (clicked() ), this, SLOT( SetEditCurrentArgument() ) ) ;
280   connect( SelectButtonC1A2, SIGNAL (clicked() ), this, SLOT( SetEditCurrentArgument() ) ) ;
281
282   connect( SpinBox_C1A3,   SIGNAL ( valueChanged( double) ), this, SLOT( ValueChangedInSpinBox( double) ) ) ;
283   connect( SpinBox_C1A4,   SIGNAL ( valueChanged( double) ), this, SLOT( ValueChangedInSpinBox( double) ) ) ;
284   connect( SpinBox_Radius, SIGNAL ( valueChanged( double) ), this, SLOT( ValueChangedInSpinBox( double) ) ) ;
285   connect( SpinBox_Height, SIGNAL ( valueChanged( double) ), this, SLOT( ValueChangedInSpinBox( double) ) ) ;
286
287   connect( LineEditC1A1, SIGNAL ( returnPressed() ), this, SLOT( LineEditReturnPressed() ) ) ;
288   connect( LineEditC1A2, SIGNAL ( returnPressed() ), this, SLOT( LineEditReturnPressed() ) ) ;
289
290   connect( myGeomGUI, SIGNAL ( SignalDeactivateActiveDialog() ), this, SLOT( DeactivateActiveDialog() ) ) ;  
291   connect( mySelection, SIGNAL( currentSelectionChanged() ),     this, SLOT( SelectionIntoArgument() ) );
292   /* to close dialog if study change */
293   connect( myGeomGUI, SIGNAL ( SignalCloseAllDialogs() ), this, SLOT( ClickOnCancel() ) ) ;
294
295   /* Move widget on the botton right corner of main widget */
296   int x, y ;
297   myGeomGUI->DefineDlgPosition( this, x, y ) ;
298   this->move( x, y ) ; 
299   this->show() ; /* displays Dialog */
300
301   return ;
302 }
303
304
305
306 //=================================================================================
307 // function : ConstructorsClicked()
308 // purpose  : Radio button management
309 //=================================================================================
310 void GeometryGUI_CylinderDlg::ConstructorsClicked(int constructorId)
311 {
312   mySelection->ClearFilters() ;
313   myGeomGUI->EraseSimulationShape() ;
314
315   switch(myConstructorId)
316     { 
317     case 0 :
318       { 
319         GroupC1->hide();
320         GroupC2->show();
321         myConstructorId = constructorId ;
322         myOkHeight = myOkRadius = myOkPoint1 = myOkDir = true ;
323         
324         SpinBox_Radius->SetValue( 100.0 ) ;  
325         SpinBox_Height->SetValue( 300.0 ) ; 
326         myRadius = 100.0 ;
327         myHeight = 300.0 ;
328
329         disconnect( mySelection, 0, this, 0 );
330
331         myPoint1.SetCoord( 0.0, 0.0, 0.0 ) ;
332         myDir.SetCoord( 0.0, 0.0, 1.0 ) ;
333
334         if( myOkPoint1 && myOkDir && myOkRadius && myOkHeight ) {
335           gp_Dir aDir = myDir ;
336           /* allows user to reverse direction of construction with a negative height */
337           if( this->myHeight < -Precision::Confusion() ) {
338             aDir.Reverse() ;
339           }
340           MakeCylinderSimulationAndDisplay() ;
341         } 
342         break ;
343       }
344     case 1 :
345       { 
346         GroupC2->hide();
347         GroupC1->show();
348         myConstructorId = constructorId ;
349         myEditCurrentArgument = LineEditC1A1 ;
350         myOkHeight = myOkRadius = true ;
351         myOkPoint1 = myOkDir = false ;
352         LineEditC1A1->setText( tr("") );
353         
354         SpinBox_C1A3->SetValue( 100.0 ) ;  
355         SpinBox_C1A4->SetValue( 300.0 ) ; 
356         myRadius = 100.0 ;
357         myHeight = 300.0 ;
358         disconnect( mySelection, 0, this, 0 );
359         break ;
360       }
361     }
362   return ;
363 }
364
365 //=================================================================================
366 // function : ClickOnOk()
367 // purpose  :
368 //=================================================================================
369 void GeometryGUI_CylinderDlg::ClickOnOk()
370 {
371   this->ClickOnApply() ;
372   this->ClickOnCancel() ;
373
374   return ;
375 }
376
377 //=================================================================================
378 // function : ClickOnApply()
379 // purpose  :
380 //=================================================================================
381 void GeometryGUI_CylinderDlg::ClickOnApply()
382 {
383   myGeomGUI->EraseSimulationShape() ;
384   mySimulationTopoDs.Nullify() ;
385   myGeomGUI->GetDesktop()->putInfo( tr("") ) ; 
386   switch(myConstructorId)
387     { 
388     case 0 :
389       { 
390         if( myOkPoint1 && myOkDir && myOkRadius && myOkHeight ) {
391           gp_Dir aDir = myDir ;
392           /* allows user to reverse direction of construction with a negative height */
393           if( this->myHeight < -Precision::Confusion() ) {
394             aDir.Reverse() ;
395           }
396           myGeomGUI->MakeCylinderAndDisplay( myPoint1, aDir, myRadius, fabs(myHeight) ) ; 
397         }
398         break ;
399       }
400     case 1 :
401       { 
402         if( myOkPoint1 && myOkDir && myOkRadius && myOkHeight ) {
403           gp_Dir aDir = myDir ;
404           /* allows user to reverse direction of construction with a negative height */
405           if( this->myHeight < -Precision::Confusion() ) {
406             aDir.Reverse() ;
407           }
408           myGeomGUI->MakeCylinderAndDisplay( myPoint1, aDir, myRadius, fabs(myHeight) ) ; 
409         }
410         break ;
411       }
412     }
413   // accept();
414   return ;
415 }
416
417
418 //=================================================================================
419 // function : ClickOnCancel()
420 // purpose  :
421 //=================================================================================
422 void GeometryGUI_CylinderDlg::ClickOnCancel()
423 {
424   mySelection->ClearFilters() ;
425   myGeomGUI->EraseSimulationShape() ;
426   mySimulationTopoDs.Nullify() ;
427   disconnect( mySelection, 0, this, 0 );
428   myGeomGUI->ResetState() ;
429   reject() ;
430   return ;
431 }
432
433
434 //=================================================================================
435 // function : SelectionIntoArgument()
436 // purpose  : Called when selection as changed or other case
437 //=================================================================================
438 void GeometryGUI_CylinderDlg::SelectionIntoArgument()
439 {
440   myGeomGUI->EraseSimulationShape() ; 
441   mySimulationTopoDs.Nullify() ;
442   
443   QString aString = ""; /* name of future selection */
444
445   int nbSel = myGeomGUI->GetNameOfSelectedIObjects(mySelection, aString) ;
446   if ( nbSel != 1 ) {
447     if ( myEditCurrentArgument == LineEditC1A1 ) {
448       LineEditC1A1->setText("") ;
449       myOkPoint1 = false ;
450     }
451     else if ( myEditCurrentArgument == LineEditC1A2 ) { 
452       LineEditC1A2->setText("") ;
453       myOkDir = false ;
454     }
455     return ;
456   }
457
458   /* nbSel == 1 */
459   TopoDS_Shape S;  
460   if( !myGeomGUI->GetTopoFromSelection(mySelection, S) )
461     return ;  
462  
463   /*  gp_Pnt : not used */
464   if ( myEditCurrentArgument == LineEditC1A1 && myGeomGUI->VertexToPoint(S, myPoint1) ) {
465     LineEditC1A1->setText(aString) ;
466     myOkPoint1 = true ;
467   }    
468   else if ( myEditCurrentArgument == LineEditC1A2 /*&& myGeomGUI->LinearLocationAndDirection(S, notUsed, myDir)*/ ) {
469     BRepAdaptor_Curve curv(TopoDS::Edge(S));
470     myDir = curv.Line().Direction();
471
472     LineEditC1A2->setText(aString) ;
473     myOkDir = true ;
474   }
475   
476   if( myOkPoint1 && myOkDir && myOkRadius && myOkHeight ) {
477     MakeCylinderSimulationAndDisplay() ;
478   }
479   return ;
480 }
481
482 //=================================================================================
483 // function : SetEditCurrentArgument()
484 // purpose  :
485 //=================================================================================
486 void GeometryGUI_CylinderDlg::SetEditCurrentArgument()
487 {
488   QPushButton* send = (QPushButton*)sender();
489   mySelection->ClearFilters() ;
490   switch (myConstructorId)
491     {
492     case 0: /* default constructor */
493       { 
494         if(send == SelectButtonC1A1) {
495           LineEditC1A1->setFocus() ;
496           myEditCurrentArgument = LineEditC1A1;
497           mySelection->AddFilter(myVertexFilter) ;
498         }
499         else if(send == SelectButtonC1A2) {
500           LineEditC1A2->setFocus() ;      
501           myEditCurrentArgument = LineEditC1A2;
502           mySelection->AddFilter(myEdgeFilter) ;
503         }       
504         SelectionIntoArgument() ;
505         break;
506       }
507      case 1:
508       { 
509         break ;
510       }
511     }
512
513   return ;
514 }
515
516 //=================================================================================
517 // function : LineEditReturnPressed()
518 // purpose  :
519 //=================================================================================
520 void GeometryGUI_CylinderDlg::LineEditReturnPressed()
521 {  
522   QLineEdit* send = (QLineEdit*)sender();  
523   if( send == LineEditC1A1 )
524     myEditCurrentArgument = LineEditC1A1 ;
525   else if ( send == LineEditC1A2 )
526     myEditCurrentArgument = LineEditC1A2 ; 
527   else
528     return ;
529   
530   /* User name of object input management                          */
531   /* If successfull the selection is changed and signal emitted... */
532   /* so SelectionIntoArgument() is automatically called.           */
533   QLineEdit* LE = (QLineEdit*)myEditCurrentArgument ;
534   const QString objectUserName = LE->text() ;
535   QWidget* thisWidget = (QWidget*)this ;
536   if( myGeomGUI->SelectionByNameInDialogs( thisWidget, objectUserName, mySelection ) ) {
537     LE->setText( objectUserName ) ;
538   }
539   return ;
540 }
541
542
543 //=================================================================================
544 // function : ValueChangedInSpinBox
545 // purpose  :
546 //=================================================================================
547 void GeometryGUI_CylinderDlg::ValueChangedInSpinBox( double newValue )
548 {  
549   
550   myGeomGUI->EraseSimulationShape() ; 
551   mySimulationTopoDs.Nullify() ;
552   QObject* send = (QObject*)sender();
553   
554   if(send == SpinBox_C1A3 ) { /* radius */
555
556     myRadius = newValue ;
557     myOkRadius = true ;
558     if (myOkPoint1 && myOkDir && myOkRadius && myOkHeight ) {
559       MakeCylinderSimulationAndDisplay() ;
560     }
561   } else if (send == SpinBox_C1A4 ) { /* algebric height */    
562     
563     myHeight = newValue ;
564     myOkHeight = true ;
565     if (myOkPoint1 && myOkDir && myOkRadius && myOkHeight ) {
566       MakeCylinderSimulationAndDisplay() ;
567     }
568   } 
569   else if (send == SpinBox_Height) { /* algebric height */
570
571     myOkHeight = true ;
572     myHeight = newValue ;
573     if (myOkPoint1 && myOkDir && myOkRadius && myOkHeight ) {
574       MakeCylinderSimulationAndDisplay() ;
575     }
576   } 
577   else if (send == SpinBox_Radius) { /* radius */
578     myRadius = newValue ;
579     myOkRadius = true ;
580     if (myOkPoint1 && myOkDir && myOkRadius && myOkHeight ) {
581       MakeCylinderSimulationAndDisplay() ;
582     }
583   } 
584   return ;
585 }
586
587 //=================================================================================
588 // function : DeactivateActiveDialog()
589 // purpose  :
590 //=================================================================================
591 void GeometryGUI_CylinderDlg::DeactivateActiveDialog()
592 {
593   if ( GroupConstructors->isEnabled() ) {
594     GroupConstructors->setEnabled(false) ;
595     GroupC1->setEnabled(false) ;
596     GroupC2->setEnabled(false) ;
597     GroupButtons->setEnabled(false) ;
598     disconnect( mySelection, 0, this, 0 );
599     myGeomGUI->EraseSimulationShape() ;
600     mySelection->ClearFilters() ;
601   }
602   return ;
603 }
604
605
606 //=================================================================================
607 // function : ActivateThisDialog()
608 // purpose  :
609 //=================================================================================
610 void GeometryGUI_CylinderDlg::ActivateThisDialog()
611 {
612   /* Emit a signal to deactivate the active dialog */
613   myGeomGUI->EmitSignalDeactivateDialog() ;   
614   GroupConstructors->setEnabled(true) ;
615   GroupC1->setEnabled(true) ;
616   GroupC2->setEnabled(true) ;
617   GroupButtons->setEnabled(true) ;
618   connect ( mySelection, SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) );
619   if( !mySimulationTopoDs.IsNull() )
620     myGeomGUI->DisplaySimulationShape( mySimulationTopoDs ) ;
621   return ;
622 }
623
624
625 //=================================================================================
626 // function : enterEvent()
627 // purpose  :
628 //=================================================================================
629 void GeometryGUI_CylinderDlg::enterEvent(QEvent* e)
630 {
631   if ( GroupConstructors->isEnabled() )
632     return ;  
633   ActivateThisDialog() ;
634   return ;
635 }
636
637
638 //=================================================================================
639 // function : closeEvent()
640 // purpose  :
641 //=================================================================================
642 void GeometryGUI_CylinderDlg::closeEvent( QCloseEvent* e )
643 {
644   /* same than click on cancel button */
645   this->ClickOnCancel() ;
646   return ;
647 }
648
649
650 //=================================================================================
651 // function : MakeCylinderSimulationAndDisplay()
652 // purpose  :
653 //=================================================================================
654 void GeometryGUI_CylinderDlg::MakeCylinderSimulationAndDisplay() 
655 {
656   myGeomGUI->EraseSimulationShape() ;
657   mySimulationTopoDs.Nullify() ;
658   gp_Dir aDir = this->myDir ;
659   
660   try {
661     /* allows user to reverse direction of construction with a negative height */
662     if( this->myHeight < -Precision::Confusion() ) {
663       aDir.Reverse() ;
664     }
665     gp_Ax2 anAxis(this->myPoint1, aDir) ;
666
667     mySimulationTopoDs = BRepPrimAPI_MakeCylinder( anAxis, this->myRadius, fabs(myHeight) ).Shape() ;
668     myGeomGUI->DisplaySimulationShape( mySimulationTopoDs ) ;
669   }
670   catch(Standard_Failure) {
671     MESSAGE( "Exception catched in MakeCylinderSimulationAndDisplay" ) ;
672   }
673   return ;
674 }
675