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