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()
352 //=================================================================================
353 // function : SelectionIntoArgument()
354 // purpose : Called when selection has changed
355 //=================================================================================
356 void OperationGUI_ChamferDlg::SelectionIntoArgument()
359 myEditCurrentArgument->setText( "" );
361 // Get index of current selection focus
363 QMap< int, QLineEdit* >::iterator anIter;
364 for ( anIter = mySelName.begin(); anIter != mySelName.end(); ++anIter ) {
365 if ( myEditCurrentArgument == anIter.value() ) {
366 aCurrFocus = anIter.key();
371 // If selection of main object is activated
372 if ( aCurrFocus == MainObj1 || aCurrFocus == MainObj2 || aCurrFocus == MainObj3 || aCurrFocus == MainObj4) {
373 if ( IObjectCount() == 1 ) {
374 Standard_Boolean aResult = Standard_False;
375 GEOM::GEOM_Object_var anObj =
376 GEOMBase::ConvertIOinGEOMObject( firstIObject(), aResult );
378 if ( aResult && !anObj->_is_nil() ) {
380 mySelName[ aCurrFocus ]->setText( GEOMBase::GetName( anObj ) );
387 myShape = GEOM::GEOM_Object::_nil();
390 // If face selection of second tab is activated
391 else if ( aCurrFocus == Face1 || aCurrFocus == Face2 ) {
392 if ( IObjectCount() == 1 ) {
393 Standard_Boolean aResult = Standard_False;
394 GEOM::GEOM_Object_var anObj =
395 GEOMBase::ConvertIOinGEOMObject( firstIObject(), aResult );
397 if ( aResult && !anObj->_is_nil() ) {
398 TColStd_IndexedMapOfInteger anIndexes;
399 ( (SalomeApp_Application*)( SUIT_Session::session()->activeApplication() ) )->selectionMgr()->GetIndexes( firstIObject(), anIndexes );
401 if ( anIndexes.Extent() == 1 ) {
402 int anIndex = anIndexes( 1 );
403 QString aFaceName = QString( GEOMBase::GetName( anObj ) ) + ":%1";
404 myEditCurrentArgument->setText( aFaceName.arg( anIndex ) );
405 myFace[ aCurrFocus ] = anIndex;
412 myFace[ aCurrFocus ] = -1;
414 // If face selection of third or fourth tab is activated
415 else if ( aCurrFocus == Faces || aCurrFocus == Edges ) {
416 if ( IObjectCount() == 1 ) {
417 Standard_Boolean aResult = Standard_False;
418 GEOM::GEOM_Object_var anObj =
419 GEOMBase::ConvertIOinGEOMObject( firstIObject(), aResult );
421 if ( aResult && !anObj->_is_nil() ) {
422 TColStd_IndexedMapOfInteger anIndexes;
423 ( (SalomeApp_Application*)( SUIT_Session::session()->activeApplication() ) )->selectionMgr()->GetIndexes( firstIObject(), anIndexes );
425 if ( anIndexes.Extent() > 0 ) {
427 if ( anIndexes.Extent() == 1 ) {
428 int anIndex = anIndexes( 1 );
430 aName = QString( GEOMBase::GetName( anObj ) ) + QString( ":%1" ).arg( anIndex );
433 aName = tr( "GEOM_MEN_POPUP_NAME" ).arg( anIndexes.Extent() );
436 myEditCurrentArgument->setText( aName );
437 int aConstructorId = getConstructorId();
438 if ( aConstructorId == 2)
440 else if ( aConstructorId == 3 )
454 //=================================================================================
455 // function : LineEditReturnPressed()
457 //=================================================================================
458 void OperationGUI_ChamferDlg::LineEditReturnPressed()
460 QLineEdit* aSender = ( QLineEdit* )sender();
462 QMap< int, QLineEdit* >::iterator anIterLE;
463 for ( anIterLE = mySelName.begin(); anIterLE != mySelName.end(); ++anIterLE )
464 if ( anIterLE.value() == aSender )
465 myEditCurrentArgument = anIterLE.value();
467 GEOMBase_Skeleton::LineEditReturnPressed();
471 //=================================================================================
472 // function : RadioButtonPressed()
474 //=================================================================================
475 void OperationGUI_ChamferDlg::RadioButtonPressed()
477 const QObject* s = sender();
478 bool flag = s == myRadioButton[ RadioButton21 ] ||
479 s == myRadioButton[ RadioButton31 ] ||
480 s == myRadioButton[ RadioButton41 ];
482 myRadioButton[ RadioButton21 ]->blockSignals( true );
483 myRadioButton[ RadioButton22 ]->blockSignals( true );
484 myRadioButton[ RadioButton31 ]->blockSignals( true );
485 myRadioButton[ RadioButton32 ]->blockSignals( true );
486 myRadioButton[ RadioButton41 ]->blockSignals( true );
487 myRadioButton[ RadioButton42 ]->blockSignals( true );
489 myRadioButton[ RadioButton21 ]->setChecked( flag );
490 myRadioButton[ RadioButton31 ]->setChecked( flag );
491 myRadioButton[ RadioButton41 ]->setChecked( flag );
492 myRadioButton[ RadioButton22 ]->setChecked( !flag );
493 myRadioButton[ RadioButton32 ]->setChecked( !flag );
494 myRadioButton[ RadioButton42 ]->setChecked( !flag );
495 mySpinBox[ SpinBox21 ]->setEnabled( flag );
496 mySpinBox[ SpinBox22 ]->setEnabled( flag );
497 mySpinBox[ SpinBox31 ]->setEnabled( flag );
498 mySpinBox[ SpinBox32 ]->setEnabled( flag );
499 mySpinBox[ SpinBox41 ]->setEnabled( flag );
500 mySpinBox[ SpinBox42 ]->setEnabled( flag );
501 mySpinBox[ SpinBox23 ]->setEnabled( !flag );
502 mySpinBox[ SpinBox24 ]->setEnabled( !flag );
503 mySpinBox[ SpinBox33 ]->setEnabled( !flag );
504 mySpinBox[ SpinBox34 ]->setEnabled( !flag );
505 mySpinBox[ SpinBox43 ]->setEnabled( !flag );
506 mySpinBox[ SpinBox44 ]->setEnabled( !flag );
508 myRadioButton[ RadioButton21 ]->blockSignals( false );
509 myRadioButton[ RadioButton22 ]->blockSignals( false );
510 myRadioButton[ RadioButton31 ]->blockSignals( false );
511 myRadioButton[ RadioButton32 ]->blockSignals( false );
512 myRadioButton[ RadioButton41 ]->blockSignals( false );
513 myRadioButton[ RadioButton42 ]->blockSignals( false );
519 //=================================================================================
520 // function : SetEditCurrentArgument()
522 //=================================================================================
523 void OperationGUI_ChamferDlg::SetEditCurrentArgument()
525 QPushButton* aSender = ( QPushButton* )sender();
527 QMap< int, QPushButton* >::iterator anIter;
528 for ( anIter = mySelBtn.begin(); anIter != mySelBtn.end(); ++anIter ) {
529 if ( anIter.value() == aSender ) {
530 mySelName[ anIter.key() ]->setFocus();
531 myEditCurrentArgument = mySelName[ anIter.key() ];
539 //=================================================================================
540 // function : ActivateThisDialog()
542 //=================================================================================
543 void OperationGUI_ChamferDlg::ActivateThisDialog()
545 GEOMBase_Skeleton::ActivateThisDialog();
547 connect( ( (SalomeApp_Application*)( SUIT_Session::session()->activeApplication() ) )->selectionMgr(),
548 SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) );
555 //=================================================================================
556 // function : enterEvent()
558 //=================================================================================
559 void OperationGUI_ChamferDlg::enterEvent( QEvent* )
561 if ( !mainFrame()->GroupConstructors->isEnabled() )
562 this->ActivateThisDialog();
566 //=================================================================================
567 // function : ValueChangedInSpinBox()
569 //=================================================================================
570 void OperationGUI_ChamferDlg::ValueChangedInSpinBox( double )
576 //=================================================================================
577 // function : createSelWg()
579 //=================================================================================
580 void OperationGUI_ChamferDlg::createSelWg( const QString& theLbl,
583 QGridLayout* theLayout,
586 QLabel* lab = new QLabel( theLbl, theParent );
587 mySelBtn[ theId ] = new QPushButton( theParent );
588 mySelBtn[ theId ]->setIcon( thePix );
589 mySelName[ theId ] = new QLineEdit( theParent );
590 mySelName[ theId ]->setReadOnly( true );
591 int row = theLayout->rowCount();
592 theLayout->addWidget( lab, row, 0 );
593 theLayout->addWidget( mySelBtn[ theId ], row, 1 );
594 theLayout->addWidget( mySelName[ theId ], row, 2, 1, 4 ); // take into account createRadioWg()
597 //=================================================================================
598 // function : createRadioWg()
600 //=================================================================================
601 void OperationGUI_ChamferDlg::createRadioWg( const QString& theLbl1,
602 const QString& theLbl2,
604 QGridLayout* theLayout,
606 const int theSpin1Id,
607 const int theSpin2Id )
609 myRadioButton[ theRbId ] = new QRadioButton( theParent );
610 QLabel* lab1 = new QLabel( theLbl1, theParent );
611 QLabel* lab2 = new QLabel( theLbl2, theParent );
612 mySpinBox[ theSpin1Id ] = new QDoubleSpinBox( theParent );
613 mySpinBox[ theSpin2Id ] = new QDoubleSpinBox( theParent );
614 int row = theLayout->rowCount();
615 theLayout->addWidget( myRadioButton[ theRbId ], row, 0 );
616 theLayout->addWidget( lab1, row, 2 );
617 theLayout->addWidget( mySpinBox[ theSpin1Id ], row, 3 );
618 theLayout->addWidget( lab2, row, 4 );
619 theLayout->addWidget( mySpinBox[ theSpin2Id ], row, 5 );
622 //=================================================================================
623 // function : reset()
625 //=================================================================================
626 void OperationGUI_ChamferDlg::reset()
628 // Set Initial values of spinboxes
629 QMap< int, QDoubleSpinBox* >::iterator anIter;
630 for ( anIter = mySpinBox.begin(); anIter != mySpinBox.end(); ++anIter )
631 anIter.value()->setValue( 5 );
634 QMap< int, QLineEdit* >::iterator anIterLE;
635 for ( anIterLE = mySelName.begin(); anIterLE != mySelName.end(); ++anIterLE )
636 anIterLE.value()->setText( "" );
639 int aConstructorId = getConstructorId();
641 if ( aConstructorId == 0 ) myEditCurrentArgument = mySelName[ MainObj1 ];
642 else if ( aConstructorId == 1 ) myEditCurrentArgument = mySelName[ MainObj2 ];
643 else if ( aConstructorId == 2 ) myEditCurrentArgument = mySelName[ MainObj3 ];
644 else myEditCurrentArgument = mySelName[ MainObj4 ];
646 myShape = GEOM::GEOM_Object::_nil();
650 myFace[ Face1 ] = -1;
651 myFace[ Face2 ] = -1;
653 erasePreview( true );
660 //=================================================================================
661 // function : activateSelection
662 // purpose : Activate selection in accordance with myEditCurrentArgument
663 //=================================================================================
664 void OperationGUI_ChamferDlg::activateSelection()
666 if ( !myShape->_is_nil() &&
667 ( myEditCurrentArgument == mySelName[ Face1 ] ||
668 myEditCurrentArgument == mySelName[ Face2 ] ||
669 myEditCurrentArgument == mySelName[ Faces ] ) ) {
670 localSelection( myShape, TopAbs_FACE );
672 else if ( !myShape->_is_nil() && myEditCurrentArgument == mySelName[ Edges ] ) {
673 localSelection( myShape, TopAbs_EDGE );
676 TColStd_MapOfInteger aMap;
677 aMap.Add( GEOM_SHELL );
678 aMap.Add( GEOM_SOLID );
679 aMap.Add( GEOM_COMPOUND );
680 globalSelection( aMap );
683 SelectionIntoArgument();
686 //=================================================================================
687 // function : enableWidgets
688 // purpose : Enable widgets of faces in accordance with value of main object
689 //=================================================================================
690 void OperationGUI_ChamferDlg::enableWidgets()
692 int anId = getConstructorId();
694 bool toEnable = !myShape->_is_nil();
698 mySelName[ Face1 ]->setEnabled( toEnable );
699 mySelName[ Face2 ]->setEnabled( toEnable );
700 mySelBtn[ Face1 ]->setEnabled( toEnable );
701 mySelBtn[ Face2 ]->setEnabled( toEnable );
705 mySelName[ Face1 ]->setText( "" );
706 mySelName[ Face2 ]->setText( "" );
707 myFace[ Face1 ] = -1;
708 myFace[ Face2 ] = -1;
711 else if ( anId == 2 )
713 mySelName[ Faces ]->setEnabled( toEnable );
715 mySelName[ Faces ]->setText( "" );
719 else if ( anId == 3 ) {
720 mySelName[ Edges ]->setEnabled( toEnable );
723 mySelName[ Edges ]->setText( "" );
729 //=================================================================================
730 // function : createOperation
732 //=================================================================================
733 GEOM::GEOM_IOperations_ptr OperationGUI_ChamferDlg::createOperation()
735 return getGeomEngine()->GetILocalOperations( getStudyId() );
738 //=================================================================================
739 // function : ClickOnApply()
740 // purpose : Verify validity of input data
741 //=================================================================================
742 bool OperationGUI_ChamferDlg::isValid( QString& )
744 switch ( getConstructorId() )
746 case 0: return !myShape->_is_nil();
747 case 1: return !myShape->_is_nil() && myFace[ Face1 ] > 0 && myFace[ Face2 ] > 0;
748 case 2: return !myShape->_is_nil() && myFaces.Extent() > 0;
749 case 3: return !myShape->_is_nil() && myEdges.Extent() > 0;
750 default: return false;
754 //=================================================================================
755 // function : execute
757 //=================================================================================
758 bool OperationGUI_ChamferDlg::execute( ObjectList& objects )
760 GEOM::GEOM_Object_var anObj;
761 bool flag = ( myRadioButton[ RadioButton21 ]->isChecked() &&
762 myRadioButton[ RadioButton31 ]->isChecked() &&
763 myRadioButton[ RadioButton41 ]->isChecked() );
765 int anId = getConstructorId();
767 anObj = GEOM::GEOM_ILocalOperations::_narrow(
768 getOperation() )->MakeChamferAll( myShape,
769 mySpinBox[ SpinBox1 ]->value() );
771 else if ( anId == 1 ) {
773 anObj = GEOM::GEOM_ILocalOperations::_narrow( getOperation() )->
774 MakeChamferEdge( myShape,
775 mySpinBox[ SpinBox21 ]->value(),
776 mySpinBox[ SpinBox22 ]->value(),
781 anObj = GEOM::GEOM_ILocalOperations::_narrow( getOperation() )->
782 MakeChamferEdgeAD( myShape,
783 mySpinBox[ SpinBox23 ]->value(),
784 mySpinBox[ SpinBox24 ]->value() * PI180,
789 else if ( anId == 2 )
791 GEOM::ListOfLong_var anArray = new GEOM::ListOfLong;
792 anArray->length( myFaces.Extent() );
794 for ( int i = 1, n = myFaces.Extent(); i <= n; i++ )
795 anArray[ i - 1 ] = myFaces( i );
798 anObj = GEOM::GEOM_ILocalOperations::_narrow(
799 getOperation() )->MakeChamferFaces( myShape,
800 mySpinBox[ SpinBox31 ]->value(),
801 mySpinBox[ SpinBox32 ]->value(),
804 anObj = GEOM::GEOM_ILocalOperations::_narrow(
805 getOperation() )->MakeChamferFacesAD( myShape,
806 mySpinBox[ SpinBox33 ]->value(),
807 mySpinBox[ SpinBox34 ]->value() * PI180,
810 else if ( anId == 3 ) {
811 GEOM::ListOfLong_var anArray = new GEOM::ListOfLong;
812 anArray->length( myEdges.Extent() );
813 for ( int i = 1, n = myEdges.Extent(); i <= n; i++ )
814 anArray[ i - 1 ] = myEdges( i );
816 anObj = GEOM::GEOM_ILocalOperations::_narrow( getOperation() )->
817 MakeChamferEdges( myShape, mySpinBox[ SpinBox41 ]->value(),
818 mySpinBox[ SpinBox42 ]->value(), anArray );
821 anObj = GEOM::GEOM_ILocalOperations::_narrow( getOperation() )->
822 MakeChamferEdgesAD( myShape, mySpinBox[ SpinBox43 ]->value(),
823 mySpinBox[ SpinBox44 ]->value() * PI180, anArray );
827 if ( !anObj->_is_nil() )
828 objects.push_back( anObj._retn() );