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_ConeDlg.cxx
25 // Author : Lucien PIGNOLONI
30 #include "GeometryGUI_ConeDlg.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>
54 //=================================================================================
55 // class : GeometryGUI_ConeDlg()
56 // purpose : Constructs a GeometryGUI_ConeDlg which is a child of 'parent', with the
57 // name 'name' and widget flags set to 'f'.
58 // The dialog will by default be modeless, unless you set 'modal' to
59 // TRUE to construct a modal dialog.
60 //=================================================================================
61 GeometryGUI_ConeDlg::GeometryGUI_ConeDlg( QWidget* parent, const char* name, SALOME_Selection* Sel, bool modal, WFlags fl )
62 : QDialog( parent, name, modal, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu )
64 QPixmap image0(QAD_Desktop::getResourceManager()->loadPixmap( "GEOM",tr("ICON_DLG_CONE_PV")));
65 QPixmap image1(QAD_Desktop::getResourceManager()->loadPixmap( "GEOM",tr("ICON_SELECT")));
66 QPixmap image2(QAD_Desktop::getResourceManager()->loadPixmap( "GEOM",tr("ICON_DLG_CONE_DXYZ")));
69 setName( "GeometryGUI_ConeDlg" );
71 setCaption( tr( "GEOM_CONE_TITLE" ) );
72 setSizeGripEnabled( TRUE );
73 GeometryGUI_ConeDlgLayout = new QGridLayout( this );
74 GeometryGUI_ConeDlgLayout->setSpacing( 6 );
75 GeometryGUI_ConeDlgLayout->setMargin( 11 );
77 /***************************************************************/
78 GroupConstructors = new QButtonGroup( this, "GroupConstructors" );
79 GroupConstructors->setTitle( tr( "GEOM_CONE" ) );
80 GroupConstructors->setExclusive( TRUE );
81 GroupConstructors->setColumnLayout(0, Qt::Vertical );
82 GroupConstructors->layout()->setSpacing( 0 );
83 GroupConstructors->layout()->setMargin( 0 );
84 GroupConstructorsLayout = new QGridLayout( GroupConstructors->layout() );
85 GroupConstructorsLayout->setAlignment( Qt::AlignTop );
86 GroupConstructorsLayout->setSpacing( 6 );
87 GroupConstructorsLayout->setMargin( 11 );
88 QSpacerItem* spacer = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum );
89 GroupConstructorsLayout->addItem( spacer, 0, 1 );
90 Constructor1 = new QRadioButton( GroupConstructors, "Constructor1" );
91 Constructor1->setText( tr( "" ) );
92 Constructor1->setPixmap( image0 );
93 Constructor1->setChecked( TRUE );
94 Constructor1->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)3, (QSizePolicy::SizeType)0, Constructor1->sizePolicy().hasHeightForWidth() ) );
95 Constructor1->setMinimumSize( QSize( 50, 0 ) );
96 GroupConstructorsLayout->addWidget( Constructor1, 0, 0 );
97 Constructor2 = new QRadioButton( GroupConstructors, "Constructor2" );
98 Constructor2->setText( tr( "" ) );
99 Constructor2->setMinimumSize( QSize( 50, 0 ) );
100 Constructor2->setPixmap( image2 );
101 Constructor2->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)3, (QSizePolicy::SizeType)0, Constructor1->sizePolicy().hasHeightForWidth() ) );
102 GroupConstructorsLayout->addWidget( Constructor2, 0, 2 );
103 QSpacerItem* spacer_2 = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum );
104 GroupConstructorsLayout->addItem( spacer_2, 0, 3 );
105 GeometryGUI_ConeDlgLayout->addWidget( GroupConstructors, 0, 0 );
107 /***************************************************************/
108 GroupButtons = new QGroupBox( this, "GroupButtons" );
109 GroupButtons->setGeometry( QRect( 10, 10, 281, 48 ) );
110 GroupButtons->setTitle( tr( "" ) );
111 GroupButtons->setColumnLayout(0, Qt::Vertical );
112 GroupButtons->layout()->setSpacing( 0 );
113 GroupButtons->layout()->setMargin( 0 );
114 GroupButtonsLayout = new QGridLayout( GroupButtons->layout() );
115 GroupButtonsLayout->setAlignment( Qt::AlignTop );
116 GroupButtonsLayout->setSpacing( 6 );
117 GroupButtonsLayout->setMargin( 11 );
118 buttonCancel = new QPushButton( GroupButtons, "buttonCancel" );
119 buttonCancel->setText( tr( "GEOM_BUT_CLOSE" ) );
120 buttonCancel->setAutoDefault( TRUE );
121 GroupButtonsLayout->addWidget( buttonCancel, 0, 3 );
122 buttonApply = new QPushButton( GroupButtons, "buttonApply" );
123 buttonApply->setText( tr( "GEOM_BUT_APPLY" ) );
124 buttonApply->setAutoDefault( TRUE );
125 GroupButtonsLayout->addWidget( buttonApply, 0, 1 );
126 QSpacerItem* spacer_9 = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum );
127 GroupButtonsLayout->addItem( spacer_9, 0, 2 );
128 buttonOk = new QPushButton( GroupButtons, "buttonOk" );
129 buttonOk->setText( tr( "GEOM_BUT_OK" ) );
130 buttonOk->setAutoDefault( TRUE );
131 buttonOk->setDefault( TRUE );
132 GroupButtonsLayout->addWidget( buttonOk, 0, 0 );
133 GeometryGUI_ConeDlgLayout->addWidget( GroupButtons, 2, 0 );
135 /***************************************************************/
136 GroupC1 = new QGroupBox( this, "GroupC1" );
137 GroupC1->setTitle( tr( "GEOM_ARGUMENTS" ) );
138 GroupC1->setColumnLayout(0, Qt::Vertical );
139 GroupC1->layout()->setSpacing( 0 );
140 GroupC1->layout()->setMargin( 0 );
141 GroupC1Layout = new QGridLayout( GroupC1->layout() );
142 GroupC1Layout->setAlignment( Qt::AlignTop );
143 GroupC1Layout->setSpacing( 6 );
144 GroupC1Layout->setMargin( 11 );
145 SelectButtonC1A1 = new QPushButton( GroupC1, "SelectButtonC1A1" );
146 SelectButtonC1A1->setText( tr( "" ) );
147 SelectButtonC1A1->setPixmap( image1 );
148 GroupC1Layout->addWidget( SelectButtonC1A1, 0, 1 );
149 LineEditC1A1 = new QLineEdit( GroupC1, "LineEditC1A1" );
150 LineEditC1A1->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)3, (QSizePolicy::SizeType)0, LineEditC1A1->sizePolicy().hasHeightForWidth() ) );
151 GroupC1Layout->addWidget( LineEditC1A1, 0, 2 );
152 TextLabelC1A1 = new QLabel( GroupC1, "TextLabelC1A1" );
153 TextLabelC1A1->setText( tr( "GEOM_BASE_POINT" ) );
154 TextLabelC1A1->setMinimumSize( QSize( 50, 0 ) );
155 TextLabelC1A1->setFrameShape( QLabel::NoFrame );
156 TextLabelC1A1->setFrameShadow( QLabel::Plain );
157 GroupC1Layout->addWidget( TextLabelC1A1, 0, 0 );
158 SelectButtonC1A2 = new QPushButton( GroupC1, "SelectButtonC1A2" );
159 SelectButtonC1A2->setText( tr( "" ) );
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_I" ).arg("1") );
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 SpinBox_C1A3->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)3, (QSizePolicy::SizeType)0, SpinBox_C1A3->sizePolicy().hasHeightForWidth() ) );
180 GroupC1Layout->addWidget( SpinBox_C1A3 , 2, 2 );
182 TextLabelC1A4 = new QLabel( GroupC1, "TextLabelC1A4" );
183 TextLabelC1A4->setText( tr( "GEOM_RADIUS_I" ).arg("2") );
184 TextLabelC1A4->setMinimumSize( QSize( 50, 0 ) );
185 TextLabelC1A4->setFrameShape( QLabel::NoFrame );
186 TextLabelC1A4->setFrameShadow( QLabel::Plain );
187 GroupC1Layout->addWidget( TextLabelC1A4, 3, 0 );
189 SpinBox_C1A4 = new GeometryGUI_SpinBox( GroupC1, "GeomSpinBox_C1A4" ) ;
190 SpinBox_C1A4->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)3, (QSizePolicy::SizeType)0, SpinBox_C1A4->sizePolicy().hasHeightForWidth() ) );
191 GroupC1Layout->addWidget( SpinBox_C1A4 , 3, 2 ) ;
193 TextLabelC1A5 = new QLabel( GroupC1, "TextLabelC1A5" );
194 TextLabelC1A5->setText( tr( "GEOM_HEIGHT" ) );
195 TextLabelC1A5->setMinimumSize( QSize( 50, 0 ) );
196 TextLabelC1A5->setFrameShape( QLabel::NoFrame );
197 TextLabelC1A5->setFrameShadow( QLabel::Plain );
198 GroupC1Layout->addWidget( TextLabelC1A5, 4, 0 );
200 SpinBox_C1A5 = new GeometryGUI_SpinBox( GroupC1, "GeomSpinBox_C1A5" ) ;
201 SpinBox_C1A5->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)3, (QSizePolicy::SizeType)0, SpinBox_C1A5->sizePolicy().hasHeightForWidth() ) );
202 GroupC1Layout->addWidget( SpinBox_C1A5 , 4, 2 ) ;
204 GeometryGUI_ConeDlgLayout->addWidget( GroupC1, 1, 0 );
205 /***************************************************************/
207 GroupC2 = new QGroupBox( this, "GroupC2" );
208 GroupC2->setTitle( tr( "GEOM_BOX_OBJ" ) );
209 GroupC2->setColumnLayout(0, Qt::Vertical );
210 GroupC2->layout()->setSpacing( 0 );
211 GroupC2->layout()->setMargin( 0 );
212 GroupC2Layout = new QGridLayout( GroupC2->layout() );
213 GroupC2Layout->setAlignment( Qt::AlignTop );
214 GroupC2Layout->setSpacing( 6 );
215 GroupC2Layout->setMargin( 11 );
216 TextLabel_Height = new QLabel(GroupC2 , "TextLabel_Height" );
217 TextLabel_Height->setText( tr( "GEOM_HEIGHT" ) );
218 GroupC2Layout->addWidget( TextLabel_Height, 2, 0 );
219 TextLabel_Radius1 = new QLabel( GroupC2, "TextLabel_Radius1" );
220 TextLabel_Radius1->setText( tr( "GEOM_RADIUS_I" ).arg("1") );
221 GroupC2Layout->addWidget( TextLabel_Radius1, 0, 0 );
222 TextLabel_Radius2 = new QLabel( GroupC2, "TextLabel_Radius2" );
223 TextLabel_Radius2->setText( tr( "GEOM_RADIUS_I" ).arg("2") );
224 GroupC2Layout->addWidget( TextLabel_Radius2, 1, 0 );
226 SpinBox_Radius1 = new GeometryGUI_SpinBox( GroupC2, "GeomSpinBox_Radius1" ) ;
227 GroupC2Layout->addWidget( SpinBox_Radius1 , 0, 1 ) ;
229 SpinBox_Radius2 = new GeometryGUI_SpinBox( GroupC2, "GeomSpinBox_Radius2" ) ;
230 GroupC2Layout->addWidget( SpinBox_Radius2 , 1, 1 ) ;
232 SpinBox_Height = new GeometryGUI_SpinBox( GroupC2, "GeomSpinBox_Height" ) ;
233 GroupC2Layout->addWidget( SpinBox_Height , 2, 1 ) ;
235 QSpacerItem* spacer1 = new QSpacerItem( 20, 60, QSizePolicy::Minimum, QSizePolicy::Fixed );
236 GroupC2Layout->addItem( spacer1 );
238 GeometryGUI_ConeDlgLayout->addWidget(GroupC2 , 1, 0 );
240 /***************************************************************/
242 /* Initialisations */
247 //=================================================================================
248 // function : ~GeometryGUI_ConeDlg()
249 // purpose : Destroys the object and frees any allocated resources
250 //=================================================================================
251 GeometryGUI_ConeDlg::~GeometryGUI_ConeDlg()
253 // no need to delete child widgets, Qt does it all for us
257 //=================================================================================
260 //=================================================================================
261 void GeometryGUI_ConeDlg::Init( SALOME_Selection* Sel )
264 /* Get setting of step value from file configuration */
266 QString St = QAD_CONFIG->getSetting( "Geometry:SettingsGeomStep" ) ;
267 step = St.toDouble() ;
269 /* min, max, step and decimals for spin boxes */
270 SpinBox_C1A3->RangeStepAndValidator( 0.001, 999.999, step, 3 ) ; /* radius 1 */
271 SpinBox_C1A3->SetValue( 100.0 ) ;
272 SpinBox_C1A4->RangeStepAndValidator( 0.000, 999.999, step, 3 ) ; /* radius 2 */
273 SpinBox_C1A4->SetValue( 0.0 ) ;
274 SpinBox_C1A5->RangeStepAndValidator( -999.999, 999.999, step, 3 ) ; /* algebric height */
275 SpinBox_C1A5->SetValue( 300.0 ) ;
277 SpinBox_Radius1->RangeStepAndValidator( 0.001, 999.999, step, 3 ) ; /* radius 1 */
278 SpinBox_Radius1->SetValue( 100.0 ) ;
279 SpinBox_Radius2->RangeStepAndValidator( 0.000, 999.999, step, 3 ) ; /* radius 2 */
280 SpinBox_Radius2->SetValue( 0.0 ) ;
281 SpinBox_Height->RangeStepAndValidator( -999.999, 999.999, step, 3 ) ; /* algebric height */
282 SpinBox_Height->SetValue( 300.0 ) ;
286 myConstructorId = 0 ;
287 Constructor1->setChecked( TRUE );
288 myEditCurrentArgument = LineEditC1A1 ;
290 myGeomGUI = GeometryGUI::GetGeometryGUI() ;
301 mySimulationTopoDs.Nullify() ;
302 myGeomGUI->SetActiveDialogBox( (QDialog*)this ) ;
304 // TODO : previous selection into argument ?
306 /* Filter definitions */
307 Engines::Component_var comp = QAD_Application::getDesktop()->getEngine("FactoryServer", "GEOM");
308 myGeom = GEOM::GEOM_Gen::_narrow(comp);
309 myEdgeFilter = new GEOM_EdgeFilter( StdSelect_Line, myGeom );
310 myVertexFilter = new GEOM_ShapeTypeFilter( TopAbs_VERTEX, myGeom );
311 /* first filter used */
312 mySelection->AddFilter(myVertexFilter) ;
314 /* signals and slots connections */
315 connect( buttonOk, SIGNAL( clicked() ), this, SLOT( ClickOnOk() ) );
316 connect( buttonCancel, SIGNAL( clicked() ), this, SLOT( ClickOnCancel() ) ) ;
317 connect( buttonApply, SIGNAL( clicked() ), this, SLOT(ClickOnApply() ) );
318 connect( GroupConstructors, SIGNAL(clicked(int) ), SLOT( ConstructorsClicked(int) ) );
319 connect( SelectButtonC1A1, SIGNAL (clicked() ), this, SLOT( SetEditCurrentArgument() ) ) ;
320 connect( SelectButtonC1A2, SIGNAL (clicked() ), this, SLOT( SetEditCurrentArgument() ) ) ;
322 connect( SpinBox_C1A3, SIGNAL ( valueChanged( double) ), this, SLOT( ValueChangedInSpinBox( double) ) ) ;
323 connect( SpinBox_C1A4, SIGNAL ( valueChanged( double) ), this, SLOT( ValueChangedInSpinBox( double) ) ) ;
324 connect( SpinBox_C1A5, SIGNAL ( valueChanged( double) ), this, SLOT( ValueChangedInSpinBox( double) ) ) ;
325 connect( SpinBox_Radius1, SIGNAL ( valueChanged( double) ), this, SLOT( ValueChangedInSpinBox( double) ) ) ;
326 connect( SpinBox_Radius2, SIGNAL ( valueChanged( double) ), this, SLOT( ValueChangedInSpinBox( double) ) ) ;
327 connect( SpinBox_Height, SIGNAL ( valueChanged( double) ), this, SLOT( ValueChangedInSpinBox( double) ) ) ;
329 connect( LineEditC1A1, SIGNAL ( returnPressed() ), this, SLOT( LineEditReturnPressed() ) ) ;
330 connect( LineEditC1A2, SIGNAL ( returnPressed() ), this, SLOT( LineEditReturnPressed() ) ) ;
332 connect( myGeomGUI, SIGNAL ( SignalDeactivateActiveDialog() ), this, SLOT( DeactivateActiveDialog() ) ) ;
333 connect( mySelection, SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) );
334 /* to close dialog if study change */
335 connect( myGeomGUI, SIGNAL ( SignalCloseAllDialogs() ), this, SLOT( ClickOnCancel() ) ) ;
337 /* Move widget on the botton right corner of main widget */
339 myGeomGUI->DefineDlgPosition( this, x, y ) ;
341 this->show() ; /* displays Dialog */
348 //=================================================================================
349 // function : ConstructorsClicked()
350 // purpose : Radio button management
351 //=================================================================================
352 void GeometryGUI_ConeDlg::ConstructorsClicked(int constructorId)
354 mySelection->ClearFilters() ;
355 myGeomGUI->EraseSimulationShape() ;
357 switch(myConstructorId)
363 myConstructorId = constructorId ;
364 myOkHeight = myOkRadius1 = myOkRadius2 = myOkPoint1 = myOkDir = true ;
366 SpinBox_Radius1->SetValue( 100.0 ) ; /* radius 1 */
367 SpinBox_Radius2->SetValue( 0.0 ) ; /* radius 2 */
368 SpinBox_Height->SetValue( 300.0 ) ; /* height */
370 disconnect( mySelection, 0, this, 0 );
376 myPoint1.SetCoord( 0.0, 0.0, 0.0 ) ;
377 myDir.SetCoord( 0.0, 0.0, 1.0 ) ;
379 if( myOkPoint1 && myOkDir && myOkRadius1 && myOkRadius2 && myOkHeight ) {
380 gp_Dir aDir = myDir ;
381 /* allows user to reverse direction of construction with a negative height */
382 if( this->myHeight < -Precision::Confusion() ) {
385 MakeConeSimulationAndDisplay() ;
393 myConstructorId = constructorId ;
394 myEditCurrentArgument = LineEditC1A1 ;
395 myOkHeight = myOkRadius1 = myOkRadius2 = true ;
396 myOkPoint1 = myOkDir = false ;
398 SpinBox_C1A3->SetValue( 100.0 ) ; /* radius 1 */
399 SpinBox_C1A4->SetValue( 0.0 ) ; /* radius 2 */
400 SpinBox_C1A5->SetValue( 300.0 ) ; /* height */
405 disconnect( mySelection, 0, this, 0 );
412 //=================================================================================
413 // function : ClickOnOk()
415 //=================================================================================
416 void GeometryGUI_ConeDlg::ClickOnOk()
418 this->ClickOnApply() ;
419 this->ClickOnCancel() ;
424 //=================================================================================
425 // function : ClickOnApply()
427 //=================================================================================
428 void GeometryGUI_ConeDlg::ClickOnApply()
430 myGeomGUI->EraseSimulationShape() ;
431 mySimulationTopoDs.Nullify() ;
432 myGeomGUI->GetDesktop()->putInfo( tr("") ) ;
434 switch(myConstructorId)
438 if(myOkPoint1 && myOkDir && myOkRadius1 && myOkRadius2 && myOkHeight) {
439 gp_Dir aDir = myDir ;
440 /* allows user to reverse direction of construction with a negative height */
441 if( this->myHeight < -Precision::Confusion() ) {
444 myGeomGUI->MakeConeAndDisplay( myPoint1, aDir, myRadius1, myRadius2, fabs(myHeight) ) ;
450 if(myOkPoint1 && myOkDir && myOkRadius1 && myOkRadius2 && myOkHeight) {
451 gp_Dir aDir = myDir ;
452 /* allows user to reverse direction of construction with a negative height */
453 if( this->myHeight < -Precision::Confusion() ) {
456 myGeomGUI->MakeConeAndDisplay( myPoint1, aDir, myRadius1, myRadius2, fabs(myHeight) ) ;
466 //=================================================================================
467 // function : ClickOnCancel()
469 //=================================================================================
470 void GeometryGUI_ConeDlg::ClickOnCancel()
472 mySelection->ClearFilters() ;
473 myGeomGUI->EraseSimulationShape() ;
474 mySimulationTopoDs.Nullify() ;
475 disconnect( mySelection, 0, this, 0 );
476 myGeomGUI->ResetState() ;
482 //=================================================================================
483 // function : SelectionIntoArgument()
484 // purpose : Called when selection as changed or other case
485 //=================================================================================
486 void GeometryGUI_ConeDlg::SelectionIntoArgument()
488 myGeomGUI->EraseSimulationShape() ;
489 mySimulationTopoDs.Nullify() ;
491 /* Future name of selection */
492 QString aString = "";
494 int nbSel = myGeomGUI->GetNameOfSelectedIObjects(mySelection, aString) ;
496 if ( myEditCurrentArgument == LineEditC1A1 ) {
497 LineEditC1A1->setText("") ;
500 else if ( myEditCurrentArgument == LineEditC1A2 ) {
501 LineEditC1A2->setText("") ;
509 if( !myGeomGUI->GetTopoFromSelection(mySelection, S) )
512 /* gp_Pnt : not used */
513 if ( myEditCurrentArgument == LineEditC1A1 && myGeomGUI->VertexToPoint(S, myPoint1) ) {
514 LineEditC1A1->setText(aString) ;
517 else if ( myEditCurrentArgument == LineEditC1A2 /*&& myGeomGUI->LinearLocationAndDirection(S, notUsed, myDir)*/ ) {
518 BRepAdaptor_Curve curv(TopoDS::Edge(S));
519 myDir = curv.Line().Direction();
520 LineEditC1A2->setText(aString) ;
524 if( myConstructorId == 0 && myOkPoint1 && myOkDir && myOkRadius1 && myOkRadius2 && myOkHeight) {
525 MakeConeSimulationAndDisplay() ;
530 //=================================================================================
531 // function : SetEditCurrentArgument()
533 //=================================================================================
534 void GeometryGUI_ConeDlg::SetEditCurrentArgument()
536 QPushButton* send = (QPushButton*)sender();
537 mySelection->ClearFilters() ;
538 switch (myConstructorId)
540 case 0: /* default constructor */
542 if(send == SelectButtonC1A1) {
543 LineEditC1A1->setFocus() ;
544 myEditCurrentArgument = LineEditC1A1;
545 mySelection->AddFilter(myVertexFilter) ;
547 else if(send == SelectButtonC1A2) {
548 LineEditC1A2->setFocus() ;
549 myEditCurrentArgument = LineEditC1A2;
550 mySelection->AddFilter(myEdgeFilter) ;
552 SelectionIntoArgument() ;
564 //=================================================================================
565 // function : LineEditReturnPressed()
567 //=================================================================================
568 void GeometryGUI_ConeDlg::LineEditReturnPressed()
570 QLineEdit* send = (QLineEdit*)sender();
571 if( send == LineEditC1A1 )
572 myEditCurrentArgument = LineEditC1A1 ;
573 else if ( send == LineEditC1A2 )
574 myEditCurrentArgument = LineEditC1A2 ;
578 /* User name of object input management */
579 /* If successfull the selection is changed and signal emitted... */
580 /* so SelectionIntoArgument() is automatically called. */
581 QLineEdit* LE = (QLineEdit*)myEditCurrentArgument ;
582 const QString objectUserName = LE->text() ;
583 QWidget* thisWidget = (QWidget*)this ;
584 if( myGeomGUI->SelectionByNameInDialogs( thisWidget, objectUserName, mySelection ) ) {
585 LE->setText( objectUserName ) ;
590 //=================================================================================
591 // function : ValueChangedInSpinBox()
593 //=================================================================================
594 void GeometryGUI_ConeDlg::ValueChangedInSpinBox( double newValue )
596 myGeomGUI->EraseSimulationShape() ;
597 mySimulationTopoDs.Nullify() ;
599 QObject* send = (QObject*)sender();
601 if( send == SpinBox_C1A3 || send == SpinBox_Radius1 ) { /* radius1 */
602 myRadius1 = newValue ;
604 } else if( send == SpinBox_C1A4 || send == SpinBox_Radius2 ) { /* radius2 */
605 myRadius2 = newValue ;
608 else if( send == SpinBox_C1A5 || send == SpinBox_Height ) { /* algebric height */
609 myHeight = newValue ;
613 if ( myOkPoint1 && myOkDir && myOkRadius1 && myOkRadius2 && myOkHeight ) {
614 MakeConeSimulationAndDisplay() ;
621 //=================================================================================
622 // function : TextChangedInLineEdit()
624 //=================================================================================
625 // void GeometryGUI_ConeDlg::TextChangedInLineEdit(const QString& newText)
628 // myGeomGUI->EraseSimulationShape() ;
629 // mySimulationTopoDs.Nullify() ;
630 // QLineEdit* send = (QLineEdit*)sender();
631 // QString newT = strdup(newText) ;
634 // if(send == LineEditC1A3) { /* radius1 */
635 // if( myVa->validate(newT, i) == myVa->Acceptable ) {
636 // myRadius1 = newText.toFloat() ;
637 // myOkRadius1 = true ;
640 // myOkRadius1 = false ;
642 // } else if(send == LineEditC1A4) { /* radius2 */
643 // if( myVb->validate(newT, i) == myVb->Acceptable ) {
644 // myRadius2 = newText.toFloat() ;
645 // myOkRadius2 = true ;
648 // myOkRadius2 = false ;
650 // } else if(send == LineEditC1A5) { /* algebric height */
652 // if( myVc->validate(newT, i) == myVc->Acceptable ) {
653 // myHeight = newText.toFloat() ;
654 // if( fabs(myHeight) > Precision::Confusion() )
655 // myOkHeight = true ;
657 // myOkHeight = false ;
659 // }else if(send == LineEdit_Radius1) { /* radius1 */
660 // if( myVa->validate(newT, i) == myVa->Acceptable ) {
661 // myRadius1 = newText.toFloat() ;
662 // myOkRadius1 = true ;
665 // myOkRadius1 = false ;
667 // } else if(send == LineEdit_Radius2) { /* radius2 */
668 // if( myVb->validate(newT, i) == myVb->Acceptable ) {
669 // myRadius2 = newText.toFloat() ;
670 // myOkRadius2 = true ;
673 // myOkRadius2 = false ;
675 // } else if(send == LineEdit_Height) { /* algebric height */
677 // if( myVc->validate(newT, i) == myVc->Acceptable ) {
678 // myHeight = newText.toFloat() ;
679 // if( fabs(myHeight) > Precision::Confusion() )
680 // myOkHeight = true ;
682 // myOkHeight = false ;
685 // if (myOkPoint1 && myOkDir && myOkRadius1 && myOkRadius2 && myOkHeight) {
686 // MakeConeSimulationAndDisplay() ;
693 //=================================================================================
694 // function : DeactivateActiveDialog()
696 //=================================================================================
697 void GeometryGUI_ConeDlg::DeactivateActiveDialog()
699 if ( GroupConstructors->isEnabled() ) {
700 GroupConstructors->setEnabled(false) ;
701 GroupC1->setEnabled(false) ;
702 GroupC2->setEnabled(false) ;
703 GroupButtons->setEnabled(false) ;
704 disconnect( mySelection, 0, this, 0 );
705 myGeomGUI->EraseSimulationShape() ;
706 mySelection->ClearFilters() ;
712 //=================================================================================
713 // function : ActivateThisDialog()
715 //=================================================================================
716 void GeometryGUI_ConeDlg::ActivateThisDialog()
718 /* Emit a signal to deactivate the active dialog */
719 myGeomGUI->EmitSignalDeactivateDialog() ;
720 GroupConstructors->setEnabled(true) ;
721 GroupC1->setEnabled(true) ;
722 GroupC2->setEnabled(true) ;
723 GroupButtons->setEnabled(true) ;
724 connect ( mySelection, SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) );
725 if( !mySimulationTopoDs.IsNull() )
726 myGeomGUI->DisplaySimulationShape( mySimulationTopoDs ) ;
731 //=================================================================================
732 // function : enterEvent()
734 //=================================================================================
735 void GeometryGUI_ConeDlg::enterEvent(QEvent* e)
737 if ( GroupConstructors->isEnabled() )
739 ActivateThisDialog() ;
744 //=================================================================================
745 // function : closeEvent()
747 //=================================================================================
748 void GeometryGUI_ConeDlg::closeEvent( QCloseEvent* e )
750 /* same than click on cancel button */
751 this->ClickOnCancel() ;
756 //=================================================================================
757 // function : MakeConeSimulationAndDisplay()
759 //=================================================================================
760 void GeometryGUI_ConeDlg::MakeConeSimulationAndDisplay()
762 myGeomGUI->EraseSimulationShape() ;
763 mySimulationTopoDs.Nullify() ;
764 gp_Dir aDir = myDir ;
767 /* allows user to reverse direction of construction with a negative height */
768 if( this->myHeight < -Precision::Confusion() ) {
772 gp_Ax2 anAxis(this->myPoint1, aDir) ;
774 if( fabs(myRadius1 - myRadius2) <= Precision::Confusion() ) {
775 mySimulationTopoDs = BRepPrimAPI_MakeCylinder( anAxis, (myRadius1+myRadius2)/2.0, fabs(myHeight) ).Shape() ;
778 if( fabs(myHeight) > Precision::Confusion() )
779 mySimulationTopoDs = BRepPrimAPI_MakeCone( anAxis, myRadius1, myRadius2, fabs(myHeight) ).Shape() ;
781 myGeomGUI->DisplaySimulationShape( mySimulationTopoDs ) ;
783 catch(Standard_Failure) {
784 MESSAGE( "Exception catched in MakeConeSimulationAndDisplay" ) ;