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_FilletDlg.cxx
25 // Author : Damien COQUERET
30 #include "GeometryGUI_FilletDlg.h"
32 #include "GeometryGUI.h"
33 #include "QAD_Application.h"
34 #include "QAD_Desktop.h"
35 #include "QAD_Config.h"
36 #include "utilities.h"
37 #include "QAD_RightFrame.h"
38 #include "OCCViewer_Viewer3d.h"
40 #include <qbuttongroup.h>
41 #include <qcheckbox.h>
42 #include <qcombobox.h>
43 #include <qgroupbox.h>
45 #include <qlineedit.h>
46 #include <qpushbutton.h>
47 #include <qradiobutton.h>
51 #include <qwhatsthis.h>
55 #include <TopExp_Explorer.hxx>
56 #include <BRepFilletAPI_MakeFillet.hxx>
58 #include <Standard_ErrorHandler.hxx>
59 #include <Standard_Failure.hxx>
62 //=================================================================================
63 // class : GeometryGUI_FilletDlg()
64 // purpose : Constructs a GeometryGUI_FilletDlg which is a child of 'parent', with the
65 // name 'name' and widget flags set to 'f'.
66 // The dialog will by default be modeless, unless you set 'modal' to
67 // TRUE to construct a modal dialog.
68 //=================================================================================
69 GeometryGUI_FilletDlg::GeometryGUI_FilletDlg( QWidget* parent,
71 SALOME_Selection* Sel,
72 Handle (AIS_InteractiveContext) ic,
75 : QDialog( parent, name, modal, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu )
77 /***************************************************************/
78 QPixmap image0(QAD_Desktop::getResourceManager()->loadPixmap( "GeometryGUI",tr("ICON_DLG_FILLET_ALL")));
79 QPixmap image1(QAD_Desktop::getResourceManager()->loadPixmap( "GeometryGUI",tr("ICON_SELECT")));
80 QPixmap image2(QAD_Desktop::getResourceManager()->loadPixmap( "GeometryGUI",tr("ICON_DLG_FILLET_EDGE")));
81 QPixmap image3(QAD_Desktop::getResourceManager()->loadPixmap( "GeometryGUI",tr("ICON_DLG_FILLET_FACE")));
84 setName( "GeometryGUI_FilletDlg" );
86 setCaption( tr( "GEOM_FILLET_TITLE" ) );
87 setSizeGripEnabled( TRUE );
88 GeometryGUI_FilletDlgLayout = new QGridLayout( this );
89 GeometryGUI_FilletDlgLayout->setSpacing( 6 );
90 GeometryGUI_FilletDlgLayout->setMargin( 11 );
92 /***************************************************************/
93 GroupButtons = new QGroupBox( this, "GroupButtons" );
94 GroupButtons->setGeometry( QRect( 10, 10, 281, 48 ) );
95 GroupButtons->setTitle( tr( "" ) );
96 GroupButtons->setColumnLayout(0, Qt::Vertical );
97 GroupButtons->layout()->setSpacing( 0 );
98 GroupButtons->layout()->setMargin( 0 );
99 GroupButtonsLayout = new QGridLayout( GroupButtons->layout() );
100 GroupButtonsLayout->setAlignment( Qt::AlignTop );
101 GroupButtonsLayout->setSpacing( 6 );
102 GroupButtonsLayout->setMargin( 11 );
103 buttonCancel = new QPushButton( GroupButtons, "buttonCancel" );
104 buttonCancel->setText( tr( "GEOM_BUT_CLOSE" ) );
105 buttonCancel->setAutoDefault( TRUE );
106 GroupButtonsLayout->addWidget( buttonCancel, 0, 3 );
107 buttonApply = new QPushButton( GroupButtons, "buttonApply" );
108 buttonApply->setText( tr( "GEOM_BUT_APPLY" ) );
109 buttonApply->setAutoDefault( TRUE );
110 GroupButtonsLayout->addWidget( buttonApply, 0, 1 );
111 QSpacerItem* spacer = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum );
112 GroupButtonsLayout->addItem( spacer, 0, 2 );
113 buttonOk = new QPushButton( GroupButtons, "buttonOk" );
114 buttonOk->setText( tr( "GEOM_BUT_OK" ) );
115 buttonOk->setAutoDefault( TRUE );
116 buttonOk->setDefault( TRUE );
117 GroupButtonsLayout->addWidget( buttonOk, 0, 0 );
118 GeometryGUI_FilletDlgLayout->addWidget( GroupButtons, 2, 0 );
120 /***************************************************************/
121 GroupConstructors = new QButtonGroup( this, "GroupConstructors" );
122 GroupConstructors->setTitle( tr( "GEOM_FILLET" ) );
123 GroupConstructors->setExclusive( TRUE );
124 GroupConstructors->setColumnLayout(0, Qt::Vertical );
125 GroupConstructors->layout()->setSpacing( 0 );
126 GroupConstructors->layout()->setMargin( 0 );
127 GroupConstructorsLayout = new QGridLayout( GroupConstructors->layout() );
128 GroupConstructorsLayout->setAlignment( Qt::AlignTop );
129 GroupConstructorsLayout->setSpacing( 6 );
130 GroupConstructorsLayout->setMargin( 11 );
131 Constructor1 = new QRadioButton( GroupConstructors, "Constructor1" );
132 Constructor1->setText( tr( "" ) );
133 Constructor1->setPixmap( image0 );
134 Constructor1->setChecked( TRUE );
135 Constructor1->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)1, (QSizePolicy::SizeType)0, Constructor1->sizePolicy().hasHeightForWidth() ) );
136 Constructor1->setMinimumSize( QSize( 50, 0 ) );
137 GroupConstructorsLayout->addWidget( Constructor1, 0, 0 );
138 Constructor2 = new QRadioButton( GroupConstructors, "Constructor2" );
139 Constructor2->setText( tr( "" ) );
140 Constructor2->setPixmap( image2 );
141 Constructor2->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)1, (QSizePolicy::SizeType)0, Constructor2->sizePolicy().hasHeightForWidth() ) );
142 Constructor2->setMinimumSize( QSize( 50, 0 ) );
143 GroupConstructorsLayout->addWidget( Constructor2, 0, 2 );
144 QSpacerItem* spacer_2 = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum );
145 GroupConstructorsLayout->addItem( spacer_2, 0, 3 );
146 QSpacerItem* spacer_3 = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum );
147 GroupConstructorsLayout->addItem( spacer_3, 0, 1 );
148 Constructor3 = new QRadioButton( GroupConstructors, "Constructor3" );
149 Constructor3->setText( tr( "" ) );
150 Constructor3->setPixmap( image3 );
151 Constructor3->setMinimumSize( QSize( 50, 0 ) );
152 GroupConstructorsLayout->addWidget( Constructor3, 0, 4 );
153 QSpacerItem* spacer_4 = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum );
154 GroupConstructorsLayout->addItem( spacer_4, 0, 5 );
155 GeometryGUI_FilletDlgLayout->addWidget( GroupConstructors, 0, 0 );
157 /***************************************************************/
158 GroupC1 = new QGroupBox( this, "GroupC1" );
159 GroupC1->setTitle( tr( "GEOM_FILLET_ALL" ) );
160 GroupC1->setMinimumSize( QSize( 0, 0 ) );
161 GroupC1->setFrameShape( QGroupBox::Box );
162 GroupC1->setFrameShadow( QGroupBox::Sunken );
163 GroupC1->setColumnLayout(0, Qt::Vertical );
164 GroupC1->layout()->setSpacing( 0 );
165 GroupC1->layout()->setMargin( 0 );
166 GroupC1Layout = new QGridLayout( GroupC1->layout() );
167 GroupC1Layout->setAlignment( Qt::AlignTop );
168 GroupC1Layout->setSpacing( 6 );
169 GroupC1Layout->setMargin( 11 );
171 TextLabelC1A1 = new QLabel( GroupC1, "TextLabelC1A1" );
172 TextLabelC1A1->setText( tr( "GEOM_MAIN_OBJECT" ) );
173 TextLabelC1A1->setMinimumSize( QSize( 50, 0 ) );
174 TextLabelC1A1->setFrameShape( QLabel::NoFrame );
175 TextLabelC1A1->setFrameShadow( QLabel::Plain );
176 GroupC1Layout->addWidget( TextLabelC1A1, 0, 0 );
178 TextLabelC1A2 = new QLabel( GroupC1, "TextLabelC1A2" );
179 TextLabelC1A2->setText( tr( "GEOM_RADIUS" ) );
180 TextLabelC1A2->setMinimumSize( QSize( 50, 0 ) );
181 TextLabelC1A2->setFrameShape( QLabel::NoFrame );
182 TextLabelC1A2->setFrameShadow( QLabel::Plain );
183 GroupC1Layout->addWidget( TextLabelC1A2, 1, 0 );
185 LineEditC1A1 = new QLineEdit( GroupC1, "LineEditC1A1" );
186 GroupC1Layout->addWidget( LineEditC1A1, 0, 2 );
188 SpinBox_C1A2 = new GeometryGUI_SpinBox( GroupC1, "GeomSpinBox_C1A2" ) ;
189 SpinBox_C1A2->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)3, (QSizePolicy::SizeType)0, SpinBox_C1A2->sizePolicy().hasHeightForWidth() ) );
190 GroupC1Layout->addWidget( SpinBox_C1A2, 1, 2 );
192 SelectButtonC1A1 = new QPushButton( GroupC1, "SelectButtonC1A1" );
193 SelectButtonC1A1->setText( tr( "" ) );
194 SelectButtonC1A1->setPixmap( image1 );
195 SelectButtonC1A1->setToggleButton( FALSE );
196 SelectButtonC1A1->setMaximumSize( QSize( 28, 32767 ) );
197 GroupC1Layout->addWidget( SelectButtonC1A1, 0, 1 );
198 GeometryGUI_FilletDlgLayout->addWidget( GroupC1, 1, 0 );
200 /***************************************************************/
201 GroupC2 = new QGroupBox( this, "GroupC2" );
202 GroupC2->setTitle( tr( "GEOM_FILLET_EDGES" ) );
203 GroupC2->setMinimumSize( QSize( 0, 0 ) );
204 GroupC2->setFrameShape( QGroupBox::Box );
205 GroupC2->setFrameShadow( QGroupBox::Sunken );
206 GroupC2->setColumnLayout(0, Qt::Vertical );
207 GroupC2->layout()->setSpacing( 0 );
208 GroupC2->layout()->setMargin( 0 );
209 GroupC2Layout = new QGridLayout( GroupC2->layout() );
210 GroupC2Layout->setAlignment( Qt::AlignTop );
211 GroupC2Layout->setSpacing( 6 );
212 GroupC2Layout->setMargin( 11 );
214 TextLabelC2A1 = new QLabel( GroupC2, "TextLabelC2A1" );
215 TextLabelC2A1->setText( tr( "GEOM_MAIN_OBJECT" ) );
216 TextLabelC2A1->setMinimumSize( QSize( 50, 0 ) );
217 TextLabelC2A1->setFrameShape( QLabel::NoFrame );
218 TextLabelC2A1->setFrameShadow( QLabel::Plain );
219 GroupC2Layout->addWidget( TextLabelC2A1, 0, 0 );
221 TextLabelC2A2 = new QLabel( GroupC2, "TextLabelC2A2" );
222 TextLabelC2A2->setText( tr( "GEOM_RADIUS" ) );
223 TextLabelC2A2->setMinimumSize( QSize( 50, 0 ) );
224 TextLabelC2A2->setFrameShape( QLabel::NoFrame );
225 TextLabelC2A2->setFrameShadow( QLabel::Plain );
226 GroupC2Layout->addWidget( TextLabelC2A2, 1, 0 );
228 LineEditC2A1 = new QLineEdit( GroupC2, "LineEditC2A1" );
229 GroupC2Layout->addWidget( LineEditC2A1, 0, 2 );
231 SpinBox_C2A2 = new GeometryGUI_SpinBox( GroupC2, "GeomSpinBox_C2A2" ) ;
232 SpinBox_C2A2->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)3, (QSizePolicy::SizeType)0, SpinBox_C2A2->sizePolicy().hasHeightForWidth() ) );
233 GroupC2Layout->addWidget( SpinBox_C2A2, 1, 2 );
235 SelectButtonC2A1 = new QPushButton( GroupC2, "SelectButtonC2A1" );
236 SelectButtonC2A1->setText( tr( "" ) );
237 SelectButtonC2A1->setPixmap( image1 );
238 SelectButtonC2A1->setToggleButton( FALSE );
239 SelectButtonC2A1->setMaximumSize( QSize( 28, 32767 ) );
240 GroupC2Layout->addWidget( SelectButtonC2A1, 0, 1 );
241 GeometryGUI_FilletDlgLayout->addWidget( GroupC2, 1, 0 );
243 /***************************************************************/
244 GroupC3 = new QGroupBox( this, "GroupC3" );
245 GroupC3->setTitle( tr( "GEOM_FILLET_FACES" ) );
246 GroupC3->setMinimumSize( QSize( 0, 0 ) );
247 GroupC3->setFrameShape( QGroupBox::Box );
248 GroupC3->setFrameShadow( QGroupBox::Sunken );
249 GroupC3->setColumnLayout(0, Qt::Vertical );
250 GroupC3->layout()->setSpacing( 0 );
251 GroupC3->layout()->setMargin( 0 );
252 GroupC3Layout = new QGridLayout( GroupC3->layout() );
253 GroupC3Layout->setAlignment( Qt::AlignTop );
254 GroupC3Layout->setSpacing( 6 );
255 GroupC3Layout->setMargin( 11 );
257 TextLabelC3A1 = new QLabel( GroupC3, "TextLabelC3A1" );
258 TextLabelC3A1->setText( tr( "GEOM_MAIN_OBJECT" ) );
259 TextLabelC3A1->setMinimumSize( QSize( 50, 0 ) );
260 TextLabelC3A1->setFrameShape( QLabel::NoFrame );
261 TextLabelC3A1->setFrameShadow( QLabel::Plain );
262 GroupC3Layout->addWidget( TextLabelC3A1, 0, 0 );
264 TextLabelC3A2 = new QLabel( GroupC3, "TextLabelC3A2" );
265 TextLabelC3A2->setText( tr( "GEOM_RADIUS" ) );
266 TextLabelC3A2->setMinimumSize( QSize( 50, 0 ) );
267 TextLabelC3A2->setFrameShape( QLabel::NoFrame );
268 TextLabelC3A2->setFrameShadow( QLabel::Plain );
269 GroupC3Layout->addWidget( TextLabelC3A2, 1, 0 );
271 LineEditC3A1 = new QLineEdit( GroupC3, "LineEditC3A1" );
272 GroupC3Layout->addWidget( LineEditC3A1, 0, 2 );
274 SpinBox_C3A2 = new GeometryGUI_SpinBox( GroupC3, "GeomSpinBox_C3A2" ) ;
275 SpinBox_C3A2->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)3, (QSizePolicy::SizeType)0, SpinBox_C3A2->sizePolicy().hasHeightForWidth() ) );
276 GroupC3Layout->addWidget( SpinBox_C3A2, 1, 2 );
278 SelectButtonC3A1 = new QPushButton( GroupC3, "SelectButtonC3A1" );
279 SelectButtonC3A1->setText( tr( "" ) );
280 SelectButtonC3A1->setPixmap( image1 );
281 SelectButtonC3A1->setToggleButton( FALSE );
282 SelectButtonC3A1->setMaximumSize( QSize( 28, 32767 ) );
283 GroupC3Layout->addWidget( SelectButtonC3A1, 0, 1 );
284 GeometryGUI_FilletDlgLayout->addWidget( GroupC3, 1, 0 );
291 //=================================================================================
292 // function : ~GeometryGUI_FilletDlg()
293 // purpose : Destroys the object and frees any allocated resources
294 //=================================================================================
295 GeometryGUI_FilletDlg::~GeometryGUI_FilletDlg()
297 /* no need to delete child widgets, Qt does it all for us */
298 this->destroy(TRUE, TRUE) ;
302 //=================================================================================
305 //=================================================================================
306 void GeometryGUI_FilletDlg::Init( SALOME_Selection* Sel, Handle (AIS_InteractiveContext) ic )
309 /* Get setting of step value from file configuration */
311 QString St = QAD_CONFIG->getSetting( "Geometry:SettingsGeomStep" ) ;
312 step = St.toDouble() ;
314 /* min, max, step and decimals for spin boxes */
315 SpinBox_C1A2->RangeStepAndValidator( 0.001, 999.999, step, 3 ) ;
316 SpinBox_C1A2->SetValue( 50 ) ;
317 SpinBox_C2A2->RangeStepAndValidator( 0.001, 999.999, step, 3 ) ;
318 SpinBox_C2A2->SetValue( 50 ) ;
319 SpinBox_C3A2->RangeStepAndValidator( 0.001, 999.999, step, 3 ) ;
320 SpinBox_C3A2->SetValue( 50 ) ;
325 myConstructorId = 0 ;
326 Constructor1->setChecked( TRUE );
329 myEditCurrentArgument = LineEditC1A1 ;
334 myLocalContextId = -1 ;
335 myUseLocalContext = false ;
338 myGeomGUI = GeometryGUI::GetGeometryGUI() ;
339 myGeomGUI->SetActiveDialogBox( (QDialog*)this ) ;
341 mySimulationTopoDs.Nullify() ;
343 /* Filters definition */
344 Engines::Component_var comp = QAD_Application::getDesktop()->getEngine("FactoryServer", "Geometry");
345 myGeom = GEOM::GEOM_Gen::_narrow(comp);
347 /* signals and slots connections */
348 connect( buttonOk, SIGNAL( clicked() ), this, SLOT( ClickOnOk() ) );
349 connect( buttonApply, SIGNAL( clicked() ), this, SLOT( ClickOnApply() ) );
350 connect( buttonCancel, SIGNAL( clicked() ), this, SLOT( ClickOnCancel() ) ) ;
351 connect( GroupConstructors, SIGNAL(clicked(int) ), SLOT( ConstructorsClicked(int) ) );
352 connect( SelectButtonC1A1, SIGNAL (clicked() ), this, SLOT( SetEditCurrentArgument() ) ) ;
353 connect( SelectButtonC2A1, SIGNAL (clicked() ), this, SLOT( SetEditCurrentArgument() ) ) ;
354 connect( SelectButtonC3A1, SIGNAL (clicked() ), this, SLOT( SetEditCurrentArgument() ) ) ;
356 connect( SpinBox_C1A2, SIGNAL ( valueChanged( double) ), this, SLOT( ValueChangedInSpinBox( double) ) ) ;
357 connect( SpinBox_C2A2, SIGNAL ( valueChanged( double) ), this, SLOT( ValueChangedInSpinBox( double) ) ) ;
358 connect( SpinBox_C3A2, SIGNAL ( valueChanged( double) ), this, SLOT( ValueChangedInSpinBox( double) ) ) ;
360 connect( LineEditC1A1, SIGNAL ( returnPressed() ), this, SLOT( LineEditReturnPressed() ) ) ;
361 connect( LineEditC2A1, SIGNAL ( returnPressed() ), this, SLOT( LineEditReturnPressed() ) ) ;
362 connect( LineEditC3A1, SIGNAL ( returnPressed() ), this, SLOT( LineEditReturnPressed() ) ) ;
364 connect( mySelection, SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) );
365 connect( myGeomGUI, SIGNAL ( SignalDeactivateActiveDialog() ), this, SLOT( DeactivateActiveDialog() ) ) ;
366 /* to close dialog if study change */
367 connect( myGeomGUI, SIGNAL ( SignalCloseAllDialogs() ), this, SLOT( ClickOnCancel() ) ) ;
369 /* Move widget on the botton right corner of main widget */
371 myGeomGUI->DefineDlgPosition( this, x, y ) ;
373 this->show() ; /* Displays Dialog */
380 //=================================================================================
381 // function : ConstructorsClicked()
382 // purpose : Radio button management
383 //=================================================================================
384 void GeometryGUI_FilletDlg::ConstructorsClicked(int constructorId)
386 myGeomGUI->EraseSimulationShape() ;
387 mySimulationTopoDs.Nullify() ;
389 myEditCurrentArgument->setText(tr("")) ;
391 if ( myGeomGUI->GetActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_OCC ) {
392 OCCViewer_Viewer3d* v3d = ((OCCViewer_ViewFrame*)myGeomGUI->GetActiveStudy()->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getViewer();
393 myIC = v3d->getAISContext(); // myIC = myGeomGUI->GetActiveStudy()->getActiveStudyFrame()->getViewerOCC()->getAISContext();
394 if(this->myUseLocalContext) {
395 myIC->CloseLocalContext(this->myLocalContextId) ;
396 myGeomGUI->OnDisplayAll(true) ;
397 this->myUseLocalContext = false ;
404 myConstructorId = constructorId ;
406 // connect ( mySelection, SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) );
408 switch (constructorId)
410 case 0: /* Fillet All */
416 myEditCurrentArgument = LineEditC1A1 ;
417 SpinBox_C1A2->SetValue( 50 ) ;;
418 LineEditC1A1->setText(tr("")) ;
422 case 1: /* Fillet edges */
428 myEditCurrentArgument = LineEditC2A1 ;
429 SpinBox_C2A2->SetValue( 50 ) ;;
430 LineEditC2A1->setText(tr("")) ;
434 case 2: /* Fillet Faces */
440 myEditCurrentArgument = LineEditC3A1 ;
441 SpinBox_C3A2->SetValue( 50 ) ;;
442 LineEditC3A1->setText(tr("")) ;
450 //=================================================================================
451 // function : ClickOnApply()
453 //=================================================================================
454 void GeometryGUI_FilletDlg::ClickOnApply()
456 myGeomGUI->EraseSimulationShape() ;
457 mySimulationTopoDs.Nullify() ;
459 bool testResult = false ;
460 myGeomGUI->GetDesktop()->putInfo( tr("") ) ;
461 switch(myConstructorId)
463 case 0 : /* Fillet All */
467 testResult = myGeomGUI->OnFilletGetAll( myShape, myRadius, myShapeType, myShapeIOR ) ;
471 myGeomGUI->GetDesktop()->putInfo(tr("GEOM_PRP_ABORT")) ;
473 myGeomGUI->GetDesktop()->putInfo(tr("GEOM_PRP_DONE")) ;
475 /* Reset all arguments and local context to allow user a new selection ...*/
476 this->ResetStateOfDialog() ;
480 case 1 : /* Fillet Edge */
484 testResult = myGeomGUI->OnFilletGetSelected( myShape, myShapeIOR, myRadius, myShapeType, myLocalContextId, myUseLocalContext );
488 myGeomGUI->GetDesktop()->putInfo(tr("GEOM_PRP_ABORT")) ;
490 myGeomGUI->GetDesktop()->putInfo(tr("GEOM_PRP_DONE")) ;
492 /* Reset all arguments and local context to allow user a new selection ...*/
493 this->ResetStateOfDialog() ;
497 case 2 : /* Fillet Face */
501 testResult = myGeomGUI->OnFilletGetSelected( myShape, myShapeIOR, myRadius, myShapeType, myLocalContextId, myUseLocalContext ) ;
505 myGeomGUI->GetDesktop()->putInfo(tr("GEOM_PRP_ABORT")) ;
507 myGeomGUI->GetDesktop()->putInfo(tr("GEOM_PRP_DONE")) ;
509 /* Reset all arguments and local context to allow user a new selection ...*/
510 this->ResetStateOfDialog() ;
520 //=================================================================================
521 // function : ClickOnCancel()
523 //=================================================================================
524 void GeometryGUI_FilletDlg::ClickOnCancel()
526 myGeomGUI->EraseSimulationShape() ;
527 mySimulationTopoDs.Nullify() ;
529 disconnect( mySelection, 0, this, 0 );
530 myGeomGUI->ResetState() ;
531 if ( myGeomGUI->GetActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_OCC ) {
532 OCCViewer_Viewer3d* v3d = ((OCCViewer_ViewFrame*)myGeomGUI->GetActiveStudy()->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getViewer();
533 myIC = v3d->getAISContext(); // myIC = myGeomGUI->GetActiveStudy()->getActiveStudyFrame()->getViewerOCC()->getAISContext();
534 if(this->myUseLocalContext) {
535 myIC->CloseLocalContext(this->myLocalContextId) ;
536 this->myUseLocalContext = false ;
537 myGeomGUI->OnDisplayAll(true) ;
544 //=================================================================================
545 // function : ClickOnOk()
547 //=================================================================================
548 void GeometryGUI_FilletDlg::ClickOnOk()
550 this->ClickOnApply() ;
551 this->ClickOnCancel() ;
556 //=================================================================================
557 // function : LineEditReturnPressed()
559 //=================================================================================
560 void GeometryGUI_FilletDlg::LineEditReturnPressed()
562 QLineEdit* send = (QLineEdit*)sender();
563 if( send == LineEditC1A1 )
564 myEditCurrentArgument = LineEditC1A1 ;
565 else if ( send == LineEditC2A1 )
566 myEditCurrentArgument = LineEditC2A1 ;
567 else if ( send == LineEditC3A1 )
568 myEditCurrentArgument = LineEditC3A1 ;
572 /* User name of object input management */
573 /* If successfull the selection is changed and signal emitted... */
574 /* so SelectionIntoArgument() is automatically called. */
575 const QString objectUserName = myEditCurrentArgument->text() ;
576 QWidget* thisWidget = (QWidget*)this ;
577 if( myGeomGUI->SelectionByNameInDialogs( thisWidget, objectUserName, mySelection ) ) {
578 myEditCurrentArgument->setText( objectUserName ) ;
585 //=================================================================================
586 // function : SelectionIntoArgument()
587 // purpose : Called when selection has changed
588 //=================================================================================
589 void GeometryGUI_FilletDlg::SelectionIntoArgument()
591 myGeomGUI->EraseSimulationShape() ;
592 mySimulationTopoDs.Nullify() ;
594 /* Reset all arguments and local context when selection as changed */
595 this->ResetStateOfDialog() ;
597 /* Future name of argument */
598 QString aString = "";
600 int nbSel = myGeomGUI->GetNameOfSelectedIObjects(mySelection, aString) ;
604 Handle(SALOME_InteractiveObject) IO = mySelection->firstIObject() ;
606 if( !myGeomGUI->GetTopoFromSelection(mySelection, S) )
609 if( !IO->hasEntry() ) {
610 myGeomGUI->GetDesktop()->putInfo(tr("GEOM_PRP_SHAPE_IN_STUDY")) ;
614 if ( !S.IsNull() && S.ShapeType() <= 2 ) {
615 if ( IO->IsInstance(STANDARD_TYPE(GEOM_InteractiveObject)) ) {
616 Handle(GEOM_InteractiveObject) GIObject = Handle(GEOM_InteractiveObject)::DownCast( IO );
617 myShapeIOR = GIObject->getIOR(); /* the Geom IOR string of selection */
618 myEditCurrentArgument->setText(aString) ;
623 if ( IO->hasEntry() ) {
624 SALOMEDS::Study_var aStudy = myGeomGUI->GetActiveStudy()->getStudyDocument();
625 SALOMEDS::SObject_var obj = aStudy->FindObjectID( IO->getEntry() );
626 SALOMEDS::GenericAttribute_var anAttr;
627 SALOMEDS::AttributeIOR_var anIOR;
628 if ( !obj->_is_nil() ) {
629 if (obj->FindAttribute(anAttr, "AttributeIOR")) {
630 anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
631 myShapeIOR = anIOR->Value();
634 myEditCurrentArgument->setText(aString) ;
645 if( myOkShape && myShapeType!=-1 && myConstructorId != 0 ) {
646 /* local context is defined into the method */
647 myGeomGUI->PrepareSubShapeSelection( this->myShapeType, this->myLocalContextId ) ;
648 myUseLocalContext = true ;
649 myGeomGUI->GetDesktop()->putInfo(tr("GEOM_PRP_SELECT_EDGE")) ;
655 //=================================================================================
656 // function : SetEditCurrentArgument()
658 //=================================================================================
659 void GeometryGUI_FilletDlg::SetEditCurrentArgument()
661 QPushButton* send = (QPushButton*)sender();
663 switch (myConstructorId)
667 if(send == SelectButtonC1A1) {
668 LineEditC1A1->setFocus() ;
669 myEditCurrentArgument = LineEditC1A1;
670 SelectionIntoArgument() ;
677 if(send ==SelectButtonC2A1 ) {
678 LineEditC2A1->setFocus() ;
679 myEditCurrentArgument = LineEditC2A1;
680 SelectionIntoArgument() ;
687 if(send ==SelectButtonC3A1 ) {
688 LineEditC3A1->setFocus() ;
689 myEditCurrentArgument = LineEditC3A1;
690 SelectionIntoArgument() ;
698 //=================================================================================
699 // function : ValueChangedInSpinBox()
701 //=================================================================================
702 void GeometryGUI_FilletDlg::ValueChangedInSpinBox( double newValue )
704 myGeomGUI->EraseSimulationShape() ;
705 mySimulationTopoDs.Nullify() ;
707 myRadius = newValue ;
713 //=================================================================================
714 // function : DeactivateActiveDialog()
716 //=================================================================================
717 void GeometryGUI_FilletDlg::DeactivateActiveDialog()
719 if ( GroupConstructors->isEnabled() ) {
720 this->ResetStateOfDialog() ;
721 GroupConstructors->setEnabled(false) ;
722 GroupC1->setEnabled(false) ;
723 GroupC2->setEnabled(false) ;
724 GroupC3->setEnabled(false) ;
725 GroupButtons->setEnabled(false) ;
726 disconnect( mySelection, 0, this, 0 );
727 myGeomGUI->ResetState() ;
728 myGeomGUI->SetActiveDialogBox(0) ;
729 myGeomGUI->OnDisplayAll(true) ;
735 //=================================================================================
736 // function : ActivateThisDialog()
738 //=================================================================================
739 void GeometryGUI_FilletDlg::ActivateThisDialog()
741 /* Emit a signal to deactivate the active dialog */
742 myGeomGUI->EmitSignalDeactivateDialog() ;
744 GroupConstructors->setEnabled(true) ;
745 GroupC1->setEnabled(true) ;
746 GroupC2->setEnabled(true) ;
747 GroupC3->setEnabled(true) ;
748 GroupButtons->setEnabled(true) ;
749 connect ( mySelection, SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) );
750 myGeomGUI->SetActiveDialogBox( (QDialog*)this ) ;
752 if( !mySimulationTopoDs.IsNull() )
753 myGeomGUI->DisplaySimulationShape( mySimulationTopoDs ) ;
758 //=================================================================================
759 // function : enterEvent()
761 //=================================================================================
762 void GeometryGUI_FilletDlg::enterEvent( QEvent* e)
764 if ( GroupConstructors->isEnabled() )
766 ActivateThisDialog() ;
771 //=================================================================================
772 // function : closeEvent()
774 //=================================================================================
775 void GeometryGUI_FilletDlg::closeEvent( QCloseEvent* e )
777 /* same than click on cancel button */
778 this->ClickOnCancel() ;
783 //=================================================================================
784 // function : ResetStateOfDialog()
786 //=================================================================================
787 void GeometryGUI_FilletDlg::ResetStateOfDialog()
789 this->myOkShape = false ;
790 this->myEditCurrentArgument->setText("") ;
792 /* Close its local contact if opened */
793 if ( myGeomGUI->GetActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_OCC ) {
794 OCCViewer_Viewer3d* v3d = ((OCCViewer_ViewFrame*)myGeomGUI->GetActiveStudy()->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getViewer();
795 myIC = v3d->getAISContext(); // myIC = myGeomGUI->GetActiveStudy()->getActiveStudyFrame()->getViewerOCC()->getAISContext();
796 if(this->myUseLocalContext) {
797 myIC->CloseLocalContext(this->myLocalContextId) ;
798 this->myUseLocalContext = false ;
799 myGeomGUI->OnDisplayAll(true) ;
806 void GeometryGUI_FilletDlg::MakePreview()
811 BRepFilletAPI_MakeFillet fill(myShape);
812 switch (myConstructorId)
814 case 0: /* Fillet All */
816 TopExp_Explorer Exp ( myShape, TopAbs_EDGE );
817 for (Exp; Exp.More(); Exp.Next())
819 TopoDS_Edge E =TopoDS::Edge(Exp.Current());
822 for (int i = 1;i<=fill.NbContours();i++)
823 fill.SetRadius(myRadius,i);
828 // case 1: /* Fillet edges */
829 // case 2: /* Fillet Faces */
833 mySimulationTopoDs = tds;
834 myGeomGUI->DisplaySimulationShape( mySimulationTopoDs ) ;
837 catch(Standard_Failure)
839 myGeomGUI->EraseSimulationShape() ;
840 mySimulationTopoDs.Nullify() ;