2 // File : GeometryGUI_FilletDlg.cxx
4 // Author : Damien COQUERET
7 // Copyright : OPEN CASCADE 2002
10 #include "GeometryGUI_FilletDlg.h"
12 #include "GeometryGUI.h"
13 #include "QAD_Application.h"
14 #include "QAD_Desktop.h"
15 #include "QAD_Config.h"
16 #include "utilities.h"
17 #include "QAD_RightFrame.h"
18 #include "OCCViewer_Viewer3d.h"
20 #include <qbuttongroup.h>
21 #include <qcheckbox.h>
22 #include <qcombobox.h>
23 #include <qgroupbox.h>
25 #include <qlineedit.h>
26 #include <qpushbutton.h>
27 #include <qradiobutton.h>
31 #include <qwhatsthis.h>
35 #include <TopExp_Explorer.hxx>
36 #include <BRepFilletAPI_MakeFillet.hxx>
38 #include <Standard_ErrorHandler.hxx>
39 #include <Standard_Failure.hxx>
42 //=================================================================================
43 // class : GeometryGUI_FilletDlg()
44 // purpose : Constructs a GeometryGUI_FilletDlg which is a child of 'parent', with the
45 // name 'name' and widget flags set to 'f'.
46 // The dialog will by default be modeless, unless you set 'modal' to
47 // TRUE to construct a modal dialog.
48 //=================================================================================
49 GeometryGUI_FilletDlg::GeometryGUI_FilletDlg( QWidget* parent,
51 SALOME_Selection* Sel,
52 Handle (AIS_InteractiveContext) ic,
55 : QDialog( parent, name, modal, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu )
57 /***************************************************************/
58 QPixmap image0(QAD_Desktop::getResourceManager()->loadPixmap( "GeometryGUI",tr("ICON_DLG_FILLET_ALL")));
59 QPixmap image1(QAD_Desktop::getResourceManager()->loadPixmap( "GeometryGUI",tr("ICON_SELECT")));
60 QPixmap image2(QAD_Desktop::getResourceManager()->loadPixmap( "GeometryGUI",tr("ICON_DLG_FILLET_EDGE")));
61 QPixmap image3(QAD_Desktop::getResourceManager()->loadPixmap( "GeometryGUI",tr("ICON_DLG_FILLET_FACE")));
64 setName( "GeometryGUI_FilletDlg" );
66 setCaption( tr( "GEOM_FILLET_TITLE" ) );
67 setSizeGripEnabled( TRUE );
68 GeometryGUI_FilletDlgLayout = new QGridLayout( this );
69 GeometryGUI_FilletDlgLayout->setSpacing( 6 );
70 GeometryGUI_FilletDlgLayout->setMargin( 11 );
72 /***************************************************************/
73 GroupButtons = new QGroupBox( this, "GroupButtons" );
74 GroupButtons->setGeometry( QRect( 10, 10, 281, 48 ) );
75 GroupButtons->setTitle( tr( "" ) );
76 GroupButtons->setColumnLayout(0, Qt::Vertical );
77 GroupButtons->layout()->setSpacing( 0 );
78 GroupButtons->layout()->setMargin( 0 );
79 GroupButtonsLayout = new QGridLayout( GroupButtons->layout() );
80 GroupButtonsLayout->setAlignment( Qt::AlignTop );
81 GroupButtonsLayout->setSpacing( 6 );
82 GroupButtonsLayout->setMargin( 11 );
83 buttonCancel = new QPushButton( GroupButtons, "buttonCancel" );
84 buttonCancel->setText( tr( "GEOM_BUT_CLOSE" ) );
85 buttonCancel->setAutoDefault( TRUE );
86 GroupButtonsLayout->addWidget( buttonCancel, 0, 3 );
87 buttonApply = new QPushButton( GroupButtons, "buttonApply" );
88 buttonApply->setText( tr( "GEOM_BUT_APPLY" ) );
89 buttonApply->setAutoDefault( TRUE );
90 GroupButtonsLayout->addWidget( buttonApply, 0, 1 );
91 QSpacerItem* spacer = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum );
92 GroupButtonsLayout->addItem( spacer, 0, 2 );
93 buttonOk = new QPushButton( GroupButtons, "buttonOk" );
94 buttonOk->setText( tr( "GEOM_BUT_OK" ) );
95 buttonOk->setAutoDefault( TRUE );
96 buttonOk->setDefault( TRUE );
97 GroupButtonsLayout->addWidget( buttonOk, 0, 0 );
98 GeometryGUI_FilletDlgLayout->addWidget( GroupButtons, 2, 0 );
100 /***************************************************************/
101 GroupConstructors = new QButtonGroup( this, "GroupConstructors" );
102 GroupConstructors->setTitle( tr( "GEOM_FILLET" ) );
103 GroupConstructors->setExclusive( TRUE );
104 GroupConstructors->setColumnLayout(0, Qt::Vertical );
105 GroupConstructors->layout()->setSpacing( 0 );
106 GroupConstructors->layout()->setMargin( 0 );
107 GroupConstructorsLayout = new QGridLayout( GroupConstructors->layout() );
108 GroupConstructorsLayout->setAlignment( Qt::AlignTop );
109 GroupConstructorsLayout->setSpacing( 6 );
110 GroupConstructorsLayout->setMargin( 11 );
111 Constructor1 = new QRadioButton( GroupConstructors, "Constructor1" );
112 Constructor1->setText( tr( "" ) );
113 Constructor1->setPixmap( image0 );
114 Constructor1->setChecked( TRUE );
115 Constructor1->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)1, (QSizePolicy::SizeType)0, Constructor1->sizePolicy().hasHeightForWidth() ) );
116 Constructor1->setMinimumSize( QSize( 50, 0 ) );
117 GroupConstructorsLayout->addWidget( Constructor1, 0, 0 );
118 Constructor2 = new QRadioButton( GroupConstructors, "Constructor2" );
119 Constructor2->setText( tr( "" ) );
120 Constructor2->setPixmap( image2 );
121 Constructor2->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)1, (QSizePolicy::SizeType)0, Constructor2->sizePolicy().hasHeightForWidth() ) );
122 Constructor2->setMinimumSize( QSize( 50, 0 ) );
123 GroupConstructorsLayout->addWidget( Constructor2, 0, 2 );
124 QSpacerItem* spacer_2 = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum );
125 GroupConstructorsLayout->addItem( spacer_2, 0, 3 );
126 QSpacerItem* spacer_3 = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum );
127 GroupConstructorsLayout->addItem( spacer_3, 0, 1 );
128 Constructor3 = new QRadioButton( GroupConstructors, "Constructor3" );
129 Constructor3->setText( tr( "" ) );
130 Constructor3->setPixmap( image3 );
131 Constructor3->setMinimumSize( QSize( 50, 0 ) );
132 GroupConstructorsLayout->addWidget( Constructor3, 0, 4 );
133 QSpacerItem* spacer_4 = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum );
134 GroupConstructorsLayout->addItem( spacer_4, 0, 5 );
135 GeometryGUI_FilletDlgLayout->addWidget( GroupConstructors, 0, 0 );
137 /***************************************************************/
138 GroupC1 = new QGroupBox( this, "GroupC1" );
139 GroupC1->setTitle( tr( "GEOM_FILLET_ALL" ) );
140 GroupC1->setMinimumSize( QSize( 0, 0 ) );
141 GroupC1->setFrameShape( QGroupBox::Box );
142 GroupC1->setFrameShadow( QGroupBox::Sunken );
143 GroupC1->setColumnLayout(0, Qt::Vertical );
144 GroupC1->layout()->setSpacing( 0 );
145 GroupC1->layout()->setMargin( 0 );
146 GroupC1Layout = new QGridLayout( GroupC1->layout() );
147 GroupC1Layout->setAlignment( Qt::AlignTop );
148 GroupC1Layout->setSpacing( 6 );
149 GroupC1Layout->setMargin( 11 );
151 TextLabelC1A1 = new QLabel( GroupC1, "TextLabelC1A1" );
152 TextLabelC1A1->setText( tr( "GEOM_MAIN_OBJECT" ) );
153 TextLabelC1A1->setMinimumSize( QSize( 50, 0 ) );
154 TextLabelC1A1->setFrameShape( QLabel::NoFrame );
155 TextLabelC1A1->setFrameShadow( QLabel::Plain );
156 GroupC1Layout->addWidget( TextLabelC1A1, 0, 0 );
158 TextLabelC1A2 = new QLabel( GroupC1, "TextLabelC1A2" );
159 TextLabelC1A2->setText( tr( "GEOM_RADIUS" ) );
160 TextLabelC1A2->setMinimumSize( QSize( 50, 0 ) );
161 TextLabelC1A2->setFrameShape( QLabel::NoFrame );
162 TextLabelC1A2->setFrameShadow( QLabel::Plain );
163 GroupC1Layout->addWidget( TextLabelC1A2, 1, 0 );
165 LineEditC1A1 = new QLineEdit( GroupC1, "LineEditC1A1" );
166 GroupC1Layout->addWidget( LineEditC1A1, 0, 2 );
168 SpinBox_C1A2 = new GeometryGUI_SpinBox( GroupC1, "GeomSpinBox_C1A2" ) ;
169 SpinBox_C1A2->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)3, (QSizePolicy::SizeType)0, SpinBox_C1A2->sizePolicy().hasHeightForWidth() ) );
170 GroupC1Layout->addWidget( SpinBox_C1A2, 1, 2 );
172 SelectButtonC1A1 = new QPushButton( GroupC1, "SelectButtonC1A1" );
173 SelectButtonC1A1->setText( tr( "" ) );
174 SelectButtonC1A1->setPixmap( image1 );
175 SelectButtonC1A1->setToggleButton( FALSE );
176 SelectButtonC1A1->setMaximumSize( QSize( 28, 32767 ) );
177 GroupC1Layout->addWidget( SelectButtonC1A1, 0, 1 );
178 GeometryGUI_FilletDlgLayout->addWidget( GroupC1, 1, 0 );
180 /***************************************************************/
181 GroupC2 = new QGroupBox( this, "GroupC2" );
182 GroupC2->setTitle( tr( "GEOM_FILLET_EDGES" ) );
183 GroupC2->setMinimumSize( QSize( 0, 0 ) );
184 GroupC2->setFrameShape( QGroupBox::Box );
185 GroupC2->setFrameShadow( QGroupBox::Sunken );
186 GroupC2->setColumnLayout(0, Qt::Vertical );
187 GroupC2->layout()->setSpacing( 0 );
188 GroupC2->layout()->setMargin( 0 );
189 GroupC2Layout = new QGridLayout( GroupC2->layout() );
190 GroupC2Layout->setAlignment( Qt::AlignTop );
191 GroupC2Layout->setSpacing( 6 );
192 GroupC2Layout->setMargin( 11 );
194 TextLabelC2A1 = new QLabel( GroupC2, "TextLabelC2A1" );
195 TextLabelC2A1->setText( tr( "GEOM_MAIN_OBJECT" ) );
196 TextLabelC2A1->setMinimumSize( QSize( 50, 0 ) );
197 TextLabelC2A1->setFrameShape( QLabel::NoFrame );
198 TextLabelC2A1->setFrameShadow( QLabel::Plain );
199 GroupC2Layout->addWidget( TextLabelC2A1, 0, 0 );
201 TextLabelC2A2 = new QLabel( GroupC2, "TextLabelC2A2" );
202 TextLabelC2A2->setText( tr( "GEOM_RADIUS" ) );
203 TextLabelC2A2->setMinimumSize( QSize( 50, 0 ) );
204 TextLabelC2A2->setFrameShape( QLabel::NoFrame );
205 TextLabelC2A2->setFrameShadow( QLabel::Plain );
206 GroupC2Layout->addWidget( TextLabelC2A2, 1, 0 );
208 LineEditC2A1 = new QLineEdit( GroupC2, "LineEditC2A1" );
209 GroupC2Layout->addWidget( LineEditC2A1, 0, 2 );
211 SpinBox_C2A2 = new GeometryGUI_SpinBox( GroupC2, "GeomSpinBox_C2A2" ) ;
212 SpinBox_C2A2->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)3, (QSizePolicy::SizeType)0, SpinBox_C2A2->sizePolicy().hasHeightForWidth() ) );
213 GroupC2Layout->addWidget( SpinBox_C2A2, 1, 2 );
215 SelectButtonC2A1 = new QPushButton( GroupC2, "SelectButtonC2A1" );
216 SelectButtonC2A1->setText( tr( "" ) );
217 SelectButtonC2A1->setPixmap( image1 );
218 SelectButtonC2A1->setToggleButton( FALSE );
219 SelectButtonC2A1->setMaximumSize( QSize( 28, 32767 ) );
220 GroupC2Layout->addWidget( SelectButtonC2A1, 0, 1 );
221 GeometryGUI_FilletDlgLayout->addWidget( GroupC2, 1, 0 );
223 /***************************************************************/
224 GroupC3 = new QGroupBox( this, "GroupC3" );
225 GroupC3->setTitle( tr( "GEOM_FILLET_FACES" ) );
226 GroupC3->setMinimumSize( QSize( 0, 0 ) );
227 GroupC3->setFrameShape( QGroupBox::Box );
228 GroupC3->setFrameShadow( QGroupBox::Sunken );
229 GroupC3->setColumnLayout(0, Qt::Vertical );
230 GroupC3->layout()->setSpacing( 0 );
231 GroupC3->layout()->setMargin( 0 );
232 GroupC3Layout = new QGridLayout( GroupC3->layout() );
233 GroupC3Layout->setAlignment( Qt::AlignTop );
234 GroupC3Layout->setSpacing( 6 );
235 GroupC3Layout->setMargin( 11 );
237 TextLabelC3A1 = new QLabel( GroupC3, "TextLabelC3A1" );
238 TextLabelC3A1->setText( tr( "GEOM_MAIN_OBJECT" ) );
239 TextLabelC3A1->setMinimumSize( QSize( 50, 0 ) );
240 TextLabelC3A1->setFrameShape( QLabel::NoFrame );
241 TextLabelC3A1->setFrameShadow( QLabel::Plain );
242 GroupC3Layout->addWidget( TextLabelC3A1, 0, 0 );
244 TextLabelC3A2 = new QLabel( GroupC3, "TextLabelC3A2" );
245 TextLabelC3A2->setText( tr( "GEOM_RADIUS" ) );
246 TextLabelC3A2->setMinimumSize( QSize( 50, 0 ) );
247 TextLabelC3A2->setFrameShape( QLabel::NoFrame );
248 TextLabelC3A2->setFrameShadow( QLabel::Plain );
249 GroupC3Layout->addWidget( TextLabelC3A2, 1, 0 );
251 LineEditC3A1 = new QLineEdit( GroupC3, "LineEditC3A1" );
252 GroupC3Layout->addWidget( LineEditC3A1, 0, 2 );
254 SpinBox_C3A2 = new GeometryGUI_SpinBox( GroupC3, "GeomSpinBox_C3A2" ) ;
255 SpinBox_C3A2->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)3, (QSizePolicy::SizeType)0, SpinBox_C3A2->sizePolicy().hasHeightForWidth() ) );
256 GroupC3Layout->addWidget( SpinBox_C3A2, 1, 2 );
258 SelectButtonC3A1 = new QPushButton( GroupC3, "SelectButtonC3A1" );
259 SelectButtonC3A1->setText( tr( "" ) );
260 SelectButtonC3A1->setPixmap( image1 );
261 SelectButtonC3A1->setToggleButton( FALSE );
262 SelectButtonC3A1->setMaximumSize( QSize( 28, 32767 ) );
263 GroupC3Layout->addWidget( SelectButtonC3A1, 0, 1 );
264 GeometryGUI_FilletDlgLayout->addWidget( GroupC3, 1, 0 );
271 //=================================================================================
272 // function : ~GeometryGUI_FilletDlg()
273 // purpose : Destroys the object and frees any allocated resources
274 //=================================================================================
275 GeometryGUI_FilletDlg::~GeometryGUI_FilletDlg()
277 /* no need to delete child widgets, Qt does it all for us */
278 this->destroy(TRUE, TRUE) ;
282 //=================================================================================
285 //=================================================================================
286 void GeometryGUI_FilletDlg::Init( SALOME_Selection* Sel, Handle (AIS_InteractiveContext) ic )
289 /* Get setting of step value from file configuration */
291 QString St = QAD_CONFIG->getSetting( "Geometry:SettingsGeomStep" ) ;
292 step = St.toDouble() ;
294 /* min, max, step and decimals for spin boxes */
295 SpinBox_C1A2->RangeStepAndValidator( 0.001, 999.999, step, 3 ) ;
296 SpinBox_C1A2->SetValue( 50 ) ;
297 SpinBox_C2A2->RangeStepAndValidator( 0.001, 999.999, step, 3 ) ;
298 SpinBox_C2A2->SetValue( 50 ) ;
299 SpinBox_C3A2->RangeStepAndValidator( 0.001, 999.999, step, 3 ) ;
300 SpinBox_C3A2->SetValue( 50 ) ;
305 myConstructorId = 0 ;
306 Constructor1->setChecked( TRUE );
309 myEditCurrentArgument = LineEditC1A1 ;
314 myLocalContextId = -1 ;
315 myUseLocalContext = false ;
318 myGeomGUI = GeometryGUI::GetGeometryGUI() ;
319 myGeomGUI->SetActiveDialogBox( (QDialog*)this ) ;
321 mySimulationTopoDs.Nullify() ;
323 /* Filters definition */
324 Engines::Component_var comp = QAD_Application::getDesktop()->getEngine("FactoryServer", "Geometry");
325 myGeom = GEOM::GEOM_Gen::_narrow(comp);
327 /* signals and slots connections */
328 connect( buttonOk, SIGNAL( clicked() ), this, SLOT( ClickOnOk() ) );
329 connect( buttonApply, SIGNAL( clicked() ), this, SLOT( ClickOnApply() ) );
330 connect( buttonCancel, SIGNAL( clicked() ), this, SLOT( ClickOnCancel() ) ) ;
331 connect( GroupConstructors, SIGNAL(clicked(int) ), SLOT( ConstructorsClicked(int) ) );
332 connect( SelectButtonC1A1, SIGNAL (clicked() ), this, SLOT( SetEditCurrentArgument() ) ) ;
333 connect( SelectButtonC2A1, SIGNAL (clicked() ), this, SLOT( SetEditCurrentArgument() ) ) ;
334 connect( SelectButtonC3A1, SIGNAL (clicked() ), this, SLOT( SetEditCurrentArgument() ) ) ;
336 connect( SpinBox_C1A2, SIGNAL ( valueChanged( double) ), this, SLOT( ValueChangedInSpinBox( double) ) ) ;
337 connect( SpinBox_C2A2, SIGNAL ( valueChanged( double) ), this, SLOT( ValueChangedInSpinBox( double) ) ) ;
338 connect( SpinBox_C3A2, SIGNAL ( valueChanged( double) ), this, SLOT( ValueChangedInSpinBox( double) ) ) ;
340 connect( LineEditC1A1, SIGNAL ( returnPressed() ), this, SLOT( LineEditReturnPressed() ) ) ;
341 connect( LineEditC2A1, SIGNAL ( returnPressed() ), this, SLOT( LineEditReturnPressed() ) ) ;
342 connect( LineEditC3A1, SIGNAL ( returnPressed() ), this, SLOT( LineEditReturnPressed() ) ) ;
344 connect( mySelection, SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) );
345 connect( myGeomGUI, SIGNAL ( SignalDeactivateActiveDialog() ), this, SLOT( DeactivateActiveDialog() ) ) ;
346 /* to close dialog if study change */
347 connect( myGeomGUI, SIGNAL ( SignalCloseAllDialogs() ), this, SLOT( ClickOnCancel() ) ) ;
349 /* Move widget on the botton right corner of main widget */
351 myGeomGUI->DefineDlgPosition( this, x, y ) ;
353 this->show() ; /* Displays Dialog */
360 //=================================================================================
361 // function : ConstructorsClicked()
362 // purpose : Radio button management
363 //=================================================================================
364 void GeometryGUI_FilletDlg::ConstructorsClicked(int constructorId)
366 myGeomGUI->EraseSimulationShape() ;
367 mySimulationTopoDs.Nullify() ;
369 myEditCurrentArgument->setText(tr("")) ;
371 if ( myGeomGUI->GetActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_OCC ) {
372 OCCViewer_Viewer3d* v3d = ((OCCViewer_ViewFrame*)myGeomGUI->GetActiveStudy()->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getViewer();
373 myIC = v3d->getAISContext(); // myIC = myGeomGUI->GetActiveStudy()->getActiveStudyFrame()->getViewerOCC()->getAISContext();
374 if(this->myUseLocalContext) {
375 myIC->CloseLocalContext(this->myLocalContextId) ;
376 myGeomGUI->OnDisplayAll(true) ;
377 this->myUseLocalContext = false ;
384 myConstructorId = constructorId ;
386 // connect ( mySelection, SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) );
388 switch (constructorId)
390 case 0: /* Fillet All */
396 myEditCurrentArgument = LineEditC1A1 ;
397 SpinBox_C1A2->SetValue( 50 ) ;;
398 LineEditC1A1->setText(tr("")) ;
402 case 1: /* Fillet edges */
408 myEditCurrentArgument = LineEditC2A1 ;
409 SpinBox_C2A2->SetValue( 50 ) ;;
410 LineEditC2A1->setText(tr("")) ;
414 case 2: /* Fillet Faces */
420 myEditCurrentArgument = LineEditC3A1 ;
421 SpinBox_C3A2->SetValue( 50 ) ;;
422 LineEditC3A1->setText(tr("")) ;
430 //=================================================================================
431 // function : ClickOnApply()
433 //=================================================================================
434 void GeometryGUI_FilletDlg::ClickOnApply()
436 myGeomGUI->EraseSimulationShape() ;
437 mySimulationTopoDs.Nullify() ;
439 bool testResult = false ;
440 myGeomGUI->GetDesktop()->putInfo( tr("") ) ;
441 switch(myConstructorId)
443 case 0 : /* Fillet All */
447 testResult = myGeomGUI->OnFilletGetAll( myShape, myRadius, myShapeType, myShapeIOR ) ;
451 myGeomGUI->GetDesktop()->putInfo(tr("GEOM_PRP_ABORT")) ;
453 myGeomGUI->GetDesktop()->putInfo(tr("GEOM_PRP_DONE")) ;
455 /* Reset all arguments and local context to allow user a new selection ...*/
456 this->ResetStateOfDialog() ;
460 case 1 : /* Fillet Edge */
464 testResult = myGeomGUI->OnFilletGetSelected( myShape, myShapeIOR, myRadius, myShapeType, myLocalContextId, myUseLocalContext );
468 myGeomGUI->GetDesktop()->putInfo(tr("GEOM_PRP_ABORT")) ;
470 myGeomGUI->GetDesktop()->putInfo(tr("GEOM_PRP_DONE")) ;
472 /* Reset all arguments and local context to allow user a new selection ...*/
473 this->ResetStateOfDialog() ;
477 case 2 : /* Fillet Face */
481 testResult = myGeomGUI->OnFilletGetSelected( myShape, myShapeIOR, myRadius, myShapeType, myLocalContextId, myUseLocalContext ) ;
485 myGeomGUI->GetDesktop()->putInfo(tr("GEOM_PRP_ABORT")) ;
487 myGeomGUI->GetDesktop()->putInfo(tr("GEOM_PRP_DONE")) ;
489 /* Reset all arguments and local context to allow user a new selection ...*/
490 this->ResetStateOfDialog() ;
500 //=================================================================================
501 // function : ClickOnCancel()
503 //=================================================================================
504 void GeometryGUI_FilletDlg::ClickOnCancel()
506 myGeomGUI->EraseSimulationShape() ;
507 mySimulationTopoDs.Nullify() ;
509 disconnect( mySelection, 0, this, 0 );
510 myGeomGUI->ResetState() ;
511 if ( myGeomGUI->GetActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_OCC ) {
512 OCCViewer_Viewer3d* v3d = ((OCCViewer_ViewFrame*)myGeomGUI->GetActiveStudy()->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getViewer();
513 myIC = v3d->getAISContext(); // myIC = myGeomGUI->GetActiveStudy()->getActiveStudyFrame()->getViewerOCC()->getAISContext();
514 if(this->myUseLocalContext) {
515 myIC->CloseLocalContext(this->myLocalContextId) ;
516 this->myUseLocalContext = false ;
517 myGeomGUI->OnDisplayAll(true) ;
524 //=================================================================================
525 // function : ClickOnOk()
527 //=================================================================================
528 void GeometryGUI_FilletDlg::ClickOnOk()
530 this->ClickOnApply() ;
531 this->ClickOnCancel() ;
536 //=================================================================================
537 // function : LineEditReturnPressed()
539 //=================================================================================
540 void GeometryGUI_FilletDlg::LineEditReturnPressed()
542 QLineEdit* send = (QLineEdit*)sender();
543 if( send == LineEditC1A1 )
544 myEditCurrentArgument = LineEditC1A1 ;
545 else if ( send == LineEditC2A1 )
546 myEditCurrentArgument = LineEditC2A1 ;
547 else if ( send == LineEditC3A1 )
548 myEditCurrentArgument = LineEditC3A1 ;
552 /* User name of object input management */
553 /* If successfull the selection is changed and signal emitted... */
554 /* so SelectionIntoArgument() is automatically called. */
555 const QString objectUserName = myEditCurrentArgument->text() ;
556 QWidget* thisWidget = (QWidget*)this ;
557 if( myGeomGUI->SelectionByNameInDialogs( thisWidget, objectUserName, mySelection ) ) {
558 myEditCurrentArgument->setText( objectUserName ) ;
565 //=================================================================================
566 // function : SelectionIntoArgument()
567 // purpose : Called when selection has changed
568 //=================================================================================
569 void GeometryGUI_FilletDlg::SelectionIntoArgument()
571 myGeomGUI->EraseSimulationShape() ;
572 mySimulationTopoDs.Nullify() ;
574 /* Reset all arguments and local context when selection as changed */
575 this->ResetStateOfDialog() ;
577 /* Future name of argument */
578 QString aString = "";
580 int nbSel = myGeomGUI->GetNameOfSelectedIObjects(mySelection, aString) ;
584 Handle(SALOME_InteractiveObject) IO = mySelection->firstIObject() ;
586 if( !myGeomGUI->GetTopoFromSelection(mySelection, S) )
589 if( !IO->hasEntry() ) {
590 myGeomGUI->GetDesktop()->putInfo(tr("GEOM_PRP_SHAPE_IN_STUDY")) ;
594 if ( !S.IsNull() && S.ShapeType() <= 2 ) {
595 if ( IO->IsInstance(STANDARD_TYPE(GEOM_InteractiveObject)) ) {
596 Handle(GEOM_InteractiveObject) GIObject = Handle(GEOM_InteractiveObject)::DownCast( IO );
597 myShapeIOR = GIObject->getIOR(); /* the Geom IOR string of selection */
598 myEditCurrentArgument->setText(aString) ;
603 if ( IO->hasEntry() ) {
604 SALOMEDS::Study_var aStudy = myGeomGUI->GetActiveStudy()->getStudyDocument();
605 SALOMEDS::SObject_var obj = aStudy->FindObjectID( IO->getEntry() );
606 SALOMEDS::GenericAttribute_var anAttr;
607 SALOMEDS::AttributeIOR_var anIOR;
608 if ( !obj->_is_nil() ) {
609 if (obj->FindAttribute(anAttr, "AttributeIOR")) {
610 anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
611 myShapeIOR = anIOR->Value();
614 myEditCurrentArgument->setText(aString) ;
625 if( myOkShape && myShapeType!=-1 && myConstructorId != 0 ) {
626 /* local context is defined into the method */
627 myGeomGUI->PrepareSubShapeSelection( this->myShapeType, this->myLocalContextId ) ;
628 myUseLocalContext = true ;
629 myGeomGUI->GetDesktop()->putInfo(tr("GEOM_PRP_SELECT_EDGE")) ;
635 //=================================================================================
636 // function : SetEditCurrentArgument()
638 //=================================================================================
639 void GeometryGUI_FilletDlg::SetEditCurrentArgument()
641 QPushButton* send = (QPushButton*)sender();
643 switch (myConstructorId)
647 if(send == SelectButtonC1A1) {
648 LineEditC1A1->setFocus() ;
649 myEditCurrentArgument = LineEditC1A1;
650 SelectionIntoArgument() ;
657 if(send ==SelectButtonC2A1 ) {
658 LineEditC2A1->setFocus() ;
659 myEditCurrentArgument = LineEditC2A1;
660 SelectionIntoArgument() ;
667 if(send ==SelectButtonC3A1 ) {
668 LineEditC3A1->setFocus() ;
669 myEditCurrentArgument = LineEditC3A1;
670 SelectionIntoArgument() ;
678 //=================================================================================
679 // function : ValueChangedInSpinBox()
681 //=================================================================================
682 void GeometryGUI_FilletDlg::ValueChangedInSpinBox( double newValue )
684 myGeomGUI->EraseSimulationShape() ;
685 mySimulationTopoDs.Nullify() ;
687 myRadius = newValue ;
693 //=================================================================================
694 // function : DeactivateActiveDialog()
696 //=================================================================================
697 void GeometryGUI_FilletDlg::DeactivateActiveDialog()
699 if ( GroupConstructors->isEnabled() ) {
700 this->ResetStateOfDialog() ;
701 GroupConstructors->setEnabled(false) ;
702 GroupC1->setEnabled(false) ;
703 GroupC2->setEnabled(false) ;
704 GroupC3->setEnabled(false) ;
705 GroupButtons->setEnabled(false) ;
706 disconnect( mySelection, 0, this, 0 );
707 myGeomGUI->ResetState() ;
708 myGeomGUI->SetActiveDialogBox(0) ;
709 myGeomGUI->OnDisplayAll(true) ;
715 //=================================================================================
716 // function : ActivateThisDialog()
718 //=================================================================================
719 void GeometryGUI_FilletDlg::ActivateThisDialog()
721 /* Emit a signal to deactivate the active dialog */
722 myGeomGUI->EmitSignalDeactivateDialog() ;
724 GroupConstructors->setEnabled(true) ;
725 GroupC1->setEnabled(true) ;
726 GroupC2->setEnabled(true) ;
727 GroupC3->setEnabled(true) ;
728 GroupButtons->setEnabled(true) ;
729 connect ( mySelection, SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) );
730 myGeomGUI->SetActiveDialogBox( (QDialog*)this ) ;
732 if( !mySimulationTopoDs.IsNull() )
733 myGeomGUI->DisplaySimulationShape( mySimulationTopoDs ) ;
738 //=================================================================================
739 // function : enterEvent()
741 //=================================================================================
742 void GeometryGUI_FilletDlg::enterEvent( QEvent* e)
744 if ( GroupConstructors->isEnabled() )
746 ActivateThisDialog() ;
751 //=================================================================================
752 // function : closeEvent()
754 //=================================================================================
755 void GeometryGUI_FilletDlg::closeEvent( QCloseEvent* e )
757 /* same than click on cancel button */
758 this->ClickOnCancel() ;
763 //=================================================================================
764 // function : ResetStateOfDialog()
766 //=================================================================================
767 void GeometryGUI_FilletDlg::ResetStateOfDialog()
769 this->myOkShape = false ;
770 this->myEditCurrentArgument->setText("") ;
772 /* Close its local contact if opened */
773 if ( myGeomGUI->GetActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_OCC ) {
774 OCCViewer_Viewer3d* v3d = ((OCCViewer_ViewFrame*)myGeomGUI->GetActiveStudy()->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getViewer();
775 myIC = v3d->getAISContext(); // myIC = myGeomGUI->GetActiveStudy()->getActiveStudyFrame()->getViewerOCC()->getAISContext();
776 if(this->myUseLocalContext) {
777 myIC->CloseLocalContext(this->myLocalContextId) ;
778 this->myUseLocalContext = false ;
779 myGeomGUI->OnDisplayAll(true) ;
786 void GeometryGUI_FilletDlg::MakePreview()
791 BRepFilletAPI_MakeFillet fill(myShape);
792 switch (myConstructorId)
794 case 0: /* Fillet All */
796 TopExp_Explorer Exp ( myShape, TopAbs_EDGE );
797 for (Exp; Exp.More(); Exp.Next())
799 TopoDS_Edge E =TopoDS::Edge(Exp.Current());
802 for (int i = 1;i<=fill.NbContours();i++)
803 fill.SetRadius(myRadius,i);
808 // case 1: /* Fillet edges */
809 // case 2: /* Fillet Faces */
813 mySimulationTopoDs = tds;
814 myGeomGUI->DisplaySimulationShape( mySimulationTopoDs ) ;
817 catch(Standard_Failure)
819 myGeomGUI->EraseSimulationShape() ;
820 mySimulationTopoDs.Nullify() ;