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 anIter.data()->RangeStepAndValidator( 0.001, COORD_MAX, SpecificStep, 3 );
224 if ( anIter.key() == SpinBox44 || anIter.key() == SpinBox34 || anIter.key() == SpinBox24 )
225 anIter.data()->RangeStepAndValidator( 0.001, 89.999, 5, 0 );
228 setHelpFileName("chamfer_operation_page.html");
230 /* Initialisations */
231 RadioButtonPressed();
236 //=================================================================================
237 // function : ~OperationGUI_ChamferDlg()
238 // purpose : Destroys the object and frees any allocated resources
239 //=================================================================================
240 OperationGUI_ChamferDlg::~OperationGUI_ChamferDlg()
245 //=================================================================================
248 //=================================================================================
249 void OperationGUI_ChamferDlg::Init()
251 myConstructorId = -1;
253 RadioButton1->setChecked( true );
254 myEditCurrentArgument = mySelName[ MainObj1 ];
256 /* signals and slots connections */
259 connect( buttonOk , SIGNAL( clicked() ), this, SLOT( ClickOnOk() ) );
260 connect( buttonApply, SIGNAL( clicked() ), this, SLOT( ClickOnApply() ) );
263 connect( GroupConstructors, SIGNAL( clicked( int ) ),
264 this, SLOT( ConstructorsClicked( int ) ) );
267 QMap< int, QPushButton* >::iterator anIterBtn;
268 for ( anIterBtn = mySelBtn.begin(); anIterBtn != mySelBtn.end(); ++anIterBtn )
269 connect( anIterBtn.data(), SIGNAL( clicked() ),
270 this, SLOT( SetEditCurrentArgument() ) );
273 QMap< int, QLineEdit* >::iterator anIterLE2;
274 for ( anIterLE2 = mySelName.begin(); anIterLE2 != mySelName.end(); ++anIterLE2 )
275 connect( anIterLE2.data(), SIGNAL( returnPressed() ),
276 this, SLOT( LineEditReturnPressed() ) );
279 QMap< int, DlgRef_SpinBox* >::iterator anIterSpin;
280 for ( anIterSpin = mySpinBox.begin(); anIterSpin != mySpinBox.end(); ++anIterSpin )
281 connect( anIterSpin.data(), SIGNAL( valueChanged( double ) ),
282 this, SLOT( ValueChangedInSpinBox( double ) ) );
285 QMap< int, QRadioButton* >::iterator anIterRadio;
286 for ( anIterRadio = myRadioButton.begin(); anIterRadio != myRadioButton.end(); ++anIterRadio )
287 connect( anIterRadio.data(), SIGNAL( clicked() ),
288 this, SLOT( RadioButtonPressed() ) );
291 connect(myGeomGUI->getApp()->selectionMgr(),
292 SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument()));
294 initName( tr( "GEOM_CHAMFER" ) );
303 //=================================================================================
304 // function : ConstructorsClicked()
305 // purpose : Radio button management
306 //=================================================================================
307 void OperationGUI_ChamferDlg::ConstructorsClicked( int constructorId )
309 // Activate next widget
310 if (myGeomGUI->getApp()->desktop()->activeWindow()->getViewManager()->getType()
311 != OCCViewer_Viewer::Type())
313 RadioButton1->setChecked( true );
317 if (myConstructorId == constructorId)
320 // Get values from previous widget
321 double D1 = 5, D2 = 5, D = 5, Angle = 5;
322 if ( myConstructorId == 0 )
323 D1 = D2 = mySpinBox[ SpinBox1 ]->GetValue();
324 else if ( myConstructorId == 1 )
326 D1 = mySpinBox[ SpinBox21 ]->GetValue();
327 D2 = mySpinBox[ SpinBox22 ]->GetValue();
328 D = mySpinBox[ SpinBox23 ]->GetValue();
329 Angle = mySpinBox[ SpinBox24 ]->GetValue();
331 else if ( myConstructorId == 2 )
333 D1 = mySpinBox[ SpinBox31 ]->GetValue();
334 D2 = mySpinBox[ SpinBox32 ]->GetValue();
335 D = mySpinBox[ SpinBox33 ]->GetValue();
336 Angle = mySpinBox[ SpinBox34 ]->GetValue();
338 else if ( myConstructorId == 3 )
340 D1 = mySpinBox[ SpinBox41 ]->GetValue();
341 D2 = mySpinBox[ SpinBox42 ]->GetValue();
342 D = mySpinBox[ SpinBox43 ]->GetValue();
343 Angle = mySpinBox[ SpinBox44 ]->GetValue();
346 myConstructorId = constructorId;
348 switch ( constructorId )
355 mySpinBox[ SpinBox1 ]->SetValue( D1 );
362 mySpinBox[ SpinBox21 ]->SetValue( D1 );
363 mySpinBox[ SpinBox22 ]->SetValue( D2 );
364 mySpinBox[ SpinBox23 ]->SetValue( D );
365 mySpinBox[ SpinBox24 ]->SetValue( Angle );
372 mySpinBox[ SpinBox31 ]->SetValue( D1 );
373 mySpinBox[ SpinBox32 ]->SetValue( D2 );
374 mySpinBox[ SpinBox33 ]->SetValue( D );
375 mySpinBox[ SpinBox34 ]->SetValue( Angle );
382 mySpinBox[ SpinBox41 ]->SetValue( D1 );
383 mySpinBox[ SpinBox42 ]->SetValue( D2 );
384 mySpinBox[ SpinBox43 ]->SetValue( D );
385 mySpinBox[ SpinBox44 ]->SetValue( Angle );
391 if ( constructorId == 0 ) myEditCurrentArgument = mySelName[ MainObj1 ];
392 else if ( constructorId == 1 ) myEditCurrentArgument = mySelName[ MainObj2 ];
393 else if ( constructorId == 2 ) myEditCurrentArgument = mySelName[ MainObj3 ];
394 else myEditCurrentArgument = mySelName[ MainObj4 ];
399 if ( !myShape->_is_nil() )
401 myEditCurrentArgument->setText( GEOMBase::GetName( myShape ) );
402 GEOMBase_Skeleton::LineEditReturnPressed();
405 myEditCurrentArgument->setText( "" );
411 //=================================================================================
412 // function : ClickOnOk()
414 //=================================================================================
415 void OperationGUI_ChamferDlg::ClickOnOk()
417 if ( ClickOnApply() )
421 //=================================================================================
422 // function : ClickOnApply()
424 //=================================================================================
425 bool OperationGUI_ChamferDlg::ClickOnApply()
434 //=================================================================================
435 // function : SelectionIntoArgument()
436 // purpose : Called when selection has changed
437 //=================================================================================
438 void OperationGUI_ChamferDlg::SelectionIntoArgument()
441 myEditCurrentArgument->setText( "" );
443 // Get index of current selection focus
445 QMap< int, QLineEdit* >::iterator anIter;
446 for ( anIter = mySelName.begin(); anIter != mySelName.end(); ++anIter )
447 if ( myEditCurrentArgument == anIter.data() )
449 aCurrFocus = anIter.key();
453 // If selection of main object is activated
454 if ( aCurrFocus == MainObj1 || aCurrFocus == MainObj2 || aCurrFocus == MainObj3 || aCurrFocus == MainObj4)
456 if ( IObjectCount() == 1 )
458 Standard_Boolean aResult = Standard_False;
459 GEOM::GEOM_Object_var anObj =
460 GEOMBase::ConvertIOinGEOMObject( firstIObject(), aResult );
462 if ( aResult && !anObj->_is_nil() )
465 mySelName[ aCurrFocus ]->setText( GEOMBase::GetName( anObj ) );
472 myShape = GEOM::GEOM_Object::_nil();
475 // If face selection of second tab is activated
476 else if ( aCurrFocus == Face1 || aCurrFocus == Face2 )
478 if ( IObjectCount() == 1 )
480 Standard_Boolean aResult = Standard_False;
481 GEOM::GEOM_Object_var anObj =
482 GEOMBase::ConvertIOinGEOMObject( firstIObject(), aResult );
484 if ( aResult && !anObj->_is_nil() )
486 TColStd_IndexedMapOfInteger anIndexes;
487 ((SalomeApp_Application*)(SUIT_Session::session()->activeApplication()))->selectionMgr()->GetIndexes( firstIObject(), anIndexes );
489 if ( anIndexes.Extent() == 1 )
491 int anIndex = anIndexes( 1 );
492 QString aFaceName = QString( GEOMBase::GetName( anObj ) ) + ":%1";
493 myEditCurrentArgument->setText( aFaceName.arg( anIndex ) );
494 myFace[ aCurrFocus ] = anIndex;
501 myFace[ aCurrFocus ] = -1;
503 // If face selection of third or fourth tab is activated
504 else if ( aCurrFocus == Faces || aCurrFocus == Edges )
506 if ( IObjectCount() == 1 )
508 Standard_Boolean aResult = Standard_False;
509 GEOM::GEOM_Object_var anObj =
510 GEOMBase::ConvertIOinGEOMObject( firstIObject(), aResult );
512 if ( aResult && !anObj->_is_nil() )
514 TColStd_IndexedMapOfInteger anIndexes;
515 ((SalomeApp_Application*)(SUIT_Session::session()->activeApplication()))->selectionMgr()->GetIndexes( firstIObject(), anIndexes );
517 if ( anIndexes.Extent() > 0 )
520 if ( anIndexes.Extent() == 1 )
522 int anIndex = anIndexes( 1 );
524 aName = QString( GEOMBase::GetName( anObj ) ) + QString( ":%1" ).arg( anIndex );
527 aName = tr( "GEOM_MEN_POPUP_NAME" ).arg( anIndexes.Extent() );
529 myEditCurrentArgument->setText( aName );
530 int aConstructorId = getConstructorId();
531 if ( aConstructorId == 2)
533 else if (aConstructorId == 3)
547 //=================================================================================
548 // function : LineEditReturnPressed()
550 //=================================================================================
551 void OperationGUI_ChamferDlg::LineEditReturnPressed()
553 QLineEdit* aSender = ( QLineEdit* )sender();
555 QMap< int, QLineEdit* >::iterator anIterLE;
556 for ( anIterLE = mySelName.begin(); anIterLE != mySelName.end(); ++anIterLE )
557 if ( anIterLE.data() == aSender )
558 myEditCurrentArgument = anIterLE.data();
560 GEOMBase_Skeleton::LineEditReturnPressed();
563 //=================================================================================
564 // function : RadioButtonPressed()
566 //=================================================================================
567 void OperationGUI_ChamferDlg::RadioButtonPressed()
570 flag = ( myRadioButton[ RadioButton21 ]->isChecked() &&
571 myRadioButton[ RadioButton31 ]->isChecked() &&
572 myRadioButton[ RadioButton41 ]->isChecked() );
574 myRadioButton[ RadioButton21 ]->setChecked(!flag);
575 myRadioButton[ RadioButton31 ]->setChecked(!flag);
576 myRadioButton[ RadioButton41 ]->setChecked(!flag);
577 myRadioButton[ RadioButton22 ]->setChecked(flag);
578 myRadioButton[ RadioButton32 ]->setChecked(flag);
579 myRadioButton[ RadioButton42 ]->setChecked(flag);
580 mySpinBox[ SpinBox21 ]->setDisabled(flag);
581 mySpinBox[ SpinBox22 ]->setDisabled(flag);
582 mySpinBox[ SpinBox31 ]->setDisabled(flag);
583 mySpinBox[ SpinBox32 ]->setDisabled(flag);
584 mySpinBox[ SpinBox41 ]->setDisabled(flag);
585 mySpinBox[ SpinBox42 ]->setDisabled(flag);
586 mySpinBox[ SpinBox23 ]->setDisabled(!flag);
587 mySpinBox[ SpinBox24 ]->setDisabled(!flag);
588 mySpinBox[ SpinBox33 ]->setDisabled(!flag);
589 mySpinBox[ SpinBox34 ]->setDisabled(!flag);
590 mySpinBox[ SpinBox43 ]->setDisabled(!flag);
591 mySpinBox[ SpinBox44 ]->setDisabled(!flag);
596 //=================================================================================
597 // function : SetEditCurrentArgument()
599 //=================================================================================
600 void OperationGUI_ChamferDlg::SetEditCurrentArgument()
602 QPushButton* aSender = ( QPushButton* )sender();
604 QMap< int, QPushButton* >::iterator anIter;
605 for ( anIter = mySelBtn.begin(); anIter != mySelBtn.end(); ++anIter )
606 if ( anIter.data() == aSender )
608 mySelName[ anIter.key() ]->setFocus();
609 myEditCurrentArgument = mySelName[ anIter.key() ];
616 //=================================================================================
617 // function : ActivateThisDialog()
619 //=================================================================================
620 void OperationGUI_ChamferDlg::ActivateThisDialog()
622 GEOMBase_Skeleton::ActivateThisDialog();
624 connect( ((SalomeApp_Application*)(SUIT_Session::session()->activeApplication()))->selectionMgr(),
625 SIGNAL(currentSelectionChanged()), this, SLOT( SelectionIntoArgument() ) );
632 //=================================================================================
633 // function : enterEvent()
635 //=================================================================================
636 void OperationGUI_ChamferDlg::enterEvent(QEvent* e)
638 if ( !GroupConstructors->isEnabled() )
639 this->ActivateThisDialog();
643 //=================================================================================
644 // function : ValueChangedInSpinBox()
646 //=================================================================================
647 void OperationGUI_ChamferDlg::ValueChangedInSpinBox( double newValue )
653 //=================================================================================
654 // function : createSelWg()
656 //=================================================================================
657 void OperationGUI_ChamferDlg::createSelWg( const QString& theLbl,
662 new QLabel( theLbl, theParent );
663 mySelBtn[ theId ] = new QPushButton( theParent );
664 mySelBtn[ theId ]->setPixmap( thePix );
665 mySelName[ theId ] = new QLineEdit( theParent );
666 mySelName[ theId ]->setReadOnly( true );
669 //=================================================================================
670 // function : reset()
672 //=================================================================================
673 void OperationGUI_ChamferDlg::reset()
675 // Set Initial values of spinboxes
676 QMap< int, DlgRef_SpinBox* >::iterator anIter;
677 for ( anIter = mySpinBox.begin(); anIter != mySpinBox.end(); ++anIter )
678 anIter.data()->SetValue( 5 );
681 QMap< int, QLineEdit* >::iterator anIterLE;
682 for ( anIterLE = mySelName.begin(); anIterLE != mySelName.end(); ++anIterLE )
683 anIterLE.data()->setText( "" );
686 int aConstructorId = getConstructorId();
688 if ( aConstructorId == 0 ) myEditCurrentArgument = mySelName[ MainObj1 ];
689 else if ( aConstructorId == 1 ) myEditCurrentArgument = mySelName[ MainObj2 ];
690 else if ( aConstructorId == 2 ) myEditCurrentArgument = mySelName[ MainObj3 ];
691 else myEditCurrentArgument = mySelName[ MainObj4 ];
693 myShape = GEOM::GEOM_Object::_nil();
697 myFace[ Face1 ] = -1;
698 myFace[ Face2 ] = -1;
700 erasePreview( true );
707 //=================================================================================
708 // function : getConstructorId()
710 //=================================================================================
711 int OperationGUI_ChamferDlg::getConstructorId() const
713 return GroupConstructors->id( GroupConstructors->selected() );
716 //=================================================================================
717 // function : activateSelection
718 // purpose : Activate selection in accordance with myEditCurrentArgument
719 //=================================================================================
720 void OperationGUI_ChamferDlg::activateSelection()
722 if ( !myShape->_is_nil() &&
723 ( myEditCurrentArgument == mySelName[ Face1 ] ||
724 myEditCurrentArgument == mySelName[ Face2 ] ||
725 myEditCurrentArgument == mySelName[ Faces ] ) )
726 localSelection( myShape, TopAbs_FACE );
727 else if (!myShape->_is_nil() && myEditCurrentArgument == mySelName[ Edges ] )
728 localSelection( myShape, TopAbs_EDGE );
731 TColStd_MapOfInteger aMap;
732 aMap.Add( GEOM_SHELL );
733 aMap.Add( GEOM_SOLID );
734 aMap.Add( GEOM_COMPOUND );
735 globalSelection( aMap );
738 SelectionIntoArgument();
741 //=================================================================================
742 // function : enableWidgets
743 // purpose : Enable widgets of faces in accordance with value of main object
744 //=================================================================================
745 void OperationGUI_ChamferDlg::enableWidgets()
747 int anId = getConstructorId();
749 bool toEnable = !myShape->_is_nil();
753 mySelName[ Face1 ]->setEnabled( toEnable );
754 mySelName[ Face2 ]->setEnabled( toEnable );
755 mySelBtn[ Face1 ]->setEnabled( toEnable );
756 mySelBtn[ Face2 ]->setEnabled( toEnable );
760 mySelName[ Face1 ]->setText( "" );
761 mySelName[ Face2 ]->setText( "" );
762 myFace[ Face1 ] = -1;
763 myFace[ Face2 ] = -1;
766 else if ( anId == 2 )
768 mySelName[ Faces ]->setEnabled( toEnable );
771 mySelName[ Faces ]->setText( "" );
775 else if ( anId == 3 )
777 mySelName[ Edges ]->setEnabled( toEnable );
781 mySelName[ Edges ]->setText( "" );
787 //=================================================================================
788 // function : createOperation
790 //=================================================================================
791 GEOM::GEOM_IOperations_ptr OperationGUI_ChamferDlg::createOperation()
793 return getGeomEngine()->GetILocalOperations( getStudyId() );
795 //=================================================================================
796 // function : ClickOnApply()
797 // purpose : Verify validity of input data
798 //=================================================================================
799 bool OperationGUI_ChamferDlg::isValid( QString& )
801 switch ( getConstructorId() )
803 case 0: return !myShape->_is_nil();
804 case 1: return !myShape->_is_nil() && myFace[ Face1 ] > 0 && myFace[ Face2 ] > 0;
805 case 2: return !myShape->_is_nil() && myFaces.Extent() > 0;
806 case 3: return !myShape->_is_nil() && myEdges.Extent() > 0;
807 default: return false;
811 //=================================================================================
812 // function : execute
814 //=================================================================================
815 bool OperationGUI_ChamferDlg::execute( ObjectList& objects )
817 GEOM::GEOM_Object_var anObj;
818 bool flag = ( myRadioButton[ RadioButton21 ]->isChecked() &&
819 myRadioButton[ RadioButton31 ]->isChecked() &&
820 myRadioButton[ RadioButton41 ]->isChecked() );
822 int anId = getConstructorId();
824 anObj = GEOM::GEOM_ILocalOperations::_narrow(
825 getOperation() )->MakeChamferAll( myShape,
826 mySpinBox[ SpinBox1 ]->GetValue() );
827 else if ( anId == 1 )
830 anObj = GEOM::GEOM_ILocalOperations::_narrow(
831 getOperation() )->MakeChamferEdge( myShape,
832 mySpinBox[ SpinBox21 ]->GetValue(),
833 mySpinBox[ SpinBox22 ]->GetValue(),
837 anObj = GEOM::GEOM_ILocalOperations::_narrow(
838 getOperation() )->MakeChamferEdgeAD( myShape,
839 mySpinBox[ SpinBox23 ]->GetValue(),
840 mySpinBox[ SpinBox24 ]->GetValue() * PI180,
844 else if ( anId == 2 )
846 GEOM::ListOfLong_var anArray = new GEOM::ListOfLong;
847 anArray->length( myFaces.Extent() );
848 for ( int i = 1, n = myFaces.Extent(); i <= n; i++ )
849 anArray[ i - 1 ] = myFaces( i );
851 anObj = GEOM::GEOM_ILocalOperations::_narrow(
852 getOperation() )->MakeChamferFaces( myShape,
853 mySpinBox[ SpinBox31 ]->GetValue(),
854 mySpinBox[ SpinBox32 ]->GetValue(),
857 anObj = GEOM::GEOM_ILocalOperations::_narrow(
858 getOperation() )->MakeChamferFacesAD( myShape,
859 mySpinBox[ SpinBox33 ]->GetValue(),
860 mySpinBox[ SpinBox34 ]->GetValue() * PI180,
863 else if ( anId == 3 )
865 GEOM::ListOfLong_var anArray = new GEOM::ListOfLong;
866 anArray->length( myEdges.Extent() );
867 for ( int i = 1, n = myEdges.Extent(); i <= n; i++ )
868 anArray[ i - 1 ] = myEdges( i );
870 anObj = GEOM::GEOM_ILocalOperations::_narrow(
871 getOperation() )->MakeChamferEdges( myShape, mySpinBox[ SpinBox41 ]->GetValue(),
872 mySpinBox[ SpinBox42 ]->GetValue(), anArray );
874 anObj = GEOM::GEOM_ILocalOperations::_narrow(
875 getOperation() )->MakeChamferEdgesAD( myShape, mySpinBox[ SpinBox43 ]->GetValue(),
876 mySpinBox[ SpinBox44 ]->GetValue() * PI180, anArray );
879 if ( !anObj->_is_nil() )
880 objects.push_back( anObj._retn() );