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_TorusDlg.cxx
25 // Author : Lucien PIGNOLONI
30 #include "GeometryGUI_TorusDlg.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>
56 //=================================================================================
57 // class : GeometryGUI_TorusDlg()
58 // purpose : Constructs a GeometryGUI_TorusDlg which is a child of 'parent', with the
59 // name 'name' and widget flags set to 'f'.
60 // The dialog will by default be modeless, unless you set 'modal' to
61 // TRUE to construct a modal dialog.
62 //=================================================================================
63 GeometryGUI_TorusDlg::GeometryGUI_TorusDlg( QWidget* parent, const char* name, SALOME_Selection* Sel, bool modal, WFlags fl )
64 : QDialog( parent, name, modal, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu )
67 QPixmap image0(QAD_Desktop::getResourceManager()->loadPixmap( "GeometryGUI",tr("ICON_DLG_TORUS_PV")));
68 QPixmap image1(QAD_Desktop::getResourceManager()->loadPixmap( "GeometryGUI",tr("ICON_SELECT")));
69 QPixmap image2(QAD_Desktop::getResourceManager()->loadPixmap( "GeometryGUI",tr("ICON_DLG_TORUS_DXYZ")));
72 setName( "GeometryGUI_TorusDlg" );
74 setCaption( tr( "GEOM_TORUS_TITLE" ) );
75 setSizeGripEnabled( TRUE );
76 GeometryGUI_TorusDlgLayout = new QGridLayout( this );
77 GeometryGUI_TorusDlgLayout->setSpacing( 6 );
78 GeometryGUI_TorusDlgLayout->setMargin( 11 );
80 /***************************************************************/
81 GroupConstructors = new QButtonGroup( this, "GroupConstructors" );
82 GroupConstructors->setTitle( tr( "GEOM_TORUS" ) );
83 GroupConstructors->setExclusive( TRUE );
84 GroupConstructors->setColumnLayout(0, Qt::Vertical );
85 GroupConstructors->layout()->setSpacing( 0 );
86 GroupConstructors->layout()->setMargin( 0 );
87 GroupConstructorsLayout = new QGridLayout( GroupConstructors->layout() );
88 GroupConstructorsLayout->setAlignment( Qt::AlignTop );
89 GroupConstructorsLayout->setSpacing( 6 );
90 GroupConstructorsLayout->setMargin( 11 );
91 QSpacerItem* spacer = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum );
92 GroupConstructorsLayout->addItem( spacer, 0, 1 );
93 Constructor1 = new QRadioButton( GroupConstructors, "Constructor1" );
94 Constructor1->setText( tr( "" ) );
95 Constructor1->setPixmap( image0 );
96 Constructor1->setChecked( TRUE );
97 Constructor1->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)3, (QSizePolicy::SizeType)0,Constructor1->sizePolicy().hasHeightForWidth() ) );
98 Constructor1->setMinimumSize( QSize( 50, 0 ) );
99 GroupConstructorsLayout->addWidget( Constructor1, 0, 0 );
100 Constructor2 = new QRadioButton( GroupConstructors, "Constructor2" );
101 Constructor2->setText( tr( "" ) );
102 Constructor2->setMinimumSize( QSize( 50, 0 ) );
103 Constructor2->setPixmap( image2 );
104 Constructor2->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)3, (QSizePolicy::SizeType)0, Constructor1->sizePolicy().hasHeightForWidth() ) );
105 GroupConstructorsLayout->addWidget( Constructor2, 0, 2 );
106 QSpacerItem* spacer_2 = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum );
107 GroupConstructorsLayout->addItem( spacer_2, 0, 2 );
108 GeometryGUI_TorusDlgLayout->addWidget( GroupConstructors, 0, 0 );
110 /***************************************************************/
111 GroupButtons = new QGroupBox( this, "GroupButtons" );
112 GroupButtons->setGeometry( QRect( 10, 10, 281, 48 ) );
113 GroupButtons->setTitle( tr( "" ) );
114 GroupButtons->setColumnLayout(0, Qt::Vertical );
115 GroupButtons->layout()->setSpacing( 0 );
116 GroupButtons->layout()->setMargin( 0 );
117 GroupButtonsLayout = new QGridLayout( GroupButtons->layout() );
118 GroupButtonsLayout->setAlignment( Qt::AlignTop );
119 GroupButtonsLayout->setSpacing( 6 );
120 GroupButtonsLayout->setMargin( 11 );
121 buttonCancel = new QPushButton( GroupButtons, "buttonCancel" );
122 buttonCancel->setText( tr( "GEOM_BUT_CLOSE" ) );
123 buttonCancel->setAutoDefault( TRUE );
124 GroupButtonsLayout->addWidget( buttonCancel, 0, 3 );
125 buttonApply = new QPushButton( GroupButtons, "buttonApply" );
126 buttonApply->setText( tr( "GEOM_BUT_APPLY" ) );
127 buttonApply->setAutoDefault( TRUE );
128 GroupButtonsLayout->addWidget( buttonApply, 0, 1 );
129 QSpacerItem* spacer_9 = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum );
130 GroupButtonsLayout->addItem( spacer_9, 0, 2 );
131 buttonOk = new QPushButton( GroupButtons, "buttonOk" );
132 buttonOk->setText( tr( "GEOM_BUT_OK" ) );
133 buttonOk->setAutoDefault( TRUE );
134 buttonOk->setDefault( TRUE );
135 GroupButtonsLayout->addWidget( buttonOk, 0, 0 );
136 GeometryGUI_TorusDlgLayout->addWidget( GroupButtons, 2, 0 );
138 /***************************************************************/
139 GroupC1 = new QGroupBox( this, "GroupC1" );
140 GroupC1->setTitle( tr( "GEOM_ARGUMENTS" ) );
141 GroupC1->setColumnLayout(0, Qt::Vertical );
142 GroupC1->layout()->setSpacing( 0 );
143 GroupC1->layout()->setMargin( 0 );
144 GroupC1Layout = new QGridLayout( GroupC1->layout() );
145 GroupC1Layout->setAlignment( Qt::AlignTop );
146 GroupC1Layout->setSpacing( 6 );
147 GroupC1Layout->setMargin( 11 );
148 SelectButtonC1A1 = new QPushButton( GroupC1, "SelectButtonC1A1" );
149 SelectButtonC1A1->setText( tr( "" ) );
150 SelectButtonC1A1->setPixmap( image1 );
151 GroupC1Layout->addWidget( SelectButtonC1A1, 0, 1 );
153 LineEditC1A1 = new QLineEdit( GroupC1, "LineEditC1A1" );
154 LineEditC1A1->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)3, (QSizePolicy::SizeType)0, LineEditC1A1->sizePolicy().hasHeightForWidth() ) );
155 GroupC1Layout->addWidget( LineEditC1A1, 0, 2 );
156 TextLabelC1A1 = new QLabel( GroupC1, "TextLabelC1A1" );
157 TextLabelC1A1->setText( tr( "GEOM_BASE_POINT" ) );
158 TextLabelC1A1->setMinimumSize( QSize( 50, 0 ) );
159 TextLabelC1A1->setFrameShape( QLabel::NoFrame );
160 TextLabelC1A1->setFrameShadow( QLabel::Plain );
161 GroupC1Layout->addWidget( TextLabelC1A1, 0, 0 );
162 SelectButtonC1A2 = new QPushButton( GroupC1, "SelectButtonC1A2" );
163 SelectButtonC1A2->setText( tr( "" ) );
164 SelectButtonC1A2->setPixmap( image1 );
165 GroupC1Layout->addWidget( SelectButtonC1A2, 1, 1 );
166 LineEditC1A2 = new QLineEdit( GroupC1, "LineEditC1A2" );
167 LineEditC1A2->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)3, (QSizePolicy::SizeType)0, LineEditC1A2->sizePolicy().hasHeightForWidth() ) );
168 GroupC1Layout->addWidget( LineEditC1A2, 1, 2 );
169 TextLabelC1A2 = new QLabel( GroupC1, "TextLabelC1A2" );
170 TextLabelC1A2->setText( tr( "GEOM_VECTOR" ) );
171 TextLabelC1A2->setMinimumSize( QSize( 50, 0 ) );
172 TextLabelC1A2->setFrameShape( QLabel::NoFrame );
173 TextLabelC1A2->setFrameShadow( QLabel::Plain );
174 GroupC1Layout->addWidget( TextLabelC1A2, 1, 0 );
175 TextLabelC1A3 = new QLabel( GroupC1, "TextLabelC1A3" );
176 TextLabelC1A3->setText( tr( "GEOM_RADIUS_I" ).arg("1") );
177 TextLabelC1A3->setMinimumSize( QSize( 50, 0 ) );
178 TextLabelC1A3->setFrameShape( QLabel::NoFrame );
179 TextLabelC1A3->setFrameShadow( QLabel::Plain );
180 GroupC1Layout->addWidget( TextLabelC1A3, 2, 0 );
182 SpinBox_C1A3 = new GeometryGUI_SpinBox( GroupC1, "GeomSpinBox_C1A3" ) ;
183 SpinBox_C1A3->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)3, (QSizePolicy::SizeType)0, SpinBox_C1A3->sizePolicy().hasHeightForWidth() ) );
184 GroupC1Layout->addWidget( SpinBox_C1A3, 2, 2 );
186 TextLabelC1A4 = new QLabel( GroupC1, "TextLabelC1A4" );
187 TextLabelC1A4->setText( tr( "GEOM_RADIUS_I" ).arg("2") );
188 TextLabelC1A4->setMinimumSize( QSize( 50, 0 ) );
189 TextLabelC1A4->setFrameShape( QLabel::NoFrame );
190 TextLabelC1A4->setFrameShadow( QLabel::Plain );
191 GroupC1Layout->addWidget( TextLabelC1A4, 3, 0 );
193 SpinBox_C1A4 = new GeometryGUI_SpinBox( GroupC1, "GeomSpinBox_C1A4" ) ;
194 SpinBox_C1A4->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)3, (QSizePolicy::SizeType)0, SpinBox_C1A4->sizePolicy().hasHeightForWidth() ) );
195 GroupC1Layout->addWidget( SpinBox_C1A4, 3, 2 );
197 GeometryGUI_TorusDlgLayout->addWidget( GroupC1, 1, 0 );
198 /***************************************************************/
200 GroupC2 = new QGroupBox( this, "GroupC2" );
201 GroupC2->setTitle( tr( "GEOM_BOX_OBJ" ) );
202 GroupC2->setColumnLayout(0, Qt::Vertical );
203 GroupC2->layout()->setSpacing( 0 );
204 GroupC2->layout()->setMargin( 0 );
205 GroupC2Layout = new QGridLayout( GroupC2->layout() );
206 GroupC2Layout->setAlignment( Qt::AlignTop );
207 GroupC2Layout->setSpacing( 6 );
208 GroupC2Layout->setMargin( 11 );
209 TextLabel_Radius1 = new QLabel( GroupC2, "TextLabel_Radius1" );
210 TextLabel_Radius1->setText( tr( "GEOM_RADIUS_I" ).arg("1") );
211 GroupC2Layout->addWidget( TextLabel_Radius1, 0, 0 );
212 TextLabel_Radius2 = new QLabel( GroupC2, "TextLabel_Radius2" );
213 TextLabel_Radius2->setText( tr( "GEOM_RADIUS_I" ).arg("2") );
214 GroupC2Layout->addWidget( TextLabel_Radius2, 1, 0 );
216 SpinBox_Radius1 = new GeometryGUI_SpinBox( GroupC2, "GeomSpinBox_Radius1" ) ;
217 GroupC2Layout->addWidget( SpinBox_Radius1, 0, 1 );
219 SpinBox_Radius2 = new GeometryGUI_SpinBox( GroupC2, "GeomSpinBox_Radius2" ) ;
220 GroupC2Layout->addWidget( SpinBox_Radius2, 1, 1 );
222 QSpacerItem* spacer1 = new QSpacerItem( 20, 62, QSizePolicy::Minimum, QSizePolicy::Fixed );
223 GroupC2Layout->addItem( spacer1 );
224 GeometryGUI_TorusDlgLayout->addWidget(GroupC2 , 1, 0 );
226 /***************************************************************/
228 /* Initialisations */
233 //=================================================================================
234 // function : ~GeometryGUI_TorusDlg()
235 // purpose : Destroys the object and frees any allocated resources
236 //=================================================================================
237 GeometryGUI_TorusDlg::~GeometryGUI_TorusDlg()
239 // no need to delete child widgets, Qt does it all for us
243 //=================================================================================
246 //=================================================================================
247 void GeometryGUI_TorusDlg::Init( SALOME_Selection* Sel )
250 /* Get setting of step value from file configuration */
252 QString St = QAD_CONFIG->getSetting( "Geometry:SettingsGeomStep" ) ;
253 step = St.toDouble() ;
255 /* min, max, step and decimals for spin boxes */
256 SpinBox_C1A3->RangeStepAndValidator( 0.001, 999.999, step, 3 ) ;
257 SpinBox_C1A4->RangeStepAndValidator( 0.001, 999.999, step, 3 ) ;
258 SpinBox_Radius1->RangeStepAndValidator( 0.001, 999.999, step, 3 ) ;
259 SpinBox_Radius2->RangeStepAndValidator( 0.001, 999.999, step, 3 ) ;
263 myConstructorId = 0 ;
264 Constructor1->setChecked( TRUE );
265 myEditCurrentArgument = LineEditC1A1 ;
267 myGeomGUI = GeometryGUI::GetGeometryGUI() ;
269 SpinBox_C1A3->SetValue( 300.0 ) ;
270 SpinBox_C1A4->SetValue( 100.0 ) ;
271 SpinBox_Radius1->SetValue( 300.0 ) ;
272 SpinBox_Radius2->SetValue( 100.0 ) ;
281 mySimulationTopoDs.Nullify() ;
282 myGeomGUI->SetActiveDialogBox( (QDialog*)this ) ;
284 // TODO : previous selection into argument ?
286 /* Filter definitions */
287 Engines::Component_var comp = QAD_Application::getDesktop()->getEngine("FactoryServer", "Geometry");
288 myGeom = GEOM::GEOM_Gen::_narrow(comp);
289 myEdgeFilter = new GEOM_EdgeFilter( StdSelect_Line, myGeom );
290 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_Radius1, SIGNAL ( valueChanged( double) ), this, SLOT( ValueChangedInSpinBox( double) ) ) ;
305 connect( SpinBox_Radius2, 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 */
325 //=================================================================================
326 // function : ConstructorsClicked()
327 // purpose : Radio button management
328 //=================================================================================
329 void GeometryGUI_TorusDlg::ConstructorsClicked(int constructorId)
331 mySelection->ClearFilters() ;
332 myGeomGUI->EraseSimulationShape() ;
334 switch(myConstructorId)
340 myConstructorId = constructorId ;
341 myOkRadius1 = myOkPoint1 = myOkRadius2 = myOkDir = true ;
343 SpinBox_C1A3->SetValue( 300.0 ) ; /* radius 1 */
344 SpinBox_C1A4->SetValue( 100.0 ) ; /* radius 2 */
348 disconnect( mySelection, 0, this, 0 );
350 myPoint1.SetCoord( 0.0, 0.0, 0.0 ) ;
351 myDir.SetCoord( 0.0, 0.0, 1.0 ) ;
353 if( myOkPoint1 && myOkDir && myOkRadius1 && myOkRadius2 ) {
354 gp_Dir aDir = myDir ;
356 MakeTorusSimulationAndDisplay() ;
364 myConstructorId = constructorId ;
365 myEditCurrentArgument = LineEditC1A1 ;
366 myOkRadius1 = myOkRadius2 = true ;
367 myOkPoint1 = myOkDir = false ;
369 SpinBox_Radius1->SetValue( 300.0 ) ;
370 SpinBox_Radius2->SetValue( 100.0 ) ;
374 LineEditC1A1->setText( tr("") );
375 disconnect( mySelection, 0, this, 0 );
383 //=================================================================================
384 // function : ClickOnApply()
386 //=================================================================================
387 void GeometryGUI_TorusDlg::ClickOnApply()
389 myGeomGUI->GetDesktop()->putInfo( tr("") ) ;
390 myGeomGUI->EraseSimulationShape() ;
391 mySimulationTopoDs.Nullify() ;
392 switch(myConstructorId)
396 if(myOkPoint1 && myOkDir && myOkRadius1 && myOkRadius2 ) {
397 myGeomGUI->MakeTorusAndDisplay( myPoint1, myDir, myRadius1, myRadius2 ) ;
403 if(myOkPoint1 && myOkDir && myOkRadius1 && myOkRadius2 ) {
404 myGeomGUI->MakeTorusAndDisplay( myPoint1, myDir, myRadius1, myRadius2 ) ;
413 //=================================================================================
414 // function : ClickOnOk()
416 //=================================================================================
417 void GeometryGUI_TorusDlg::ClickOnOk()
419 this->ClickOnApply() ;
420 this->ClickOnCancel() ;
425 //=================================================================================
426 // function : ClickOnCancel()
428 //=================================================================================
429 void GeometryGUI_TorusDlg::ClickOnCancel()
431 mySelection->ClearFilters() ;
432 myGeomGUI->EraseSimulationShape() ;
433 mySimulationTopoDs.Nullify() ;
434 disconnect( mySelection, 0, this, 0 );
435 myGeomGUI->ResetState() ;
441 //=================================================================================
442 // function : SelectionIntoArgument()
443 // purpose : Called when selection as changed or other case
444 //=================================================================================
445 void GeometryGUI_TorusDlg::SelectionIntoArgument()
447 myGeomGUI->EraseSimulationShape() ;
448 mySimulationTopoDs.Nullify() ;
450 QString aString = ""; /* Name of future selection */
452 int nbSel = myGeomGUI->GetNameOfSelectedIObjects(mySelection, aString) ;
454 if ( myEditCurrentArgument == LineEditC1A1 ) {
455 LineEditC1A1->setText("") ;
458 else if ( myEditCurrentArgument == LineEditC1A2 ) {
459 LineEditC1A2->setText("") ;
467 if( !myGeomGUI->GetTopoFromSelection(mySelection, S) )
470 /* gp_Pnt : not used */
471 if ( myEditCurrentArgument == LineEditC1A1 && myGeomGUI->VertexToPoint(S, myPoint1) ) {
472 LineEditC1A1->setText(aString) ;
475 else if ( myEditCurrentArgument == LineEditC1A2 /*&& myGeomGUI->LinearLocationAndDirection(S, notUsed, myDir) */) {
476 BRepAdaptor_Curve curv(TopoDS::Edge(S));
477 myDir = curv.Line().Direction();
478 LineEditC1A2->setText(aString) ;
482 if( myConstructorId == 0 && myOkPoint1 && myOkDir && myOkRadius1 && myOkRadius2 ) {
483 MakeTorusSimulationAndDisplay() ;
489 //=================================================================================
490 // function : SetEditCurrentArgument()
492 //=================================================================================
493 void GeometryGUI_TorusDlg::SetEditCurrentArgument()
495 QPushButton* send = (QPushButton*)sender();
496 mySelection->ClearFilters() ;
497 switch (myConstructorId)
499 case 0: /* default constructor */
501 if(send == SelectButtonC1A1) {
502 LineEditC1A1->setFocus() ;
503 myEditCurrentArgument = LineEditC1A1;
504 mySelection->AddFilter(myVertexFilter) ;
506 else if(send == SelectButtonC1A2) {
507 LineEditC1A2->setFocus() ;
508 myEditCurrentArgument = LineEditC1A2;
509 mySelection->AddFilter(myEdgeFilter) ;
511 SelectionIntoArgument() ;
524 //=================================================================================
525 // function : LineEditReturnPressed()
527 //=================================================================================
528 void GeometryGUI_TorusDlg::LineEditReturnPressed()
530 QLineEdit* send = (QLineEdit*)sender();
531 if( send == LineEditC1A1 )
532 myEditCurrentArgument = LineEditC1A1 ;
533 else if ( send == LineEditC1A2)
534 myEditCurrentArgument = LineEditC1A2;
538 /* User name of object input management */
539 /* If successfull the selection is changed and signal emitted... */
540 /* so SelectionIntoArgument() is automatically called. */
541 QLineEdit* LE = (QLineEdit*)myEditCurrentArgument ;
542 const QString objectUserName = LE->text() ;
543 QWidget* thisWidget = (QWidget*)this ;
544 if( myGeomGUI->SelectionByNameInDialogs( thisWidget, objectUserName, mySelection ) ) {
545 LE->setText( objectUserName ) ;
552 //=================================================================================
553 // function : ValueChangedInSpinBox
555 //=================================================================================
556 void GeometryGUI_TorusDlg::ValueChangedInSpinBox( double newValue )
558 QObject* send = (QObject*)sender();
560 if(send == SpinBox_C1A3 ) {
561 myRadius1 = newValue ;
564 else if(send == SpinBox_C1A4 ) {
565 myRadius2 = newValue ;
568 else if(send == SpinBox_Radius1 ) {
569 myRadius1 = newValue ;
572 else if(send == SpinBox_Radius2 ) {
573 myRadius2 = newValue ;
577 if (myOkPoint1 && myOkDir && myOkRadius1 && myOkRadius2 ) {
578 MakeTorusSimulationAndDisplay() ;
581 myGeomGUI->EraseSimulationShape() ;
582 mySimulationTopoDs.Nullify() ;
588 //=================================================================================
589 // function : DeactivateActiveDialog()
591 //=================================================================================
592 void GeometryGUI_TorusDlg::DeactivateActiveDialog()
594 if ( GroupConstructors->isEnabled() ) {
595 GroupConstructors->setEnabled(false) ;
596 GroupC1->setEnabled(false) ;
597 GroupC2->setEnabled(false) ;
598 GroupButtons->setEnabled(false) ;
599 disconnect( mySelection, 0, this, 0 );
600 myGeomGUI->EraseSimulationShape() ;
601 mySelection->ClearFilters() ;
607 //=================================================================================
608 // function : ActivateThisDialog()
610 //=================================================================================
611 void GeometryGUI_TorusDlg::ActivateThisDialog()
613 /* Emit a signal to deactivate the active dialog */
614 myGeomGUI->EmitSignalDeactivateDialog() ;
615 GroupConstructors->setEnabled(true) ;
616 GroupC1->setEnabled(true) ;
617 GroupC2->setEnabled(true) ;
618 GroupButtons->setEnabled(true) ;
619 connect ( mySelection, SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) );
620 if( !mySimulationTopoDs.IsNull() )
621 myGeomGUI->DisplaySimulationShape( mySimulationTopoDs ) ;
626 //=================================================================================
627 // function : enterEvent()
629 //=================================================================================
630 void GeometryGUI_TorusDlg::enterEvent(QEvent* e)
632 if ( GroupConstructors->isEnabled() )
634 ActivateThisDialog() ;
639 //=================================================================================
640 // function : closeEvent()
642 //=================================================================================
643 void GeometryGUI_TorusDlg::closeEvent( QCloseEvent* e )
645 /* same than click on cancel button */
646 this->ClickOnCancel() ;
651 //=================================================================================
652 // function : MakeTorusSimulationAndDisplay()
654 //=================================================================================
655 void GeometryGUI_TorusDlg::MakeTorusSimulationAndDisplay()
657 myGeomGUI->EraseSimulationShape() ;
658 mySimulationTopoDs.Nullify() ;
661 gp_Ax2 anAxis(this->myPoint1, this->myDir) ;
662 mySimulationTopoDs = BRepPrimAPI_MakeTorus( anAxis, this->myRadius1, this->myRadius2 ).Shape() ;
663 myGeomGUI->DisplaySimulationShape( mySimulationTopoDs ) ;
665 catch(Standard_Failure) {
666 MESSAGE( "Exception catched in MakeTorusSimulationAndDisplay" ) ;