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.salome-platform.org/ or email : webmaster.salome@opencascade.com
24 // File : OperationGUI_ChamferDlg.cxx
25 // Author : Damien COQUERET
29 #include "OperationGUI_ChamferDlg.h"
30 #include "DlgRef_SpinBox.h"
32 #include "SUIT_Desktop.h"
33 #include "SUIT_Session.h"
34 #include "SalomeApp_Application.h"
35 #include "LightApp_SelectionMgr.h"
36 #include "OCCViewer_ViewModel.h"
38 #include <TColStd_MapOfInteger.hxx>
44 #include "GEOMImpl_Types.hxx"
46 //=================================================================================
47 // class : OperationGUI_ChamferDlg()
48 // purpose : Constructs a OperationGUI_ChamferDlg which is a child of 'parent', with the
49 // name 'name' and widget flags set to 'f'.
50 // The dialog will by default be modeless, unless you set 'modal' to
51 // TRUE to construct a modal dialog.
52 //=================================================================================
53 OperationGUI_ChamferDlg::OperationGUI_ChamferDlg(GeometryGUI* theGeometryGUI, QWidget* parent)
54 : GEOMBase_Skeleton(theGeometryGUI, parent, "ChamferDlg", false,
55 WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu)
59 QPixmap image1(SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM",tr("ICON_DLG_CHAMFER_ALL")));
60 QPixmap image2(SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM",tr("ICON_DLG_CHAMFER_EDGE_FROM_FACE")));
61 QPixmap image3(SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM",tr("ICON_DLG_CHAMFER_FACE")));
62 QPixmap image4(SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM",tr("ICON_DLG_CHAMFER_EDGE")));
63 QPixmap iconSelect(SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM",tr("ICON_SELECT")));
65 setCaption( tr( "GEOM_CHAMFER_TITLE" ) );
67 GroupConstructors->setTitle( tr( "GEOM_CHAMFER" ) );
69 RadioButton1->setPixmap( image1 );
70 RadioButton2->setPixmap( image2 );
71 RadioButton3->setPixmap( image3 );
73 RadioButton4->setPixmap( image4 );
77 myGrp1 = new QGroupBox( 1, Qt::Horizontal, tr( "GEOM_CHAMFER_ALL" ), this );
79 QGroupBox* aSelGrp1 = new QGroupBox( 3, Qt::Horizontal, myGrp1 );
80 aSelGrp1->setFrameStyle( QFrame::NoFrame );
81 aSelGrp1->setInsideMargin( 0 );
83 createSelWg( tr( "GEOM_MAIN_OBJECT" ), iconSelect, aSelGrp1, MainObj1 );
85 QGroupBox* aSpinGrp = new QGroupBox( 1, Qt::Vertical, myGrp1 );
86 aSpinGrp->setFrameStyle( QFrame::NoFrame );
87 aSpinGrp->setInsideMargin( 0 );
89 new QLabel( tr( "D" ), aSpinGrp );
90 mySpinBox[ SpinBox1 ] = new DlgRef_SpinBox( aSpinGrp );
92 ( new QFrame( myGrp1 ) )->setSizePolicy(
93 QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding ) );
95 // Create second group
97 myGrp2 = new QGroupBox( 1, Qt::Horizontal, tr( "GEOM_CHAMFER_EDGES" ), this );
99 QGroupBox* aSelGrp2 = new QGroupBox( 3, Qt::Horizontal, myGrp2 );
100 aSelGrp2->setFrameStyle( QFrame::NoFrame );
101 aSelGrp2->setInsideMargin( 0 );
103 createSelWg( tr( "GEOM_MAIN_OBJECT" ), iconSelect, aSelGrp2, MainObj2 );
104 createSelWg( tr( "FACE_1" ), iconSelect, aSelGrp2, Face1 );
105 createSelWg( tr( "FACE_2" ), iconSelect, aSelGrp2, Face2 );
107 QGroupBox* aSpinGrp1 = new QGroupBox( 1, Qt::Vertical, myGrp2 );
108 aSpinGrp1->setFrameStyle( QFrame::NoFrame );
109 aSpinGrp1->setInsideMargin( 0 );
111 myRadioButton[ RadioButton21] = new QRadioButton( aSpinGrp1 );
113 new QLabel( tr( "GEOM_D1" ), aSpinGrp1 );
114 mySpinBox[ SpinBox21 ] = new DlgRef_SpinBox( aSpinGrp1 );
116 new QLabel( tr( "GEOM_D2" ), aSpinGrp1 );
117 mySpinBox[ SpinBox22 ] = new DlgRef_SpinBox( aSpinGrp1 );
119 QGroupBox* aSpinGrp2 = new QGroupBox( 1, Qt::Vertical, myGrp2 );
120 aSpinGrp2->setFrameStyle( QFrame::NoFrame );
121 aSpinGrp2->setInsideMargin( 0 );
123 myRadioButton[ RadioButton22] = new QRadioButton( aSpinGrp2 );
125 new QLabel( tr( "GEOM_D" ), aSpinGrp2 );
126 mySpinBox[ SpinBox23 ] = new DlgRef_SpinBox( aSpinGrp2 );
128 new QLabel( tr( "GEOM_ANGLE" ), aSpinGrp2 );
129 mySpinBox[ SpinBox24 ] = new DlgRef_SpinBox( aSpinGrp2 );
131 ( new QLabel( myGrp2 ) )->setSizePolicy(
132 QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding ) );
134 // Create third group
136 myGrp3 = new QGroupBox( 1, Qt::Horizontal, tr( "GEOM_CHAMFER_FACES" ), this );
138 QGroupBox* aSelGrp3 = new QGroupBox( 3, Qt::Horizontal, myGrp3 );
139 aSelGrp3->setFrameStyle( QFrame::NoFrame );
140 aSelGrp3->setInsideMargin( 0 );
142 createSelWg( tr( "GEOM_MAIN_OBJECT" ), iconSelect, aSelGrp3, MainObj3 );
143 createSelWg( tr( "SELECTED_FACES" ), iconSelect, aSelGrp3, Faces );
145 aSpinGrp1 = new QGroupBox( 1, Qt::Vertical, myGrp3 );
146 aSpinGrp1->setFrameStyle( QFrame::NoFrame );
147 aSpinGrp1->setInsideMargin( 0 );
149 myRadioButton[ RadioButton31] = new QRadioButton( aSpinGrp1 );
151 new QLabel( tr( "GEOM_D1" ), aSpinGrp1 );
152 mySpinBox[ SpinBox31 ] = new DlgRef_SpinBox( aSpinGrp1 );
154 new QLabel( tr( "GEOM_D2" ), aSpinGrp1 );
155 mySpinBox[ SpinBox32 ] = new DlgRef_SpinBox( aSpinGrp1 );
157 aSpinGrp2 = new QGroupBox( 1, Qt::Vertical, myGrp3 );
158 aSpinGrp2->setFrameStyle( QFrame::NoFrame );
159 aSpinGrp2->setInsideMargin( 0 );
161 myRadioButton[ RadioButton32] = new QRadioButton( aSpinGrp2 );
163 new QLabel( tr( "GEOM_D" ), aSpinGrp2 );
164 mySpinBox[ SpinBox33 ] = new DlgRef_SpinBox( aSpinGrp2 );
166 new QLabel( tr( "GEOM_ANGLE" ), aSpinGrp2 );
167 mySpinBox[ SpinBox34 ] = new DlgRef_SpinBox( aSpinGrp2 );
169 ( new QLabel( myGrp3 ) )->setSizePolicy(
170 QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding ) );
172 // Create fourth group
174 myGrp4 = new QGroupBox( 1, Qt::Horizontal, tr( "GEOM_CHAMFER_EDGE" ), this );
176 QGroupBox* aSelGrp4 = new QGroupBox( 3, Qt::Horizontal, myGrp4 );
177 aSelGrp4->setFrameStyle( QFrame::NoFrame );
178 aSelGrp4->setInsideMargin( 0 );
180 createSelWg( tr( "GEOM_MAIN_OBJECT" ), iconSelect, aSelGrp4, MainObj4 );
181 createSelWg( tr( "SELECTED_EDGE" ), iconSelect, aSelGrp4, Edges );
183 aSpinGrp1 = new QGroupBox( 1, Qt::Vertical, myGrp4 );
184 aSpinGrp1->setFrameStyle( QFrame::NoFrame );
185 aSpinGrp1->setInsideMargin( 0 );
187 myRadioButton[ RadioButton41] = new QRadioButton( aSpinGrp1 );
189 new QLabel( tr( "GEOM_D1" ), aSpinGrp1 );
190 mySpinBox[ SpinBox41 ] = new DlgRef_SpinBox( aSpinGrp1 );
192 new QLabel( tr( "GEOM_D2" ), aSpinGrp1 );
193 mySpinBox[ SpinBox42 ] = new DlgRef_SpinBox( aSpinGrp1 );
195 aSpinGrp2 = new QGroupBox( 1, Qt::Vertical, myGrp4 );
196 aSpinGrp2->setFrameStyle( QFrame::NoFrame );
197 aSpinGrp2->setInsideMargin( 0 );
199 myRadioButton[ RadioButton42] = new QRadioButton( aSpinGrp2 );
201 new QLabel( tr( "GEOM_D" ), aSpinGrp2 );
202 mySpinBox[ SpinBox43 ] = new DlgRef_SpinBox( aSpinGrp2 );
204 new QLabel( tr( "GEOM_ANGLE" ), aSpinGrp2 );
205 mySpinBox[ SpinBox44 ] = new DlgRef_SpinBox( aSpinGrp2 );
207 ( new QLabel( myGrp4 ) )->setSizePolicy(
208 QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding ) );
210 // Add groups to layout
212 Layout1->addWidget( myGrp1, 2, 0 );
213 Layout1->addWidget( myGrp2, 2, 0 );
214 Layout1->addWidget( myGrp3, 2, 0 );
215 Layout1->addWidget( myGrp4, 2, 0 );
217 // Set range of spinboxes
219 double SpecificStep = 10.0;
220 QMap< int, DlgRef_SpinBox* >::iterator anIter;
221 for ( anIter = mySpinBox.begin(); anIter != mySpinBox.end(); ++anIter )
223 if ( anIter.key() == SpinBox44 || anIter.key() == SpinBox34 || anIter.key() == SpinBox24 )
224 anIter.data()->RangeStepAndValidator( 0.001, 89.999, 5, 0 );
226 anIter.data()->RangeStepAndValidator( 0.001, COORD_MAX, SpecificStep, DBL_DIGITS_DISPLAY );
229 setHelpFileName("chamfer_operation_page.html");
231 /* Initialisations */
232 RadioButtonPressed();
237 //=================================================================================
238 // function : ~OperationGUI_ChamferDlg()
239 // purpose : Destroys the object and frees any allocated resources
240 //=================================================================================
241 OperationGUI_ChamferDlg::~OperationGUI_ChamferDlg()
246 //=================================================================================
249 //=================================================================================
250 void OperationGUI_ChamferDlg::Init()
252 myConstructorId = -1;
254 RadioButton1->setChecked( true );
255 myEditCurrentArgument = mySelName[ MainObj1 ];
257 /* signals and slots connections */
260 connect( buttonOk , SIGNAL( clicked() ), this, SLOT( ClickOnOk() ) );
261 connect( buttonApply, SIGNAL( clicked() ), this, SLOT( ClickOnApply() ) );
264 connect( GroupConstructors, SIGNAL( clicked( int ) ),
265 this, SLOT( ConstructorsClicked( int ) ) );
268 QMap< int, QPushButton* >::iterator anIterBtn;
269 for ( anIterBtn = mySelBtn.begin(); anIterBtn != mySelBtn.end(); ++anIterBtn )
270 connect( anIterBtn.data(), SIGNAL( clicked() ),
271 this, SLOT( SetEditCurrentArgument() ) );
274 QMap< int, QLineEdit* >::iterator anIterLE2;
275 for ( anIterLE2 = mySelName.begin(); anIterLE2 != mySelName.end(); ++anIterLE2 )
276 connect( anIterLE2.data(), SIGNAL( returnPressed() ),
277 this, SLOT( LineEditReturnPressed() ) );
280 QMap< int, DlgRef_SpinBox* >::iterator anIterSpin;
281 for ( anIterSpin = mySpinBox.begin(); anIterSpin != mySpinBox.end(); ++anIterSpin )
282 connect( anIterSpin.data(), SIGNAL( valueChanged( double ) ),
283 this, SLOT( ValueChangedInSpinBox( double ) ) );
286 QMap< int, QRadioButton* >::iterator anIterRadio;
287 for ( anIterRadio = myRadioButton.begin(); anIterRadio != myRadioButton.end(); ++anIterRadio )
288 connect( anIterRadio.data(), SIGNAL( clicked() ),
289 this, SLOT( RadioButtonPressed() ) );
292 connect(myGeomGUI->getApp()->selectionMgr(),
293 SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument()));
295 initName( tr( "GEOM_CHAMFER" ) );
304 //=================================================================================
305 // function : ConstructorsClicked()
306 // purpose : Radio button management
307 //=================================================================================
308 void OperationGUI_ChamferDlg::ConstructorsClicked( int constructorId )
310 // Activate next widget
311 if (myGeomGUI->getApp()->desktop()->activeWindow()->getViewManager()->getType()
312 != OCCViewer_Viewer::Type())
314 RadioButton1->setChecked( true );
318 if (myConstructorId == constructorId)
321 // Get values from previous widget
322 double D1 = 5, D2 = 5, D = 5, Angle = 5;
323 if ( myConstructorId == 0 )
324 D1 = D2 = mySpinBox[ SpinBox1 ]->GetValue();
325 else if ( myConstructorId == 1 )
327 D1 = mySpinBox[ SpinBox21 ]->GetValue();
328 D2 = mySpinBox[ SpinBox22 ]->GetValue();
329 D = mySpinBox[ SpinBox23 ]->GetValue();
330 Angle = mySpinBox[ SpinBox24 ]->GetValue();
332 else if ( myConstructorId == 2 )
334 D1 = mySpinBox[ SpinBox31 ]->GetValue();
335 D2 = mySpinBox[ SpinBox32 ]->GetValue();
336 D = mySpinBox[ SpinBox33 ]->GetValue();
337 Angle = mySpinBox[ SpinBox34 ]->GetValue();
339 else if ( myConstructorId == 3 )
341 D1 = mySpinBox[ SpinBox41 ]->GetValue();
342 D2 = mySpinBox[ SpinBox42 ]->GetValue();
343 D = mySpinBox[ SpinBox43 ]->GetValue();
344 Angle = mySpinBox[ SpinBox44 ]->GetValue();
347 myConstructorId = constructorId;
349 switch ( constructorId )
356 mySpinBox[ SpinBox1 ]->SetValue( D1 );
363 mySpinBox[ SpinBox21 ]->SetValue( D1 );
364 mySpinBox[ SpinBox22 ]->SetValue( D2 );
365 mySpinBox[ SpinBox23 ]->SetValue( D );
366 mySpinBox[ SpinBox24 ]->SetValue( Angle );
373 mySpinBox[ SpinBox31 ]->SetValue( D1 );
374 mySpinBox[ SpinBox32 ]->SetValue( D2 );
375 mySpinBox[ SpinBox33 ]->SetValue( D );
376 mySpinBox[ SpinBox34 ]->SetValue( Angle );
383 mySpinBox[ SpinBox41 ]->SetValue( D1 );
384 mySpinBox[ SpinBox42 ]->SetValue( D2 );
385 mySpinBox[ SpinBox43 ]->SetValue( D );
386 mySpinBox[ SpinBox44 ]->SetValue( Angle );
392 if ( constructorId == 0 ) myEditCurrentArgument = mySelName[ MainObj1 ];
393 else if ( constructorId == 1 ) myEditCurrentArgument = mySelName[ MainObj2 ];
394 else if ( constructorId == 2 ) myEditCurrentArgument = mySelName[ MainObj3 ];
395 else myEditCurrentArgument = mySelName[ MainObj4 ];
400 if ( !myShape->_is_nil() )
402 myEditCurrentArgument->setText( GEOMBase::GetName( myShape ) );
403 GEOMBase_Skeleton::LineEditReturnPressed();
406 myEditCurrentArgument->setText( "" );
412 //=================================================================================
413 // function : ClickOnOk()
415 //=================================================================================
416 void OperationGUI_ChamferDlg::ClickOnOk()
418 if ( ClickOnApply() )
422 //=================================================================================
423 // function : ClickOnApply()
425 //=================================================================================
426 bool OperationGUI_ChamferDlg::ClickOnApply()
435 //=================================================================================
436 // function : SelectionIntoArgument()
437 // purpose : Called when selection has changed
438 //=================================================================================
439 void OperationGUI_ChamferDlg::SelectionIntoArgument()
442 myEditCurrentArgument->setText( "" );
444 // Get index of current selection focus
446 QMap< int, QLineEdit* >::iterator anIter;
447 for ( anIter = mySelName.begin(); anIter != mySelName.end(); ++anIter )
448 if ( myEditCurrentArgument == anIter.data() )
450 aCurrFocus = anIter.key();
454 // If selection of main object is activated
455 if ( aCurrFocus == MainObj1 || aCurrFocus == MainObj2 || aCurrFocus == MainObj3 || aCurrFocus == MainObj4)
457 if ( IObjectCount() == 1 )
459 Standard_Boolean aResult = Standard_False;
460 GEOM::GEOM_Object_var anObj =
461 GEOMBase::ConvertIOinGEOMObject( firstIObject(), aResult );
463 if ( aResult && !anObj->_is_nil() )
466 mySelName[ aCurrFocus ]->setText( GEOMBase::GetName( anObj ) );
473 myShape = GEOM::GEOM_Object::_nil();
476 // If face selection of second tab is activated
477 else if ( aCurrFocus == Face1 || aCurrFocus == Face2 )
479 if ( IObjectCount() == 1 )
481 Standard_Boolean aResult = Standard_False;
482 GEOM::GEOM_Object_var anObj =
483 GEOMBase::ConvertIOinGEOMObject( firstIObject(), aResult );
485 if ( aResult && !anObj->_is_nil() )
487 TColStd_IndexedMapOfInteger anIndexes;
488 ((SalomeApp_Application*)(SUIT_Session::session()->activeApplication()))->selectionMgr()->GetIndexes( firstIObject(), anIndexes );
490 if ( anIndexes.Extent() == 1 )
492 int anIndex = anIndexes( 1 );
493 QString aFaceName = QString( GEOMBase::GetName( anObj ) ) + ":%1";
494 myEditCurrentArgument->setText( aFaceName.arg( anIndex ) );
495 myFace[ aCurrFocus ] = anIndex;
502 myFace[ aCurrFocus ] = -1;
504 // If face selection of third or fourth tab is activated
505 else if ( aCurrFocus == Faces || aCurrFocus == Edges )
507 if ( IObjectCount() == 1 )
509 Standard_Boolean aResult = Standard_False;
510 GEOM::GEOM_Object_var anObj =
511 GEOMBase::ConvertIOinGEOMObject( firstIObject(), aResult );
513 if ( aResult && !anObj->_is_nil() )
515 TColStd_IndexedMapOfInteger anIndexes;
516 ((SalomeApp_Application*)(SUIT_Session::session()->activeApplication()))->selectionMgr()->GetIndexes( firstIObject(), anIndexes );
518 if ( anIndexes.Extent() > 0 )
521 if ( anIndexes.Extent() == 1 )
523 int anIndex = anIndexes( 1 );
525 aName = QString( GEOMBase::GetName( anObj ) ) + QString( ":%1" ).arg( anIndex );
528 aName = tr( "GEOM_MEN_POPUP_NAME" ).arg( anIndexes.Extent() );
530 myEditCurrentArgument->setText( aName );
531 int aConstructorId = getConstructorId();
532 if ( aConstructorId == 2)
534 else if (aConstructorId == 3)
548 //=================================================================================
549 // function : LineEditReturnPressed()
551 //=================================================================================
552 void OperationGUI_ChamferDlg::LineEditReturnPressed()
554 QLineEdit* aSender = ( QLineEdit* )sender();
556 QMap< int, QLineEdit* >::iterator anIterLE;
557 for ( anIterLE = mySelName.begin(); anIterLE != mySelName.end(); ++anIterLE )
558 if ( anIterLE.data() == aSender )
559 myEditCurrentArgument = anIterLE.data();
561 GEOMBase_Skeleton::LineEditReturnPressed();
564 //=================================================================================
565 // function : RadioButtonPressed()
567 //=================================================================================
568 void OperationGUI_ChamferDlg::RadioButtonPressed()
571 flag = ( myRadioButton[ RadioButton21 ]->isChecked() &&
572 myRadioButton[ RadioButton31 ]->isChecked() &&
573 myRadioButton[ RadioButton41 ]->isChecked() );
575 myRadioButton[ RadioButton21 ]->setChecked(!flag);
576 myRadioButton[ RadioButton31 ]->setChecked(!flag);
577 myRadioButton[ RadioButton41 ]->setChecked(!flag);
578 myRadioButton[ RadioButton22 ]->setChecked(flag);
579 myRadioButton[ RadioButton32 ]->setChecked(flag);
580 myRadioButton[ RadioButton42 ]->setChecked(flag);
581 mySpinBox[ SpinBox21 ]->setDisabled(flag);
582 mySpinBox[ SpinBox22 ]->setDisabled(flag);
583 mySpinBox[ SpinBox31 ]->setDisabled(flag);
584 mySpinBox[ SpinBox32 ]->setDisabled(flag);
585 mySpinBox[ SpinBox41 ]->setDisabled(flag);
586 mySpinBox[ SpinBox42 ]->setDisabled(flag);
587 mySpinBox[ SpinBox23 ]->setDisabled(!flag);
588 mySpinBox[ SpinBox24 ]->setDisabled(!flag);
589 mySpinBox[ SpinBox33 ]->setDisabled(!flag);
590 mySpinBox[ SpinBox34 ]->setDisabled(!flag);
591 mySpinBox[ SpinBox43 ]->setDisabled(!flag);
592 mySpinBox[ SpinBox44 ]->setDisabled(!flag);
597 //=================================================================================
598 // function : SetEditCurrentArgument()
600 //=================================================================================
601 void OperationGUI_ChamferDlg::SetEditCurrentArgument()
603 QPushButton* aSender = ( QPushButton* )sender();
605 QMap< int, QPushButton* >::iterator anIter;
606 for ( anIter = mySelBtn.begin(); anIter != mySelBtn.end(); ++anIter )
607 if ( anIter.data() == aSender )
609 mySelName[ anIter.key() ]->setFocus();
610 myEditCurrentArgument = mySelName[ anIter.key() ];
617 //=================================================================================
618 // function : ActivateThisDialog()
620 //=================================================================================
621 void OperationGUI_ChamferDlg::ActivateThisDialog()
623 GEOMBase_Skeleton::ActivateThisDialog();
625 connect( ((SalomeApp_Application*)(SUIT_Session::session()->activeApplication()))->selectionMgr(),
626 SIGNAL(currentSelectionChanged()), this, SLOT( SelectionIntoArgument() ) );
633 //=================================================================================
634 // function : enterEvent()
636 //=================================================================================
637 void OperationGUI_ChamferDlg::enterEvent(QEvent* e)
639 if ( !GroupConstructors->isEnabled() )
640 this->ActivateThisDialog();
644 //=================================================================================
645 // function : ValueChangedInSpinBox()
647 //=================================================================================
648 void OperationGUI_ChamferDlg::ValueChangedInSpinBox( double newValue )
654 //=================================================================================
655 // function : createSelWg()
657 //=================================================================================
658 void OperationGUI_ChamferDlg::createSelWg( const QString& theLbl,
663 new QLabel( theLbl, theParent );
664 mySelBtn[ theId ] = new QPushButton( theParent );
665 mySelBtn[ theId ]->setPixmap( thePix );
666 mySelName[ theId ] = new QLineEdit( theParent );
667 mySelName[ theId ]->setReadOnly( true );
670 //=================================================================================
671 // function : reset()
673 //=================================================================================
674 void OperationGUI_ChamferDlg::reset()
676 // Set Initial values of spinboxes
677 QMap< int, DlgRef_SpinBox* >::iterator anIter;
678 for ( anIter = mySpinBox.begin(); anIter != mySpinBox.end(); ++anIter )
679 anIter.data()->SetValue( 5 );
682 QMap< int, QLineEdit* >::iterator anIterLE;
683 for ( anIterLE = mySelName.begin(); anIterLE != mySelName.end(); ++anIterLE )
684 anIterLE.data()->setText( "" );
687 int aConstructorId = getConstructorId();
689 if ( aConstructorId == 0 ) myEditCurrentArgument = mySelName[ MainObj1 ];
690 else if ( aConstructorId == 1 ) myEditCurrentArgument = mySelName[ MainObj2 ];
691 else if ( aConstructorId == 2 ) myEditCurrentArgument = mySelName[ MainObj3 ];
692 else myEditCurrentArgument = mySelName[ MainObj4 ];
694 myShape = GEOM::GEOM_Object::_nil();
698 myFace[ Face1 ] = -1;
699 myFace[ Face2 ] = -1;
701 erasePreview( true );
708 //=================================================================================
709 // function : getConstructorId()
711 //=================================================================================
712 int OperationGUI_ChamferDlg::getConstructorId() const
714 return GroupConstructors->id( GroupConstructors->selected() );
717 //=================================================================================
718 // function : activateSelection
719 // purpose : Activate selection in accordance with myEditCurrentArgument
720 //=================================================================================
721 void OperationGUI_ChamferDlg::activateSelection()
723 if ( !myShape->_is_nil() &&
724 ( myEditCurrentArgument == mySelName[ Face1 ] ||
725 myEditCurrentArgument == mySelName[ Face2 ] ||
726 myEditCurrentArgument == mySelName[ Faces ] ) )
727 localSelection( myShape, TopAbs_FACE );
728 else if (!myShape->_is_nil() && myEditCurrentArgument == mySelName[ Edges ] )
729 localSelection( myShape, TopAbs_EDGE );
732 TColStd_MapOfInteger aMap;
733 aMap.Add( GEOM_SHELL );
734 aMap.Add( GEOM_SOLID );
735 aMap.Add( GEOM_COMPOUND );
736 globalSelection( aMap );
739 SelectionIntoArgument();
742 //=================================================================================
743 // function : enableWidgets
744 // purpose : Enable widgets of faces in accordance with value of main object
745 //=================================================================================
746 void OperationGUI_ChamferDlg::enableWidgets()
748 int anId = getConstructorId();
750 bool toEnable = !myShape->_is_nil();
754 mySelName[ Face1 ]->setEnabled( toEnable );
755 mySelName[ Face2 ]->setEnabled( toEnable );
756 mySelBtn[ Face1 ]->setEnabled( toEnable );
757 mySelBtn[ Face2 ]->setEnabled( toEnable );
761 mySelName[ Face1 ]->setText( "" );
762 mySelName[ Face2 ]->setText( "" );
763 myFace[ Face1 ] = -1;
764 myFace[ Face2 ] = -1;
767 else if ( anId == 2 )
769 mySelName[ Faces ]->setEnabled( toEnable );
772 mySelName[ Faces ]->setText( "" );
776 else if ( anId == 3 )
778 mySelName[ Edges ]->setEnabled( toEnable );
782 mySelName[ Edges ]->setText( "" );
788 //=================================================================================
789 // function : createOperation
791 //=================================================================================
792 GEOM::GEOM_IOperations_ptr OperationGUI_ChamferDlg::createOperation()
794 return getGeomEngine()->GetILocalOperations( getStudyId() );
796 //=================================================================================
797 // function : ClickOnApply()
798 // purpose : Verify validity of input data
799 //=================================================================================
800 bool OperationGUI_ChamferDlg::isValid( QString& )
802 switch ( getConstructorId() )
804 case 0: return !myShape->_is_nil();
805 case 1: return !myShape->_is_nil() && myFace[ Face1 ] > 0 && myFace[ Face2 ] > 0;
806 case 2: return !myShape->_is_nil() && myFaces.Extent() > 0;
807 case 3: return !myShape->_is_nil() && myEdges.Extent() > 0;
808 default: return false;
812 //=================================================================================
813 // function : execute
815 //=================================================================================
816 bool OperationGUI_ChamferDlg::execute( ObjectList& objects )
818 GEOM::GEOM_Object_var anObj;
819 bool flag = ( myRadioButton[ RadioButton21 ]->isChecked() &&
820 myRadioButton[ RadioButton31 ]->isChecked() &&
821 myRadioButton[ RadioButton41 ]->isChecked() );
823 int anId = getConstructorId();
825 anObj = GEOM::GEOM_ILocalOperations::_narrow(
826 getOperation() )->MakeChamferAll( myShape,
827 mySpinBox[ SpinBox1 ]->GetValue() );
828 else if ( anId == 1 )
831 anObj = GEOM::GEOM_ILocalOperations::_narrow(
832 getOperation() )->MakeChamferEdge( myShape,
833 mySpinBox[ SpinBox21 ]->GetValue(),
834 mySpinBox[ SpinBox22 ]->GetValue(),
838 anObj = GEOM::GEOM_ILocalOperations::_narrow(
839 getOperation() )->MakeChamferEdgeAD( myShape,
840 mySpinBox[ SpinBox23 ]->GetValue(),
841 mySpinBox[ SpinBox24 ]->GetValue() * PI180,
845 else if ( anId == 2 )
847 GEOM::ListOfLong_var anArray = new GEOM::ListOfLong;
848 anArray->length( myFaces.Extent() );
849 for ( int i = 1, n = myFaces.Extent(); i <= n; i++ )
850 anArray[ i - 1 ] = myFaces( i );
852 anObj = GEOM::GEOM_ILocalOperations::_narrow(
853 getOperation() )->MakeChamferFaces( myShape,
854 mySpinBox[ SpinBox31 ]->GetValue(),
855 mySpinBox[ SpinBox32 ]->GetValue(),
858 anObj = GEOM::GEOM_ILocalOperations::_narrow(
859 getOperation() )->MakeChamferFacesAD( myShape,
860 mySpinBox[ SpinBox33 ]->GetValue(),
861 mySpinBox[ SpinBox34 ]->GetValue() * PI180,
864 else if ( anId == 3 )
866 GEOM::ListOfLong_var anArray = new GEOM::ListOfLong;
867 anArray->length( myEdges.Extent() );
868 for ( int i = 1, n = myEdges.Extent(); i <= n; i++ )
869 anArray[ i - 1 ] = myEdges( i );
871 anObj = GEOM::GEOM_ILocalOperations::_narrow(
872 getOperation() )->MakeChamferEdges( myShape, mySpinBox[ SpinBox41 ]->GetValue(),
873 mySpinBox[ SpinBox42 ]->GetValue(), anArray );
875 anObj = GEOM::GEOM_ILocalOperations::_narrow(
876 getOperation() )->MakeChamferEdgesAD( myShape, mySpinBox[ SpinBox43 ]->GetValue(),
877 mySpinBox[ SpinBox44 ]->GetValue() * PI180, anArray );
880 if ( !anObj->_is_nil() )
881 objects.push_back( anObj._retn() );