2 // File : GeometryGUI_CylinderDlg.cxx
4 // Author : Lucien PIGNOLONI
6 // Module : GeometryGUI
7 // Copyright : OPEN CASCADE
10 #include "GeometryGUI_CylinderDlg.h"
12 #include "GeometryGUI.h"
13 #include "QAD_Application.h"
14 #include "QAD_Desktop.h"
15 #include "QAD_Config.h"
16 #include "utilities.h"
18 #include <BRepAdaptor_Curve.hxx>
20 #include <qbuttongroup.h>
21 #include <qgroupbox.h>
23 #include <qlineedit.h>
24 #include <qpushbutton.h>
25 #include <qradiobutton.h>
29 #include <qwhatsthis.h>
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 )
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")));
48 setName( "GeometryGUI_CylinderDlg" );
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 );
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 );
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 );
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 );
158 SpinBox_C1A3 = new GeometryGUI_SpinBox( GroupC1, "GeomSpinBox_C1A3" ) ;
159 GroupC1Layout->addWidget( SpinBox_C1A3, 2, 2 ) ;
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 );
168 SpinBox_C1A4 = new GeometryGUI_SpinBox( GroupC1, "GeomSpinBox_C1A4" ) ;
169 GroupC1Layout->addWidget( SpinBox_C1A4, 3, 2 );
171 GeometryGUI_CylinderDlgLayout->addWidget( GroupC1, 1, 0 );
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 );
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 ) ;
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 ) ;
198 QSpacerItem* spacer1 = new QSpacerItem( 20, 62, QSizePolicy::Minimum, QSizePolicy::Fixed );
199 GroupC2Layout->addItem( spacer1 );
201 GeometryGUI_CylinderDlgLayout->addWidget(GroupC2 , 1, 0 );
202 /***************************************************************/
204 Init(Sel) ; /* Initialisations */
208 //=================================================================================
209 // function : ~GeometryGUI_CylinderDlg()
210 // purpose : Destroys the object and frees any allocated resources
211 //=================================================================================
212 GeometryGUI_CylinderDlg::~GeometryGUI_CylinderDlg()
214 // no need to delete child widgets, Qt does it all for us
218 //=================================================================================
221 //=================================================================================
222 void GeometryGUI_CylinderDlg::Init( SALOME_Selection* Sel )
225 /* Get setting of step value from file configuration */
227 QString St = QAD_CONFIG->getSetting( "Geometry:SettingsGeomStep" );
228 step = St.toDouble() ;
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 ) ;
242 myConstructorId = 0 ;
243 Constructor1->setChecked( TRUE );
244 myEditCurrentArgument = LineEditC1A1 ;
246 myGeomGUI = GeometryGUI::GetGeometryGUI() ;
248 SpinBox_C1A3->SetValue( 100.0 ) ;
249 SpinBox_C1A4->SetValue( 300.0 ) ;
250 SpinBox_Radius->SetValue( 100.0 ) ;
251 SpinBox_Height->SetValue( 300.0 ) ;
260 mySimulationTopoDs.Nullify() ;
261 myGeomGUI->SetActiveDialogBox( (QDialog*)this ) ;
263 // TODO : previous selection into argument ?
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 );
271 /* first filter used */
272 mySelection->AddFilter(myVertexFilter) ;
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() ) ) ;
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) ) ) ;
287 connect( LineEditC1A1, SIGNAL ( returnPressed() ), this, SLOT( LineEditReturnPressed() ) ) ;
288 connect( LineEditC1A2, SIGNAL ( returnPressed() ), this, SLOT( LineEditReturnPressed() ) ) ;
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() ) ) ;
295 /* Move widget on the botton right corner of main widget */
297 myGeomGUI->DefineDlgPosition( this, x, y ) ;
299 this->show() ; /* displays Dialog */
306 //=================================================================================
307 // function : ConstructorsClicked()
308 // purpose : Radio button management
309 //=================================================================================
310 void GeometryGUI_CylinderDlg::ConstructorsClicked(int constructorId)
312 mySelection->ClearFilters() ;
313 myGeomGUI->EraseSimulationShape() ;
315 switch(myConstructorId)
321 myConstructorId = constructorId ;
322 myOkHeight = myOkRadius = myOkPoint1 = myOkDir = true ;
324 SpinBox_Radius->SetValue( 100.0 ) ;
325 SpinBox_Height->SetValue( 300.0 ) ;
329 disconnect( mySelection, 0, this, 0 );
331 myPoint1.SetCoord( 0.0, 0.0, 0.0 ) ;
332 myDir.SetCoord( 0.0, 0.0, 1.0 ) ;
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() ) {
340 MakeCylinderSimulationAndDisplay() ;
348 myConstructorId = constructorId ;
349 myEditCurrentArgument = LineEditC1A1 ;
350 myOkHeight = myOkRadius = true ;
351 myOkPoint1 = myOkDir = false ;
352 LineEditC1A1->setText( tr("") );
354 SpinBox_C1A3->SetValue( 100.0 ) ;
355 SpinBox_C1A4->SetValue( 300.0 ) ;
358 disconnect( mySelection, 0, this, 0 );
365 //=================================================================================
366 // function : ClickOnOk()
368 //=================================================================================
369 void GeometryGUI_CylinderDlg::ClickOnOk()
371 this->ClickOnApply() ;
372 this->ClickOnCancel() ;
377 //=================================================================================
378 // function : ClickOnApply()
380 //=================================================================================
381 void GeometryGUI_CylinderDlg::ClickOnApply()
383 myGeomGUI->EraseSimulationShape() ;
384 mySimulationTopoDs.Nullify() ;
385 myGeomGUI->GetDesktop()->putInfo( tr("") ) ;
386 switch(myConstructorId)
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() ) {
396 myGeomGUI->MakeCylinderAndDisplay( myPoint1, aDir, myRadius, fabs(myHeight) ) ;
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() ) {
408 myGeomGUI->MakeCylinderAndDisplay( myPoint1, aDir, myRadius, fabs(myHeight) ) ;
418 //=================================================================================
419 // function : ClickOnCancel()
421 //=================================================================================
422 void GeometryGUI_CylinderDlg::ClickOnCancel()
424 mySelection->ClearFilters() ;
425 myGeomGUI->EraseSimulationShape() ;
426 mySimulationTopoDs.Nullify() ;
427 disconnect( mySelection, 0, this, 0 );
428 myGeomGUI->ResetState() ;
434 //=================================================================================
435 // function : SelectionIntoArgument()
436 // purpose : Called when selection as changed or other case
437 //=================================================================================
438 void GeometryGUI_CylinderDlg::SelectionIntoArgument()
440 myGeomGUI->EraseSimulationShape() ;
441 mySimulationTopoDs.Nullify() ;
443 QString aString = ""; /* name of future selection */
445 int nbSel = myGeomGUI->GetNameOfSelectedIObjects(mySelection, aString) ;
447 if ( myEditCurrentArgument == LineEditC1A1 ) {
448 LineEditC1A1->setText("") ;
451 else if ( myEditCurrentArgument == LineEditC1A2 ) {
452 LineEditC1A2->setText("") ;
460 if( !myGeomGUI->GetTopoFromSelection(mySelection, S) )
463 /* gp_Pnt : not used */
464 if ( myEditCurrentArgument == LineEditC1A1 && myGeomGUI->VertexToPoint(S, myPoint1) ) {
465 LineEditC1A1->setText(aString) ;
468 else if ( myEditCurrentArgument == LineEditC1A2 /*&& myGeomGUI->LinearLocationAndDirection(S, notUsed, myDir)*/ ) {
469 BRepAdaptor_Curve curv(TopoDS::Edge(S));
470 myDir = curv.Line().Direction();
472 LineEditC1A2->setText(aString) ;
476 if( myOkPoint1 && myOkDir && myOkRadius && myOkHeight ) {
477 MakeCylinderSimulationAndDisplay() ;
482 //=================================================================================
483 // function : SetEditCurrentArgument()
485 //=================================================================================
486 void GeometryGUI_CylinderDlg::SetEditCurrentArgument()
488 QPushButton* send = (QPushButton*)sender();
489 mySelection->ClearFilters() ;
490 switch (myConstructorId)
492 case 0: /* default constructor */
494 if(send == SelectButtonC1A1) {
495 LineEditC1A1->setFocus() ;
496 myEditCurrentArgument = LineEditC1A1;
497 mySelection->AddFilter(myVertexFilter) ;
499 else if(send == SelectButtonC1A2) {
500 LineEditC1A2->setFocus() ;
501 myEditCurrentArgument = LineEditC1A2;
502 mySelection->AddFilter(myEdgeFilter) ;
504 SelectionIntoArgument() ;
516 //=================================================================================
517 // function : LineEditReturnPressed()
519 //=================================================================================
520 void GeometryGUI_CylinderDlg::LineEditReturnPressed()
522 QLineEdit* send = (QLineEdit*)sender();
523 if( send == LineEditC1A1 )
524 myEditCurrentArgument = LineEditC1A1 ;
525 else if ( send == LineEditC1A2 )
526 myEditCurrentArgument = LineEditC1A2 ;
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 ) ;
543 //=================================================================================
544 // function : ValueChangedInSpinBox
546 //=================================================================================
547 void GeometryGUI_CylinderDlg::ValueChangedInSpinBox( double newValue )
550 myGeomGUI->EraseSimulationShape() ;
551 mySimulationTopoDs.Nullify() ;
552 QObject* send = (QObject*)sender();
554 if(send == SpinBox_C1A3 ) { /* radius */
556 myRadius = newValue ;
558 if (myOkPoint1 && myOkDir && myOkRadius && myOkHeight ) {
559 MakeCylinderSimulationAndDisplay() ;
561 } else if (send == SpinBox_C1A4 ) { /* algebric height */
563 myHeight = newValue ;
565 if (myOkPoint1 && myOkDir && myOkRadius && myOkHeight ) {
566 MakeCylinderSimulationAndDisplay() ;
569 else if (send == SpinBox_Height) { /* algebric height */
572 myHeight = newValue ;
573 if (myOkPoint1 && myOkDir && myOkRadius && myOkHeight ) {
574 MakeCylinderSimulationAndDisplay() ;
577 else if (send == SpinBox_Radius) { /* radius */
578 myRadius = newValue ;
580 if (myOkPoint1 && myOkDir && myOkRadius && myOkHeight ) {
581 MakeCylinderSimulationAndDisplay() ;
587 //=================================================================================
588 // function : DeactivateActiveDialog()
590 //=================================================================================
591 void GeometryGUI_CylinderDlg::DeactivateActiveDialog()
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() ;
606 //=================================================================================
607 // function : ActivateThisDialog()
609 //=================================================================================
610 void GeometryGUI_CylinderDlg::ActivateThisDialog()
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 ) ;
625 //=================================================================================
626 // function : enterEvent()
628 //=================================================================================
629 void GeometryGUI_CylinderDlg::enterEvent(QEvent* e)
631 if ( GroupConstructors->isEnabled() )
633 ActivateThisDialog() ;
638 //=================================================================================
639 // function : closeEvent()
641 //=================================================================================
642 void GeometryGUI_CylinderDlg::closeEvent( QCloseEvent* e )
644 /* same than click on cancel button */
645 this->ClickOnCancel() ;
650 //=================================================================================
651 // function : MakeCylinderSimulationAndDisplay()
653 //=================================================================================
654 void GeometryGUI_CylinderDlg::MakeCylinderSimulationAndDisplay()
656 myGeomGUI->EraseSimulationShape() ;
657 mySimulationTopoDs.Nullify() ;
658 gp_Dir aDir = this->myDir ;
661 /* allows user to reverse direction of construction with a negative height */
662 if( this->myHeight < -Precision::Confusion() ) {
665 gp_Ax2 anAxis(this->myPoint1, aDir) ;
667 mySimulationTopoDs = BRepPrimAPI_MakeCylinder( anAxis, this->myRadius, fabs(myHeight) ).Shape() ;
668 myGeomGUI->DisplaySimulationShape( mySimulationTopoDs ) ;
670 catch(Standard_Failure) {
671 MESSAGE( "Exception catched in MakeCylinderSimulationAndDisplay" ) ;