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
22 // File : OperationGUI_ChamferDlg.cxx
23 // Author : Damien COQUERET, Open CASCADE S.A.S.
26 #include "OperationGUI_ChamferDlg.h"
29 #include <GeometryGUI.h>
32 #include <SUIT_Desktop.h>
33 #include <SUIT_Session.h>
34 #include <SUIT_ResourceMgr.h>
35 #include <SUIT_ViewWindow.h>
36 #include <SUIT_ViewManager.h>
37 #include <SalomeApp_Application.h>
38 #include <LightApp_SelectionMgr.h>
39 #include <OCCViewer_ViewModel.h>
41 #include <TColStd_MapOfInteger.hxx>
43 #include <GEOMImpl_Types.hxx>
45 //=================================================================================
46 // class : OperationGUI_ChamferDlg()
47 // purpose : Constructs a OperationGUI_ChamferDlg which is a child of 'parent', with the
48 // name 'name' and widget flags set to 'f'.
49 // The dialog will by default be modeless, unless you set 'modal' to
50 // TRUE to construct a modal dialog.
51 //=================================================================================
52 OperationGUI_ChamferDlg::OperationGUI_ChamferDlg( GeometryGUI* theGeometryGUI, QWidget* parent )
53 : GEOMBase_Skeleton( theGeometryGUI, parent, false )
55 QPixmap image1( SUIT_Session::session()->resourceMgr()->loadPixmap( "GEOM", tr( "ICON_DLG_CHAMFER_ALL" ) ) );
56 QPixmap image2( SUIT_Session::session()->resourceMgr()->loadPixmap( "GEOM", tr( "ICON_DLG_CHAMFER_EDGE_FROM_FACE" ) ) );
57 QPixmap image3( SUIT_Session::session()->resourceMgr()->loadPixmap( "GEOM", tr( "ICON_DLG_CHAMFER_FACE" ) ) );
58 QPixmap image4( SUIT_Session::session()->resourceMgr()->loadPixmap( "GEOM", tr( "ICON_DLG_CHAMFER_EDGE" ) ) );
59 QPixmap iconSelect( SUIT_Session::session()->resourceMgr()->loadPixmap( "GEOM", tr( "ICON_SELECT" ) ) );
61 setWindowTitle( tr( "GEOM_CHAMFER_TITLE" ) );
63 mainFrame()->GroupConstructors->setTitle( tr( "GEOM_CHAMFER" ) );
65 mainFrame()->RadioButton1->setIcon( image1 );
66 mainFrame()->RadioButton2->setIcon( image2 );
67 mainFrame()->RadioButton3->setIcon( image3 );
68 mainFrame()->RadioButton4->show();
69 mainFrame()->RadioButton4->setIcon( image4 );
73 myGrp1 = new QGroupBox( tr( "GEOM_CHAMFER_ALL" ), centralWidget() );
75 QGridLayout* aLayout = new QGridLayout( myGrp1 );
76 aLayout->setMargin( 9 ); aLayout->setSpacing( 6 );
78 createSelWg( tr( "GEOM_MAIN_OBJECT" ), iconSelect, myGrp1, aLayout, MainObj1 );
80 int row = aLayout->rowCount();
81 aLayout->addWidget( new QLabel( tr( "D" ), myGrp1 ), row, 0 );
82 aLayout->addWidget( ( mySpinBox[ SpinBox1 ] = new QDoubleSpinBox( myGrp1 ) ), row++, 2 );
83 aLayout->setRowStretch( row, 10 );
85 // Create second group
87 myGrp2 = new QGroupBox( tr( "GEOM_CHAMFER_EDGES" ), centralWidget() );
89 aLayout = new QGridLayout( myGrp2 );
90 aLayout->setMargin( 9 ); aLayout->setSpacing( 6 );
92 createSelWg( tr( "GEOM_MAIN_OBJECT" ), iconSelect, myGrp2, aLayout, MainObj2 );
93 createSelWg( tr( "FACE_1" ), iconSelect, myGrp2, aLayout, Face1 );
94 createSelWg( tr( "FACE_2" ), iconSelect, myGrp2, aLayout, Face2 );
96 createRadioWg( tr( "GEOM_D1" ), tr( "GEOM_D2" ), myGrp2, aLayout, RadioButton21, SpinBox21, SpinBox22 );
97 createRadioWg( tr( "GEOM_D" ), tr( "GEOM_ANGLE" ), myGrp2, aLayout, RadioButton22, SpinBox23, SpinBox24 );
99 aLayout->setRowStretch( aLayout->rowCount(), 10 );
101 // Create third group
103 myGrp3 = new QGroupBox( tr( "GEOM_CHAMFER_FACES" ), centralWidget() );
105 aLayout = new QGridLayout( myGrp3 );
106 aLayout->setMargin( 9 ); aLayout->setSpacing( 6 );
108 createSelWg( tr( "GEOM_MAIN_OBJECT" ), iconSelect, myGrp3, aLayout, MainObj3 );
109 createSelWg( tr( "SELECTED_FACES" ), iconSelect, myGrp3, aLayout, Faces );
111 createRadioWg( tr( "GEOM_D1" ), tr( "GEOM_D2" ), myGrp3, aLayout, RadioButton31, SpinBox31, SpinBox32 );
112 createRadioWg( tr( "GEOM_D" ), tr( "GEOM_ANGLE" ), myGrp3, aLayout, RadioButton32, SpinBox33, SpinBox34 );
114 aLayout->setRowStretch( aLayout->rowCount(), 10 );
116 // Create fourth group
118 myGrp4 = new QGroupBox( tr( "GEOM_CHAMFER_EDGE" ), centralWidget() );
120 aLayout = new QGridLayout( myGrp4 );
121 aLayout->setMargin( 9 ); aLayout->setSpacing( 6 );
123 createSelWg( tr( "GEOM_MAIN_OBJECT" ), iconSelect, myGrp4, aLayout, MainObj4 );
124 createSelWg( tr( "SELECTED_EDGE" ), iconSelect, myGrp4, aLayout, Edges );
126 createRadioWg( tr( "GEOM_D1" ), tr( "GEOM_D2" ), myGrp4, aLayout, RadioButton41, SpinBox41, SpinBox42 );
127 createRadioWg( tr( "GEOM_D" ), tr( "GEOM_ANGLE" ), myGrp4, aLayout, RadioButton42, SpinBox43, SpinBox44 );
129 aLayout->setRowStretch( aLayout->rowCount(), 10 );
131 // Add groups to layout
133 QVBoxLayout* layout = new QVBoxLayout( centralWidget() );
134 layout->setMargin( 0 ); layout->setSpacing( 6 );
135 layout->addWidget( myGrp1 );
136 layout->addWidget( myGrp2 );
137 layout->addWidget( myGrp3 );
138 layout->addWidget( myGrp4 );
140 // Set range of spinboxes
142 double SpecificStep = 10.0;
143 QMap< int, QDoubleSpinBox* >::iterator anIter;
144 for ( anIter = mySpinBox.begin(); anIter != mySpinBox.end(); ++anIter ) {
145 if ( anIter.key() == SpinBox44 || anIter.key() == SpinBox34 || anIter.key() == SpinBox24 )
146 initSpinBox( anIter.value(), 0.001, 89.999, 5, 0 );
148 initSpinBox( anIter.value(), 0.001, COORD_MAX, SpecificStep, 3 );
151 setHelpFileName( "chamfer_operation_page.html" );
153 /* Initialisations */
155 myRadioButton[ RadioButton21 ]->click();
159 //=================================================================================
160 // function : ~OperationGUI_ChamferDlg()
161 // purpose : Destroys the object and frees any allocated resources
162 //=================================================================================
163 OperationGUI_ChamferDlg::~OperationGUI_ChamferDlg()
168 //=================================================================================
171 //=================================================================================
172 void OperationGUI_ChamferDlg::Init()
174 myConstructorId = -1;
177 /* signals and slots connections */
180 connect( buttonOk(), SIGNAL( clicked() ), this, SLOT( ClickOnOk() ) );
181 connect( buttonApply(), SIGNAL( clicked() ), this, SLOT( ClickOnApply() ) );
184 connect( this, SIGNAL( constructorsClicked( int ) ), this, SLOT( ConstructorsClicked( int ) ) );
187 QMap< int, QPushButton* >::iterator anIterBtn;
188 for ( anIterBtn = mySelBtn.begin(); anIterBtn != mySelBtn.end(); ++anIterBtn )
189 connect( anIterBtn.value(), SIGNAL( clicked() ),
190 this, SLOT( SetEditCurrentArgument() ) );
193 QMap< int, QLineEdit* >::iterator anIterLE2;
194 for ( anIterLE2 = mySelName.begin(); anIterLE2 != mySelName.end(); ++anIterLE2 )
195 connect( anIterLE2.value(), SIGNAL( returnPressed() ),
196 this, SLOT( LineEditReturnPressed() ) );
199 QMap< int, QDoubleSpinBox* >::iterator anIterSpin;
200 for ( anIterSpin = mySpinBox.begin(); anIterSpin != mySpinBox.end(); ++anIterSpin )
201 connect( anIterSpin.value(), SIGNAL( valueChanged( double ) ),
202 this, SLOT( ValueChangedInSpinBox( double ) ) );
205 QMap< int, QRadioButton* >::iterator anIterRadio;
206 for ( anIterRadio = myRadioButton.begin(); anIterRadio != myRadioButton.end(); ++anIterRadio )
207 connect( anIterRadio.value(), SIGNAL( clicked() ),
208 this, SLOT( RadioButtonPressed() ) );
211 connect( myGeomGUI->getApp()->selectionMgr(),
212 SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) );
214 initName( tr( "GEOM_CHAMFER" ) );
216 ConstructorsClicked( 0 );
220 //=================================================================================
221 // function : ConstructorsClicked()
222 // purpose : Radio button management
223 //=================================================================================
224 void OperationGUI_ChamferDlg::ConstructorsClicked( int constructorId )
226 // Activate next widget
227 if ( myGeomGUI->getApp()->desktop()->activeWindow()->getViewManager()->getType()
228 != OCCViewer_Viewer::Type() ) {
229 mainFrame()->RadioButton1->setChecked( true );
233 if ( myConstructorId == constructorId )
236 // Get values from previous widget
237 double D1 = 5, D2 = 5, D = 5, Angle = 5;
238 if ( myConstructorId == 0 )
239 D1 = D2 = mySpinBox[ SpinBox1 ]->value();
240 else if ( myConstructorId == 1 ) {
241 D1 = mySpinBox[ SpinBox21 ]->value();
242 D2 = mySpinBox[ SpinBox22 ]->value();
243 D = mySpinBox[ SpinBox23 ]->value();
244 Angle = mySpinBox[ SpinBox24 ]->value();
246 else if ( myConstructorId == 2 ) {
247 D1 = mySpinBox[ SpinBox31 ]->value();
248 D2 = mySpinBox[ SpinBox32 ]->value();
249 D = mySpinBox[ SpinBox33 ]->value();
250 Angle = mySpinBox[ SpinBox34 ]->value();
252 else if ( myConstructorId == 3 ) {
253 D1 = mySpinBox[ SpinBox41 ]->value();
254 D2 = mySpinBox[ SpinBox42 ]->value();
255 D = mySpinBox[ SpinBox43 ]->value();
256 Angle = mySpinBox[ SpinBox44 ]->value();
259 myConstructorId = constructorId;
261 switch ( constructorId ) {
267 mySpinBox[ SpinBox1 ]->setValue( D1 );
274 mySpinBox[ SpinBox21 ]->setValue( D1 );
275 mySpinBox[ SpinBox22 ]->setValue( D2 );
276 mySpinBox[ SpinBox23 ]->setValue( D );
277 mySpinBox[ SpinBox24 ]->setValue( Angle );
284 mySpinBox[ SpinBox31 ]->setValue( D1 );
285 mySpinBox[ SpinBox32 ]->setValue( D2 );
286 mySpinBox[ SpinBox32 ]->setValue( D2 );
287 mySpinBox[ SpinBox33 ]->setValue( D );
288 mySpinBox[ SpinBox34 ]->setValue( Angle );
295 mySpinBox[ SpinBox41 ]->setValue( D1 );
296 mySpinBox[ SpinBox42 ]->setValue( D2 );
297 mySpinBox[ SpinBox43 ]->setValue( D );
298 mySpinBox[ SpinBox44 ]->setValue( Angle );
304 if ( constructorId == 0 ) myEditCurrentArgument = mySelName[ MainObj1 ];
305 else if ( constructorId == 1 ) myEditCurrentArgument = mySelName[ MainObj2 ];
306 else if ( constructorId == 2 ) myEditCurrentArgument = mySelName[ MainObj3 ];
307 else myEditCurrentArgument = mySelName[ MainObj4 ];
312 if ( !myShape->_is_nil() )
314 myEditCurrentArgument->setText( GEOMBase::GetName( myShape ) );
315 GEOMBase_Skeleton::LineEditReturnPressed();
318 myEditCurrentArgument->setText( "" );
320 qApp->processEvents();
322 resize( minimumSize() );
328 //=================================================================================
329 // function : ClickOnOk()
331 //=================================================================================
332 void OperationGUI_ChamferDlg::ClickOnOk()
334 if ( ClickOnApply() )
338 //=================================================================================
339 // function : ClickOnApply()
341 //=================================================================================
342 bool OperationGUI_ChamferDlg::ClickOnApply()
351 //=================================================================================
352 // function : SelectionIntoArgument()
353 // purpose : Called when selection has changed
354 //=================================================================================
355 void OperationGUI_ChamferDlg::SelectionIntoArgument()
358 myEditCurrentArgument->setText("");
360 // Get index of current selection focus
362 QMap< int, QLineEdit* >::iterator anIter;
363 for ( anIter = mySelName.begin(); anIter != mySelName.end(); ++anIter ) {
364 if ( myEditCurrentArgument == anIter.value() ) {
365 aCurrFocus = anIter.key();
370 LightApp_SelectionMgr* aSelMgr = myGeomGUI->getApp()->selectionMgr();
371 SALOME_ListIO aSelList;
372 aSelMgr->selectedObjects(aSelList);
374 // If selection of main object is activated
375 if (aCurrFocus == MainObj1 || aCurrFocus == MainObj2 || aCurrFocus == MainObj3 || aCurrFocus == MainObj4)
377 if (aSelList.Extent() == 1) {
378 Standard_Boolean aResult = Standard_False;
379 GEOM::GEOM_Object_var anObj =
380 GEOMBase::ConvertIOinGEOMObject(aSelList.First(), aResult);
382 if ( aResult && !anObj->_is_nil() ) {
384 mySelName[ aCurrFocus ]->setText( GEOMBase::GetName( anObj ) );
391 myShape = GEOM::GEOM_Object::_nil();
394 // If face selection of second tab is activated
395 else if (aCurrFocus == Face1 || aCurrFocus == Face2)
397 if (aSelList.Extent() == 1) {
398 Standard_Boolean aResult = Standard_False;
399 GEOM::GEOM_Object_var anObj =
400 GEOMBase::ConvertIOinGEOMObject(aSelList.First(), aResult);
402 if ( aResult && !anObj->_is_nil() ) {
403 TColStd_IndexedMapOfInteger anIndexes;
404 aSelMgr->GetIndexes(aSelList.First(), anIndexes);
406 if (anIndexes.Extent() == 1) {
407 int anIndex = anIndexes(1);
408 QString aFaceName = QString( GEOMBase::GetName( anObj ) ) + ":%1";
409 myEditCurrentArgument->setText( aFaceName.arg( anIndex ) );
410 myFace[ aCurrFocus ] = anIndex;
417 myFace[ aCurrFocus ] = -1;
419 // If face selection of third or fourth tab is activated
420 else if (aCurrFocus == Faces || aCurrFocus == Edges) {
421 if (aSelList.Extent() == 1) {
422 Standard_Boolean aResult = Standard_False;
423 GEOM::GEOM_Object_var anObj =
424 GEOMBase::ConvertIOinGEOMObject(aSelList.First(), aResult);
426 if ( aResult && !anObj->_is_nil() ) {
427 TColStd_IndexedMapOfInteger anIndexes;
428 aSelMgr->GetIndexes(aSelList.First(), anIndexes);
430 if (anIndexes.Extent() > 0) {
432 if (anIndexes.Extent() == 1) {
433 int anIndex = anIndexes(1);
435 aName = QString( GEOMBase::GetName( anObj ) ) + QString( ":%1" ).arg( anIndex );
438 aName = tr( "GEOM_MEN_POPUP_NAME" ).arg( anIndexes.Extent() );
441 myEditCurrentArgument->setText( aName );
442 int aConstructorId = getConstructorId();
443 if ( aConstructorId == 2)
445 else if ( aConstructorId == 3 )
459 //=================================================================================
460 // function : LineEditReturnPressed()
462 //=================================================================================
463 void OperationGUI_ChamferDlg::LineEditReturnPressed()
465 QLineEdit* aSender = ( QLineEdit* )sender();
467 QMap< int, QLineEdit* >::iterator anIterLE;
468 for ( anIterLE = mySelName.begin(); anIterLE != mySelName.end(); ++anIterLE )
469 if ( anIterLE.value() == aSender )
470 myEditCurrentArgument = anIterLE.value();
472 GEOMBase_Skeleton::LineEditReturnPressed();
476 //=================================================================================
477 // function : RadioButtonPressed()
479 //=================================================================================
480 void OperationGUI_ChamferDlg::RadioButtonPressed()
482 const QObject* s = sender();
483 bool flag = s == myRadioButton[ RadioButton21 ] ||
484 s == myRadioButton[ RadioButton31 ] ||
485 s == myRadioButton[ RadioButton41 ];
487 myRadioButton[ RadioButton21 ]->blockSignals( true );
488 myRadioButton[ RadioButton22 ]->blockSignals( true );
489 myRadioButton[ RadioButton31 ]->blockSignals( true );
490 myRadioButton[ RadioButton32 ]->blockSignals( true );
491 myRadioButton[ RadioButton41 ]->blockSignals( true );
492 myRadioButton[ RadioButton42 ]->blockSignals( true );
494 myRadioButton[ RadioButton21 ]->setChecked( flag );
495 myRadioButton[ RadioButton31 ]->setChecked( flag );
496 myRadioButton[ RadioButton41 ]->setChecked( flag );
497 myRadioButton[ RadioButton22 ]->setChecked( !flag );
498 myRadioButton[ RadioButton32 ]->setChecked( !flag );
499 myRadioButton[ RadioButton42 ]->setChecked( !flag );
500 mySpinBox[ SpinBox21 ]->setEnabled( flag );
501 mySpinBox[ SpinBox22 ]->setEnabled( flag );
502 mySpinBox[ SpinBox31 ]->setEnabled( flag );
503 mySpinBox[ SpinBox32 ]->setEnabled( flag );
504 mySpinBox[ SpinBox41 ]->setEnabled( flag );
505 mySpinBox[ SpinBox42 ]->setEnabled( flag );
506 mySpinBox[ SpinBox23 ]->setEnabled( !flag );
507 mySpinBox[ SpinBox24 ]->setEnabled( !flag );
508 mySpinBox[ SpinBox33 ]->setEnabled( !flag );
509 mySpinBox[ SpinBox34 ]->setEnabled( !flag );
510 mySpinBox[ SpinBox43 ]->setEnabled( !flag );
511 mySpinBox[ SpinBox44 ]->setEnabled( !flag );
513 myRadioButton[ RadioButton21 ]->blockSignals( false );
514 myRadioButton[ RadioButton22 ]->blockSignals( false );
515 myRadioButton[ RadioButton31 ]->blockSignals( false );
516 myRadioButton[ RadioButton32 ]->blockSignals( false );
517 myRadioButton[ RadioButton41 ]->blockSignals( false );
518 myRadioButton[ RadioButton42 ]->blockSignals( false );
524 //=================================================================================
525 // function : SetEditCurrentArgument()
527 //=================================================================================
528 void OperationGUI_ChamferDlg::SetEditCurrentArgument()
530 QPushButton* aSender = ( QPushButton* )sender();
532 QMap< int, QPushButton* >::iterator anIter;
533 for ( anIter = mySelBtn.begin(); anIter != mySelBtn.end(); ++anIter ) {
534 if ( anIter.value() == aSender ) {
535 mySelName[ anIter.key() ]->setFocus();
536 myEditCurrentArgument = mySelName[ anIter.key() ];
544 //=================================================================================
545 // function : ActivateThisDialog()
547 //=================================================================================
548 void OperationGUI_ChamferDlg::ActivateThisDialog()
550 GEOMBase_Skeleton::ActivateThisDialog();
552 connect( ( (SalomeApp_Application*)( SUIT_Session::session()->activeApplication() ) )->selectionMgr(),
553 SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) );
560 //=================================================================================
561 // function : enterEvent()
563 //=================================================================================
564 void OperationGUI_ChamferDlg::enterEvent( QEvent* )
566 if ( !mainFrame()->GroupConstructors->isEnabled() )
567 this->ActivateThisDialog();
571 //=================================================================================
572 // function : ValueChangedInSpinBox()
574 //=================================================================================
575 void OperationGUI_ChamferDlg::ValueChangedInSpinBox( double )
581 //=================================================================================
582 // function : createSelWg()
584 //=================================================================================
585 void OperationGUI_ChamferDlg::createSelWg( const QString& theLbl,
588 QGridLayout* theLayout,
591 QLabel* lab = new QLabel( theLbl, theParent );
592 mySelBtn[ theId ] = new QPushButton( theParent );
593 mySelBtn[ theId ]->setIcon( thePix );
594 mySelName[ theId ] = new QLineEdit( theParent );
595 mySelName[ theId ]->setReadOnly( true );
596 int row = theLayout->rowCount();
597 theLayout->addWidget( lab, row, 0 );
598 theLayout->addWidget( mySelBtn[ theId ], row, 1 );
599 theLayout->addWidget( mySelName[ theId ], row, 2, 1, 4 ); // take into account createRadioWg()
602 //=================================================================================
603 // function : createRadioWg()
605 //=================================================================================
606 void OperationGUI_ChamferDlg::createRadioWg( const QString& theLbl1,
607 const QString& theLbl2,
609 QGridLayout* theLayout,
611 const int theSpin1Id,
612 const int theSpin2Id )
614 myRadioButton[ theRbId ] = new QRadioButton( theParent );
615 QLabel* lab1 = new QLabel( theLbl1, theParent );
616 QLabel* lab2 = new QLabel( theLbl2, theParent );
617 mySpinBox[ theSpin1Id ] = new QDoubleSpinBox( theParent );
618 mySpinBox[ theSpin2Id ] = new QDoubleSpinBox( theParent );
619 int row = theLayout->rowCount();
620 theLayout->addWidget( myRadioButton[ theRbId ], row, 0 );
621 theLayout->addWidget( lab1, row, 2 );
622 theLayout->addWidget( mySpinBox[ theSpin1Id ], row, 3 );
623 theLayout->addWidget( lab2, row, 4 );
624 theLayout->addWidget( mySpinBox[ theSpin2Id ], row, 5 );
627 //=================================================================================
628 // function : reset()
630 //=================================================================================
631 void OperationGUI_ChamferDlg::reset()
633 // Set Initial values of spinboxes
634 QMap< int, QDoubleSpinBox* >::iterator anIter;
635 for ( anIter = mySpinBox.begin(); anIter != mySpinBox.end(); ++anIter )
636 anIter.value()->setValue( 5 );
639 QMap< int, QLineEdit* >::iterator anIterLE;
640 for ( anIterLE = mySelName.begin(); anIterLE != mySelName.end(); ++anIterLE )
641 anIterLE.value()->setText( "" );
644 int aConstructorId = getConstructorId();
646 if ( aConstructorId == 0 ) myEditCurrentArgument = mySelName[ MainObj1 ];
647 else if ( aConstructorId == 1 ) myEditCurrentArgument = mySelName[ MainObj2 ];
648 else if ( aConstructorId == 2 ) myEditCurrentArgument = mySelName[ MainObj3 ];
649 else myEditCurrentArgument = mySelName[ MainObj4 ];
651 myShape = GEOM::GEOM_Object::_nil();
655 myFace[ Face1 ] = -1;
656 myFace[ Face2 ] = -1;
658 erasePreview( true );
665 //=================================================================================
666 // function : activateSelection
667 // purpose : Activate selection in accordance with myEditCurrentArgument
668 //=================================================================================
669 void OperationGUI_ChamferDlg::activateSelection()
671 if ( !myShape->_is_nil() &&
672 ( myEditCurrentArgument == mySelName[ Face1 ] ||
673 myEditCurrentArgument == mySelName[ Face2 ] ||
674 myEditCurrentArgument == mySelName[ Faces ] ) ) {
675 localSelection( myShape, TopAbs_FACE );
677 else if ( !myShape->_is_nil() && myEditCurrentArgument == mySelName[ Edges ] ) {
678 localSelection( myShape, TopAbs_EDGE );
681 TColStd_MapOfInteger aMap;
682 aMap.Add( GEOM_SHELL );
683 aMap.Add( GEOM_SOLID );
684 aMap.Add( GEOM_COMPOUND );
685 globalSelection( aMap );
688 SelectionIntoArgument();
691 //=================================================================================
692 // function : enableWidgets
693 // purpose : Enable widgets of faces in accordance with value of main object
694 //=================================================================================
695 void OperationGUI_ChamferDlg::enableWidgets()
697 int anId = getConstructorId();
699 bool toEnable = !myShape->_is_nil();
703 mySelName[ Face1 ]->setEnabled( toEnable );
704 mySelName[ Face2 ]->setEnabled( toEnable );
705 mySelBtn[ Face1 ]->setEnabled( toEnable );
706 mySelBtn[ Face2 ]->setEnabled( toEnable );
710 mySelName[ Face1 ]->setText( "" );
711 mySelName[ Face2 ]->setText( "" );
712 myFace[ Face1 ] = -1;
713 myFace[ Face2 ] = -1;
716 else if ( anId == 2 )
718 mySelName[ Faces ]->setEnabled( toEnable );
720 mySelName[ Faces ]->setText( "" );
724 else if ( anId == 3 ) {
725 mySelName[ Edges ]->setEnabled( toEnable );
728 mySelName[ Edges ]->setText( "" );
734 //=================================================================================
735 // function : createOperation
737 //=================================================================================
738 GEOM::GEOM_IOperations_ptr OperationGUI_ChamferDlg::createOperation()
740 return getGeomEngine()->GetILocalOperations( getStudyId() );
743 //=================================================================================
744 // function : ClickOnApply()
745 // purpose : Verify validity of input data
746 //=================================================================================
747 bool OperationGUI_ChamferDlg::isValid( QString& )
749 switch ( getConstructorId() )
751 case 0: return !myShape->_is_nil();
752 case 1: return !myShape->_is_nil() && myFace[ Face1 ] > 0 && myFace[ Face2 ] > 0;
753 case 2: return !myShape->_is_nil() && myFaces.Extent() > 0;
754 case 3: return !myShape->_is_nil() && myEdges.Extent() > 0;
755 default: return false;
759 //=================================================================================
760 // function : execute
762 //=================================================================================
763 bool OperationGUI_ChamferDlg::execute( ObjectList& objects )
765 GEOM::GEOM_Object_var anObj;
766 bool flag = ( myRadioButton[ RadioButton21 ]->isChecked() &&
767 myRadioButton[ RadioButton31 ]->isChecked() &&
768 myRadioButton[ RadioButton41 ]->isChecked() );
770 int anId = getConstructorId();
772 anObj = GEOM::GEOM_ILocalOperations::_narrow(
773 getOperation() )->MakeChamferAll( myShape,
774 mySpinBox[ SpinBox1 ]->value() );
776 else if ( anId == 1 ) {
778 anObj = GEOM::GEOM_ILocalOperations::_narrow( getOperation() )->
779 MakeChamferEdge( myShape,
780 mySpinBox[ SpinBox21 ]->value(),
781 mySpinBox[ SpinBox22 ]->value(),
786 anObj = GEOM::GEOM_ILocalOperations::_narrow( getOperation() )->
787 MakeChamferEdgeAD( myShape,
788 mySpinBox[ SpinBox23 ]->value(),
789 mySpinBox[ SpinBox24 ]->value() * PI180,
794 else if ( anId == 2 )
796 GEOM::ListOfLong_var anArray = new GEOM::ListOfLong;
797 anArray->length( myFaces.Extent() );
799 for ( int i = 1, n = myFaces.Extent(); i <= n; i++ )
800 anArray[ i - 1 ] = myFaces( i );
803 anObj = GEOM::GEOM_ILocalOperations::_narrow(
804 getOperation() )->MakeChamferFaces( myShape,
805 mySpinBox[ SpinBox31 ]->value(),
806 mySpinBox[ SpinBox32 ]->value(),
809 anObj = GEOM::GEOM_ILocalOperations::_narrow(
810 getOperation() )->MakeChamferFacesAD( myShape,
811 mySpinBox[ SpinBox33 ]->value(),
812 mySpinBox[ SpinBox34 ]->value() * PI180,
815 else if ( anId == 3 ) {
816 GEOM::ListOfLong_var anArray = new GEOM::ListOfLong;
817 anArray->length( myEdges.Extent() );
818 for ( int i = 1, n = myEdges.Extent(); i <= n; i++ )
819 anArray[ i - 1 ] = myEdges( i );
821 anObj = GEOM::GEOM_ILocalOperations::_narrow( getOperation() )->
822 MakeChamferEdges( myShape, mySpinBox[ SpinBox41 ]->value(),
823 mySpinBox[ SpinBox42 ]->value(), anArray );
826 anObj = GEOM::GEOM_ILocalOperations::_narrow( getOperation() )->
827 MakeChamferEdgesAD( myShape, mySpinBox[ SpinBox43 ]->value(),
828 mySpinBox[ SpinBox44 ]->value() * PI180, anArray );
832 if ( !anObj->_is_nil() )
833 objects.push_back( anObj._retn() );