2 // File : GeometryGUI_ConeDlg.cxx
4 // Author : Lucien PIGNOLONI
6 // Module : GeometryGUI
7 // Copyright : OPEN CASCADE
11 #include "GeometryGUI_ConeDlg.h"
13 #include "GeometryGUI.h"
14 #include "QAD_Application.h"
15 #include "QAD_Desktop.h"
16 #include "QAD_Config.h"
17 #include "utilities.h"
19 #include <BRepAdaptor_Curve.hxx>
21 #include <qbuttongroup.h>
22 #include <qgroupbox.h>
24 #include <qlineedit.h>
25 #include <qpushbutton.h>
26 #include <qradiobutton.h>
30 #include <qwhatsthis.h>
35 //=================================================================================
36 // class : GeometryGUI_ConeDlg()
37 // purpose : Constructs a GeometryGUI_ConeDlg which is a child of 'parent', with the
38 // name 'name' and widget flags set to 'f'.
39 // The dialog will by default be modeless, unless you set 'modal' to
40 // TRUE to construct a modal dialog.
41 //=================================================================================
42 GeometryGUI_ConeDlg::GeometryGUI_ConeDlg( QWidget* parent, const char* name, SALOME_Selection* Sel, bool modal, WFlags fl )
43 : QDialog( parent, name, modal, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu )
45 QPixmap image0(QAD_Desktop::getResourceManager()->loadPixmap( "GEOM",tr("ICON_DLG_CONE_PV")));
46 QPixmap image1(QAD_Desktop::getResourceManager()->loadPixmap( "GEOM",tr("ICON_SELECT")));
47 QPixmap image2(QAD_Desktop::getResourceManager()->loadPixmap( "GEOM",tr("ICON_DLG_CONE_DXYZ")));
50 setName( "GeometryGUI_ConeDlg" );
52 setCaption( tr( "GEOM_CONE_TITLE" ) );
53 setSizeGripEnabled( TRUE );
54 GeometryGUI_ConeDlgLayout = new QGridLayout( this );
55 GeometryGUI_ConeDlgLayout->setSpacing( 6 );
56 GeometryGUI_ConeDlgLayout->setMargin( 11 );
58 /***************************************************************/
59 GroupConstructors = new QButtonGroup( this, "GroupConstructors" );
60 GroupConstructors->setTitle( tr( "GEOM_CONE" ) );
61 GroupConstructors->setExclusive( TRUE );
62 GroupConstructors->setColumnLayout(0, Qt::Vertical );
63 GroupConstructors->layout()->setSpacing( 0 );
64 GroupConstructors->layout()->setMargin( 0 );
65 GroupConstructorsLayout = new QGridLayout( GroupConstructors->layout() );
66 GroupConstructorsLayout->setAlignment( Qt::AlignTop );
67 GroupConstructorsLayout->setSpacing( 6 );
68 GroupConstructorsLayout->setMargin( 11 );
69 QSpacerItem* spacer = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum );
70 GroupConstructorsLayout->addItem( spacer, 0, 1 );
71 Constructor1 = new QRadioButton( GroupConstructors, "Constructor1" );
72 Constructor1->setText( tr( "" ) );
73 Constructor1->setPixmap( image0 );
74 Constructor1->setChecked( TRUE );
75 Constructor1->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)3, (QSizePolicy::SizeType)0, Constructor1->sizePolicy().hasHeightForWidth() ) );
76 Constructor1->setMinimumSize( QSize( 50, 0 ) );
77 GroupConstructorsLayout->addWidget( Constructor1, 0, 0 );
78 Constructor2 = new QRadioButton( GroupConstructors, "Constructor2" );
79 Constructor2->setText( tr( "" ) );
80 Constructor2->setMinimumSize( QSize( 50, 0 ) );
81 Constructor2->setPixmap( image2 );
82 Constructor2->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)3, (QSizePolicy::SizeType)0, Constructor1->sizePolicy().hasHeightForWidth() ) );
83 GroupConstructorsLayout->addWidget( Constructor2, 0, 2 );
84 QSpacerItem* spacer_2 = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum );
85 GroupConstructorsLayout->addItem( spacer_2, 0, 3 );
86 GeometryGUI_ConeDlgLayout->addWidget( GroupConstructors, 0, 0 );
88 /***************************************************************/
89 GroupButtons = new QGroupBox( this, "GroupButtons" );
90 GroupButtons->setGeometry( QRect( 10, 10, 281, 48 ) );
91 GroupButtons->setTitle( tr( "" ) );
92 GroupButtons->setColumnLayout(0, Qt::Vertical );
93 GroupButtons->layout()->setSpacing( 0 );
94 GroupButtons->layout()->setMargin( 0 );
95 GroupButtonsLayout = new QGridLayout( GroupButtons->layout() );
96 GroupButtonsLayout->setAlignment( Qt::AlignTop );
97 GroupButtonsLayout->setSpacing( 6 );
98 GroupButtonsLayout->setMargin( 11 );
99 buttonCancel = new QPushButton( GroupButtons, "buttonCancel" );
100 buttonCancel->setText( tr( "GEOM_BUT_CLOSE" ) );
101 buttonCancel->setAutoDefault( TRUE );
102 GroupButtonsLayout->addWidget( buttonCancel, 0, 3 );
103 buttonApply = new QPushButton( GroupButtons, "buttonApply" );
104 buttonApply->setText( tr( "GEOM_BUT_APPLY" ) );
105 buttonApply->setAutoDefault( TRUE );
106 GroupButtonsLayout->addWidget( buttonApply, 0, 1 );
107 QSpacerItem* spacer_9 = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum );
108 GroupButtonsLayout->addItem( spacer_9, 0, 2 );
109 buttonOk = new QPushButton( GroupButtons, "buttonOk" );
110 buttonOk->setText( tr( "GEOM_BUT_OK" ) );
111 buttonOk->setAutoDefault( TRUE );
112 buttonOk->setDefault( TRUE );
113 GroupButtonsLayout->addWidget( buttonOk, 0, 0 );
114 GeometryGUI_ConeDlgLayout->addWidget( GroupButtons, 2, 0 );
116 /***************************************************************/
117 GroupC1 = new QGroupBox( this, "GroupC1" );
118 GroupC1->setTitle( tr( "GEOM_ARGUMENTS" ) );
119 GroupC1->setColumnLayout(0, Qt::Vertical );
120 GroupC1->layout()->setSpacing( 0 );
121 GroupC1->layout()->setMargin( 0 );
122 GroupC1Layout = new QGridLayout( GroupC1->layout() );
123 GroupC1Layout->setAlignment( Qt::AlignTop );
124 GroupC1Layout->setSpacing( 6 );
125 GroupC1Layout->setMargin( 11 );
126 SelectButtonC1A1 = new QPushButton( GroupC1, "SelectButtonC1A1" );
127 SelectButtonC1A1->setText( tr( "" ) );
128 SelectButtonC1A1->setPixmap( image1 );
129 GroupC1Layout->addWidget( SelectButtonC1A1, 0, 1 );
130 LineEditC1A1 = new QLineEdit( GroupC1, "LineEditC1A1" );
131 LineEditC1A1->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)3, (QSizePolicy::SizeType)0, LineEditC1A1->sizePolicy().hasHeightForWidth() ) );
132 GroupC1Layout->addWidget( LineEditC1A1, 0, 2 );
133 TextLabelC1A1 = new QLabel( GroupC1, "TextLabelC1A1" );
134 TextLabelC1A1->setText( tr( "GEOM_BASE_POINT" ) );
135 TextLabelC1A1->setMinimumSize( QSize( 50, 0 ) );
136 TextLabelC1A1->setFrameShape( QLabel::NoFrame );
137 TextLabelC1A1->setFrameShadow( QLabel::Plain );
138 GroupC1Layout->addWidget( TextLabelC1A1, 0, 0 );
139 SelectButtonC1A2 = new QPushButton( GroupC1, "SelectButtonC1A2" );
140 SelectButtonC1A2->setText( tr( "" ) );
141 SelectButtonC1A2->setPixmap( image1 );
142 GroupC1Layout->addWidget( SelectButtonC1A2, 1, 1 );
143 LineEditC1A2 = new QLineEdit( GroupC1, "LineEditC1A2" );
144 LineEditC1A2->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)3, (QSizePolicy::SizeType)0, LineEditC1A2->sizePolicy().hasHeightForWidth() ) );
145 GroupC1Layout->addWidget( LineEditC1A2, 1, 2 );
146 TextLabelC1A2 = new QLabel( GroupC1, "TextLabelC1A2" );
147 TextLabelC1A2->setText( tr( "GEOM_VECTOR" ) );
148 TextLabelC1A2->setMinimumSize( QSize( 50, 0 ) );
149 TextLabelC1A2->setFrameShape( QLabel::NoFrame );
150 TextLabelC1A2->setFrameShadow( QLabel::Plain );
151 GroupC1Layout->addWidget( TextLabelC1A2, 1, 0 );
152 TextLabelC1A3 = new QLabel( GroupC1, "TextLabelC1A3" );
153 TextLabelC1A3->setText( tr( "GEOM_RADIUS_I" ).arg("1") );
154 TextLabelC1A3->setMinimumSize( QSize( 50, 0 ) );
155 TextLabelC1A3->setFrameShape( QLabel::NoFrame );
156 TextLabelC1A3->setFrameShadow( QLabel::Plain );
157 GroupC1Layout->addWidget( TextLabelC1A3, 2, 0 );
159 SpinBox_C1A3 = new GeometryGUI_SpinBox(GroupC1, "GeomSpinBox_C1A3" ) ;
160 SpinBox_C1A3->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)3, (QSizePolicy::SizeType)0, SpinBox_C1A3->sizePolicy().hasHeightForWidth() ) );
161 GroupC1Layout->addWidget( SpinBox_C1A3 , 2, 2 );
163 TextLabelC1A4 = new QLabel( GroupC1, "TextLabelC1A4" );
164 TextLabelC1A4->setText( tr( "GEOM_RADIUS_I" ).arg("2") );
165 TextLabelC1A4->setMinimumSize( QSize( 50, 0 ) );
166 TextLabelC1A4->setFrameShape( QLabel::NoFrame );
167 TextLabelC1A4->setFrameShadow( QLabel::Plain );
168 GroupC1Layout->addWidget( TextLabelC1A4, 3, 0 );
170 SpinBox_C1A4 = new GeometryGUI_SpinBox( GroupC1, "GeomSpinBox_C1A4" ) ;
171 SpinBox_C1A4->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)3, (QSizePolicy::SizeType)0, SpinBox_C1A4->sizePolicy().hasHeightForWidth() ) );
172 GroupC1Layout->addWidget( SpinBox_C1A4 , 3, 2 ) ;
174 TextLabelC1A5 = new QLabel( GroupC1, "TextLabelC1A5" );
175 TextLabelC1A5->setText( tr( "GEOM_HEIGHT" ) );
176 TextLabelC1A5->setMinimumSize( QSize( 50, 0 ) );
177 TextLabelC1A5->setFrameShape( QLabel::NoFrame );
178 TextLabelC1A5->setFrameShadow( QLabel::Plain );
179 GroupC1Layout->addWidget( TextLabelC1A5, 4, 0 );
181 SpinBox_C1A5 = new GeometryGUI_SpinBox( GroupC1, "GeomSpinBox_C1A5" ) ;
182 SpinBox_C1A5->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)3, (QSizePolicy::SizeType)0, SpinBox_C1A5->sizePolicy().hasHeightForWidth() ) );
183 GroupC1Layout->addWidget( SpinBox_C1A5 , 4, 2 ) ;
185 GeometryGUI_ConeDlgLayout->addWidget( GroupC1, 1, 0 );
186 /***************************************************************/
188 GroupC2 = new QGroupBox( this, "GroupC2" );
189 GroupC2->setTitle( tr( "GEOM_BOX_OBJ" ) );
190 GroupC2->setColumnLayout(0, Qt::Vertical );
191 GroupC2->layout()->setSpacing( 0 );
192 GroupC2->layout()->setMargin( 0 );
193 GroupC2Layout = new QGridLayout( GroupC2->layout() );
194 GroupC2Layout->setAlignment( Qt::AlignTop );
195 GroupC2Layout->setSpacing( 6 );
196 GroupC2Layout->setMargin( 11 );
197 TextLabel_Height = new QLabel(GroupC2 , "TextLabel_Height" );
198 TextLabel_Height->setText( tr( "GEOM_HEIGHT" ) );
199 GroupC2Layout->addWidget( TextLabel_Height, 2, 0 );
200 TextLabel_Radius1 = new QLabel( GroupC2, "TextLabel_Radius1" );
201 TextLabel_Radius1->setText( tr( "GEOM_RADIUS_I" ).arg("1") );
202 GroupC2Layout->addWidget( TextLabel_Radius1, 0, 0 );
203 TextLabel_Radius2 = new QLabel( GroupC2, "TextLabel_Radius2" );
204 TextLabel_Radius2->setText( tr( "GEOM_RADIUS_I" ).arg("2") );
205 GroupC2Layout->addWidget( TextLabel_Radius2, 1, 0 );
207 SpinBox_Radius1 = new GeometryGUI_SpinBox( GroupC2, "GeomSpinBox_Radius1" ) ;
208 GroupC2Layout->addWidget( SpinBox_Radius1 , 0, 1 ) ;
210 SpinBox_Radius2 = new GeometryGUI_SpinBox( GroupC2, "GeomSpinBox_Radius2" ) ;
211 GroupC2Layout->addWidget( SpinBox_Radius2 , 1, 1 ) ;
213 SpinBox_Height = new GeometryGUI_SpinBox( GroupC2, "GeomSpinBox_Height" ) ;
214 GroupC2Layout->addWidget( SpinBox_Height , 2, 1 ) ;
216 QSpacerItem* spacer1 = new QSpacerItem( 20, 60, QSizePolicy::Minimum, QSizePolicy::Fixed );
217 GroupC2Layout->addItem( spacer1 );
219 GeometryGUI_ConeDlgLayout->addWidget(GroupC2 , 1, 0 );
221 /***************************************************************/
223 /* Initialisations */
228 //=================================================================================
229 // function : ~GeometryGUI_ConeDlg()
230 // purpose : Destroys the object and frees any allocated resources
231 //=================================================================================
232 GeometryGUI_ConeDlg::~GeometryGUI_ConeDlg()
234 // no need to delete child widgets, Qt does it all for us
238 //=================================================================================
241 //=================================================================================
242 void GeometryGUI_ConeDlg::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 */
251 SpinBox_C1A3->RangeStepAndValidator( 0.001, 999.999, step, 3 ) ; /* radius 1 */
252 SpinBox_C1A3->SetValue( 100.0 ) ;
253 SpinBox_C1A4->RangeStepAndValidator( 0.000, 999.999, step, 3 ) ; /* radius 2 */
254 SpinBox_C1A4->SetValue( 0.0 ) ;
255 SpinBox_C1A5->RangeStepAndValidator( -999.999, 999.999, step, 3 ) ; /* algebric height */
256 SpinBox_C1A5->SetValue( 300.0 ) ;
258 SpinBox_Radius1->RangeStepAndValidator( 0.001, 999.999, step, 3 ) ; /* radius 1 */
259 SpinBox_Radius1->SetValue( 100.0 ) ;
260 SpinBox_Radius2->RangeStepAndValidator( 0.000, 999.999, step, 3 ) ; /* radius 2 */
261 SpinBox_Radius2->SetValue( 0.0 ) ;
262 SpinBox_Height->RangeStepAndValidator( -999.999, 999.999, step, 3 ) ; /* algebric height */
263 SpinBox_Height->SetValue( 300.0 ) ;
267 myConstructorId = 0 ;
268 Constructor1->setChecked( TRUE );
269 myEditCurrentArgument = LineEditC1A1 ;
271 myGeomGUI = GeometryGUI::GetGeometryGUI() ;
282 mySimulationTopoDs.Nullify() ;
283 myGeomGUI->SetActiveDialogBox( (QDialog*)this ) ;
285 // TODO : previous selection into argument ?
287 /* Filter definitions */
288 Engines::Component_var comp = QAD_Application::getDesktop()->getEngine("FactoryServer", "GEOM");
289 myGeom = GEOM::GEOM_Gen::_narrow(comp);
290 myEdgeFilter = new GEOM_EdgeFilter( StdSelect_Line, myGeom );
291 myVertexFilter = new GEOM_ShapeTypeFilter( TopAbs_VERTEX, myGeom );
292 /* first filter used */
293 mySelection->AddFilter(myVertexFilter) ;
295 /* signals and slots connections */
296 connect( buttonOk, SIGNAL( clicked() ), this, SLOT( ClickOnOk() ) );
297 connect( buttonCancel, SIGNAL( clicked() ), this, SLOT( ClickOnCancel() ) ) ;
298 connect( buttonApply, SIGNAL( clicked() ), this, SLOT(ClickOnApply() ) );
299 connect( GroupConstructors, SIGNAL(clicked(int) ), SLOT( ConstructorsClicked(int) ) );
300 connect( SelectButtonC1A1, SIGNAL (clicked() ), this, SLOT( SetEditCurrentArgument() ) ) ;
301 connect( SelectButtonC1A2, SIGNAL (clicked() ), this, SLOT( SetEditCurrentArgument() ) ) ;
303 connect( SpinBox_C1A3, SIGNAL ( valueChanged( double) ), this, SLOT( ValueChangedInSpinBox( double) ) ) ;
304 connect( SpinBox_C1A4, SIGNAL ( valueChanged( double) ), this, SLOT( ValueChangedInSpinBox( double) ) ) ;
305 connect( SpinBox_C1A5, SIGNAL ( valueChanged( double) ), this, SLOT( ValueChangedInSpinBox( double) ) ) ;
306 connect( SpinBox_Radius1, SIGNAL ( valueChanged( double) ), this, SLOT( ValueChangedInSpinBox( double) ) ) ;
307 connect( SpinBox_Radius2, SIGNAL ( valueChanged( double) ), this, SLOT( ValueChangedInSpinBox( double) ) ) ;
308 connect( SpinBox_Height, SIGNAL ( valueChanged( double) ), this, SLOT( ValueChangedInSpinBox( double) ) ) ;
310 connect( LineEditC1A1, SIGNAL ( returnPressed() ), this, SLOT( LineEditReturnPressed() ) ) ;
311 connect( LineEditC1A2, SIGNAL ( returnPressed() ), this, SLOT( LineEditReturnPressed() ) ) ;
313 connect( myGeomGUI, SIGNAL ( SignalDeactivateActiveDialog() ), this, SLOT( DeactivateActiveDialog() ) ) ;
314 connect( mySelection, SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) );
315 /* to close dialog if study change */
316 connect( myGeomGUI, SIGNAL ( SignalCloseAllDialogs() ), this, SLOT( ClickOnCancel() ) ) ;
318 /* Move widget on the botton right corner of main widget */
320 myGeomGUI->DefineDlgPosition( this, x, y ) ;
322 this->show() ; /* displays Dialog */
329 //=================================================================================
330 // function : ConstructorsClicked()
331 // purpose : Radio button management
332 //=================================================================================
333 void GeometryGUI_ConeDlg::ConstructorsClicked(int constructorId)
335 mySelection->ClearFilters() ;
336 myGeomGUI->EraseSimulationShape() ;
338 switch(myConstructorId)
344 myConstructorId = constructorId ;
345 myOkHeight = myOkRadius1 = myOkRadius2 = myOkPoint1 = myOkDir = true ;
347 SpinBox_Radius1->SetValue( 100.0 ) ; /* radius 1 */
348 SpinBox_Radius2->SetValue( 0.0 ) ; /* radius 2 */
349 SpinBox_Height->SetValue( 300.0 ) ; /* height */
351 disconnect( mySelection, 0, this, 0 );
357 myPoint1.SetCoord( 0.0, 0.0, 0.0 ) ;
358 myDir.SetCoord( 0.0, 0.0, 1.0 ) ;
360 if( myOkPoint1 && myOkDir && myOkRadius1 && myOkRadius2 && myOkHeight ) {
361 gp_Dir aDir = myDir ;
362 /* allows user to reverse direction of construction with a negative height */
363 if( this->myHeight < -Precision::Confusion() ) {
366 MakeConeSimulationAndDisplay() ;
374 myConstructorId = constructorId ;
375 myEditCurrentArgument = LineEditC1A1 ;
376 myOkHeight = myOkRadius1 = myOkRadius2 = true ;
377 myOkPoint1 = myOkDir = false ;
379 SpinBox_C1A3->SetValue( 100.0 ) ; /* radius 1 */
380 SpinBox_C1A4->SetValue( 0.0 ) ; /* radius 2 */
381 SpinBox_C1A5->SetValue( 300.0 ) ; /* height */
386 disconnect( mySelection, 0, this, 0 );
393 //=================================================================================
394 // function : ClickOnOk()
396 //=================================================================================
397 void GeometryGUI_ConeDlg::ClickOnOk()
399 this->ClickOnApply() ;
400 this->ClickOnCancel() ;
405 //=================================================================================
406 // function : ClickOnApply()
408 //=================================================================================
409 void GeometryGUI_ConeDlg::ClickOnApply()
411 myGeomGUI->EraseSimulationShape() ;
412 mySimulationTopoDs.Nullify() ;
413 myGeomGUI->GetDesktop()->putInfo( tr("") ) ;
415 switch(myConstructorId)
419 if(myOkPoint1 && myOkDir && myOkRadius1 && myOkRadius2 && myOkHeight) {
420 gp_Dir aDir = myDir ;
421 /* allows user to reverse direction of construction with a negative height */
422 if( this->myHeight < -Precision::Confusion() ) {
425 myGeomGUI->MakeConeAndDisplay( myPoint1, aDir, myRadius1, myRadius2, fabs(myHeight) ) ;
431 if(myOkPoint1 && myOkDir && myOkRadius1 && myOkRadius2 && myOkHeight) {
432 gp_Dir aDir = myDir ;
433 /* allows user to reverse direction of construction with a negative height */
434 if( this->myHeight < -Precision::Confusion() ) {
437 myGeomGUI->MakeConeAndDisplay( myPoint1, aDir, myRadius1, myRadius2, fabs(myHeight) ) ;
447 //=================================================================================
448 // function : ClickOnCancel()
450 //=================================================================================
451 void GeometryGUI_ConeDlg::ClickOnCancel()
453 mySelection->ClearFilters() ;
454 myGeomGUI->EraseSimulationShape() ;
455 mySimulationTopoDs.Nullify() ;
456 disconnect( mySelection, 0, this, 0 );
457 myGeomGUI->ResetState() ;
463 //=================================================================================
464 // function : SelectionIntoArgument()
465 // purpose : Called when selection as changed or other case
466 //=================================================================================
467 void GeometryGUI_ConeDlg::SelectionIntoArgument()
469 myGeomGUI->EraseSimulationShape() ;
470 mySimulationTopoDs.Nullify() ;
472 /* Future name of selection */
473 QString aString = "";
475 int nbSel = myGeomGUI->GetNameOfSelectedIObjects(mySelection, aString) ;
477 if ( myEditCurrentArgument == LineEditC1A1 ) {
478 LineEditC1A1->setText("") ;
481 else if ( myEditCurrentArgument == LineEditC1A2 ) {
482 LineEditC1A2->setText("") ;
490 if( !myGeomGUI->GetTopoFromSelection(mySelection, S) )
493 /* gp_Pnt : not used */
494 if ( myEditCurrentArgument == LineEditC1A1 && myGeomGUI->VertexToPoint(S, myPoint1) ) {
495 LineEditC1A1->setText(aString) ;
498 else if ( myEditCurrentArgument == LineEditC1A2 /*&& myGeomGUI->LinearLocationAndDirection(S, notUsed, myDir)*/ ) {
499 BRepAdaptor_Curve curv(TopoDS::Edge(S));
500 myDir = curv.Line().Direction();
501 LineEditC1A2->setText(aString) ;
505 if( myConstructorId == 0 && myOkPoint1 && myOkDir && myOkRadius1 && myOkRadius2 && myOkHeight) {
506 MakeConeSimulationAndDisplay() ;
511 //=================================================================================
512 // function : SetEditCurrentArgument()
514 //=================================================================================
515 void GeometryGUI_ConeDlg::SetEditCurrentArgument()
517 QPushButton* send = (QPushButton*)sender();
518 mySelection->ClearFilters() ;
519 switch (myConstructorId)
521 case 0: /* default constructor */
523 if(send == SelectButtonC1A1) {
524 LineEditC1A1->setFocus() ;
525 myEditCurrentArgument = LineEditC1A1;
526 mySelection->AddFilter(myVertexFilter) ;
528 else if(send == SelectButtonC1A2) {
529 LineEditC1A2->setFocus() ;
530 myEditCurrentArgument = LineEditC1A2;
531 mySelection->AddFilter(myEdgeFilter) ;
533 SelectionIntoArgument() ;
545 //=================================================================================
546 // function : LineEditReturnPressed()
548 //=================================================================================
549 void GeometryGUI_ConeDlg::LineEditReturnPressed()
551 QLineEdit* send = (QLineEdit*)sender();
552 if( send == LineEditC1A1 )
553 myEditCurrentArgument = LineEditC1A1 ;
554 else if ( send == LineEditC1A2 )
555 myEditCurrentArgument = LineEditC1A2 ;
559 /* User name of object input management */
560 /* If successfull the selection is changed and signal emitted... */
561 /* so SelectionIntoArgument() is automatically called. */
562 QLineEdit* LE = (QLineEdit*)myEditCurrentArgument ;
563 const QString objectUserName = LE->text() ;
564 QWidget* thisWidget = (QWidget*)this ;
565 if( myGeomGUI->SelectionByNameInDialogs( thisWidget, objectUserName, mySelection ) ) {
566 LE->setText( objectUserName ) ;
571 //=================================================================================
572 // function : ValueChangedInSpinBox()
574 //=================================================================================
575 void GeometryGUI_ConeDlg::ValueChangedInSpinBox( double newValue )
577 myGeomGUI->EraseSimulationShape() ;
578 mySimulationTopoDs.Nullify() ;
580 QObject* send = (QObject*)sender();
582 if( send == SpinBox_C1A3 || send == SpinBox_Radius1 ) { /* radius1 */
583 myRadius1 = newValue ;
585 } else if( send == SpinBox_C1A4 || send == SpinBox_Radius2 ) { /* radius2 */
586 myRadius2 = newValue ;
589 else if( send == SpinBox_C1A5 || send == SpinBox_Height ) { /* algebric height */
590 myHeight = newValue ;
594 if ( myOkPoint1 && myOkDir && myOkRadius1 && myOkRadius2 && myOkHeight ) {
595 MakeConeSimulationAndDisplay() ;
602 //=================================================================================
603 // function : TextChangedInLineEdit()
605 //=================================================================================
606 // void GeometryGUI_ConeDlg::TextChangedInLineEdit(const QString& newText)
609 // myGeomGUI->EraseSimulationShape() ;
610 // mySimulationTopoDs.Nullify() ;
611 // QLineEdit* send = (QLineEdit*)sender();
612 // QString newT = strdup(newText) ;
615 // if(send == LineEditC1A3) { /* radius1 */
616 // if( myVa->validate(newT, i) == myVa->Acceptable ) {
617 // myRadius1 = newText.toFloat() ;
618 // myOkRadius1 = true ;
621 // myOkRadius1 = false ;
623 // } else if(send == LineEditC1A4) { /* radius2 */
624 // if( myVb->validate(newT, i) == myVb->Acceptable ) {
625 // myRadius2 = newText.toFloat() ;
626 // myOkRadius2 = true ;
629 // myOkRadius2 = false ;
631 // } else if(send == LineEditC1A5) { /* algebric height */
633 // if( myVc->validate(newT, i) == myVc->Acceptable ) {
634 // myHeight = newText.toFloat() ;
635 // if( fabs(myHeight) > Precision::Confusion() )
636 // myOkHeight = true ;
638 // myOkHeight = false ;
640 // }else if(send == LineEdit_Radius1) { /* radius1 */
641 // if( myVa->validate(newT, i) == myVa->Acceptable ) {
642 // myRadius1 = newText.toFloat() ;
643 // myOkRadius1 = true ;
646 // myOkRadius1 = false ;
648 // } else if(send == LineEdit_Radius2) { /* radius2 */
649 // if( myVb->validate(newT, i) == myVb->Acceptable ) {
650 // myRadius2 = newText.toFloat() ;
651 // myOkRadius2 = true ;
654 // myOkRadius2 = false ;
656 // } else if(send == LineEdit_Height) { /* algebric height */
658 // if( myVc->validate(newT, i) == myVc->Acceptable ) {
659 // myHeight = newText.toFloat() ;
660 // if( fabs(myHeight) > Precision::Confusion() )
661 // myOkHeight = true ;
663 // myOkHeight = false ;
666 // if (myOkPoint1 && myOkDir && myOkRadius1 && myOkRadius2 && myOkHeight) {
667 // MakeConeSimulationAndDisplay() ;
674 //=================================================================================
675 // function : DeactivateActiveDialog()
677 //=================================================================================
678 void GeometryGUI_ConeDlg::DeactivateActiveDialog()
680 if ( GroupConstructors->isEnabled() ) {
681 GroupConstructors->setEnabled(false) ;
682 GroupC1->setEnabled(false) ;
683 GroupC2->setEnabled(false) ;
684 GroupButtons->setEnabled(false) ;
685 disconnect( mySelection, 0, this, 0 );
686 myGeomGUI->EraseSimulationShape() ;
687 mySelection->ClearFilters() ;
693 //=================================================================================
694 // function : ActivateThisDialog()
696 //=================================================================================
697 void GeometryGUI_ConeDlg::ActivateThisDialog()
699 /* Emit a signal to deactivate the active dialog */
700 myGeomGUI->EmitSignalDeactivateDialog() ;
701 GroupConstructors->setEnabled(true) ;
702 GroupC1->setEnabled(true) ;
703 GroupC2->setEnabled(true) ;
704 GroupButtons->setEnabled(true) ;
705 connect ( mySelection, SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) );
706 if( !mySimulationTopoDs.IsNull() )
707 myGeomGUI->DisplaySimulationShape( mySimulationTopoDs ) ;
712 //=================================================================================
713 // function : enterEvent()
715 //=================================================================================
716 void GeometryGUI_ConeDlg::enterEvent(QEvent* e)
718 if ( GroupConstructors->isEnabled() )
720 ActivateThisDialog() ;
725 //=================================================================================
726 // function : closeEvent()
728 //=================================================================================
729 void GeometryGUI_ConeDlg::closeEvent( QCloseEvent* e )
731 /* same than click on cancel button */
732 this->ClickOnCancel() ;
737 //=================================================================================
738 // function : MakeConeSimulationAndDisplay()
740 //=================================================================================
741 void GeometryGUI_ConeDlg::MakeConeSimulationAndDisplay()
743 myGeomGUI->EraseSimulationShape() ;
744 mySimulationTopoDs.Nullify() ;
745 gp_Dir aDir = myDir ;
748 /* allows user to reverse direction of construction with a negative height */
749 if( this->myHeight < -Precision::Confusion() ) {
753 gp_Ax2 anAxis(this->myPoint1, aDir) ;
755 if( fabs(myRadius1 - myRadius2) <= Precision::Confusion() ) {
756 mySimulationTopoDs = BRepPrimAPI_MakeCylinder( anAxis, (myRadius1+myRadius2)/2.0, fabs(myHeight) ).Shape() ;
759 if( fabs(myHeight) > Precision::Confusion() )
760 mySimulationTopoDs = BRepPrimAPI_MakeCone( anAxis, myRadius1, myRadius2, fabs(myHeight) ).Shape() ;
762 myGeomGUI->DisplaySimulationShape( mySimulationTopoDs ) ;
764 catch(Standard_Failure) {
765 MESSAGE( "Exception catched in MakeConeSimulationAndDisplay" ) ;