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