]> SALOME platform Git repositories - modules/geom.git/blob - src/OperationGUI/OperationGUI_ChamferDlg.cxx
Salome HOME
856d941d1dd77098a483a18c77772ae882fdee55
[modules/geom.git] / src / OperationGUI / OperationGUI_ChamferDlg.cxx
1 //  GEOM GEOMGUI : GUI for Geometry component
2 //
3 //  Copyright (C) 2003  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 //  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS 
5 // 
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. 
10 // 
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. 
15 // 
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 
19 // 
20 //  See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org 
21 //
22 //
23 //
24 //  File   : OperationGUI_ChamferDlg.cxx
25 //  Author : Damien COQUERET
26 //  Module : GEOM
27
28 //  $Header$
29
30 #include "OperationGUI_ChamferDlg.h"
31 #include "DlgRef_SpinBox.h"
32 #include "QAD_Desktop.h"
33 #include "qpixmap.h"
34 #include <list>
35
36 #include "GEOMImpl_Types.hxx"
37
38 //=================================================================================
39 // class    : OperationGUI_ChamferDlg()
40 // purpose  : Constructs a OperationGUI_ChamferDlg which is a child of 'parent', with the
41 //            name 'name' and widget flags set to 'f'.
42 //            The dialog will by default be modeless, unless you set 'modal' to
43 //            TRUE to construct a modal dialog.
44 //=================================================================================
45 OperationGUI_ChamferDlg::OperationGUI_ChamferDlg( QWidget* parent, SALOME_Selection* Sel )
46 : GEOMBase_Skeleton(parent, "ChamferDlg", Sel, false,
47     WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu)
48 {
49
50   mySelection = Sel;
51   myConstructorId = -1;
52
53   QPixmap image1(QAD_Desktop::getResourceManager()->loadPixmap("GEOM",tr("ICON_DLG_CHAMFER_ALL")));
54   QPixmap image2(QAD_Desktop::getResourceManager()->loadPixmap("GEOM",tr("ICON_DLG_CHAMFER_EDGE")));
55   QPixmap image3(QAD_Desktop::getResourceManager()->loadPixmap("GEOM",tr("ICON_DLG_CHAMFER_FACE")));
56   QPixmap iconSelect(QAD_Desktop::getResourceManager()->loadPixmap("GEOM",tr("ICON_SELECT")));
57
58   setCaption( tr( "GEOM_CHAMFER_TITLE" ) );
59
60   GroupConstructors->setTitle( tr( "GEOM_CHAMFER" ) );
61
62   RadioButton1->setPixmap( image1 );
63   RadioButton2->setPixmap( image2 );
64   RadioButton3->setPixmap( image3 );
65
66   // Create first group
67
68   myGrp1 = new QGroupBox( 1, Qt::Horizontal, tr( "GEOM_CHAMFER_ALL" ), this );
69
70   QGroupBox* aSelGrp1 = new QGroupBox( 3, Qt::Horizontal, myGrp1 );
71   aSelGrp1->setFrameStyle( QFrame::NoFrame );
72   aSelGrp1->setInsideMargin( 0 );
73
74   createSelWg( tr( "GEOM_MAIN_OBJECT" ), iconSelect, aSelGrp1, MainObj1 );
75
76   QGroupBox* aSpinGrp = new QGroupBox( 1, Qt::Vertical, myGrp1 );
77   aSpinGrp->setFrameStyle( QFrame::NoFrame );
78   aSpinGrp->setInsideMargin( 0 );
79
80   new QLabel( tr( "D" ), aSpinGrp );
81   mySpinBox[ SpinBox1 ] = new DlgRef_SpinBox( aSpinGrp );
82
83   ( new QFrame( myGrp1 ) )->setSizePolicy(
84     QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding ) );
85
86   // Create second group
87
88   myGrp2 = new QGroupBox( 1, Qt::Horizontal, tr( "GEOM_CHAMFER_EDGES" ), this );
89
90   QGroupBox* aSelGrp2 = new QGroupBox( 3, Qt::Horizontal, myGrp2 );
91   aSelGrp2->setFrameStyle( QFrame::NoFrame );
92   aSelGrp2->setInsideMargin( 0 );
93
94   createSelWg( tr( "GEOM_MAIN_OBJECT" ), iconSelect, aSelGrp2, MainObj2 );
95   createSelWg( tr( "FACE_1" ), iconSelect, aSelGrp2, Face1 );
96   createSelWg( tr( "FACE_2" ), iconSelect, aSelGrp2, Face2 );
97
98   aSpinGrp = new QGroupBox( 1, Qt::Vertical, myGrp2 );
99   aSpinGrp->setFrameStyle( QFrame::NoFrame );
100   aSpinGrp->setInsideMargin( 0 );
101
102   new QLabel( tr( "GEOM_D1" ), aSpinGrp );
103   mySpinBox[ SpinBox21 ] = new DlgRef_SpinBox( aSpinGrp );
104
105   new QLabel( tr( "GEOM_D2" ), aSpinGrp );
106   mySpinBox[ SpinBox22 ] = new DlgRef_SpinBox( aSpinGrp );
107
108   // Create third group
109
110   myGrp3 = new QGroupBox( 1, Qt::Horizontal, tr( "GEOM_CHAMFER_FACES" ), this );
111
112   QGroupBox* aSelGrp3 = new QGroupBox( 3, Qt::Horizontal, myGrp3 );
113   aSelGrp3->setFrameStyle( QFrame::NoFrame );
114   aSelGrp3->setInsideMargin( 0 );
115
116   createSelWg( tr( "GEOM_MAIN_OBJECT" ), iconSelect, aSelGrp3, MainObj3 );
117   createSelWg( tr( "SELECTED_FACES" ), iconSelect, aSelGrp3, Faces );
118
119   aSpinGrp = new QGroupBox( 1, Qt::Vertical, myGrp3 );
120   aSpinGrp->setFrameStyle( QFrame::NoFrame );
121   aSpinGrp->setInsideMargin( 0 );
122
123   new QLabel( tr( "GEOM_D1" ), aSpinGrp );
124   mySpinBox[ SpinBox31 ] = new DlgRef_SpinBox( aSpinGrp );
125
126   new QLabel( tr( "GEOM_D2" ), aSpinGrp );
127   mySpinBox[ SpinBox32 ] = new DlgRef_SpinBox( aSpinGrp );
128
129   ( new QLabel( myGrp3 ) )->setSizePolicy(
130     QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding ) );
131
132   // Add groups to layout
133
134   Layout1->addWidget( myGrp1, 2, 0 );
135   Layout1->addWidget( myGrp2, 2, 0 );
136   Layout1->addWidget( myGrp3, 2, 0 );
137
138   // Set range of spinboxes
139
140   double SpecificStep = 10.0;
141   QMap< int, DlgRef_SpinBox* >::iterator anIter;
142   for ( anIter = mySpinBox.begin(); anIter != mySpinBox.end(); ++anIter )
143     anIter.data()->RangeStepAndValidator( 0.001, 999.999, SpecificStep, 3 );
144
145   /* Initialisations */
146   Init( mySelection );
147 }
148
149
150 //=================================================================================
151 // function : ~OperationGUI_ChamferDlg()
152 // purpose  : Destroys the object and frees any allocated resources
153 //=================================================================================
154 OperationGUI_ChamferDlg::~OperationGUI_ChamferDlg()
155 {
156 }
157
158
159 //=================================================================================
160 // function : Init()
161 // purpose  :
162 //=================================================================================
163 void OperationGUI_ChamferDlg::Init( SALOME_Selection* Sel )
164 {
165   mySelection = Sel;
166   myConstructorId = -1;
167   reset();
168   RadioButton1->setChecked( true );
169   myEditCurrentArgument = mySelName[ MainObj1 ];
170
171   /* signals and slots connections */
172
173   // main buttons
174   connect( buttonOk   , SIGNAL( clicked() ), this, SLOT( ClickOnOk()    ) );
175   connect( buttonApply, SIGNAL( clicked() ), this, SLOT( ClickOnApply() ) );
176
177   // group box
178   connect( GroupConstructors, SIGNAL( clicked( int ) ),
179            this, SLOT( ConstructorsClicked( int ) ) );
180
181   // push buttons
182   QMap< int, QPushButton* >::iterator anIterBtn;
183   for ( anIterBtn = mySelBtn.begin(); anIterBtn != mySelBtn.end(); ++anIterBtn )
184     connect( anIterBtn.data(), SIGNAL( clicked() ),
185              this, SLOT( SetEditCurrentArgument() ) );
186
187   // line edits
188   QMap< int, QLineEdit* >::iterator anIterLE2;
189   for ( anIterLE2 = mySelName.begin(); anIterLE2 != mySelName.end(); ++anIterLE2 )
190     connect( anIterLE2.data(), SIGNAL( returnPressed() ),
191              this, SLOT( LineEditReturnPressed() ) );
192
193   // spin boxes
194   QMap< int, DlgRef_SpinBox* >::iterator anIterSpin;
195   for ( anIterSpin = mySpinBox.begin(); anIterSpin != mySpinBox.end(); ++anIterSpin )
196     connect( anIterSpin.data(), SIGNAL( valueChanged( double ) ),
197              this, SLOT( ValueChangedInSpinBox( double ) ) );
198
199   // selection
200   connect( mySelection, SIGNAL( currentSelectionChanged() ),
201            this, SLOT( SelectionIntoArgument() ) );
202
203   initName( tr( "GEOM_CHAMFER" ) );
204
205   myGrp2->hide();
206   myGrp3->hide();
207   myGrp1->show();
208
209   this->show();
210 }
211
212
213 //=================================================================================
214 // function : ConstructorsClicked()
215 // purpose  : Radio button management
216 //=================================================================================
217 void OperationGUI_ChamferDlg::ConstructorsClicked( int constructorId )
218 {
219    // Activate next widget
220  if ( QAD_Application::getDesktop()->getActiveStudy()->getActiveStudyFrame()->getTypeView() != VIEW_OCC )
221  {
222     RadioButton1->setChecked( true );
223     return;
224  }
225   
226   if ( myConstructorId == constructorId )
227     return;
228
229   // Get values from previous widget
230   double D1 = 5, D2 = 5;
231   if ( myConstructorId == 0 )
232     D1 = D2 = mySpinBox[ SpinBox1 ]->GetValue();
233   else if ( myConstructorId == 1 )
234   {
235     D1 = mySpinBox[ SpinBox21 ]->GetValue();
236     D2 = mySpinBox[ SpinBox22 ]->GetValue();
237   }
238   else if ( myConstructorId == 2 )
239   {
240     D1 = mySpinBox[ SpinBox31 ]->GetValue();
241     D2 = mySpinBox[ SpinBox32 ]->GetValue();
242   }
243
244   myConstructorId = constructorId;
245
246    switch ( constructorId )
247   {
248     case 0:
249         myGrp1->show();
250         myGrp2->hide();
251         myGrp3->hide();
252         mySpinBox[ SpinBox1 ]->SetValue( D1 );
253     break;
254     case 1:
255         myGrp1->hide();
256         myGrp2->show();
257         myGrp3->hide();
258         mySpinBox[ SpinBox21 ]->SetValue( D1 );
259         mySpinBox[ SpinBox22 ]->SetValue( D2 );
260     break;
261     case 2:
262         myGrp1->hide();
263         myGrp2->hide();
264         myGrp3->show();
265         mySpinBox[ SpinBox31 ]->SetValue( D1 );
266         mySpinBox[ SpinBox32 ]->SetValue( D2 );        
267     break;
268     default:
269     break;
270   }
271
272   if      ( constructorId == 0 ) myEditCurrentArgument = mySelName[ MainObj1 ];
273   else if ( constructorId == 1 ) myEditCurrentArgument = mySelName[ MainObj2 ];
274   else                           myEditCurrentArgument = mySelName[ MainObj3 ];
275
276   activateSelection(); 
277   enableWidgets();
278   
279   if ( !myShape->_is_nil() )
280   {
281     myEditCurrentArgument->setText( GEOMBase::GetName( myShape ) );
282     GEOMBase_Skeleton::LineEditReturnPressed();
283   }
284   else
285     myEditCurrentArgument->setText( "" );
286
287   displayPreview();
288 }
289
290
291 //=================================================================================
292 // function : ClickOnOk()
293 // purpose  :
294 //=================================================================================
295 void OperationGUI_ChamferDlg::ClickOnOk()
296 {
297   if ( ClickOnApply() )
298     ClickOnCancel();
299 }
300
301 //=================================================================================
302 // function : ClickOnApply()
303 // purpose  :
304 //=================================================================================
305 bool OperationGUI_ChamferDlg::ClickOnApply()
306 {
307   if ( !onAccept() )
308     return false;
309
310   initName();
311   return true;
312 }
313
314
315 //=================================================================================
316 // function : SelectionIntoArgument()
317 // purpose  : Called when selection has changed
318 //=================================================================================
319 void OperationGUI_ChamferDlg::SelectionIntoArgument()
320 {
321   erasePreview();
322   myEditCurrentArgument->setText( "" );
323
324   // Get index of current selection focus
325   int aCurrFocus = -1;
326   QMap< int, QLineEdit* >::iterator anIter;
327   for ( anIter = mySelName.begin(); anIter != mySelName.end(); ++anIter )
328     if ( myEditCurrentArgument == anIter.data() )
329     {
330       aCurrFocus = anIter.key();
331       break;
332     }
333
334   // If selection of main object is activated
335   if ( aCurrFocus == MainObj1 || aCurrFocus == MainObj2 || aCurrFocus == MainObj3 )
336   {
337     if ( mySelection->IObjectCount() == 1 )
338     {
339       Standard_Boolean aResult = Standard_False;
340       GEOM::GEOM_Object_var anObj =
341         GEOMBase::ConvertIOinGEOMObject( mySelection->firstIObject(), aResult );
342
343       if ( aResult && !anObj->_is_nil() )
344       {
345         myShape = anObj;
346         mySelName[ aCurrFocus ]->setText( GEOMBase::GetName( anObj ) );
347         displayPreview();
348         enableWidgets();
349         return;
350       }
351     }
352
353     myShape = GEOM::GEOM_Object::_nil();
354     enableWidgets();
355   }
356   // If face selection of second tab is activated
357   else if ( aCurrFocus == Face1 || aCurrFocus == Face2 )
358   {
359     if ( mySelection->IObjectCount() == 1 )
360     {
361       Standard_Boolean aResult = Standard_False;
362       GEOM::GEOM_Object_var anObj =
363         GEOMBase::ConvertIOinGEOMObject( mySelection->firstIObject(), aResult );
364
365       if ( aResult && !anObj->_is_nil() )
366       {
367          TColStd_IndexedMapOfInteger anIndexes;
368          mySelection->GetIndex( mySelection->firstIObject(), anIndexes );
369
370          if ( anIndexes.Extent() == 1 )
371          {
372             int anIndex = anIndexes( 1 );
373             QString aFaceName = QString( GEOMBase::GetName( anObj ) ) + ":%1";
374             myEditCurrentArgument->setText( aFaceName.arg( anIndex ) );
375             myFace[ aCurrFocus ] = anIndex;
376             displayPreview();
377             return;
378          }
379       }
380     }
381
382     myFace[ aCurrFocus ] = -1;
383   }
384   // If face selection of third tab is activated
385   else if ( aCurrFocus == Faces )
386   {
387     if ( mySelection->IObjectCount() == 1 )
388     {
389       Standard_Boolean aResult = Standard_False;
390       GEOM::GEOM_Object_var anObj =
391         GEOMBase::ConvertIOinGEOMObject( mySelection->firstIObject(), aResult );
392
393       if ( aResult && !anObj->_is_nil() )
394       {
395          TColStd_IndexedMapOfInteger anIndexes;
396          mySelection->GetIndex( mySelection->firstIObject(), anIndexes );
397
398          if ( anIndexes.Extent() > 0 )
399          {
400            QString aFaceName;
401            if ( anIndexes.Extent() == 1 )
402            {
403              int anIndex = anIndexes( 1 );
404
405              aFaceName = QString( GEOMBase::GetName( anObj ) ) + QString( ":%1" ).arg( anIndex );
406            }
407            else
408              aFaceName = tr( "GEOM_MEN_POPUP_NAME" ).arg( anIndexes.Extent() );
409
410            myEditCurrentArgument->setText( aFaceName );
411            myFaces = anIndexes;
412            displayPreview();
413            return;
414          }
415       }
416     }
417     myFaces.Clear();
418   }
419 }
420
421
422 //=================================================================================
423 // function : LineEditReturnPressed()
424 // purpose  :
425 //=================================================================================
426 void OperationGUI_ChamferDlg::LineEditReturnPressed()
427 {
428   QLineEdit* aSender = ( QLineEdit* )sender();
429
430   QMap< int, QLineEdit* >::iterator anIterLE;
431   for ( anIterLE = mySelName.begin(); anIterLE != mySelName.end(); ++anIterLE )
432     if ( anIterLE.data() == aSender )
433       myEditCurrentArgument = anIterLE.data();
434
435   GEOMBase_Skeleton::LineEditReturnPressed();
436 }
437
438
439 //=================================================================================
440 // function : SetEditCurrentArgument()
441 // purpose  :
442 //=================================================================================
443 void OperationGUI_ChamferDlg::SetEditCurrentArgument()
444 {
445   QPushButton* aSender = ( QPushButton* )sender();
446
447   QMap< int, QPushButton* >::iterator anIter;
448   for ( anIter = mySelBtn.begin(); anIter != mySelBtn.end(); ++anIter )
449     if ( anIter.data() == aSender )
450     {
451       mySelName[ anIter.key() ]->setFocus();
452       myEditCurrentArgument = mySelName[ anIter.key() ];
453     }
454
455   activateSelection();
456 }
457
458
459 //=================================================================================
460 // function : DeactivateActiveDialog()
461 // purpose  :
462 //=================================================================================
463 void OperationGUI_ChamferDlg::DeactivateActiveDialog()
464 {
465   // disconnect selection
466   GEOMBase_Skeleton::DeactivateActiveDialog();
467 }
468
469
470 //=================================================================================
471 // function : ActivateThisDialog()
472 // purpose  :
473 //=================================================================================
474 void OperationGUI_ChamferDlg::ActivateThisDialog()
475 {
476   GEOMBase_Skeleton::ActivateThisDialog();
477
478   connect( mySelection, SIGNAL(currentSelectionChanged()),
479            this, SLOT( SelectionIntoArgument() ) );
480
481   activateSelection();
482   displayPreview();
483 }
484
485
486 //=================================================================================
487 // function : enterEvent()
488 // purpose  :
489 //=================================================================================
490 void OperationGUI_ChamferDlg::enterEvent(QEvent* e)
491 {
492   if ( !GroupConstructors->isEnabled() )
493     this->ActivateThisDialog();
494 }
495
496
497 //=================================================================================
498 // function : ValueChangedInSpinBox()
499 // purpose  :
500 //=================================================================================
501 void OperationGUI_ChamferDlg::ValueChangedInSpinBox( double newValue )
502 {
503   displayPreview();
504 }
505
506
507 //=================================================================================
508 // function : createSelWg()
509 // purpose  :
510 //=================================================================================
511 void OperationGUI_ChamferDlg::createSelWg( const QString& theLbl,
512                                            QPixmap&       thePix,
513                                            QWidget*       theParent,
514                                            const int      theId )
515 {
516   new QLabel( theLbl, theParent );
517   mySelBtn[ theId ] = new QPushButton( theParent );
518   mySelBtn[ theId ]->setPixmap( thePix );
519   mySelName[ theId ] = new QLineEdit( theParent );
520   mySelName[ theId ]->setReadOnly( true );
521 }
522
523 //=================================================================================
524 // function : reset()
525 // purpose  :
526 //=================================================================================
527 void OperationGUI_ChamferDlg::reset()
528 {
529   // Set Initial values of spinboxes
530   QMap< int, DlgRef_SpinBox* >::iterator anIter;
531   for ( anIter = mySpinBox.begin(); anIter != mySpinBox.end(); ++anIter )
532     anIter.data()->SetValue( 5 );
533
534   // clear line edits
535   QMap< int, QLineEdit* >::iterator anIterLE;
536   for ( anIterLE = mySelName.begin(); anIterLE != mySelName.end(); ++anIterLE )
537     anIterLE.data()->setText( "" );
538
539   // constructor id
540   int aConstructorId = getConstructorId();
541
542   if      ( aConstructorId == 0 ) myEditCurrentArgument = mySelName[ MainObj1 ];
543   else if ( aConstructorId == 1 ) myEditCurrentArgument = mySelName[ MainObj2 ];
544   else                            myEditCurrentArgument = mySelName[ MainObj3 ];
545
546   myShape = GEOM::GEOM_Object::_nil();
547
548   myFaces.Clear();
549   myFace[ Face1 ] = -1;
550   myFace[ Face2 ] = -1;
551
552   erasePreview( true );
553
554   activateSelection();
555
556   enableWidgets();
557 }
558
559 //=================================================================================
560 // function : getConstructorId()
561 // purpose  :
562 //=================================================================================
563 int OperationGUI_ChamferDlg::getConstructorId() const
564 {
565   return GroupConstructors->id( GroupConstructors->selected() );
566 }
567
568 //=================================================================================
569 // function : activateSelection
570 // purpose  : Activate selection in accordance with myEditCurrentArgument
571 //=================================================================================
572 void OperationGUI_ChamferDlg::activateSelection()
573 {
574   if (  !myShape->_is_nil() &&
575        ( myEditCurrentArgument == mySelName[ Face1 ] ||
576          myEditCurrentArgument == mySelName[ Face2 ] ||
577          myEditCurrentArgument == mySelName[ Faces ] ) )
578     localSelection( myShape, TopAbs_FACE );
579   else
580   {
581     TColStd_MapOfInteger aMap;
582     aMap.Add( GEOM_SHELL );
583     aMap.Add( GEOM_SOLID );
584     aMap.Add( GEOM_COMPOUND );
585     globalSelection( aMap );
586   }
587
588   SelectionIntoArgument();
589 }
590
591 //=================================================================================
592 // function : enableWidgets
593 // purpose  : Enable widgets of faces in accordance with value of main object
594 //=================================================================================
595 void OperationGUI_ChamferDlg::enableWidgets()
596 {
597   int anId = getConstructorId();
598
599   bool toEnable = !myShape->_is_nil();
600   
601   if ( anId == 1 )
602   {
603     mySelName[ Face1 ]->setEnabled( toEnable );
604     mySelName[ Face2 ]->setEnabled( toEnable );
605     mySelBtn[ Face1 ]->setEnabled( toEnable );
606     mySelBtn[ Face2 ]->setEnabled( toEnable );
607
608     if ( !toEnable )
609     {
610       mySelName[ Face1 ]->setText( "" );
611       mySelName[ Face2 ]->setText( "" );
612       myFace[ Face1 ] = -1;
613       myFace[ Face2 ] = -1;
614     }
615   }
616   else if ( anId == 2 )
617   {
618     mySelName[ Faces ]->setEnabled( toEnable );
619
620     if ( !toEnable )
621       myFaces.Clear();
622   }
623 }
624
625 //=================================================================================
626 // function : createOperation
627 // purpose  :
628 //=================================================================================
629 GEOM::GEOM_IOperations_ptr OperationGUI_ChamferDlg::createOperation()
630 {
631   return getGeomEngine()->GetILocalOperations( getStudyId() );
632 }
633
634 //=================================================================================
635 // function : ClickOnApply()
636 // purpose  : Verify validity of input data
637 //=================================================================================
638 bool OperationGUI_ChamferDlg::isValid( QString& )
639 {
640   switch ( getConstructorId() )
641   {
642     case 0: return !myShape->_is_nil();
643     case 1: return !myShape->_is_nil() && myFace[ Face1 ] > 0 && myFace[ Face2 ] > 0;
644     case 2: return !myShape->_is_nil() && myFaces.Extent() > 0;
645     default: return false;
646   }
647 }
648
649 //=================================================================================
650 // function : execute
651 // purpose  :
652 //=================================================================================
653 bool OperationGUI_ChamferDlg::execute( ObjectList& objects )
654 {
655   GEOM::GEOM_Object_var anObj;
656
657   int anId = getConstructorId();
658   if ( anId == 0 )
659     anObj = GEOM::GEOM_ILocalOperations::_narrow(
660       getOperation() )->MakeChamferAll( myShape,
661                                         mySpinBox[ SpinBox1 ]->GetValue() );
662   else if ( anId == 1 )
663     anObj = GEOM::GEOM_ILocalOperations::_narrow(
664       getOperation() )->MakeChamferEdge( myShape,
665                                          mySpinBox[ SpinBox21 ]->GetValue(),
666                                          mySpinBox[ SpinBox22 ]->GetValue(),
667                                          myFace[ Face1 ],
668                                          myFace[ Face2 ] );
669   else if ( anId == 2 )
670   {
671
672     int i = 0;
673     GEOM::ListOfLong_var anArray = new GEOM::ListOfLong;
674     anArray->length( myFaces.Extent() );
675
676
677     for ( int i = 1, n = myFaces.Extent(); i <= n; i++ )
678       anArray[ i - 1 ] = myFaces( i );             
679     
680     anObj = GEOM::GEOM_ILocalOperations::_narrow(
681       getOperation() )->MakeChamferFaces( myShape,
682                                           mySpinBox[ SpinBox31 ]->GetValue(),
683                                           mySpinBox[ SpinBox32 ]->GetValue(),
684                                           anArray );
685   }
686
687
688   if ( !anObj->_is_nil() )
689     objects.push_back( anObj._retn() );
690
691   return true;
692 }
693
694
695
696
697
698
699
700
701