2 // File : GeometryGUI_ChamferDlg.cxx
4 // Author : Damien COQUERET
7 // Copyright : OPEN CASCADE 2002
10 #include "GeometryGUI_ChamferDlg.h"
12 #include "GeometryGUI.h"
13 #include "QAD_Application.h"
14 #include "QAD_Desktop.h"
15 #include "QAD_Config.h"
16 #include "QAD_RightFrame.h"
17 #include "OCCViewer_Viewer3d.h"
18 #include "utilities.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 <BRepFilletAPI_MakeChamfer.hxx>
36 #include <BRepTools.hxx>
37 #include <BRep_Tool.hxx>
40 #include <Standard_ErrorHandler.hxx>
41 #include <Standard_Failure.hxx>
43 //=================================================================================
44 // class : GeometryGUI_ChamferDlg()
45 // purpose : Constructs a GeometryGUI_ChamferDlg which is a child of 'parent', with the
46 // name 'name' and widget flags set to 'f'.
47 // The dialog will by default be modeless, unless you set 'modal' to
48 // TRUE to construct a modal dialog.
49 //=================================================================================
50 GeometryGUI_ChamferDlg::GeometryGUI_ChamferDlg( QWidget* parent,
52 SALOME_Selection* Sel,
53 Handle (AIS_InteractiveContext) ic,
56 : QDialog( parent, name, modal, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu )
58 /***************************************************************/
59 QPixmap image0(QAD_Desktop::getResourceManager()->loadPixmap( "GEOM",tr("ICON_DLG_CHAMFER_ALL")));
60 QPixmap image1(QAD_Desktop::getResourceManager()->loadPixmap( "GEOM",tr("ICON_SELECT")));
61 QPixmap image2(QAD_Desktop::getResourceManager()->loadPixmap( "GEOM",tr("ICON_DLG_CHAMFER_EDGE")));
62 QPixmap image3(QAD_Desktop::getResourceManager()->loadPixmap( "GEOM",tr("ICON_DLG_CHAMFER_FACE")));
65 setName( "GeometryGUI_ChamferDlg" );
67 setCaption( tr( "GEOM_CHAMFER_TITLE" ) );
68 setSizeGripEnabled( TRUE );
69 GeometryGUI_ChamferDlgLayout = new QGridLayout( this );
70 GeometryGUI_ChamferDlgLayout->setSpacing( 6 );
71 GeometryGUI_ChamferDlgLayout->setMargin( 11 );
73 /***************************************************************/
74 GroupButtons = new QGroupBox( this, "GroupButtons" );
75 GroupButtons->setGeometry( QRect( 10, 10, 281, 48 ) );
76 GroupButtons->setTitle( tr( "" ) );
77 GroupButtons->setColumnLayout(0, Qt::Vertical );
78 GroupButtons->layout()->setSpacing( 0 );
79 GroupButtons->layout()->setMargin( 0 );
80 GroupButtonsLayout = new QGridLayout( GroupButtons->layout() );
81 GroupButtonsLayout->setAlignment( Qt::AlignTop );
82 GroupButtonsLayout->setSpacing( 6 );
83 GroupButtonsLayout->setMargin( 11 );
84 buttonCancel = new QPushButton( GroupButtons, "buttonCancel" );
85 buttonCancel->setText( tr( "GEOM_BUT_CLOSE" ) );
86 buttonCancel->setAutoDefault( TRUE );
87 GroupButtonsLayout->addWidget( buttonCancel, 0, 3 );
88 buttonApply = new QPushButton( GroupButtons, "buttonApply" );
89 buttonApply->setText( tr( "GEOM_BUT_APPLY" ) );
90 buttonApply->setAutoDefault( TRUE );
91 GroupButtonsLayout->addWidget( buttonApply, 0, 1 );
92 QSpacerItem* spacer = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum );
93 GroupButtonsLayout->addItem( spacer, 0, 2 );
94 buttonOk = new QPushButton( GroupButtons, "buttonOk" );
95 buttonOk->setText( tr( "GEOM_BUT_OK" ) );
96 buttonOk->setAutoDefault( TRUE );
97 buttonOk->setDefault( TRUE );
98 GroupButtonsLayout->addWidget( buttonOk, 0, 0 );
99 GeometryGUI_ChamferDlgLayout->addWidget( GroupButtons, 2, 0 );
101 /***************************************************************/
102 GroupConstructors = new QButtonGroup( this, "GroupConstructors" );
103 GroupConstructors->setTitle( tr( "GEOM_CHAMFER" ) );
104 GroupConstructors->setExclusive( TRUE );
105 GroupConstructors->setColumnLayout(0, Qt::Vertical );
106 GroupConstructors->layout()->setSpacing( 0 );
107 GroupConstructors->layout()->setMargin( 0 );
108 GroupConstructorsLayout = new QGridLayout( GroupConstructors->layout() );
109 GroupConstructorsLayout->setAlignment( Qt::AlignTop );
110 GroupConstructorsLayout->setSpacing( 6 );
111 GroupConstructorsLayout->setMargin( 11 );
112 Constructor1 = new QRadioButton( GroupConstructors, "Constructor1" );
113 Constructor1->setText( tr( "" ) );
114 Constructor1->setPixmap( image0 );
115 Constructor1->setChecked( TRUE );
116 Constructor1->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)1, (QSizePolicy::SizeType)0, Constructor1->sizePolicy().hasHeightForWidth() ) );
117 Constructor1->setMinimumSize( QSize( 50, 0 ) );
118 GroupConstructorsLayout->addWidget( Constructor1, 0, 0 );
119 Constructor2 = new QRadioButton( GroupConstructors, "Constructor2" );
120 Constructor2->setText( tr( "" ) );
121 Constructor2->setPixmap( image2 );
122 Constructor2->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)1, (QSizePolicy::SizeType)0, Constructor2->sizePolicy().hasHeightForWidth() ) );
123 Constructor2->setMinimumSize( QSize( 50, 0 ) );
124 GroupConstructorsLayout->addWidget( Constructor2, 0, 2 );
125 QSpacerItem* spacer_2 = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum );
126 GroupConstructorsLayout->addItem( spacer_2, 0, 3 );
127 QSpacerItem* spacer_3 = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum );
128 GroupConstructorsLayout->addItem( spacer_3, 0, 1 );
129 Constructor3 = new QRadioButton( GroupConstructors, "Constructor3" );
130 Constructor3->setText( tr( "" ) );
131 Constructor3->setPixmap( image3 );
132 Constructor3->setMinimumSize( QSize( 50, 0 ) );
133 GroupConstructorsLayout->addWidget( Constructor3, 0, 4 );
134 QSpacerItem* spacer_4 = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum );
135 GroupConstructorsLayout->addItem( spacer_4, 0, 5 );
136 GeometryGUI_ChamferDlgLayout->addWidget( GroupConstructors, 0, 0 );
138 /***************************************************************/
139 GroupC1 = new QGroupBox( this, "GroupC1" );
140 GroupC1->setTitle( tr( "GEOM_CHAMFER_ALL" ) );
141 GroupC1->setMinimumSize( QSize( 0, 0 ) );
142 GroupC1->setFrameShape( QGroupBox::Box );
143 GroupC1->setFrameShadow( QGroupBox::Sunken );
144 GroupC1->setColumnLayout(0, Qt::Vertical );
145 GroupC1->layout()->setSpacing( 0 );
146 GroupC1->layout()->setMargin( 0 );
147 GroupC1Layout = new QGridLayout( GroupC1->layout() );
148 GroupC1Layout->setAlignment( Qt::AlignTop );
149 GroupC1Layout->setSpacing( 6 );
150 GroupC1Layout->setMargin( 11 );
152 TextLabelC1A1 = new QLabel( GroupC1, "TextLabelC1A1" );
153 TextLabelC1A1->setText( tr( "GEOM_MAIN_OBJECT" ) );
154 TextLabelC1A1->setMinimumSize( QSize( 50, 0 ) );
155 TextLabelC1A1->setFrameShape( QLabel::NoFrame );
156 TextLabelC1A1->setFrameShadow( QLabel::Plain );
157 GroupC1Layout->addWidget( TextLabelC1A1, 0, 0 );
159 TextLabelC1A2 = new QLabel( GroupC1, "TextLabelC1A2" );
160 TextLabelC1A2->setText( tr( "GEOM_D1" ) );
161 TextLabelC1A2->setMinimumSize( QSize( 50, 0 ) );
162 TextLabelC1A2->setFrameShape( QLabel::NoFrame );
163 TextLabelC1A2->setFrameShadow( QLabel::Plain );
164 GroupC1Layout->addWidget( TextLabelC1A2, 1, 0 );
166 TextLabelC1A3 = new QLabel( GroupC1, "TextLabelC1A3" );
167 TextLabelC1A3->setText( tr( "GEOM_D2" ) );
168 TextLabelC1A3->setMinimumSize( QSize( 50, 0 ) );
169 TextLabelC1A3->setFrameShape( QLabel::NoFrame );
170 TextLabelC1A3->setFrameShadow( QLabel::Plain );
171 GroupC1Layout->addWidget( TextLabelC1A3, 2, 0 );
173 LineEditC1A1 = new QLineEdit( GroupC1, "LineEditC1A1" );
174 GroupC1Layout->addWidget( LineEditC1A1, 0, 2 );
176 // LineEditC1A2 = new QLineEdit( GroupC1, "LineEditC1A2" );
177 // LineEditC1A2->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)3, (QSizePolicy::SizeType)0, LineEditC1A2->sizePolicy().hasHeightForWidth() ) );
178 // GroupC1Layout->addWidget( LineEditC1A2, 1, 2 );
180 // LineEditC1A3 = new QLineEdit( GroupC1, "LineEditC1A3" );
181 // LineEditC1A3->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)3, (QSizePolicy::SizeType)0, LineEditC1A3->sizePolicy().hasHeightForWidth() ) );
182 // GroupC1Layout->addWidget( LineEditC1A3, 2, 2 );
184 SpinBox_C1A2 = new GeometryGUI_SpinBox( GroupC1, "GeomSpinBox_C1A2" ) ;
185 SpinBox_C1A2->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)3, (QSizePolicy::SizeType)0, SpinBox_C1A2->sizePolicy().hasHeightForWidth() ) );
186 GroupC1Layout->addWidget( SpinBox_C1A2, 1, 2 );
188 SpinBox_C1A3 = new GeometryGUI_SpinBox( GroupC1, "GeomSpinBox_C1A3" ) ;
189 SpinBox_C1A3->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)3, (QSizePolicy::SizeType)0, SpinBox_C1A3->sizePolicy().hasHeightForWidth() ) );
190 GroupC1Layout->addWidget( SpinBox_C1A3, 2, 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_ChamferDlgLayout->addWidget( GroupC1, 1, 0 );
200 /***************************************************************/
201 GroupC2 = new QGroupBox( this, "GroupC2" );
202 GroupC2->setTitle( tr( "GEOM_CHAMFER_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_D1" ) );
223 TextLabelC2A2->setMinimumSize( QSize( 50, 0 ) );
224 TextLabelC2A2->setFrameShape( QLabel::NoFrame );
225 TextLabelC2A2->setFrameShadow( QLabel::Plain );
226 GroupC2Layout->addWidget( TextLabelC2A2, 1, 0 );
228 TextLabelC2A3 = new QLabel( GroupC2, "TextLabelC2A3" );
229 TextLabelC2A3->setText( tr( "GEOM_D2" ) );
230 TextLabelC2A3->setMinimumSize( QSize( 50, 0 ) );
231 TextLabelC2A3->setFrameShape( QLabel::NoFrame );
232 TextLabelC2A3->setFrameShadow( QLabel::Plain );
233 GroupC2Layout->addWidget( TextLabelC2A3, 2, 0 );
235 LineEditC2A1 = new QLineEdit( GroupC2, "LineEditC2A1" );
236 GroupC2Layout->addWidget( LineEditC2A1, 0, 2 );
238 // LineEditC2A2 = new QLineEdit( GroupC2, "LineEditC2A2" );
239 // LineEditC2A2->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)3, (QSizePolicy::SizeType)0, LineEditC2A2->sizePolicy().hasHeightForWidth() ) );
240 // GroupC2Layout->addWidget( LineEditC2A2, 1, 2 );
242 // LineEditC2A3 = new QLineEdit( GroupC2, "LineEditC2A3" );
243 // LineEditC2A3->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)3, (QSizePolicy::SizeType)0, LineEditC2A3->sizePolicy().hasHeightForWidth() ) );
244 // GroupC2Layout->addWidget( LineEditC2A3, 2, 2 );
246 SpinBox_C2A2 = new GeometryGUI_SpinBox( GroupC2, "GeomSpinBox_C2A2" ) ;
247 SpinBox_C2A2->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)3, (QSizePolicy::SizeType)0, SpinBox_C2A2->sizePolicy().hasHeightForWidth() ) );
248 GroupC2Layout->addWidget( SpinBox_C2A2, 1, 2 );
250 SpinBox_C2A3 = new GeometryGUI_SpinBox( GroupC2, "GeomSpinBox_C2A3" ) ;
251 SpinBox_C2A3->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)3, (QSizePolicy::SizeType)0, SpinBox_C2A3->sizePolicy().hasHeightForWidth() ) );
252 GroupC2Layout->addWidget( SpinBox_C2A3, 2, 2 );
254 SelectButtonC2A1 = new QPushButton( GroupC2, "SelectButtonC2A1" );
255 SelectButtonC2A1->setText( tr( "" ) );
256 SelectButtonC2A1->setPixmap( image1 );
257 SelectButtonC2A1->setToggleButton( FALSE );
258 SelectButtonC2A1->setMaximumSize( QSize( 28, 32767 ) );
259 GroupC2Layout->addWidget( SelectButtonC2A1, 0, 1 );
260 GeometryGUI_ChamferDlgLayout->addWidget( GroupC2, 1, 0 );
262 /***************************************************************/
263 GroupC3 = new QGroupBox( this, "GroupC3" );
264 GroupC3->setTitle( tr( "GEOM_CHAMFER_FACES" ) );
265 GroupC3->setMinimumSize( QSize( 0, 0 ) );
266 GroupC3->setFrameShape( QGroupBox::Box );
267 GroupC3->setFrameShadow( QGroupBox::Sunken );
268 GroupC3->setColumnLayout(0, Qt::Vertical );
269 GroupC3->layout()->setSpacing( 0 );
270 GroupC3->layout()->setMargin( 0 );
271 GroupC3Layout = new QGridLayout( GroupC3->layout() );
272 GroupC3Layout->setAlignment( Qt::AlignTop );
273 GroupC3Layout->setSpacing( 6 );
274 GroupC3Layout->setMargin( 11 );
276 TextLabelC3A1 = new QLabel( GroupC3, "TextLabelC3A1" );
277 TextLabelC3A1->setText( tr( "GEOM_MAIN_OBJECT" ) );
278 TextLabelC3A1->setMinimumSize( QSize( 50, 0 ) );
279 TextLabelC3A1->setFrameShape( QLabel::NoFrame );
280 TextLabelC3A1->setFrameShadow( QLabel::Plain );
281 GroupC3Layout->addWidget( TextLabelC3A1, 0, 0 );
283 TextLabelC3A2 = new QLabel( GroupC3, "TextLabelC3A2" );
284 TextLabelC3A2->setText( tr( "GEOM_D1" ) );
285 TextLabelC3A2->setMinimumSize( QSize( 50, 0 ) );
286 TextLabelC3A2->setFrameShape( QLabel::NoFrame );
287 TextLabelC3A2->setFrameShadow( QLabel::Plain );
288 GroupC3Layout->addWidget( TextLabelC3A2, 1, 0 );
290 TextLabelC3A3 = new QLabel( GroupC3, "TextLabelC3A3" );
291 TextLabelC3A3->setText( tr( "GEOM_D2" ) );
292 TextLabelC3A3->setMinimumSize( QSize( 50, 0 ) );
293 TextLabelC3A3->setFrameShape( QLabel::NoFrame );
294 TextLabelC3A3->setFrameShadow( QLabel::Plain );
295 GroupC3Layout->addWidget( TextLabelC3A3, 2, 0 );
297 LineEditC3A1 = new QLineEdit( GroupC3, "LineEditC3A1" );
298 GroupC3Layout->addWidget( LineEditC3A1, 0, 2 );
300 // LineEditC3A2 = new QLineEdit( GroupC3, "LineEditC3A2" );
301 // LineEditC3A2->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)3, (QSizePolicy::SizeType)0, LineEditC3A2->sizePolicy().hasHeightForWidth() ) );
302 // GroupC3Layout->addWidget( LineEditC3A2, 1, 2 );
304 // LineEditC3A3 = new QLineEdit( GroupC3, "LineEditC3A3" );
305 // LineEditC3A3->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)3, (QSizePolicy::SizeType)0, LineEditC3A3->sizePolicy().hasHeightForWidth() ) );
306 // GroupC3Layout->addWidget( LineEditC3A3, 2, 2 );
308 SpinBox_C3A2 = new GeometryGUI_SpinBox( GroupC3, "GeomSpinBox_C3A2" ) ;
309 SpinBox_C3A2->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)3, (QSizePolicy::SizeType)0, SpinBox_C3A2->sizePolicy().hasHeightForWidth() ) );
310 GroupC3Layout->addWidget( SpinBox_C3A2, 1, 2 );
312 SpinBox_C3A3 = new GeometryGUI_SpinBox( GroupC3, "GeomSpinBox_C3A3" ) ;
313 SpinBox_C3A3->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)3, (QSizePolicy::SizeType)0, SpinBox_C3A3->sizePolicy().hasHeightForWidth() ) );
314 GroupC3Layout->addWidget( SpinBox_C3A3, 2, 2 );
316 SelectButtonC3A1 = new QPushButton( GroupC3, "SelectButtonC3A1" );
317 SelectButtonC3A1->setText( tr( "" ) );
318 SelectButtonC3A1->setPixmap( image1 );
319 SelectButtonC3A1->setToggleButton( FALSE );
320 SelectButtonC3A1->setMaximumSize( QSize( 28, 32767 ) );
321 GroupC3Layout->addWidget( SelectButtonC3A1, 0, 1 );
322 GeometryGUI_ChamferDlgLayout->addWidget( GroupC3, 1, 0 );
329 //=================================================================================
330 // function : ~GeometryGUI_ChamferDlg()
331 // purpose : Destroys the object and frees any allocated resources
332 //=================================================================================
333 GeometryGUI_ChamferDlg::~GeometryGUI_ChamferDlg()
335 /* no need to delete child widgets, Qt does it all for us */
336 this->destroy(TRUE, TRUE) ;
340 //=================================================================================
343 //=================================================================================
344 void GeometryGUI_ChamferDlg::Init( SALOME_Selection* Sel, Handle (AIS_InteractiveContext) ic )
347 /* Get setting of step value from file configuration */
349 QString St = QAD_CONFIG->getSetting( "Geometry:SettingsGeomStep" ) ;
350 step = St.toDouble() ;
352 /* min, max, step and decimals for spin boxes */
353 SpinBox_C1A2->RangeStepAndValidator( 0.001, 999.999, step, 3 ) ; /* myD1 */
354 SpinBox_C1A2->SetValue( 50 ) ;
355 SpinBox_C1A3->RangeStepAndValidator( 0.001, 999.999, step, 3 ) ; /* myD2 */
356 SpinBox_C1A3->SetValue( 50 ) ;
358 SpinBox_C2A2->RangeStepAndValidator( 0.001, 999.999, step, 3 ) ;
359 SpinBox_C2A2->SetValue( 50 ) ;
360 SpinBox_C2A3->RangeStepAndValidator( 0.001, 999.999, step, 3 ) ;
361 SpinBox_C2A3->SetValue( 50 ) ;
363 SpinBox_C3A2->RangeStepAndValidator( 0.001, 999.999, step, 3 ) ;
364 SpinBox_C3A2->SetValue( 50 ) ;
365 SpinBox_C3A3->RangeStepAndValidator( 0.001, 999.999, step, 3 ) ;
366 SpinBox_C3A3->SetValue( 50 ) ;
371 myConstructorId = 0 ;
372 Constructor1->setChecked( TRUE );
375 myEditCurrentArgument = LineEditC1A1 ;
382 myUseLocalContext = false ;
385 myGeomGUI = GeometryGUI::GetGeometryGUI() ;
386 myGeomGUI->SetActiveDialogBox( (QDialog*)this ) ;
388 mySimulationTopoDs.Nullify() ;
390 /* Filters definition */
391 Engines::Component_var comp = QAD_Application::getDesktop()->getEngine("FactoryServer", "GEOM");
392 myGeom = GEOM::GEOM_Gen::_narrow(comp);
394 /* signals and slots connections */
395 connect( buttonOk, SIGNAL( clicked() ), this, SLOT( ClickOnOk() ) );
396 connect( buttonApply, SIGNAL( clicked() ), this, SLOT( ClickOnApply() ) );
397 connect( buttonCancel, SIGNAL( clicked() ), this, SLOT( ClickOnCancel() ) ) ;
398 connect( GroupConstructors, SIGNAL(clicked(int) ), SLOT( ConstructorsClicked(int) ) );
399 connect( SelectButtonC1A1, SIGNAL (clicked() ), this, SLOT( SetEditCurrentArgument() ) ) ;
400 connect( SelectButtonC2A1, SIGNAL (clicked() ), this, SLOT( SetEditCurrentArgument() ) ) ;
401 connect( SelectButtonC3A1, SIGNAL (clicked() ), this, SLOT( SetEditCurrentArgument() ) ) ;
403 connect( SpinBox_C1A2, SIGNAL ( valueChanged( double) ), this, SLOT( ValueChangedInSpinBox( double) ) ) ;
404 connect( SpinBox_C2A2, SIGNAL ( valueChanged( double) ), this, SLOT( ValueChangedInSpinBox( double) ) ) ;
405 connect( SpinBox_C3A2, SIGNAL ( valueChanged( double) ), this, SLOT( ValueChangedInSpinBox( double) ) ) ;
407 connect( SpinBox_C1A3, SIGNAL ( valueChanged( double) ), this, SLOT( ValueChangedInSpinBox( double) ) ) ;
408 connect( SpinBox_C2A3, SIGNAL ( valueChanged( double) ), this, SLOT( ValueChangedInSpinBox( double) ) ) ;
409 connect( SpinBox_C3A3, SIGNAL ( valueChanged( double) ), this, SLOT( ValueChangedInSpinBox( double) ) ) ;
411 connect( LineEditC1A1, SIGNAL ( returnPressed() ), this, SLOT( LineEditReturnPressed() ) ) ;
412 connect( LineEditC2A1, SIGNAL ( returnPressed() ), this, SLOT( LineEditReturnPressed() ) ) ;
413 connect( LineEditC3A1, SIGNAL ( returnPressed() ), this, SLOT( LineEditReturnPressed() ) ) ;
415 connect( mySelection, SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) );
416 connect( myGeomGUI, SIGNAL ( SignalDeactivateActiveDialog() ), this, SLOT( DeactivateActiveDialog() ) ) ;
417 /* to close dialog if study change */
418 connect( myGeomGUI, SIGNAL ( SignalCloseAllDialogs() ), this, SLOT( ClickOnCancel() ) ) ;
420 /* Move widget on the botton right corner of main widget */
422 myGeomGUI->DefineDlgPosition( this, x, y ) ;
424 this->show() ; /* Displays Dialog */
431 //=================================================================================
432 // function : ConstructorsClicked()
433 // purpose : Radio button management
434 //=================================================================================
435 void GeometryGUI_ChamferDlg::ConstructorsClicked(int constructorId)
437 myGeomGUI->EraseSimulationShape() ;
438 mySimulationTopoDs.Nullify() ;
440 myEditCurrentArgument->setText(tr("")) ;
442 if ( myGeomGUI->GetActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_OCC ) {
443 OCCViewer_Viewer3d* v3d = ((OCCViewer_ViewFrame*)myGeomGUI->GetActiveStudy()->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getViewer();
444 myIC = v3d->getAISContext();
445 if(myUseLocalContext ) {
446 myIC->CloseLocalContext(this->myLocalContextId);
447 myGeomGUI->OnDisplayAll(true) ;
448 myUseLocalContext = false ;
457 myConstructorId = constructorId ;
459 switch (constructorId)
461 case 0: /* Chamfer All */
466 myEditCurrentArgument = LineEditC1A1 ;
467 SpinBox_C1A2->SetValue( 50 ) ;
468 SpinBox_C1A3->SetValue( 50 ) ;
469 LineEditC1A1->setText(tr("")) ;
474 case 1: /* Chamfer edges */
480 myEditCurrentArgument = LineEditC2A1 ;
481 SpinBox_C2A2->SetValue( 50 ) ;
482 SpinBox_C2A3->SetValue( 50 ) ;
483 LineEditC2A1->setText(tr("")) ;
487 case 2: /* Chamfer Faces */
493 myEditCurrentArgument = LineEditC3A1 ;
494 SpinBox_C3A2->SetValue( 50 ) ;
495 SpinBox_C3A3->SetValue( 50 ) ;
496 LineEditC3A1->setText(tr("")) ;
504 //=================================================================================
505 // function : ClickOnApply()
507 //=================================================================================
508 void GeometryGUI_ChamferDlg::ClickOnApply()
510 myGeomGUI->EraseSimulationShape() ;
511 mySimulationTopoDs.Nullify() ;
513 bool testResult = false ;
514 myGeomGUI->GetDesktop()->putInfo( tr("") ) ;
516 switch(myConstructorId)
518 case 0 : /* Chamfer All */
520 if(myOkD1 && myOkD2) {
522 testResult = myGeomGUI->OnChamferGetAll( myShape, myD1, myD2, myShapeType, myShapeIOR ) ;
526 myGeomGUI->GetDesktop()->putInfo(tr("GEOM_PRP_ABORT")) ;
529 myGeomGUI->GetDesktop()->putInfo(tr("GEOM_PRP_DONE")) ;
531 /* Reset all arguments and local context to allow user a new selection ...*/
532 this->ResetStateOfDialog() ;
536 case 1 : /* Chamfer Edge */
538 if(myOkD1 && myOkD2) {
540 testResult = myGeomGUI->OnChamferGetSelected( myShape, myShapeIOR, myD1, myD2, myShapeType,
541 myLocalContextId, myUseLocalContext );
545 myGeomGUI->GetDesktop()->putInfo(tr("GEOM_PRP_ABORT")) ;
548 myGeomGUI->GetDesktop()->putInfo(tr("GEOM_PRP_DONE")) ;
550 /* Reset all arguments and local context to allow user a new selection ...*/
551 this->ResetStateOfDialog() ;
555 case 2 : /* Chamfer Face */
557 if(myOkD1 && myOkD2) {
559 testResult = myGeomGUI->OnChamferGetSelected( myShape, myShapeIOR, myD1, myD2, myShapeType,
560 myLocalContextId, myUseLocalContext ) ;
564 myGeomGUI->GetDesktop()->putInfo(tr("GEOM_PRP_ABORT")) ;
567 myGeomGUI->GetDesktop()->putInfo(tr("GEOM_PRP_DONE")) ;
569 /* Reset all arguments and local context to allow user a new selection ...*/
570 this->ResetStateOfDialog() ;
580 //=================================================================================
581 // function : ClickOnCancel()
583 //=================================================================================
584 void GeometryGUI_ChamferDlg::ClickOnCancel()
586 myGeomGUI->EraseSimulationShape() ;
587 mySimulationTopoDs.Nullify() ;
589 disconnect( mySelection, 0, this, 0 );
590 myGeomGUI->ResetState() ;
592 if ( myGeomGUI->GetActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_OCC ) {
593 OCCViewer_Viewer3d* v3d = ((OCCViewer_ViewFrame*)myGeomGUI->GetActiveStudy()->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getViewer();
594 myIC = v3d->getAISContext();
595 if(this->myUseLocalContext ) {
596 myIC->CloseLocalContext(this->myLocalContextId) ;
597 this->myUseLocalContext = false ;
598 myGeomGUI->OnDisplayAll(true) ;
606 //=================================================================================
607 // function : ClickOnOk()
609 //=================================================================================
610 void GeometryGUI_ChamferDlg::ClickOnOk()
612 this->ClickOnApply() ;
613 this->ClickOnCancel() ;
618 //=================================================================================
619 // function : SelectionIntoArgument()
620 // purpose : Called when selection has changed
621 //=================================================================================
622 void GeometryGUI_ChamferDlg::SelectionIntoArgument()
624 myGeomGUI->EraseSimulationShape() ;
625 mySimulationTopoDs.Nullify() ;
627 /* Reset all arguments and local context when selection as changed */
628 this->ResetStateOfDialog() ;
630 /* Future name of argument */
631 QString aString = "";
633 int nbSel = myGeomGUI->GetNameOfSelectedIObjects(mySelection, aString) ;
637 Handle(SALOME_InteractiveObject) IO = mySelection->firstIObject() ;
639 if( !myGeomGUI->GetTopoFromSelection(mySelection, S) )
642 if( !IO->hasEntry() ) {
643 myGeomGUI->GetDesktop()->putInfo(tr("GEOM_PRP_SHAPE_IN_STUDY")) ;
647 if ( !S.IsNull() && S.ShapeType() <= 2 ) {
648 if ( IO->IsInstance(STANDARD_TYPE(GEOM_InteractiveObject)) ) {
649 Handle(GEOM_InteractiveObject) GIObject = Handle(GEOM_InteractiveObject)::DownCast( IO );
650 myShapeIOR = GIObject->getIOR(); /* the Geom IOR string of selection */
651 myEditCurrentArgument->setText(aString) ;
656 if ( IO->hasEntry() ) {
657 SALOMEDS::Study_var aStudy = myGeomGUI->GetActiveStudy()->getStudyDocument();
658 SALOMEDS::SObject_var obj = aStudy->FindObjectID( IO->getEntry() );
659 SALOMEDS::GenericAttribute_var anAttr;
660 SALOMEDS::AttributeIOR_var anIOR;
661 if ( !obj->_is_nil() ) {
662 if (obj->FindAttribute(anAttr, "AttributeIOR")) {
663 anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
664 myShapeIOR = anIOR->Value();
667 myEditCurrentArgument->setText(aString) ;
678 if( myOkShape && myShapeType!=-1 && myConstructorId != 0 ) {
679 /* local context is defined into the method */
680 myGeomGUI->PrepareSubShapeSelection( this->myShapeType, this->myLocalContextId ) ;
681 myUseLocalContext = true ;
682 myGeomGUI->GetDesktop()->putInfo(tr("GEOM_PRP_SELECT_EDGE")) ;
687 //=================================================================================
688 // function : LineEditReturnPressed()
690 //=================================================================================
691 void GeometryGUI_ChamferDlg::LineEditReturnPressed()
693 QLineEdit* send = (QLineEdit*)sender();
694 if( send == LineEditC1A1 )
695 myEditCurrentArgument = LineEditC1A1 ;
696 else if ( send == LineEditC2A1 )
697 myEditCurrentArgument = LineEditC2A1 ;
698 else if ( send == LineEditC3A1 )
699 myEditCurrentArgument = LineEditC3A1 ;
703 /* User name of object input management */
704 /* If successfull the selection is changed and signal emitted... */
705 /* so SelectionIntoArgument() is automatically called. */
706 const QString objectUserName = myEditCurrentArgument->text() ;
707 QWidget* thisWidget = (QWidget*)this ;
708 if( myGeomGUI->SelectionByNameInDialogs( thisWidget, objectUserName, mySelection ) ) {
709 myEditCurrentArgument->setText( objectUserName ) ;
715 //=================================================================================
716 // function : SetEditCurrentArgument()
718 //=================================================================================
719 void GeometryGUI_ChamferDlg::SetEditCurrentArgument()
721 QPushButton* send = (QPushButton*)sender();
723 switch (myConstructorId)
727 if(send == SelectButtonC1A1) {
728 LineEditC1A1->setFocus() ;
729 myEditCurrentArgument = LineEditC1A1;
730 SelectionIntoArgument() ;
737 if(send ==SelectButtonC2A1 ) {
738 LineEditC2A1->setFocus() ;
739 myEditCurrentArgument = LineEditC2A1;
740 SelectionIntoArgument() ;
747 if(send ==SelectButtonC3A1 ) {
748 LineEditC3A1->setFocus() ;
749 myEditCurrentArgument = LineEditC3A1;
750 SelectionIntoArgument() ;
759 //=================================================================================
760 // function : ValueChangedInSpinBox()
762 //=================================================================================
763 void GeometryGUI_ChamferDlg::ValueChangedInSpinBox( double newValue )
765 QObject* send = (QObject*)sender();
767 myGeomGUI->EraseSimulationShape() ;
768 mySimulationTopoDs.Nullify() ;
771 if( send == SpinBox_C1A2 || send == SpinBox_C2A2 || send == SpinBox_C3A2 ) { /* D1 */
777 if( send == SpinBox_C1A3 || send == SpinBox_C2A3 || send == SpinBox_C3A3 ) { /* D2 */
785 //=================================================================================
786 // function : DeactivateActiveDialog()
788 //=================================================================================
789 void GeometryGUI_ChamferDlg::DeactivateActiveDialog()
791 if ( GroupConstructors->isEnabled() ) {
792 this->ResetStateOfDialog() ;
793 GroupConstructors->setEnabled(false) ;
794 GroupC1->setEnabled(false) ;
795 GroupC2->setEnabled(false) ;
796 GroupC3->setEnabled(false) ;
797 GroupButtons->setEnabled(false) ;
798 disconnect( mySelection, 0, this, 0 );
799 myGeomGUI->ResetState() ;
800 myGeomGUI->SetActiveDialogBox(0) ;
801 myGeomGUI->OnDisplayAll(true) ;
807 //=================================================================================
808 // function : ActivateThisDialog()
810 //=================================================================================
811 void GeometryGUI_ChamferDlg::ActivateThisDialog()
813 /* Emit a signal to deactivate the active dialog */
814 myGeomGUI->EmitSignalDeactivateDialog() ;
816 GroupConstructors->setEnabled(true) ;
817 GroupC1->setEnabled(true) ;
818 GroupC2->setEnabled(true) ;
819 GroupC3->setEnabled(true) ;
820 GroupButtons->setEnabled(true) ;
821 connect ( mySelection, SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) );
822 myGeomGUI->SetActiveDialogBox( (QDialog*)this ) ;
824 if( !mySimulationTopoDs.IsNull() )
825 myGeomGUI->DisplaySimulationShape( mySimulationTopoDs ) ;
830 //=================================================================================
831 // function : enterEvent()
833 //=================================================================================
834 void GeometryGUI_ChamferDlg::enterEvent( QEvent* e)
836 if ( GroupConstructors->isEnabled() )
838 ActivateThisDialog() ;
843 //=================================================================================
844 // function : closeEvent()
846 //=================================================================================
847 void GeometryGUI_ChamferDlg::closeEvent( QCloseEvent* e )
849 /* same than click on cancel button */
850 this->ClickOnCancel() ;
855 //=================================================================================
856 // function : ResetStateOfDialog()
858 //=================================================================================
859 void GeometryGUI_ChamferDlg::ResetStateOfDialog()
861 this->myOkShape = false ;
862 this->myEditCurrentArgument->setText("") ;
864 /* Close its local contact if opened */
865 if ( myGeomGUI->GetActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_OCC ) {
866 OCCViewer_Viewer3d* v3d = ((OCCViewer_ViewFrame*)myGeomGUI->GetActiveStudy()->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getViewer();
867 myIC = v3d->getAISContext();
868 if(this->myUseLocalContext) {
869 myIC->CloseLocalContext(this->myLocalContextId) ;
870 this->myUseLocalContext = false ;
871 myGeomGUI->OnDisplayAll(true) ;
877 void GeometryGUI_ChamferDlg::MakePreview()
882 BRepFilletAPI_MakeChamfer MC(myShape);
883 switch (myConstructorId)
885 case 0: /* Chamfer All */
887 TopTools_IndexedDataMapOfShapeListOfShape M;
888 TopExp::MapShapesAndAncestors(myShape,TopAbs_EDGE,TopAbs_FACE,M);
889 for (int i = 1;i<=M.Extent();i++)
891 TopoDS_Edge E = TopoDS::Edge(M.FindKey(i));
892 TopoDS_Face F = TopoDS::Face(M.FindFromIndex(i).First());
893 if (!BRepTools::IsReallyClosed(E, F) && !BRep_Tool::Degenerated(E))
894 MC.Add(myD1, myD2,E,F);
899 // case 1: /* Chamfer edges */
900 // case 2: /* Chamfer Faces */
904 mySimulationTopoDs = tds;
905 myGeomGUI->DisplaySimulationShape( mySimulationTopoDs ) ;
909 catch(Standard_Failure)
911 myGeomGUI->EraseSimulationShape() ;
912 mySimulationTopoDs.Nullify() ;