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_ChamferDlg.cxx
25 // Author : Damien COQUERET
30 #include "GeometryGUI_ChamferDlg.h"
32 #include "GeometryGUI.h"
33 #include "QAD_Application.h"
34 #include "QAD_Desktop.h"
35 #include "QAD_Config.h"
36 #include "QAD_RightFrame.h"
37 #include "OCCViewer_Viewer3d.h"
38 #include "utilities.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 <BRepFilletAPI_MakeChamfer.hxx>
56 #include <BRepTools.hxx>
57 #include <BRep_Tool.hxx>
60 #include <Standard_ErrorHandler.hxx>
61 #include <Standard_Failure.hxx>
63 //=================================================================================
64 // class : GeometryGUI_ChamferDlg()
65 // purpose : Constructs a GeometryGUI_ChamferDlg which is a child of 'parent', with the
66 // name 'name' and widget flags set to 'f'.
67 // The dialog will by default be modeless, unless you set 'modal' to
68 // TRUE to construct a modal dialog.
69 //=================================================================================
70 GeometryGUI_ChamferDlg::GeometryGUI_ChamferDlg( QWidget* parent,
72 SALOME_Selection* Sel,
73 Handle (AIS_InteractiveContext) ic,
76 : QDialog( parent, name, modal, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu )
78 /***************************************************************/
79 QPixmap image0(QAD_Desktop::getResourceManager()->loadPixmap( "GeometryGUI",tr("ICON_DLG_CHAMFER_ALL")));
80 QPixmap image1(QAD_Desktop::getResourceManager()->loadPixmap( "GeometryGUI",tr("ICON_SELECT")));
81 QPixmap image2(QAD_Desktop::getResourceManager()->loadPixmap( "GeometryGUI",tr("ICON_DLG_CHAMFER_EDGE")));
82 QPixmap image3(QAD_Desktop::getResourceManager()->loadPixmap( "GeometryGUI",tr("ICON_DLG_CHAMFER_FACE")));
85 setName( "GeometryGUI_ChamferDlg" );
87 setCaption( tr( "GEOM_CHAMFER_TITLE" ) );
88 setSizeGripEnabled( TRUE );
89 GeometryGUI_ChamferDlgLayout = new QGridLayout( this );
90 GeometryGUI_ChamferDlgLayout->setSpacing( 6 );
91 GeometryGUI_ChamferDlgLayout->setMargin( 11 );
93 /***************************************************************/
94 GroupButtons = new QGroupBox( this, "GroupButtons" );
95 GroupButtons->setGeometry( QRect( 10, 10, 281, 48 ) );
96 GroupButtons->setTitle( tr( "" ) );
97 GroupButtons->setColumnLayout(0, Qt::Vertical );
98 GroupButtons->layout()->setSpacing( 0 );
99 GroupButtons->layout()->setMargin( 0 );
100 GroupButtonsLayout = new QGridLayout( GroupButtons->layout() );
101 GroupButtonsLayout->setAlignment( Qt::AlignTop );
102 GroupButtonsLayout->setSpacing( 6 );
103 GroupButtonsLayout->setMargin( 11 );
104 buttonCancel = new QPushButton( GroupButtons, "buttonCancel" );
105 buttonCancel->setText( tr( "GEOM_BUT_CLOSE" ) );
106 buttonCancel->setAutoDefault( TRUE );
107 GroupButtonsLayout->addWidget( buttonCancel, 0, 3 );
108 buttonApply = new QPushButton( GroupButtons, "buttonApply" );
109 buttonApply->setText( tr( "GEOM_BUT_APPLY" ) );
110 buttonApply->setAutoDefault( TRUE );
111 GroupButtonsLayout->addWidget( buttonApply, 0, 1 );
112 QSpacerItem* spacer = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum );
113 GroupButtonsLayout->addItem( spacer, 0, 2 );
114 buttonOk = new QPushButton( GroupButtons, "buttonOk" );
115 buttonOk->setText( tr( "GEOM_BUT_OK" ) );
116 buttonOk->setAutoDefault( TRUE );
117 buttonOk->setDefault( TRUE );
118 GroupButtonsLayout->addWidget( buttonOk, 0, 0 );
119 GeometryGUI_ChamferDlgLayout->addWidget( GroupButtons, 2, 0 );
121 /***************************************************************/
122 GroupConstructors = new QButtonGroup( this, "GroupConstructors" );
123 GroupConstructors->setTitle( tr( "GEOM_CHAMFER" ) );
124 GroupConstructors->setExclusive( TRUE );
125 GroupConstructors->setColumnLayout(0, Qt::Vertical );
126 GroupConstructors->layout()->setSpacing( 0 );
127 GroupConstructors->layout()->setMargin( 0 );
128 GroupConstructorsLayout = new QGridLayout( GroupConstructors->layout() );
129 GroupConstructorsLayout->setAlignment( Qt::AlignTop );
130 GroupConstructorsLayout->setSpacing( 6 );
131 GroupConstructorsLayout->setMargin( 11 );
132 Constructor1 = new QRadioButton( GroupConstructors, "Constructor1" );
133 Constructor1->setText( tr( "" ) );
134 Constructor1->setPixmap( image0 );
135 Constructor1->setChecked( TRUE );
136 Constructor1->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)1, (QSizePolicy::SizeType)0, Constructor1->sizePolicy().hasHeightForWidth() ) );
137 Constructor1->setMinimumSize( QSize( 50, 0 ) );
138 GroupConstructorsLayout->addWidget( Constructor1, 0, 0 );
139 Constructor2 = new QRadioButton( GroupConstructors, "Constructor2" );
140 Constructor2->setText( tr( "" ) );
141 Constructor2->setPixmap( image2 );
142 Constructor2->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)1, (QSizePolicy::SizeType)0, Constructor2->sizePolicy().hasHeightForWidth() ) );
143 Constructor2->setMinimumSize( QSize( 50, 0 ) );
144 GroupConstructorsLayout->addWidget( Constructor2, 0, 2 );
145 QSpacerItem* spacer_2 = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum );
146 GroupConstructorsLayout->addItem( spacer_2, 0, 3 );
147 QSpacerItem* spacer_3 = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum );
148 GroupConstructorsLayout->addItem( spacer_3, 0, 1 );
149 Constructor3 = new QRadioButton( GroupConstructors, "Constructor3" );
150 Constructor3->setText( tr( "" ) );
151 Constructor3->setPixmap( image3 );
152 Constructor3->setMinimumSize( QSize( 50, 0 ) );
153 GroupConstructorsLayout->addWidget( Constructor3, 0, 4 );
154 QSpacerItem* spacer_4 = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum );
155 GroupConstructorsLayout->addItem( spacer_4, 0, 5 );
156 GeometryGUI_ChamferDlgLayout->addWidget( GroupConstructors, 0, 0 );
158 /***************************************************************/
159 GroupC1 = new QGroupBox( this, "GroupC1" );
160 GroupC1->setTitle( tr( "GEOM_CHAMFER_ALL" ) );
161 GroupC1->setMinimumSize( QSize( 0, 0 ) );
162 GroupC1->setFrameShape( QGroupBox::Box );
163 GroupC1->setFrameShadow( QGroupBox::Sunken );
164 GroupC1->setColumnLayout(0, Qt::Vertical );
165 GroupC1->layout()->setSpacing( 0 );
166 GroupC1->layout()->setMargin( 0 );
167 GroupC1Layout = new QGridLayout( GroupC1->layout() );
168 GroupC1Layout->setAlignment( Qt::AlignTop );
169 GroupC1Layout->setSpacing( 6 );
170 GroupC1Layout->setMargin( 11 );
172 TextLabelC1A1 = new QLabel( GroupC1, "TextLabelC1A1" );
173 TextLabelC1A1->setText( tr( "GEOM_MAIN_OBJECT" ) );
174 TextLabelC1A1->setMinimumSize( QSize( 50, 0 ) );
175 TextLabelC1A1->setFrameShape( QLabel::NoFrame );
176 TextLabelC1A1->setFrameShadow( QLabel::Plain );
177 GroupC1Layout->addWidget( TextLabelC1A1, 0, 0 );
179 TextLabelC1A2 = new QLabel( GroupC1, "TextLabelC1A2" );
180 TextLabelC1A2->setText( tr( "GEOM_D1" ) );
181 TextLabelC1A2->setMinimumSize( QSize( 50, 0 ) );
182 TextLabelC1A2->setFrameShape( QLabel::NoFrame );
183 TextLabelC1A2->setFrameShadow( QLabel::Plain );
184 GroupC1Layout->addWidget( TextLabelC1A2, 1, 0 );
186 TextLabelC1A3 = new QLabel( GroupC1, "TextLabelC1A3" );
187 TextLabelC1A3->setText( tr( "GEOM_D2" ) );
188 TextLabelC1A3->setMinimumSize( QSize( 50, 0 ) );
189 TextLabelC1A3->setFrameShape( QLabel::NoFrame );
190 TextLabelC1A3->setFrameShadow( QLabel::Plain );
191 GroupC1Layout->addWidget( TextLabelC1A3, 2, 0 );
193 LineEditC1A1 = new QLineEdit( GroupC1, "LineEditC1A1" );
194 GroupC1Layout->addWidget( LineEditC1A1, 0, 2 );
196 // LineEditC1A2 = new QLineEdit( GroupC1, "LineEditC1A2" );
197 // LineEditC1A2->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)3, (QSizePolicy::SizeType)0, LineEditC1A2->sizePolicy().hasHeightForWidth() ) );
198 // GroupC1Layout->addWidget( LineEditC1A2, 1, 2 );
200 // LineEditC1A3 = new QLineEdit( GroupC1, "LineEditC1A3" );
201 // LineEditC1A3->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)3, (QSizePolicy::SizeType)0, LineEditC1A3->sizePolicy().hasHeightForWidth() ) );
202 // GroupC1Layout->addWidget( LineEditC1A3, 2, 2 );
204 SpinBox_C1A2 = new GeometryGUI_SpinBox( GroupC1, "GeomSpinBox_C1A2" ) ;
205 SpinBox_C1A2->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)3, (QSizePolicy::SizeType)0, SpinBox_C1A2->sizePolicy().hasHeightForWidth() ) );
206 GroupC1Layout->addWidget( SpinBox_C1A2, 1, 2 );
208 SpinBox_C1A3 = new GeometryGUI_SpinBox( GroupC1, "GeomSpinBox_C1A3" ) ;
209 SpinBox_C1A3->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)3, (QSizePolicy::SizeType)0, SpinBox_C1A3->sizePolicy().hasHeightForWidth() ) );
210 GroupC1Layout->addWidget( SpinBox_C1A3, 2, 2 );
212 SelectButtonC1A1 = new QPushButton( GroupC1, "SelectButtonC1A1" );
213 SelectButtonC1A1->setText( tr( "" ) );
214 SelectButtonC1A1->setPixmap( image1 );
215 SelectButtonC1A1->setToggleButton( FALSE );
216 SelectButtonC1A1->setMaximumSize( QSize( 28, 32767 ) );
217 GroupC1Layout->addWidget( SelectButtonC1A1, 0, 1 );
218 GeometryGUI_ChamferDlgLayout->addWidget( GroupC1, 1, 0 );
220 /***************************************************************/
221 GroupC2 = new QGroupBox( this, "GroupC2" );
222 GroupC2->setTitle( tr( "GEOM_CHAMFER_EDGES" ) );
223 GroupC2->setMinimumSize( QSize( 0, 0 ) );
224 GroupC2->setFrameShape( QGroupBox::Box );
225 GroupC2->setFrameShadow( QGroupBox::Sunken );
226 GroupC2->setColumnLayout(0, Qt::Vertical );
227 GroupC2->layout()->setSpacing( 0 );
228 GroupC2->layout()->setMargin( 0 );
229 GroupC2Layout = new QGridLayout( GroupC2->layout() );
230 GroupC2Layout->setAlignment( Qt::AlignTop );
231 GroupC2Layout->setSpacing( 6 );
232 GroupC2Layout->setMargin( 11 );
234 TextLabelC2A1 = new QLabel( GroupC2, "TextLabelC2A1" );
235 TextLabelC2A1->setText( tr( "GEOM_MAIN_OBJECT" ) );
236 TextLabelC2A1->setMinimumSize( QSize( 50, 0 ) );
237 TextLabelC2A1->setFrameShape( QLabel::NoFrame );
238 TextLabelC2A1->setFrameShadow( QLabel::Plain );
239 GroupC2Layout->addWidget( TextLabelC2A1, 0, 0 );
241 TextLabelC2A2 = new QLabel( GroupC2, "TextLabelC2A2" );
242 TextLabelC2A2->setText( tr( "GEOM_D1" ) );
243 TextLabelC2A2->setMinimumSize( QSize( 50, 0 ) );
244 TextLabelC2A2->setFrameShape( QLabel::NoFrame );
245 TextLabelC2A2->setFrameShadow( QLabel::Plain );
246 GroupC2Layout->addWidget( TextLabelC2A2, 1, 0 );
248 TextLabelC2A3 = new QLabel( GroupC2, "TextLabelC2A3" );
249 TextLabelC2A3->setText( tr( "GEOM_D2" ) );
250 TextLabelC2A3->setMinimumSize( QSize( 50, 0 ) );
251 TextLabelC2A3->setFrameShape( QLabel::NoFrame );
252 TextLabelC2A3->setFrameShadow( QLabel::Plain );
253 GroupC2Layout->addWidget( TextLabelC2A3, 2, 0 );
255 LineEditC2A1 = new QLineEdit( GroupC2, "LineEditC2A1" );
256 GroupC2Layout->addWidget( LineEditC2A1, 0, 2 );
258 // LineEditC2A2 = new QLineEdit( GroupC2, "LineEditC2A2" );
259 // LineEditC2A2->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)3, (QSizePolicy::SizeType)0, LineEditC2A2->sizePolicy().hasHeightForWidth() ) );
260 // GroupC2Layout->addWidget( LineEditC2A2, 1, 2 );
262 // LineEditC2A3 = new QLineEdit( GroupC2, "LineEditC2A3" );
263 // LineEditC2A3->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)3, (QSizePolicy::SizeType)0, LineEditC2A3->sizePolicy().hasHeightForWidth() ) );
264 // GroupC2Layout->addWidget( LineEditC2A3, 2, 2 );
266 SpinBox_C2A2 = new GeometryGUI_SpinBox( GroupC2, "GeomSpinBox_C2A2" ) ;
267 SpinBox_C2A2->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)3, (QSizePolicy::SizeType)0, SpinBox_C2A2->sizePolicy().hasHeightForWidth() ) );
268 GroupC2Layout->addWidget( SpinBox_C2A2, 1, 2 );
270 SpinBox_C2A3 = new GeometryGUI_SpinBox( GroupC2, "GeomSpinBox_C2A3" ) ;
271 SpinBox_C2A3->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)3, (QSizePolicy::SizeType)0, SpinBox_C2A3->sizePolicy().hasHeightForWidth() ) );
272 GroupC2Layout->addWidget( SpinBox_C2A3, 2, 2 );
274 SelectButtonC2A1 = new QPushButton( GroupC2, "SelectButtonC2A1" );
275 SelectButtonC2A1->setText( tr( "" ) );
276 SelectButtonC2A1->setPixmap( image1 );
277 SelectButtonC2A1->setToggleButton( FALSE );
278 SelectButtonC2A1->setMaximumSize( QSize( 28, 32767 ) );
279 GroupC2Layout->addWidget( SelectButtonC2A1, 0, 1 );
280 GeometryGUI_ChamferDlgLayout->addWidget( GroupC2, 1, 0 );
282 /***************************************************************/
283 GroupC3 = new QGroupBox( this, "GroupC3" );
284 GroupC3->setTitle( tr( "GEOM_CHAMFER_FACES" ) );
285 GroupC3->setMinimumSize( QSize( 0, 0 ) );
286 GroupC3->setFrameShape( QGroupBox::Box );
287 GroupC3->setFrameShadow( QGroupBox::Sunken );
288 GroupC3->setColumnLayout(0, Qt::Vertical );
289 GroupC3->layout()->setSpacing( 0 );
290 GroupC3->layout()->setMargin( 0 );
291 GroupC3Layout = new QGridLayout( GroupC3->layout() );
292 GroupC3Layout->setAlignment( Qt::AlignTop );
293 GroupC3Layout->setSpacing( 6 );
294 GroupC3Layout->setMargin( 11 );
296 TextLabelC3A1 = new QLabel( GroupC3, "TextLabelC3A1" );
297 TextLabelC3A1->setText( tr( "GEOM_MAIN_OBJECT" ) );
298 TextLabelC3A1->setMinimumSize( QSize( 50, 0 ) );
299 TextLabelC3A1->setFrameShape( QLabel::NoFrame );
300 TextLabelC3A1->setFrameShadow( QLabel::Plain );
301 GroupC3Layout->addWidget( TextLabelC3A1, 0, 0 );
303 TextLabelC3A2 = new QLabel( GroupC3, "TextLabelC3A2" );
304 TextLabelC3A2->setText( tr( "GEOM_D1" ) );
305 TextLabelC3A2->setMinimumSize( QSize( 50, 0 ) );
306 TextLabelC3A2->setFrameShape( QLabel::NoFrame );
307 TextLabelC3A2->setFrameShadow( QLabel::Plain );
308 GroupC3Layout->addWidget( TextLabelC3A2, 1, 0 );
310 TextLabelC3A3 = new QLabel( GroupC3, "TextLabelC3A3" );
311 TextLabelC3A3->setText( tr( "GEOM_D2" ) );
312 TextLabelC3A3->setMinimumSize( QSize( 50, 0 ) );
313 TextLabelC3A3->setFrameShape( QLabel::NoFrame );
314 TextLabelC3A3->setFrameShadow( QLabel::Plain );
315 GroupC3Layout->addWidget( TextLabelC3A3, 2, 0 );
317 LineEditC3A1 = new QLineEdit( GroupC3, "LineEditC3A1" );
318 GroupC3Layout->addWidget( LineEditC3A1, 0, 2 );
320 // LineEditC3A2 = new QLineEdit( GroupC3, "LineEditC3A2" );
321 // LineEditC3A2->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)3, (QSizePolicy::SizeType)0, LineEditC3A2->sizePolicy().hasHeightForWidth() ) );
322 // GroupC3Layout->addWidget( LineEditC3A2, 1, 2 );
324 // LineEditC3A3 = new QLineEdit( GroupC3, "LineEditC3A3" );
325 // LineEditC3A3->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)3, (QSizePolicy::SizeType)0, LineEditC3A3->sizePolicy().hasHeightForWidth() ) );
326 // GroupC3Layout->addWidget( LineEditC3A3, 2, 2 );
328 SpinBox_C3A2 = new GeometryGUI_SpinBox( GroupC3, "GeomSpinBox_C3A2" ) ;
329 SpinBox_C3A2->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)3, (QSizePolicy::SizeType)0, SpinBox_C3A2->sizePolicy().hasHeightForWidth() ) );
330 GroupC3Layout->addWidget( SpinBox_C3A2, 1, 2 );
332 SpinBox_C3A3 = new GeometryGUI_SpinBox( GroupC3, "GeomSpinBox_C3A3" ) ;
333 SpinBox_C3A3->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)3, (QSizePolicy::SizeType)0, SpinBox_C3A3->sizePolicy().hasHeightForWidth() ) );
334 GroupC3Layout->addWidget( SpinBox_C3A3, 2, 2 );
336 SelectButtonC3A1 = new QPushButton( GroupC3, "SelectButtonC3A1" );
337 SelectButtonC3A1->setText( tr( "" ) );
338 SelectButtonC3A1->setPixmap( image1 );
339 SelectButtonC3A1->setToggleButton( FALSE );
340 SelectButtonC3A1->setMaximumSize( QSize( 28, 32767 ) );
341 GroupC3Layout->addWidget( SelectButtonC3A1, 0, 1 );
342 GeometryGUI_ChamferDlgLayout->addWidget( GroupC3, 1, 0 );
349 //=================================================================================
350 // function : ~GeometryGUI_ChamferDlg()
351 // purpose : Destroys the object and frees any allocated resources
352 //=================================================================================
353 GeometryGUI_ChamferDlg::~GeometryGUI_ChamferDlg()
355 /* no need to delete child widgets, Qt does it all for us */
356 this->destroy(TRUE, TRUE) ;
360 //=================================================================================
363 //=================================================================================
364 void GeometryGUI_ChamferDlg::Init( SALOME_Selection* Sel, Handle (AIS_InteractiveContext) ic )
367 /* Get setting of step value from file configuration */
369 QString St = QAD_CONFIG->getSetting( "Geometry:SettingsGeomStep" ) ;
370 step = St.toDouble() ;
372 /* min, max, step and decimals for spin boxes */
373 SpinBox_C1A2->RangeStepAndValidator( 0.001, 999.999, step, 3 ) ; /* myD1 */
374 SpinBox_C1A2->SetValue( 50 ) ;
375 SpinBox_C1A3->RangeStepAndValidator( 0.001, 999.999, step, 3 ) ; /* myD2 */
376 SpinBox_C1A3->SetValue( 50 ) ;
378 SpinBox_C2A2->RangeStepAndValidator( 0.001, 999.999, step, 3 ) ;
379 SpinBox_C2A2->SetValue( 50 ) ;
380 SpinBox_C2A3->RangeStepAndValidator( 0.001, 999.999, step, 3 ) ;
381 SpinBox_C2A3->SetValue( 50 ) ;
383 SpinBox_C3A2->RangeStepAndValidator( 0.001, 999.999, step, 3 ) ;
384 SpinBox_C3A2->SetValue( 50 ) ;
385 SpinBox_C3A3->RangeStepAndValidator( 0.001, 999.999, step, 3 ) ;
386 SpinBox_C3A3->SetValue( 50 ) ;
391 myConstructorId = 0 ;
392 Constructor1->setChecked( TRUE );
395 myEditCurrentArgument = LineEditC1A1 ;
402 myUseLocalContext = false ;
405 myGeomGUI = GeometryGUI::GetGeometryGUI() ;
406 myGeomGUI->SetActiveDialogBox( (QDialog*)this ) ;
408 mySimulationTopoDs.Nullify() ;
410 /* Filters definition */
411 Engines::Component_var comp = QAD_Application::getDesktop()->getEngine("FactoryServer", "Geometry");
412 myGeom = GEOM::GEOM_Gen::_narrow(comp);
414 /* signals and slots connections */
415 connect( buttonOk, SIGNAL( clicked() ), this, SLOT( ClickOnOk() ) );
416 connect( buttonApply, SIGNAL( clicked() ), this, SLOT( ClickOnApply() ) );
417 connect( buttonCancel, SIGNAL( clicked() ), this, SLOT( ClickOnCancel() ) ) ;
418 connect( GroupConstructors, SIGNAL(clicked(int) ), SLOT( ConstructorsClicked(int) ) );
419 connect( SelectButtonC1A1, SIGNAL (clicked() ), this, SLOT( SetEditCurrentArgument() ) ) ;
420 connect( SelectButtonC2A1, SIGNAL (clicked() ), this, SLOT( SetEditCurrentArgument() ) ) ;
421 connect( SelectButtonC3A1, SIGNAL (clicked() ), this, SLOT( SetEditCurrentArgument() ) ) ;
423 connect( SpinBox_C1A2, SIGNAL ( valueChanged( double) ), this, SLOT( ValueChangedInSpinBox( double) ) ) ;
424 connect( SpinBox_C2A2, SIGNAL ( valueChanged( double) ), this, SLOT( ValueChangedInSpinBox( double) ) ) ;
425 connect( SpinBox_C3A2, SIGNAL ( valueChanged( double) ), this, SLOT( ValueChangedInSpinBox( double) ) ) ;
427 connect( SpinBox_C1A3, SIGNAL ( valueChanged( double) ), this, SLOT( ValueChangedInSpinBox( double) ) ) ;
428 connect( SpinBox_C2A3, SIGNAL ( valueChanged( double) ), this, SLOT( ValueChangedInSpinBox( double) ) ) ;
429 connect( SpinBox_C3A3, SIGNAL ( valueChanged( double) ), this, SLOT( ValueChangedInSpinBox( double) ) ) ;
431 connect( LineEditC1A1, SIGNAL ( returnPressed() ), this, SLOT( LineEditReturnPressed() ) ) ;
432 connect( LineEditC2A1, SIGNAL ( returnPressed() ), this, SLOT( LineEditReturnPressed() ) ) ;
433 connect( LineEditC3A1, SIGNAL ( returnPressed() ), this, SLOT( LineEditReturnPressed() ) ) ;
435 connect( mySelection, SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) );
436 connect( myGeomGUI, SIGNAL ( SignalDeactivateActiveDialog() ), this, SLOT( DeactivateActiveDialog() ) ) ;
437 /* to close dialog if study change */
438 connect( myGeomGUI, SIGNAL ( SignalCloseAllDialogs() ), this, SLOT( ClickOnCancel() ) ) ;
440 /* Move widget on the botton right corner of main widget */
442 myGeomGUI->DefineDlgPosition( this, x, y ) ;
444 this->show() ; /* Displays Dialog */
451 //=================================================================================
452 // function : ConstructorsClicked()
453 // purpose : Radio button management
454 //=================================================================================
455 void GeometryGUI_ChamferDlg::ConstructorsClicked(int constructorId)
457 myGeomGUI->EraseSimulationShape() ;
458 mySimulationTopoDs.Nullify() ;
460 myEditCurrentArgument->setText(tr("")) ;
462 if ( myGeomGUI->GetActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_OCC ) {
463 OCCViewer_Viewer3d* v3d = ((OCCViewer_ViewFrame*)myGeomGUI->GetActiveStudy()->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getViewer();
464 myIC = v3d->getAISContext();
465 if(myUseLocalContext ) {
466 myIC->CloseLocalContext(this->myLocalContextId);
467 myGeomGUI->OnDisplayAll(true) ;
468 myUseLocalContext = false ;
477 myConstructorId = constructorId ;
479 switch (constructorId)
481 case 0: /* Chamfer All */
486 myEditCurrentArgument = LineEditC1A1 ;
487 SpinBox_C1A2->SetValue( 50 ) ;
488 SpinBox_C1A3->SetValue( 50 ) ;
489 LineEditC1A1->setText(tr("")) ;
494 case 1: /* Chamfer edges */
500 myEditCurrentArgument = LineEditC2A1 ;
501 SpinBox_C2A2->SetValue( 50 ) ;
502 SpinBox_C2A3->SetValue( 50 ) ;
503 LineEditC2A1->setText(tr("")) ;
507 case 2: /* Chamfer Faces */
513 myEditCurrentArgument = LineEditC3A1 ;
514 SpinBox_C3A2->SetValue( 50 ) ;
515 SpinBox_C3A3->SetValue( 50 ) ;
516 LineEditC3A1->setText(tr("")) ;
524 //=================================================================================
525 // function : ClickOnApply()
527 //=================================================================================
528 void GeometryGUI_ChamferDlg::ClickOnApply()
530 myGeomGUI->EraseSimulationShape() ;
531 mySimulationTopoDs.Nullify() ;
533 bool testResult = false ;
534 myGeomGUI->GetDesktop()->putInfo( tr("") ) ;
536 switch(myConstructorId)
538 case 0 : /* Chamfer All */
540 if(myOkD1 && myOkD2) {
542 testResult = myGeomGUI->OnChamferGetAll( myShape, myD1, myD2, myShapeType, myShapeIOR ) ;
546 myGeomGUI->GetDesktop()->putInfo(tr("GEOM_PRP_ABORT")) ;
549 myGeomGUI->GetDesktop()->putInfo(tr("GEOM_PRP_DONE")) ;
551 /* Reset all arguments and local context to allow user a new selection ...*/
552 this->ResetStateOfDialog() ;
556 case 1 : /* Chamfer Edge */
558 if(myOkD1 && myOkD2) {
560 testResult = myGeomGUI->OnChamferGetSelected( myShape, myShapeIOR, myD1, myD2, myShapeType,
561 myLocalContextId, myUseLocalContext );
565 myGeomGUI->GetDesktop()->putInfo(tr("GEOM_PRP_ABORT")) ;
568 myGeomGUI->GetDesktop()->putInfo(tr("GEOM_PRP_DONE")) ;
570 /* Reset all arguments and local context to allow user a new selection ...*/
571 this->ResetStateOfDialog() ;
575 case 2 : /* Chamfer Face */
577 if(myOkD1 && myOkD2) {
579 testResult = myGeomGUI->OnChamferGetSelected( myShape, myShapeIOR, myD1, myD2, myShapeType,
580 myLocalContextId, myUseLocalContext ) ;
584 myGeomGUI->GetDesktop()->putInfo(tr("GEOM_PRP_ABORT")) ;
587 myGeomGUI->GetDesktop()->putInfo(tr("GEOM_PRP_DONE")) ;
589 /* Reset all arguments and local context to allow user a new selection ...*/
590 this->ResetStateOfDialog() ;
600 //=================================================================================
601 // function : ClickOnCancel()
603 //=================================================================================
604 void GeometryGUI_ChamferDlg::ClickOnCancel()
606 myGeomGUI->EraseSimulationShape() ;
607 mySimulationTopoDs.Nullify() ;
609 disconnect( mySelection, 0, this, 0 );
610 myGeomGUI->ResetState() ;
612 if ( myGeomGUI->GetActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_OCC ) {
613 OCCViewer_Viewer3d* v3d = ((OCCViewer_ViewFrame*)myGeomGUI->GetActiveStudy()->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getViewer();
614 myIC = v3d->getAISContext();
615 if(this->myUseLocalContext ) {
616 myIC->CloseLocalContext(this->myLocalContextId) ;
617 this->myUseLocalContext = false ;
618 myGeomGUI->OnDisplayAll(true) ;
626 //=================================================================================
627 // function : ClickOnOk()
629 //=================================================================================
630 void GeometryGUI_ChamferDlg::ClickOnOk()
632 this->ClickOnApply() ;
633 this->ClickOnCancel() ;
638 //=================================================================================
639 // function : SelectionIntoArgument()
640 // purpose : Called when selection has changed
641 //=================================================================================
642 void GeometryGUI_ChamferDlg::SelectionIntoArgument()
644 myGeomGUI->EraseSimulationShape() ;
645 mySimulationTopoDs.Nullify() ;
647 /* Reset all arguments and local context when selection as changed */
648 this->ResetStateOfDialog() ;
650 /* Future name of argument */
651 QString aString = "";
653 int nbSel = myGeomGUI->GetNameOfSelectedIObjects(mySelection, aString) ;
657 Handle(SALOME_InteractiveObject) IO = mySelection->firstIObject() ;
659 if( !myGeomGUI->GetTopoFromSelection(mySelection, S) )
662 if( !IO->hasEntry() ) {
663 myGeomGUI->GetDesktop()->putInfo(tr("GEOM_PRP_SHAPE_IN_STUDY")) ;
667 if ( !S.IsNull() && S.ShapeType() <= 2 ) {
668 if ( IO->IsInstance(STANDARD_TYPE(GEOM_InteractiveObject)) ) {
669 Handle(GEOM_InteractiveObject) GIObject = Handle(GEOM_InteractiveObject)::DownCast( IO );
670 myShapeIOR = GIObject->getIOR(); /* the Geom IOR string of selection */
671 myEditCurrentArgument->setText(aString) ;
676 if ( IO->hasEntry() ) {
677 SALOMEDS::Study_var aStudy = myGeomGUI->GetActiveStudy()->getStudyDocument();
678 SALOMEDS::SObject_var obj = aStudy->FindObjectID( IO->getEntry() );
679 SALOMEDS::GenericAttribute_var anAttr;
680 SALOMEDS::AttributeIOR_var anIOR;
681 if ( !obj->_is_nil() ) {
682 if (obj->FindAttribute(anAttr, "AttributeIOR")) {
683 anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
684 myShapeIOR = anIOR->Value();
687 myEditCurrentArgument->setText(aString) ;
698 if( myOkShape && myShapeType!=-1 && myConstructorId != 0 ) {
699 /* local context is defined into the method */
700 myGeomGUI->PrepareSubShapeSelection( this->myShapeType, this->myLocalContextId ) ;
701 myUseLocalContext = true ;
702 myGeomGUI->GetDesktop()->putInfo(tr("GEOM_PRP_SELECT_EDGE")) ;
707 //=================================================================================
708 // function : LineEditReturnPressed()
710 //=================================================================================
711 void GeometryGUI_ChamferDlg::LineEditReturnPressed()
713 QLineEdit* send = (QLineEdit*)sender();
714 if( send == LineEditC1A1 )
715 myEditCurrentArgument = LineEditC1A1 ;
716 else if ( send == LineEditC2A1 )
717 myEditCurrentArgument = LineEditC2A1 ;
718 else if ( send == LineEditC3A1 )
719 myEditCurrentArgument = LineEditC3A1 ;
723 /* User name of object input management */
724 /* If successfull the selection is changed and signal emitted... */
725 /* so SelectionIntoArgument() is automatically called. */
726 const QString objectUserName = myEditCurrentArgument->text() ;
727 QWidget* thisWidget = (QWidget*)this ;
728 if( myGeomGUI->SelectionByNameInDialogs( thisWidget, objectUserName, mySelection ) ) {
729 myEditCurrentArgument->setText( objectUserName ) ;
735 //=================================================================================
736 // function : SetEditCurrentArgument()
738 //=================================================================================
739 void GeometryGUI_ChamferDlg::SetEditCurrentArgument()
741 QPushButton* send = (QPushButton*)sender();
743 switch (myConstructorId)
747 if(send == SelectButtonC1A1) {
748 LineEditC1A1->setFocus() ;
749 myEditCurrentArgument = LineEditC1A1;
750 SelectionIntoArgument() ;
757 if(send ==SelectButtonC2A1 ) {
758 LineEditC2A1->setFocus() ;
759 myEditCurrentArgument = LineEditC2A1;
760 SelectionIntoArgument() ;
767 if(send ==SelectButtonC3A1 ) {
768 LineEditC3A1->setFocus() ;
769 myEditCurrentArgument = LineEditC3A1;
770 SelectionIntoArgument() ;
779 //=================================================================================
780 // function : ValueChangedInSpinBox()
782 //=================================================================================
783 void GeometryGUI_ChamferDlg::ValueChangedInSpinBox( double newValue )
785 QObject* send = (QObject*)sender();
787 myGeomGUI->EraseSimulationShape() ;
788 mySimulationTopoDs.Nullify() ;
791 if( send == SpinBox_C1A2 || send == SpinBox_C2A2 || send == SpinBox_C3A2 ) { /* D1 */
797 if( send == SpinBox_C1A3 || send == SpinBox_C2A3 || send == SpinBox_C3A3 ) { /* D2 */
805 //=================================================================================
806 // function : DeactivateActiveDialog()
808 //=================================================================================
809 void GeometryGUI_ChamferDlg::DeactivateActiveDialog()
811 if ( GroupConstructors->isEnabled() ) {
812 this->ResetStateOfDialog() ;
813 GroupConstructors->setEnabled(false) ;
814 GroupC1->setEnabled(false) ;
815 GroupC2->setEnabled(false) ;
816 GroupC3->setEnabled(false) ;
817 GroupButtons->setEnabled(false) ;
818 disconnect( mySelection, 0, this, 0 );
819 myGeomGUI->ResetState() ;
820 myGeomGUI->SetActiveDialogBox(0) ;
821 myGeomGUI->OnDisplayAll(true) ;
827 //=================================================================================
828 // function : ActivateThisDialog()
830 //=================================================================================
831 void GeometryGUI_ChamferDlg::ActivateThisDialog()
833 /* Emit a signal to deactivate the active dialog */
834 myGeomGUI->EmitSignalDeactivateDialog() ;
836 GroupConstructors->setEnabled(true) ;
837 GroupC1->setEnabled(true) ;
838 GroupC2->setEnabled(true) ;
839 GroupC3->setEnabled(true) ;
840 GroupButtons->setEnabled(true) ;
841 connect ( mySelection, SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) );
842 myGeomGUI->SetActiveDialogBox( (QDialog*)this ) ;
844 if( !mySimulationTopoDs.IsNull() )
845 myGeomGUI->DisplaySimulationShape( mySimulationTopoDs ) ;
850 //=================================================================================
851 // function : enterEvent()
853 //=================================================================================
854 void GeometryGUI_ChamferDlg::enterEvent( QEvent* e)
856 if ( GroupConstructors->isEnabled() )
858 ActivateThisDialog() ;
863 //=================================================================================
864 // function : closeEvent()
866 //=================================================================================
867 void GeometryGUI_ChamferDlg::closeEvent( QCloseEvent* e )
869 /* same than click on cancel button */
870 this->ClickOnCancel() ;
875 //=================================================================================
876 // function : ResetStateOfDialog()
878 //=================================================================================
879 void GeometryGUI_ChamferDlg::ResetStateOfDialog()
881 this->myOkShape = false ;
882 this->myEditCurrentArgument->setText("") ;
884 /* Close its local contact if opened */
885 if ( myGeomGUI->GetActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_OCC ) {
886 OCCViewer_Viewer3d* v3d = ((OCCViewer_ViewFrame*)myGeomGUI->GetActiveStudy()->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getViewer();
887 myIC = v3d->getAISContext();
888 if(this->myUseLocalContext) {
889 myIC->CloseLocalContext(this->myLocalContextId) ;
890 this->myUseLocalContext = false ;
891 myGeomGUI->OnDisplayAll(true) ;
897 void GeometryGUI_ChamferDlg::MakePreview()
902 BRepFilletAPI_MakeChamfer MC(myShape);
903 switch (myConstructorId)
905 case 0: /* Chamfer All */
907 TopTools_IndexedDataMapOfShapeListOfShape M;
908 TopExp::MapShapesAndAncestors(myShape,TopAbs_EDGE,TopAbs_FACE,M);
909 for (int i = 1;i<=M.Extent();i++)
911 TopoDS_Edge E = TopoDS::Edge(M.FindKey(i));
912 TopoDS_Face F = TopoDS::Face(M.FindFromIndex(i).First());
913 if (!BRepTools::IsReallyClosed(E, F) && !BRep_Tool::Degenerated(E))
914 MC.Add(myD1, myD2,E,F);
919 // case 1: /* Chamfer edges */
920 // case 2: /* Chamfer Faces */
924 mySimulationTopoDs = tds;
925 myGeomGUI->DisplaySimulationShape( mySimulationTopoDs ) ;
929 catch(Standard_Failure)
931 myGeomGUI->EraseSimulationShape() ;
932 mySimulationTopoDs.Nullify() ;