1 // GEOM GEOMGUI : GUI for Geometry component
3 // Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
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.
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.
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
20 // See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
24 // File : GeometryGUI_CylinderDlg.cxx
25 // Author : Lucien PIGNOLONI
30 #include "GeometryGUI_CylinderDlg.h"
32 #include "GeometryGUI.h"
33 #include "QAD_Application.h"
34 #include "QAD_Desktop.h"
35 #include "QAD_Config.h"
36 #include "utilities.h"
38 #include <BRepAdaptor_Curve.hxx>
40 #include <qbuttongroup.h>
41 #include <qgroupbox.h>
43 #include <qlineedit.h>
44 #include <qpushbutton.h>
45 #include <qradiobutton.h>
49 #include <qwhatsthis.h>
53 //=================================================================================
54 // class : GeometryGUI_CylinderDlg()
55 // purpose : Constructs a GeometryGUI_CylinderDlg which is a child of 'parent', with the
56 // name 'name' and widget flags set to 'f'.
57 // The dialog will by default be modeless, unless you set 'modal' to
58 // TRUE to construct a modal dialog.
59 //=================================================================================
60 GeometryGUI_CylinderDlg::GeometryGUI_CylinderDlg( QWidget* parent, const char* name, SALOME_Selection* Sel, bool modal, WFlags fl )
61 : QDialog( parent, name, modal, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu )
63 QPixmap image0(QAD_Desktop::getResourceManager()->loadPixmap( "GeometryGUI",tr("ICON_DLG_CYLINDER_PV")));
64 QPixmap image1(QAD_Desktop::getResourceManager()->loadPixmap( "GeometryGUI",tr("ICON_SELECT")));
65 QPixmap image2(QAD_Desktop::getResourceManager()->loadPixmap( "GeometryGUI",tr("ICON_DLG_CYLINDER_DXYZ")));
68 setName( "GeometryGUI_CylinderDlg" );
70 setCaption( tr( "GEOM_CYLINDER_TITLE" ) );
71 setSizeGripEnabled( TRUE );
72 GeometryGUI_CylinderDlgLayout = new QGridLayout( this );
73 GeometryGUI_CylinderDlgLayout->setSpacing( 6 );
74 GeometryGUI_CylinderDlgLayout->setMargin( 11 );
76 /***************************************************************/
77 GroupButtons = new QGroupBox( this, "GroupButtons" );
78 GroupButtons->setGeometry( QRect( 10, 10, 281, 48 ) );
79 GroupButtons->setTitle( tr( "" ) );
80 GroupButtons->setColumnLayout(0, Qt::Vertical );
81 GroupButtons->layout()->setSpacing( 0 );
82 GroupButtons->layout()->setMargin( 0 );
83 GroupButtonsLayout = new QGridLayout( GroupButtons->layout() );
84 GroupButtonsLayout->setAlignment( Qt::AlignTop );
85 GroupButtonsLayout->setSpacing( 6 );
86 GroupButtonsLayout->setMargin( 11 );
87 buttonCancel = new QPushButton( GroupButtons, "buttonCancel" );
88 buttonCancel->setText( tr( "GEOM_BUT_CLOSE" ) );
89 buttonCancel->setAutoDefault( TRUE );
90 GroupButtonsLayout->addWidget( buttonCancel, 0, 3 );
91 buttonApply = new QPushButton( GroupButtons, "buttonApply" );
92 buttonApply->setText( tr( "GEOM_BUT_APPLY" ) );
93 buttonApply->setAutoDefault( TRUE );
94 GroupButtonsLayout->addWidget( buttonApply, 0, 1 );
95 QSpacerItem* spacer = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum );
96 GroupButtonsLayout->addItem( spacer, 0, 2 );
97 buttonOk = new QPushButton( GroupButtons, "buttonOk" );
98 buttonOk->setText( tr( "GEOM_BUT_OK" ) );
99 buttonOk->setAutoDefault( TRUE );
100 buttonOk->setDefault( TRUE );
101 GroupButtonsLayout->addWidget( buttonOk, 0, 0 );
102 GeometryGUI_CylinderDlgLayout->addWidget( GroupButtons, 2, 0 );
104 /***************************************************************/
105 GroupConstructors = new QButtonGroup( this, "GroupConstructors" );
106 GroupConstructors->setTitle( tr( "GEOM_CYLINDER" ) );
107 GroupConstructors->setExclusive( TRUE );
108 GroupConstructors->setColumnLayout(0, Qt::Vertical );
109 GroupConstructors->layout()->setSpacing( 0 );
110 GroupConstructors->layout()->setMargin( 0 );
111 GroupConstructorsLayout = new QGridLayout( GroupConstructors->layout() );
112 GroupConstructorsLayout->setAlignment( Qt::AlignTop );
113 GroupConstructorsLayout->setSpacing( 6 );
114 GroupConstructorsLayout->setMargin( 11 );
115 QSpacerItem* spacer_2 = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum );
116 GroupConstructorsLayout->addItem( spacer_2, 0, 1 );
117 Constructor1 = new QRadioButton( GroupConstructors, "Constructor1" );
118 Constructor1->setText( tr( "" ) );
119 Constructor1->setPixmap( image0 );
120 Constructor1->setChecked( TRUE );
121 Constructor1->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)3, (QSizePolicy::SizeType)0, Constructor1->sizePolicy().hasHeightForWidth() ) );
122 Constructor1->setMinimumSize( QSize( 50, 0 ) );
123 GroupConstructorsLayout->addWidget( Constructor1, 0, 0 );
124 Constructor2 = new QRadioButton( GroupConstructors, "Constructor2" );
125 Constructor2->setText( tr( "" ) );
126 Constructor2->setMinimumSize( QSize( 50, 0 ) );
127 Constructor2->setPixmap( image2 );
128 Constructor2->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)3, (QSizePolicy::SizeType)0, Constructor1->sizePolicy().hasHeightForWidth() ) );
129 GroupConstructorsLayout->addWidget( Constructor2, 0, 2 );
130 QSpacerItem* spacer_3 = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum );
131 GroupConstructorsLayout->addItem( spacer_3, 0, 3 );
132 GeometryGUI_CylinderDlgLayout->addWidget( GroupConstructors, 0, 0 );
134 /***************************************************************/
135 GroupC1 = new QGroupBox( this, "GroupC1" );
136 GroupC1->setTitle( tr( "GEOM_ARGUMENTS" ) );
137 GroupC1->setColumnLayout(0, Qt::Vertical );
138 GroupC1->layout()->setSpacing( 0 );
139 GroupC1->layout()->setMargin( 0 );
140 GroupC1Layout = new QGridLayout( GroupC1->layout() );
141 GroupC1Layout->setAlignment( Qt::AlignTop );
142 GroupC1Layout->setSpacing( 6 );
143 GroupC1Layout->setMargin( 11 );
144 SelectButtonC1A1 = new QPushButton( GroupC1, "SelectButtonC1A1" );
145 SelectButtonC1A1->setText( tr( "" ) );
146 SelectButtonC1A1->setPixmap( image1 );
147 GroupC1Layout->addWidget( SelectButtonC1A1, 0, 1 );
148 LineEditC1A1 = new QLineEdit( GroupC1, "LineEditC1A1" );
149 LineEditC1A1->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)3, (QSizePolicy::SizeType)0, LineEditC1A1->sizePolicy().hasHeightForWidth() ) );
150 GroupC1Layout->addWidget( LineEditC1A1, 0, 2 );
151 TextLabelC1A1 = new QLabel( GroupC1, "TextLabelC1A1" );
152 TextLabelC1A1->setText( tr( "GEOM_BASE_POINT" ) );
153 TextLabelC1A1->setMinimumSize( QSize( 50, 0 ) );
154 TextLabelC1A1->setFrameShape( QLabel::NoFrame );
155 TextLabelC1A1->setFrameShadow( QLabel::Plain );
156 GroupC1Layout->addWidget( TextLabelC1A1, 0, 0 );
157 SelectButtonC1A2 = new QPushButton( GroupC1, "SelectButtonC1A2" );
158 SelectButtonC1A2->setText( tr( "" ) );
159 SelectButtonC1A2->setMinimumSize( QSize( 0, 0 ) );
160 SelectButtonC1A2->setPixmap( image1 );
161 GroupC1Layout->addWidget( SelectButtonC1A2, 1, 1 );
162 LineEditC1A2 = new QLineEdit( GroupC1, "LineEditC1A2" );
163 LineEditC1A2->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)3, (QSizePolicy::SizeType)0, LineEditC1A2->sizePolicy().hasHeightForWidth() ) );
164 GroupC1Layout->addWidget( LineEditC1A2, 1, 2 );
165 TextLabelC1A2 = new QLabel( GroupC1, "TextLabelC1A2" );
166 TextLabelC1A2->setText( tr( "GEOM_VECTOR" ) );
167 TextLabelC1A2->setMinimumSize( QSize( 50, 0 ) );
168 TextLabelC1A2->setFrameShape( QLabel::NoFrame );
169 TextLabelC1A2->setFrameShadow( QLabel::Plain );
170 GroupC1Layout->addWidget( TextLabelC1A2, 1, 0 );
171 TextLabelC1A3 = new QLabel( GroupC1, "TextLabelC1A3" );
172 TextLabelC1A3->setText( tr( "GEOM_RADIUS" ) );
173 TextLabelC1A3->setMinimumSize( QSize( 50, 0 ) );
174 TextLabelC1A3->setFrameShape( QLabel::NoFrame );
175 TextLabelC1A3->setFrameShadow( QLabel::Plain );
176 GroupC1Layout->addWidget( TextLabelC1A3, 2, 0 );
178 SpinBox_C1A3 = new GeometryGUI_SpinBox( GroupC1, "GeomSpinBox_C1A3" ) ;
179 GroupC1Layout->addWidget( SpinBox_C1A3, 2, 2 ) ;
181 TextLabelC1A4 = new QLabel( GroupC1, "TextLabelC1A4" );
182 TextLabelC1A4->setText( tr( "GEOM_HEIGHT" ) );
183 TextLabelC1A4->setMinimumSize( QSize( 50, 0 ) );
184 TextLabelC1A4->setFrameShape( QLabel::NoFrame );
185 TextLabelC1A4->setFrameShadow( QLabel::Plain );
186 GroupC1Layout->addWidget( TextLabelC1A4, 3, 0 );
188 SpinBox_C1A4 = new GeometryGUI_SpinBox( GroupC1, "GeomSpinBox_C1A4" ) ;
189 GroupC1Layout->addWidget( SpinBox_C1A4, 3, 2 );
191 GeometryGUI_CylinderDlgLayout->addWidget( GroupC1, 1, 0 );
193 /***************************************************************/
194 GroupC2 = new QGroupBox( this, "GroupC2" );
195 GroupC2->setTitle( tr( "GEOM_BOX_OBJ" ) );
196 GroupC2->setColumnLayout(0, Qt::Vertical );
197 GroupC2->layout()->setSpacing( 0 );
198 GroupC2->layout()->setMargin( 0 );
199 GroupC2Layout = new QGridLayout( GroupC2->layout() );
200 GroupC2Layout->setAlignment( Qt::AlignTop );
201 GroupC2Layout->setSpacing( 6 );
202 GroupC2Layout->setMargin( 11 );
203 TextLabel_Height = new QLabel(GroupC2 , "TextLabel_Height" );
204 TextLabel_Height->setText( tr( "GEOM_HEIGHT" ) );
205 GroupC2Layout->addWidget( TextLabel_Height, 1, 0 );
206 TextLabel_Radius = new QLabel( GroupC2, "TextLabel_Radius" );
207 TextLabel_Radius->setText( tr( "GEOM_RADIUS" ) );
208 GroupC2Layout->addWidget( TextLabel_Radius, 0, 0 );
210 SpinBox_Height = new GeometryGUI_SpinBox( GroupC2, "GeomSpinBox_Height" ) ;
211 SpinBox_Height->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)3, (QSizePolicy::SizeType)0, SpinBox_Height->sizePolicy().hasHeightForWidth() ) );
212 GroupC2Layout->addWidget( SpinBox_Height, 1, 1 ) ;
214 SpinBox_Radius = new GeometryGUI_SpinBox( GroupC2, "GeomSpinBox_Radius" ) ;
215 SpinBox_Radius->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)3, (QSizePolicy::SizeType)0, SpinBox_Radius->sizePolicy().hasHeightForWidth() ) );
216 GroupC2Layout->addWidget( SpinBox_Radius, 0, 1 ) ;
218 QSpacerItem* spacer1 = new QSpacerItem( 20, 62, QSizePolicy::Minimum, QSizePolicy::Fixed );
219 GroupC2Layout->addItem( spacer1 );
221 GeometryGUI_CylinderDlgLayout->addWidget(GroupC2 , 1, 0 );
222 /***************************************************************/
224 Init(Sel) ; /* Initialisations */
228 //=================================================================================
229 // function : ~GeometryGUI_CylinderDlg()
230 // purpose : Destroys the object and frees any allocated resources
231 //=================================================================================
232 GeometryGUI_CylinderDlg::~GeometryGUI_CylinderDlg()
234 // no need to delete child widgets, Qt does it all for us
238 //=================================================================================
241 //=================================================================================
242 void GeometryGUI_CylinderDlg::Init( SALOME_Selection* Sel )
245 /* Get setting of step value from file configuration */
247 QString St = QAD_CONFIG->getSetting( "Geometry:SettingsGeomStep" );
248 step = St.toDouble() ;
250 /* min, max, step and decimals for spin boxes & initial values */
251 /* First constructor : radius */
252 SpinBox_C1A3->RangeStepAndValidator( 0.001, 999.999, step, 3 ) ;
253 /* First constructor : algebric height */
254 SpinBox_C1A4->RangeStepAndValidator( -999.999, 999.999, step, 3 ) ;
255 /* Second constructor : radius */
256 SpinBox_Radius->RangeStepAndValidator( 0.001, 999.999, step, 3 ) ;
257 /* Second constructor : algebric height */
258 SpinBox_Height->RangeStepAndValidator( -999.999, 999.999, step, 3 ) ;
262 myConstructorId = 0 ;
263 Constructor1->setChecked( TRUE );
264 myEditCurrentArgument = LineEditC1A1 ;
266 myGeomGUI = GeometryGUI::GetGeometryGUI() ;
268 SpinBox_C1A3->SetValue( 100.0 ) ;
269 SpinBox_C1A4->SetValue( 300.0 ) ;
270 SpinBox_Radius->SetValue( 100.0 ) ;
271 SpinBox_Height->SetValue( 300.0 ) ;
280 mySimulationTopoDs.Nullify() ;
281 myGeomGUI->SetActiveDialogBox( (QDialog*)this ) ;
283 // TODO : previous selection into argument ?
285 /* Filter definitions */
286 Engines::Component_var comp = QAD_Application::getDesktop()->getEngine("FactoryServer", "Geometry");
287 myGeom = GEOM::GEOM_Gen::_narrow(comp);
288 myEdgeFilter = new GEOM_EdgeFilter( StdSelect_Line, myGeom );
289 myVertexFilter = new GEOM_ShapeTypeFilter( TopAbs_VERTEX, myGeom );
291 /* first filter used */
292 mySelection->AddFilter(myVertexFilter) ;
294 /* signals and slots connections */
295 connect( buttonOk, SIGNAL( clicked() ), this, SLOT( ClickOnOk() ) );
296 connect( buttonCancel, SIGNAL( clicked() ), this, SLOT( ClickOnCancel() ) ) ;
297 connect( buttonApply, SIGNAL( clicked() ), this, SLOT(ClickOnApply() ) );
298 connect( GroupConstructors, SIGNAL(clicked(int) ), SLOT( ConstructorsClicked(int) ) );
299 connect( SelectButtonC1A1, SIGNAL (clicked() ), this, SLOT( SetEditCurrentArgument() ) ) ;
300 connect( SelectButtonC1A2, SIGNAL (clicked() ), this, SLOT( SetEditCurrentArgument() ) ) ;
302 connect( SpinBox_C1A3, SIGNAL ( valueChanged( double) ), this, SLOT( ValueChangedInSpinBox( double) ) ) ;
303 connect( SpinBox_C1A4, SIGNAL ( valueChanged( double) ), this, SLOT( ValueChangedInSpinBox( double) ) ) ;
304 connect( SpinBox_Radius, SIGNAL ( valueChanged( double) ), this, SLOT( ValueChangedInSpinBox( double) ) ) ;
305 connect( SpinBox_Height, SIGNAL ( valueChanged( double) ), this, SLOT( ValueChangedInSpinBox( double) ) ) ;
307 connect( LineEditC1A1, SIGNAL ( returnPressed() ), this, SLOT( LineEditReturnPressed() ) ) ;
308 connect( LineEditC1A2, SIGNAL ( returnPressed() ), this, SLOT( LineEditReturnPressed() ) ) ;
310 connect( myGeomGUI, SIGNAL ( SignalDeactivateActiveDialog() ), this, SLOT( DeactivateActiveDialog() ) ) ;
311 connect( mySelection, SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) );
312 /* to close dialog if study change */
313 connect( myGeomGUI, SIGNAL ( SignalCloseAllDialogs() ), this, SLOT( ClickOnCancel() ) ) ;
315 /* Move widget on the botton right corner of main widget */
317 myGeomGUI->DefineDlgPosition( this, x, y ) ;
319 this->show() ; /* displays Dialog */
326 //=================================================================================
327 // function : ConstructorsClicked()
328 // purpose : Radio button management
329 //=================================================================================
330 void GeometryGUI_CylinderDlg::ConstructorsClicked(int constructorId)
332 mySelection->ClearFilters() ;
333 myGeomGUI->EraseSimulationShape() ;
335 switch(myConstructorId)
341 myConstructorId = constructorId ;
342 myOkHeight = myOkRadius = myOkPoint1 = myOkDir = true ;
344 SpinBox_Radius->SetValue( 100.0 ) ;
345 SpinBox_Height->SetValue( 300.0 ) ;
349 disconnect( mySelection, 0, this, 0 );
351 myPoint1.SetCoord( 0.0, 0.0, 0.0 ) ;
352 myDir.SetCoord( 0.0, 0.0, 1.0 ) ;
354 if( myOkPoint1 && myOkDir && myOkRadius && myOkHeight ) {
355 gp_Dir aDir = myDir ;
356 /* allows user to reverse direction of construction with a negative height */
357 if( this->myHeight < -Precision::Confusion() ) {
360 MakeCylinderSimulationAndDisplay() ;
368 myConstructorId = constructorId ;
369 myEditCurrentArgument = LineEditC1A1 ;
370 myOkHeight = myOkRadius = true ;
371 myOkPoint1 = myOkDir = false ;
372 LineEditC1A1->setText( tr("") );
374 SpinBox_C1A3->SetValue( 100.0 ) ;
375 SpinBox_C1A4->SetValue( 300.0 ) ;
378 disconnect( mySelection, 0, this, 0 );
385 //=================================================================================
386 // function : ClickOnOk()
388 //=================================================================================
389 void GeometryGUI_CylinderDlg::ClickOnOk()
391 this->ClickOnApply() ;
392 this->ClickOnCancel() ;
397 //=================================================================================
398 // function : ClickOnApply()
400 //=================================================================================
401 void GeometryGUI_CylinderDlg::ClickOnApply()
403 myGeomGUI->EraseSimulationShape() ;
404 mySimulationTopoDs.Nullify() ;
405 myGeomGUI->GetDesktop()->putInfo( tr("") ) ;
406 switch(myConstructorId)
410 if( myOkPoint1 && myOkDir && myOkRadius && myOkHeight ) {
411 gp_Dir aDir = myDir ;
412 /* allows user to reverse direction of construction with a negative height */
413 if( this->myHeight < -Precision::Confusion() ) {
416 myGeomGUI->MakeCylinderAndDisplay( myPoint1, aDir, myRadius, fabs(myHeight) ) ;
422 if( myOkPoint1 && myOkDir && myOkRadius && myOkHeight ) {
423 gp_Dir aDir = myDir ;
424 /* allows user to reverse direction of construction with a negative height */
425 if( this->myHeight < -Precision::Confusion() ) {
428 myGeomGUI->MakeCylinderAndDisplay( myPoint1, aDir, myRadius, fabs(myHeight) ) ;
438 //=================================================================================
439 // function : ClickOnCancel()
441 //=================================================================================
442 void GeometryGUI_CylinderDlg::ClickOnCancel()
444 mySelection->ClearFilters() ;
445 myGeomGUI->EraseSimulationShape() ;
446 mySimulationTopoDs.Nullify() ;
447 disconnect( mySelection, 0, this, 0 );
448 myGeomGUI->ResetState() ;
454 //=================================================================================
455 // function : SelectionIntoArgument()
456 // purpose : Called when selection as changed or other case
457 //=================================================================================
458 void GeometryGUI_CylinderDlg::SelectionIntoArgument()
460 myGeomGUI->EraseSimulationShape() ;
461 mySimulationTopoDs.Nullify() ;
463 QString aString = ""; /* name of future selection */
465 int nbSel = myGeomGUI->GetNameOfSelectedIObjects(mySelection, aString) ;
467 if ( myEditCurrentArgument == LineEditC1A1 ) {
468 LineEditC1A1->setText("") ;
471 else if ( myEditCurrentArgument == LineEditC1A2 ) {
472 LineEditC1A2->setText("") ;
480 if( !myGeomGUI->GetTopoFromSelection(mySelection, S) )
483 /* gp_Pnt : not used */
484 if ( myEditCurrentArgument == LineEditC1A1 && myGeomGUI->VertexToPoint(S, myPoint1) ) {
485 LineEditC1A1->setText(aString) ;
488 else if ( myEditCurrentArgument == LineEditC1A2 /*&& myGeomGUI->LinearLocationAndDirection(S, notUsed, myDir)*/ ) {
489 BRepAdaptor_Curve curv(TopoDS::Edge(S));
490 myDir = curv.Line().Direction();
492 LineEditC1A2->setText(aString) ;
496 if( myOkPoint1 && myOkDir && myOkRadius && myOkHeight ) {
497 MakeCylinderSimulationAndDisplay() ;
502 //=================================================================================
503 // function : SetEditCurrentArgument()
505 //=================================================================================
506 void GeometryGUI_CylinderDlg::SetEditCurrentArgument()
508 QPushButton* send = (QPushButton*)sender();
509 mySelection->ClearFilters() ;
510 switch (myConstructorId)
512 case 0: /* default constructor */
514 if(send == SelectButtonC1A1) {
515 LineEditC1A1->setFocus() ;
516 myEditCurrentArgument = LineEditC1A1;
517 mySelection->AddFilter(myVertexFilter) ;
519 else if(send == SelectButtonC1A2) {
520 LineEditC1A2->setFocus() ;
521 myEditCurrentArgument = LineEditC1A2;
522 mySelection->AddFilter(myEdgeFilter) ;
524 SelectionIntoArgument() ;
536 //=================================================================================
537 // function : LineEditReturnPressed()
539 //=================================================================================
540 void GeometryGUI_CylinderDlg::LineEditReturnPressed()
542 QLineEdit* send = (QLineEdit*)sender();
543 if( send == LineEditC1A1 )
544 myEditCurrentArgument = LineEditC1A1 ;
545 else if ( send == LineEditC1A2 )
546 myEditCurrentArgument = LineEditC1A2 ;
550 /* User name of object input management */
551 /* If successfull the selection is changed and signal emitted... */
552 /* so SelectionIntoArgument() is automatically called. */
553 QLineEdit* LE = (QLineEdit*)myEditCurrentArgument ;
554 const QString objectUserName = LE->text() ;
555 QWidget* thisWidget = (QWidget*)this ;
556 if( myGeomGUI->SelectionByNameInDialogs( thisWidget, objectUserName, mySelection ) ) {
557 LE->setText( objectUserName ) ;
563 //=================================================================================
564 // function : ValueChangedInSpinBox
566 //=================================================================================
567 void GeometryGUI_CylinderDlg::ValueChangedInSpinBox( double newValue )
570 myGeomGUI->EraseSimulationShape() ;
571 mySimulationTopoDs.Nullify() ;
572 QObject* send = (QObject*)sender();
574 if(send == SpinBox_C1A3 ) { /* radius */
576 myRadius = newValue ;
578 if (myOkPoint1 && myOkDir && myOkRadius && myOkHeight ) {
579 MakeCylinderSimulationAndDisplay() ;
581 } else if (send == SpinBox_C1A4 ) { /* algebric height */
583 myHeight = newValue ;
585 if (myOkPoint1 && myOkDir && myOkRadius && myOkHeight ) {
586 MakeCylinderSimulationAndDisplay() ;
589 else if (send == SpinBox_Height) { /* algebric height */
592 myHeight = newValue ;
593 if (myOkPoint1 && myOkDir && myOkRadius && myOkHeight ) {
594 MakeCylinderSimulationAndDisplay() ;
597 else if (send == SpinBox_Radius) { /* radius */
598 myRadius = newValue ;
600 if (myOkPoint1 && myOkDir && myOkRadius && myOkHeight ) {
601 MakeCylinderSimulationAndDisplay() ;
607 //=================================================================================
608 // function : DeactivateActiveDialog()
610 //=================================================================================
611 void GeometryGUI_CylinderDlg::DeactivateActiveDialog()
613 if ( GroupConstructors->isEnabled() ) {
614 GroupConstructors->setEnabled(false) ;
615 GroupC1->setEnabled(false) ;
616 GroupC2->setEnabled(false) ;
617 GroupButtons->setEnabled(false) ;
618 disconnect( mySelection, 0, this, 0 );
619 myGeomGUI->EraseSimulationShape() ;
620 mySelection->ClearFilters() ;
626 //=================================================================================
627 // function : ActivateThisDialog()
629 //=================================================================================
630 void GeometryGUI_CylinderDlg::ActivateThisDialog()
632 /* Emit a signal to deactivate the active dialog */
633 myGeomGUI->EmitSignalDeactivateDialog() ;
634 GroupConstructors->setEnabled(true) ;
635 GroupC1->setEnabled(true) ;
636 GroupC2->setEnabled(true) ;
637 GroupButtons->setEnabled(true) ;
638 connect ( mySelection, SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) );
639 if( !mySimulationTopoDs.IsNull() )
640 myGeomGUI->DisplaySimulationShape( mySimulationTopoDs ) ;
645 //=================================================================================
646 // function : enterEvent()
648 //=================================================================================
649 void GeometryGUI_CylinderDlg::enterEvent(QEvent* e)
651 if ( GroupConstructors->isEnabled() )
653 ActivateThisDialog() ;
658 //=================================================================================
659 // function : closeEvent()
661 //=================================================================================
662 void GeometryGUI_CylinderDlg::closeEvent( QCloseEvent* e )
664 /* same than click on cancel button */
665 this->ClickOnCancel() ;
670 //=================================================================================
671 // function : MakeCylinderSimulationAndDisplay()
673 //=================================================================================
674 void GeometryGUI_CylinderDlg::MakeCylinderSimulationAndDisplay()
676 myGeomGUI->EraseSimulationShape() ;
677 mySimulationTopoDs.Nullify() ;
678 gp_Dir aDir = this->myDir ;
681 /* allows user to reverse direction of construction with a negative height */
682 if( this->myHeight < -Precision::Confusion() ) {
685 gp_Ax2 anAxis(this->myPoint1, aDir) ;
687 mySimulationTopoDs = BRepPrimAPI_MakeCylinder( anAxis, this->myRadius, fabs(myHeight) ).Shape() ;
688 myGeomGUI->DisplaySimulationShape( mySimulationTopoDs ) ;
690 catch(Standard_Failure) {
691 MESSAGE( "Exception catched in MakeCylinderSimulationAndDisplay" ) ;