Salome HOME
84a2f3134cdff391ba2d223c87b060e45811de0f
[modules/geom.git] / src / OperationGUI / OperationGUI_FilletDlg.cxx
1 //  Copyright (C) 2007-2008  CEA/DEN, EDF R&D, OPEN CASCADE
2 //
3 //  Copyright (C) 2003-2007  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 // GEOM GEOMGUI : GUI for Geometry component
23 // File   : OperationGUI_FilletDlg.cxx
24 // Author : Damien COQUERET, Open CASCADE S.A.S.
25 //
26 #include "OperationGUI_FilletDlg.h"
27
28 #include <DlgRef.h>
29 #include <GeometryGUI.h>
30 #include <GEOMBase.h>
31
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>
40
41 // OCCT Includes
42 #include <TColStd_MapOfInteger.hxx>
43 #include <TColStd_IndexedMapOfInteger.hxx>
44
45 #include <GEOMImpl_Types.hxx>
46
47 //=================================================================================
48 // class    : OperationGUI_FilletDlg()
49 // purpose  : Constructs a OperationGUI_FilletDlg which is a child of 'parent', with the
50 //            name 'name' and widget flags set to 'f'.
51 //            The dialog will by default be modeless, unless you set 'modal' to
52 //            TRUE to construct a modal dialog.
53 //=================================================================================
54 OperationGUI_FilletDlg::OperationGUI_FilletDlg (GeometryGUI* theGeometryGUI, QWidget* parent)
55   : GEOMBase_Skeleton(theGeometryGUI, parent, false),
56     myInitial(true)
57 {
58   SUIT_ResourceMgr* aResMgr = myGeomGUI->getApp()->resourceMgr();
59   QPixmap image0 (aResMgr->loadPixmap("GEOM", tr("ICON_DLG_FILLET_ALL")));
60   QPixmap image1 (aResMgr->loadPixmap("GEOM", tr("ICON_DLG_FILLET_EDGE")));
61   QPixmap image2 (aResMgr->loadPixmap("GEOM", tr("ICON_DLG_FILLET_FACE")));
62
63   QPixmap iconSelect (aResMgr->loadPixmap("GEOM", tr("ICON_SELECT")));
64
65   setWindowTitle(tr("GEOM_FILLET_TITLE"));
66
67   /***************************************************************/
68   mainFrame()->GroupConstructors->setTitle(tr("GEOM_FILLET"));
69   mainFrame()->RadioButton1->setIcon(image0);
70   mainFrame()->RadioButton2->setIcon(image1);
71   mainFrame()->RadioButton3->setIcon(image2);
72
73   Group1 = new DlgRef_1Sel1Spin(centralWidget());
74   Group1->GroupBox1->setTitle(tr("GEOM_FILLET_ALL"));
75   Group1->TextLabel1->setText(tr("GEOM_MAIN_OBJECT"));
76   Group1->TextLabel2->setText(tr("GEOM_RADIUS"));
77   Group1->PushButton1->setIcon(iconSelect);
78   Group1->LineEdit1->setReadOnly(true);
79
80   Group2 = new DlgRef_2Sel3Spin2Rb(centralWidget());
81   Group2->GroupBox1->setTitle(tr("GEOM_FILLET_EDGES"));
82   Group2->TextLabel1->setText(tr("GEOM_MAIN_OBJECT"));
83   Group2->TextLabel2->setText(tr("SELECTED_EDGES"));
84   Group2->TextLabel3->setText(tr("GEOM_RADIUS"));
85   Group2->TextLabel4->setText(tr("GEOM_R1"));
86   Group2->TextLabel5->setText(tr("GEOM_R2"));
87   Group2->PushButton1->setIcon(iconSelect);
88   Group2->PushButton2->setIcon(iconSelect);
89   Group2->LineEdit1->setReadOnly(true);
90   Group2->LineEdit2->setReadOnly(true);
91
92   Group3 = new DlgRef_2Sel3Spin2Rb(centralWidget());
93   Group3->GroupBox1->setTitle(tr("GEOM_FILLET_FACES"));
94   Group3->TextLabel1->setText(tr("GEOM_MAIN_OBJECT"));
95   Group3->TextLabel2->setText(tr("SELECTED_FACES"));
96   Group3->TextLabel3->setText(tr("GEOM_RADIUS"));
97   Group3->TextLabel4->setText(tr("GEOM_R1"));
98   Group3->TextLabel5->setText(tr("GEOM_R2"));
99   Group3->PushButton1->setIcon(iconSelect);
100   Group3->PushButton2->setIcon(iconSelect);
101   Group3->LineEdit1->setReadOnly(true);
102   Group3->LineEdit2->setReadOnly(true);
103
104   QVBoxLayout* layout = new QVBoxLayout(centralWidget());
105   layout->setMargin(0); layout->setSpacing(6);
106   layout->addWidget(Group1);
107   layout->addWidget(Group2);
108   layout->addWidget(Group3);
109   /***************************************************************/
110
111   // Set range of spinboxes
112   double SpecificStep = 10.0;
113   initSpinBox(Group1->SpinBox_DX, 0.001, COORD_MAX, SpecificStep, 3); // VSR: TODO: DBL_DIGITS_DISPLAY
114   initSpinBox(Group2->SpinBox_DX, 0.001, COORD_MAX, SpecificStep, 3); // VSR: TODO: DBL_DIGITS_DISPLAY
115   initSpinBox(Group2->SpinBox_DY, 0.001, COORD_MAX, SpecificStep, 3); // VSR: TODO: DBL_DIGITS_DISPLAY
116   initSpinBox(Group2->SpinBox_DZ, 0.001, COORD_MAX, SpecificStep, 3); // VSR: TODO: DBL_DIGITS_DISPLAY
117   initSpinBox(Group3->SpinBox_DX, 0.001, COORD_MAX, SpecificStep, 3); // VSR: TODO: DBL_DIGITS_DISPLAY
118   initSpinBox(Group3->SpinBox_DY, 0.001, COORD_MAX, SpecificStep, 3); // VSR: TODO: DBL_DIGITS_DISPLAY
119   initSpinBox(Group3->SpinBox_DZ, 0.001, COORD_MAX, SpecificStep, 3); // VSR: TODO: DBL_DIGITS_DISPLAY
120
121   setHelpFileName("fillet_operation_page.html");
122
123   // Initialisation
124   Init();
125 }
126
127 //=================================================================================
128 // function : ~OperationGUI_FilletDlg()
129 // purpose  : Destroys the object and frees any allocated resources
130 //=================================================================================
131 OperationGUI_FilletDlg::~OperationGUI_FilletDlg()
132 {
133 }
134
135 //=================================================================================
136 // function : Init()
137 // purpose  :
138 //=================================================================================
139 void OperationGUI_FilletDlg::Init()
140 {
141   // Set Initial values of spinboxes
142   Group1->SpinBox_DX->setValue(5);
143   Group2->SpinBox_DX->setValue(5);
144   Group2->SpinBox_DY->setValue(5);
145   Group2->SpinBox_DZ->setValue(5);
146   Group3->SpinBox_DX->setValue(5);
147   Group3->SpinBox_DY->setValue(5);
148   Group3->SpinBox_DZ->setValue(5);
149
150   // Clear line edits
151   Group1->LineEdit1->setText("");
152   Group2->LineEdit1->setText("");
153   Group2->LineEdit2->setText("");
154   Group3->LineEdit1->setText("");
155   Group3->LineEdit2->setText("");
156
157   myShape = GEOM::GEOM_Object::_nil();
158
159   myFaces.Clear();
160   myEdges.Clear();
161
162   // signals and slots connections
163
164   // main buttons
165   connect(buttonOk(),    SIGNAL(clicked()), this, SLOT(ClickOnOk()   ));
166   connect(buttonApply(), SIGNAL(clicked()), this, SLOT(ClickOnApply()));
167
168   // group box
169   connect(this,          SIGNAL(constructorsClicked(int)), this, SLOT(ConstructorsClicked(int)));
170
171   // push buttons
172   connect(Group1->PushButton1, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
173   connect(Group2->PushButton1, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
174   connect(Group3->PushButton1, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
175   connect(Group2->PushButton2, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
176   connect(Group3->PushButton2, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
177
178   // line edits
179   connect(Group1->LineEdit1, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed()));
180   connect(Group2->LineEdit1, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed()));
181   connect(Group3->LineEdit1, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed()));
182
183   // spin boxes
184   connect(Group1->SpinBox_DX, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double)));
185   connect(Group2->SpinBox_DX, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double)));
186   connect(Group2->SpinBox_DY, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double)));
187   connect(Group2->SpinBox_DZ, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double)));
188   connect(Group3->SpinBox_DX, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double)));
189   connect(Group3->SpinBox_DY, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double)));
190   connect(Group3->SpinBox_DZ, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double)));
191
192   // radio buttons
193   connect(Group2->RadioButton1, SIGNAL(clicked()), this, SLOT(RadioButtonClicked()));
194   connect(Group2->RadioButton2, SIGNAL(clicked()), this, SLOT(RadioButtonClicked()));
195   connect(Group3->RadioButton1, SIGNAL(clicked()), this, SLOT(RadioButtonClicked()));
196   connect(Group3->RadioButton2, SIGNAL(clicked()), this, SLOT(RadioButtonClicked()));
197
198   initName(tr("GEOM_FILLET"));
199
200   myConstructorId = -1;
201   ConstructorsClicked(0);
202 }
203
204 //=================================================================================
205 // function : ConstructorsClicked()
206 // purpose  : Radio button management
207 //=================================================================================
208 void OperationGUI_FilletDlg::ConstructorsClicked (int constructorId)
209 {
210   if (myGeomGUI->getApp()->desktop()->activeWindow()->getViewManager()->getType()
211       != OCCViewer_Viewer::Type()) {
212     mainFrame()->RadioButton1->setChecked(true);
213     return;
214   }
215
216   if (myConstructorId == constructorId)
217     return;
218
219   // Get radius from previous widget
220   QString R = "5", R1 = "5", R2 = "5";
221   if      (myConstructorId == 0) {
222     R = Group1->SpinBox_DX->text();
223   }
224   else if (myConstructorId == 1) {
225     R = Group2->SpinBox_DX->text();
226     R1 = Group2->SpinBox_DY->text();
227     R2 = Group2->SpinBox_DZ->text();
228   }
229   else {
230     R = Group3->SpinBox_DX->text();
231     R1 = Group3->SpinBox_DY->text();
232     R2 = Group3->SpinBox_DZ->text();
233   }
234
235   myConstructorId = constructorId;
236
237   switch (constructorId) {
238   case 0:
239     Group2->hide();
240     Group3->hide();
241     Group1->show();
242     Group1->SpinBox_DX->setText(R);
243     break;
244   case 1:
245     Group1->hide();
246     Group3->hide();
247     Group2->show();
248     Group2->SpinBox_DX->setText(R);
249     Group2->SpinBox_DY->setText(R1);
250     Group2->SpinBox_DZ->setText(R2);
251     break;
252   case 2:
253     Group1->hide();
254     Group2->hide();
255     Group3->show();
256     Group3->SpinBox_DX->setText(R);
257     Group3->SpinBox_DY->setText(R1);
258     Group3->SpinBox_DZ->setText(R2);
259     break;
260   default:
261     break;
262   }
263
264   if      (constructorId == 0) Group1->PushButton1->click();
265   else if (constructorId == 1) Group2->PushButton1->click();
266   else                         Group3->PushButton1->click();
267
268   enableWidgets();
269
270   if (myInitial) {
271     myInitial = false;
272     SelectionIntoArgument();
273   }
274   else {
275     if (!myShape->_is_nil()) {
276       myEditCurrentArgument->setText(GEOMBase::GetName(myShape));
277       GEOMBase_Skeleton::LineEditReturnPressed();
278       switch (getConstructorId()) {
279       case 1:
280         if (myEdges.Extent() == 0)
281           Group2->PushButton2->click();
282         break;
283       case 2:
284         if (myFaces.Extent() == 0)
285           Group3->PushButton2->click();
286         break;
287       default:
288         break;
289       }
290     }
291     else
292       myEditCurrentArgument->setText("");
293
294     displayPreview();
295   }
296
297   qApp->processEvents();
298   updateGeometry();
299   resize(minimumSizeHint());
300 }
301
302 //=================================================================================
303 // function : ClickOnOk()
304 // purpose  :
305 //=================================================================================
306 void OperationGUI_FilletDlg::ClickOnOk()
307 {
308   if (ClickOnApply())
309     ClickOnCancel();
310 }
311
312 //=================================================================================
313 // function : ClickOnApply()
314 // purpose  :
315 //=================================================================================
316 bool OperationGUI_FilletDlg::ClickOnApply()
317 {
318   if (!onAccept())
319     return false;
320
321   initName();
322   // activate selection and connect selection manager
323   ConstructorsClicked(getConstructorId());
324   return true;
325 }
326
327 //=================================================================================
328 // function : SelectionIntoArgument()
329 // purpose  : Called when selection is changed or on dialog initialization or activation
330 //=================================================================================
331 void OperationGUI_FilletDlg::SelectionIntoArgument()
332 {
333   erasePreview();
334   myEditCurrentArgument->setText("");
335
336   LightApp_SelectionMgr* aSelMgr = myGeomGUI->getApp()->selectionMgr();
337   SALOME_ListIO aSelList;
338   aSelMgr->selectedObjects(aSelList);
339
340   // If selection of main object is activated
341   if (myEditCurrentArgument == Group1->LineEdit1 ||
342       myEditCurrentArgument == Group2->LineEdit1 ||
343       myEditCurrentArgument == Group3->LineEdit1)
344   {
345     myShape = GEOM::GEOM_Object::_nil();
346     if (aSelList.Extent() == 1) {
347       Standard_Boolean aResult = Standard_False;
348       GEOM::GEOM_Object_var anObj =
349         GEOMBase::ConvertIOinGEOMObject(aSelList.First(), aResult);
350
351       if (aResult && !anObj->_is_nil()) {
352         myShape = anObj;
353         myEditCurrentArgument->setText(GEOMBase::GetName(anObj));
354         displayPreview();
355       }
356     }
357
358     enableWidgets();
359   }
360   // If face or edge selection is activated
361   else if (myEditCurrentArgument == Group2->LineEdit2 ||
362            myEditCurrentArgument == Group3->LineEdit2)
363   {
364     if (myEditCurrentArgument == Group2->LineEdit2) myEdges.Clear();
365     else myFaces.Clear();
366     if (aSelList.Extent() == 1) {
367       Standard_Boolean aResult = Standard_False;
368       GEOM::GEOM_Object_var anObj =
369         GEOMBase::ConvertIOinGEOMObject(aSelList.First(), aResult);
370
371       if (aResult && !anObj->_is_nil()) {
372         TColStd_IndexedMapOfInteger anIndexes;
373         aSelMgr->GetIndexes(aSelList.First(), anIndexes);
374
375         if (anIndexes.Extent() > 0) {
376           QString aName;
377           if (anIndexes.Extent() == 1) {
378             int anIndex = anIndexes(1);
379
380             aName = QString(GEOMBase::GetName(anObj)) + QString(":%1").arg(anIndex);
381           }
382           else {
383             aName = tr("GEOM_MEN_POPUP_NAME").arg(anIndexes.Extent());
384           }
385
386           myEditCurrentArgument->setText(aName);
387
388           if (myConstructorId == 1)
389             myEdges = anIndexes;
390           else
391             myFaces = anIndexes;
392
393           displayPreview();
394         }
395       }
396     }
397   }
398
399   // clear selection
400   if (!(myEditCurrentArgument == Group2->LineEdit2 ||
401         myEditCurrentArgument == Group3->LineEdit2)) {
402     disconnect(myGeomGUI->getApp()->selectionMgr(), 0, this, 0);
403     myGeomGUI->getApp()->selectionMgr()->clearSelected();
404     connect(myGeomGUI->getApp()->selectionMgr(), SIGNAL(currentSelectionChanged()),
405             this, SLOT(SelectionIntoArgument()));
406   }
407
408   switch (getConstructorId()) {
409   case 1:
410     if (myEditCurrentArgument == Group2->LineEdit1) {
411       if (!myShape->_is_nil() && myEdges.Extent() == 0)
412         Group2->PushButton2->click();
413     }
414     break;
415   case 2:
416     if (myEditCurrentArgument == Group3->LineEdit1) {
417       if (!myShape->_is_nil() && myFaces.Extent() == 0)
418         Group3->PushButton2->click();
419     }
420     break;
421   default:
422     break;
423   }
424 }
425
426 //=================================================================================
427 // function : SetEditCurrentArgument()
428 // purpose  :
429 //=================================================================================
430 void OperationGUI_FilletDlg::SetEditCurrentArgument()
431 {
432   QPushButton* send = (QPushButton*)sender();
433
434   if (send == Group1->PushButton1) {
435     myEditCurrentArgument = Group1->LineEdit1;
436   }
437   else if (send == Group2->PushButton1) {
438     myEditCurrentArgument = Group2->LineEdit1;
439     Group2->PushButton2->setDown(false);
440     Group2->LineEdit2->setEnabled(false);
441   }
442   else if (send == Group2->PushButton2) {
443     myEditCurrentArgument = Group2->LineEdit2;
444     Group2->PushButton1->setDown(false);
445     Group2->LineEdit1->setEnabled(false);
446   }
447   else if (send == Group3->PushButton1) {
448     myEditCurrentArgument = Group3->LineEdit1;
449     Group3->PushButton2->setDown(false);
450     Group3->LineEdit2->setEnabled(false);
451   }
452   else if (send == Group3->PushButton2) {
453     myEditCurrentArgument = Group3->LineEdit2;
454     Group3->PushButton1->setDown(false);
455     Group3->LineEdit1->setEnabled(false);
456   }
457
458   // enable line edit
459   myEditCurrentArgument->setEnabled(true);
460   myEditCurrentArgument->setFocus();
461   // after setFocus(), because it will be setDown(false) when loses focus
462   send->setDown(true);
463
464   activateSelection();
465
466   // seems we need it only to avoid preview disappearing, caused by selection mode change
467   displayPreview();
468 }
469
470 //=================================================================================
471 // function : LineEditReturnPressed()
472 // purpose  :
473 //=================================================================================
474 void OperationGUI_FilletDlg::LineEditReturnPressed()
475 {
476   QLineEdit* send = (QLineEdit*)sender();
477
478   if (send == Group1->LineEdit1)
479     myEditCurrentArgument = Group1->LineEdit1;
480   else if (send == Group2->LineEdit1)
481     myEditCurrentArgument = Group2->LineEdit1;
482   else if (send == Group3->LineEdit1)
483     myEditCurrentArgument = Group3->LineEdit1;
484   else
485     return;
486
487   GEOMBase_Skeleton::LineEditReturnPressed();
488 }
489
490 //=================================================================================
491 // function : ActivateThisDialog()
492 // purpose  :
493 //=================================================================================
494 void OperationGUI_FilletDlg::ActivateThisDialog()
495 {
496   GEOMBase_Skeleton::ActivateThisDialog();
497   connect( myGeomGUI->getApp()->selectionMgr(), SIGNAL( currentSelectionChanged() ),
498            this, SLOT( SelectionIntoArgument() ) );
499
500   ConstructorsClicked( getConstructorId() );
501 }
502
503 //=================================================================================
504 // function : enterEvent()
505 // purpose  :
506 //=================================================================================
507 void OperationGUI_FilletDlg::enterEvent (QEvent*)
508 {
509   if (!mainFrame()->GroupConstructors->isEnabled())
510     this->ActivateThisDialog();
511 }
512
513 //=================================================================================
514 // function : ValueChangedInSpinBox()
515 // purpose  :
516 //=================================================================================
517 void OperationGUI_FilletDlg::ValueChangedInSpinBox (double)
518 {
519   displayPreview();
520 }
521
522 //=================================================================================
523 // function : activateSelection
524 // purpose  : Activate selection in accordance with myEditCurrentArgument
525 //=================================================================================
526 void OperationGUI_FilletDlg::activateSelection()
527 {
528   disconnect(myGeomGUI->getApp()->selectionMgr(), 0, this, 0);
529
530   if (!myShape->_is_nil() && myEditCurrentArgument == Group2->LineEdit2)
531     localSelection(myShape, TopAbs_EDGE);
532   else if (!myShape->_is_nil() && myEditCurrentArgument == Group3->LineEdit2)
533     localSelection(myShape, TopAbs_FACE);
534   else {
535     TColStd_MapOfInteger aMap;
536     aMap.Add(GEOM_SHELL);
537     aMap.Add(GEOM_SOLID);
538     aMap.Add(GEOM_COMPOUND);
539     globalSelection(aMap);
540   }
541
542   connect(myGeomGUI->getApp()->selectionMgr(), SIGNAL(currentSelectionChanged()),
543           this, SLOT(SelectionIntoArgument()));
544 }
545
546 //=================================================================================
547 // function : enableWidgets
548 // purpose  : Enable widgets of faces in accordance with value of main object
549 //=================================================================================
550 void OperationGUI_FilletDlg::enableWidgets()
551 {
552   int anId = getConstructorId();
553
554   bool toEnable = !myShape->_is_nil();
555
556   if (anId == 1) {
557     //Group2->LineEdit2->setEnabled(toEnable);
558     Group2->PushButton2->setEnabled(toEnable);
559
560     if (!toEnable) {
561       Group2->LineEdit2->setText("");
562       myEdges.Clear();
563     }
564   }
565   else if (anId == 2) {
566     //Group3->LineEdit2->setEnabled(toEnable);
567     Group3->PushButton2->setEnabled(toEnable);
568
569     if (!toEnable) {
570       Group3->LineEdit2->setText("");
571       myFaces.Clear();
572     }
573   }
574 }
575
576 //=================================================================================
577 // function : createOperation
578 // purpose  :
579 //=================================================================================
580 GEOM::GEOM_IOperations_ptr OperationGUI_FilletDlg::createOperation()
581 {
582   return getGeomEngine()->GetILocalOperations(getStudyId());
583 }
584
585 //=================================================================================
586 // function : isValid()
587 // purpose  : Verify validity of input data
588 //=================================================================================
589 bool OperationGUI_FilletDlg::isValid (QString& msg)
590 {
591   bool ok = true;
592   switch (getConstructorId())
593   {
594     case 0:
595       ok = Group1->SpinBox_DX->isValid( msg, !IsPreview() ) && ok;
596       return !myShape->_is_nil() && ok;
597     case 1:
598       if (Group2->RadioButton1->isChecked())
599         ok = Group2->SpinBox_DX->isValid( msg, !IsPreview() );
600       else
601       {
602         ok = Group2->SpinBox_DY->isValid( msg, !IsPreview() ) && ok;
603         ok = Group2->SpinBox_DZ->isValid( msg, !IsPreview() ) && ok;
604       }
605       return !myShape->_is_nil() && myEdges.Extent() > 0 && ok;
606     case 2:
607       if (Group3->RadioButton1->isChecked())
608         ok = Group3->SpinBox_DX->isValid( msg, !IsPreview() );
609       else
610       {
611         ok = Group3->SpinBox_DY->isValid( msg, !IsPreview() ) && ok;
612         ok = Group3->SpinBox_DZ->isValid( msg, !IsPreview() ) && ok;
613       }
614       return !myShape->_is_nil() && myFaces.Extent() > 0 && ok;
615     default: return false;
616   }
617 }
618
619 //=================================================================================
620 // function : execute
621 // purpose  :
622 //=================================================================================
623 bool OperationGUI_FilletDlg::execute (ObjectList& objects)
624 {
625   QStringList aParameters;
626   GEOM::GEOM_Object_var anObj;
627
628   int anId = getConstructorId();
629   if (anId == 0) {
630     anObj = GEOM::GEOM_ILocalOperations::_narrow(getOperation())->
631       MakeFilletAll(myShape, getRadius());
632     if (!anObj->_is_nil())
633       aParameters << Group1->SpinBox_DX->text();
634   }
635   else if (anId == 1) {
636     GEOM::ListOfLong_var aList = new GEOM::ListOfLong;
637     aList->length(myEdges.Extent());
638
639     for (int i = 1, n = myEdges.Extent(); i <= n; i++)
640       aList[ i - 1 ] = myEdges(i);
641
642     if (Group2->RadioButton1->isChecked())
643     {
644       anObj = GEOM::GEOM_ILocalOperations::_narrow(getOperation())->
645         MakeFilletEdges(myShape, getRadius(), aList);
646       if (!anObj->_is_nil())
647         aParameters << Group2->SpinBox_DX->text();
648     }
649     else
650     {
651       anObj = GEOM::GEOM_ILocalOperations::_narrow(getOperation())->
652         MakeFilletEdgesR1R2(myShape,
653                             Group2->SpinBox_DY->value(),
654                             Group2->SpinBox_DZ->value(),
655                             aList);
656       if (!anObj->_is_nil())
657       {
658         aParameters << Group2->SpinBox_DY->text();
659         aParameters << Group2->SpinBox_DZ->text();
660       }
661     }
662   }
663   else if (anId == 2) {
664     GEOM::ListOfLong_var aList = new GEOM::ListOfLong;
665     aList->length(myFaces.Extent());
666
667     for (int i = 1, n = myFaces.Extent(); i <= n; i++)
668       aList[ i - 1 ] = myFaces(i);
669
670     if (Group3->RadioButton1->isChecked()) {
671       anObj = GEOM::GEOM_ILocalOperations::_narrow(getOperation())->
672         MakeFilletFaces(myShape, getRadius(), aList);
673       if (!anObj->_is_nil())
674         aParameters << Group3->SpinBox_DX->text();
675     }
676     else {
677       anObj = GEOM::GEOM_ILocalOperations::_narrow(getOperation())->
678         MakeFilletFacesR1R2(myShape,
679                             Group3->SpinBox_DY->value(),
680                             Group3->SpinBox_DZ->value(), aList);
681       if (!anObj->_is_nil())
682       {
683         aParameters << Group3->SpinBox_DY->text();
684         aParameters << Group3->SpinBox_DZ->text();
685       }
686     }
687   }
688
689   if (!anObj->_is_nil())
690   {
691     if (!IsPreview())
692       anObj->SetParameters(GeometryGUI::JoinObjectParameters(aParameters));
693     objects.push_back(anObj._retn());
694   }
695
696   return true;
697 }
698
699 //=================================================================================
700 // function : getRadius
701 // purpose  : Get radius
702 //=================================================================================
703 double OperationGUI_FilletDlg::getRadius() const
704 {
705   int anId = getConstructorId();
706   if      (anId == 0) return Group1->SpinBox_DX->value();
707   else if (anId == 1) return Group2->SpinBox_DX->value();
708   else                return Group3->SpinBox_DX->value();
709 }
710
711 //=================================================================================
712 // function : RadiobuttonClicked
713 // purpose  :
714 //=================================================================================
715 void OperationGUI_FilletDlg::RadioButtonClicked()
716 {
717   const QObject* s = sender();
718
719   bool flag = s == Group2->RadioButton1 || s == Group3->RadioButton1;
720
721   Group2->RadioButton1->blockSignals(true);
722   Group2->RadioButton2->blockSignals(true);
723   Group3->RadioButton1->blockSignals(true);
724   Group3->RadioButton2->blockSignals(true);
725
726   Group2->SpinBox_DX->setEnabled(flag);
727   Group2->SpinBox_DY->setEnabled(!flag);
728   Group2->SpinBox_DZ->setEnabled(!flag);
729   Group2->RadioButton1->setChecked(flag);
730   Group2->RadioButton2->setChecked(!flag);
731   Group3->SpinBox_DX->setEnabled(flag);
732   Group3->SpinBox_DY->setEnabled(!flag);
733   Group3->SpinBox_DZ->setEnabled(!flag);
734   Group3->RadioButton1->setChecked(flag);
735   Group3->RadioButton2->setChecked(!flag);
736
737   Group2->RadioButton1->blockSignals(false);
738   Group2->RadioButton2->blockSignals(false);
739   Group3->RadioButton1->blockSignals(false);
740   Group3->RadioButton2->blockSignals(false);
741
742   displayPreview();
743 }