Salome HOME
cf7a1609bfd530ae1768b8cba2718ae47bd7163d
[modules/geom.git] / src / OperationGUI / OperationGUI_FilletDlg.cxx
1 // Copyright (C) 2007-2023  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, or (at your option) any later version.
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   showOnlyPreviewControl();
164
165   // signals and slots connections
166
167   // main buttons
168   connect(buttonOk(),    SIGNAL(clicked()), this, SLOT(ClickOnOk()   ));
169   connect(buttonApply(), SIGNAL(clicked()), this, SLOT(ClickOnApply()));
170
171   // group box
172   connect(this,          SIGNAL(constructorsClicked(int)), this, SLOT(ConstructorsClicked(int)));
173
174   // push buttons
175   connect(Group1->PushButton1, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
176   connect(Group2->PushButton1, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
177   connect(Group3->PushButton1, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
178   connect(Group2->PushButton2, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
179   connect(Group3->PushButton2, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
180
181   // line edits
182   connect(Group1->LineEdit1, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed()));
183   connect(Group2->LineEdit1, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed()));
184   connect(Group3->LineEdit1, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed()));
185
186   // spin boxes
187   connect(Group1->SpinBox_DX, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double)));
188   connect(Group2->SpinBox_DX, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double)));
189   connect(Group2->SpinBox_DY, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double)));
190   connect(Group2->SpinBox_DZ, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double)));
191   connect(Group3->SpinBox_DX, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double)));
192   connect(Group3->SpinBox_DY, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double)));
193   connect(Group3->SpinBox_DZ, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double)));
194
195   // radio buttons
196   connect(Group2->RadioButton1, SIGNAL(clicked()), this, SLOT(RadioButtonClicked()));
197   connect(Group2->RadioButton2, SIGNAL(clicked()), this, SLOT(RadioButtonClicked()));
198   connect(Group3->RadioButton1, SIGNAL(clicked()), this, SLOT(RadioButtonClicked()));
199   connect(Group3->RadioButton2, SIGNAL(clicked()), this, SLOT(RadioButtonClicked()));
200
201   initName(tr("GEOM_FILLET"));
202
203   myConstructorId = -1;
204   ConstructorsClicked(0);
205 }
206
207 //=================================================================================
208 // function : ConstructorsClicked()
209 // purpose  : Radio button management
210 //=================================================================================
211 void OperationGUI_FilletDlg::ConstructorsClicked (int constructorId)
212 {
213   if (myGeomGUI->getApp()->desktop()->activeWindow()->getViewManager()->getType()
214       != OCCViewer_Viewer::Type()) {
215     mainFrame()->RadioButton1->setChecked(true);
216     return;
217   }
218
219   if (myConstructorId == constructorId)
220     return;
221
222   // Get radius from previous widget
223   QString R = "5", R1 = "5", R2 = "5";
224   if      (myConstructorId == 0) {
225     R = Group1->SpinBox_DX->text();
226   }
227   else if (myConstructorId == 1) {
228     R = Group2->SpinBox_DX->text();
229     R1 = Group2->SpinBox_DY->text();
230     R2 = Group2->SpinBox_DZ->text();
231   }
232   else {
233     R = Group3->SpinBox_DX->text();
234     R1 = Group3->SpinBox_DY->text();
235     R2 = Group3->SpinBox_DZ->text();
236   }
237
238   myConstructorId = constructorId;
239
240   switch (constructorId) {
241   case 0:
242     Group2->hide();
243     Group3->hide();
244     Group1->show();
245     Group1->SpinBox_DX->setText(R);
246     break;
247   case 1:
248     Group1->hide();
249     Group3->hide();
250     Group2->show();
251     Group2->SpinBox_DX->setText(R);
252     Group2->SpinBox_DY->setText(R1);
253     Group2->SpinBox_DZ->setText(R2);
254     break;
255   case 2:
256     Group1->hide();
257     Group2->hide();
258     Group3->show();
259     Group3->SpinBox_DX->setText(R);
260     Group3->SpinBox_DY->setText(R1);
261     Group3->SpinBox_DZ->setText(R2);
262     break;
263   default:
264     break;
265   }
266
267   if      (constructorId == 0) Group1->PushButton1->click();
268   else if (constructorId == 1) Group2->PushButton1->click();
269   else                         Group3->PushButton1->click();
270
271   enableWidgets();
272
273   if (myInitial) {
274     myInitial = false;
275     SelectionIntoArgument();
276   }
277   else {
278     if (!myShape->_is_nil()) {
279       myEditCurrentArgument->setText(GEOMBase::GetName(myShape));
280       GEOMBase_Skeleton::LineEditReturnPressed();
281       switch (getConstructorId()) {
282       case 1:
283         if (myEdges.Extent() == 0)
284           Group2->PushButton2->click();
285         break;
286       case 2:
287         if (myFaces.Extent() == 0)
288           Group3->PushButton2->click();
289         break;
290       default:
291         break;
292       }
293     }
294     else
295       myEditCurrentArgument->setText("");
296
297     processPreview();
298   }
299
300   qApp->processEvents();
301   updateGeometry();
302   resize(minimumSizeHint());
303 }
304
305 //=================================================================================
306 // function : ClickOnOk()
307 // purpose  :
308 //=================================================================================
309 void OperationGUI_FilletDlg::ClickOnOk()
310 {
311   setIsApplyAndClose( true );
312   if (ClickOnApply())
313     ClickOnCancel();
314 }
315
316 //=================================================================================
317 // function : ClickOnApply()
318 // purpose  :
319 //=================================================================================
320 bool OperationGUI_FilletDlg::ClickOnApply()
321 {
322   if (!onAccept())
323     return false;
324
325   initName();
326   // activate selection and connect selection manager
327   ConstructorsClicked(getConstructorId());
328   return true;
329 }
330
331 //=================================================================================
332 // function : SelectionIntoArgument()
333 // purpose  : Called when selection is changed or on dialog initialization or activation
334 //=================================================================================
335 void OperationGUI_FilletDlg::SelectionIntoArgument()
336 {
337   erasePreview();
338   myEditCurrentArgument->setText("");
339
340   LightApp_SelectionMgr* aSelMgr = myGeomGUI->getApp()->selectionMgr();
341   SALOME_ListIO aSelList;
342   aSelMgr->selectedObjects(aSelList);
343
344   // If selection of main object is activated
345   if (myEditCurrentArgument == Group1->LineEdit1 ||
346       myEditCurrentArgument == Group2->LineEdit1 ||
347       myEditCurrentArgument == Group3->LineEdit1)
348   {
349     myShape = GEOM::GEOM_Object::_nil();
350     if (aSelList.Extent() == 1) {
351       GEOM::GEOM_Object_var anObj =
352         GEOMBase::ConvertIOinGEOMObject( aSelList.First() );
353
354       if ( !anObj->_is_nil() ) {
355         myShape = anObj;
356         myEditCurrentArgument->setText(GEOMBase::GetName(anObj));
357         processPreview();
358       }
359     }
360
361     enableWidgets();
362   }
363   // If face or edge selection is activated
364   else if (myEditCurrentArgument == Group2->LineEdit2 ||
365            myEditCurrentArgument == Group3->LineEdit2)
366   {
367     if (myEditCurrentArgument == Group2->LineEdit2) myEdges.Clear();
368     else myFaces.Clear();
369     if (aSelList.Extent() == 1) {
370       GEOM::GEOM_Object_var anObj =
371         GEOMBase::ConvertIOinGEOMObject( aSelList.First() );
372
373       if ( !anObj->_is_nil() ) {
374         TColStd_IndexedMapOfInteger anIndexes;
375         aSelMgr->GetIndexes(aSelList.First(), anIndexes);
376
377         if (anIndexes.Extent() > 0) {
378           QString aName;
379           if (anIndexes.Extent() == 1) {
380             int anIndex = anIndexes(1);
381
382             aName = QString(GEOMBase::GetName(anObj)) + QString(":%1").arg(anIndex);
383           }
384           else {
385             aName = tr("GEOM_MEN_POPUP_NAME").arg(anIndexes.Extent());
386           }
387
388           myEditCurrentArgument->setText(aName);
389
390           if (myConstructorId == 1)
391             myEdges = anIndexes;
392           else
393             myFaces = anIndexes;
394
395           processPreview();
396         }
397       }
398     }
399   }
400
401   // clear selection of the faces or edges
402   if (!(myEditCurrentArgument == Group2->LineEdit2 ||
403         myEditCurrentArgument == Group3->LineEdit2)) {
404     disconnect(myGeomGUI->getApp()->selectionMgr(), 0, this, 0);
405     myGeomGUI->getApp()->selectionMgr()->clearSelected();
406     connect(myGeomGUI->getApp()->selectionMgr(), SIGNAL(currentSelectionChanged()),
407             this, SLOT(SelectionIntoArgument()));
408   }
409
410   switch (getConstructorId()) {
411   case 1:
412     if (myEditCurrentArgument == Group2->LineEdit1) {
413       if (!myShape->_is_nil() && myEdges.Extent() == 0)
414         Group2->PushButton2->click();
415     }
416     break;
417   case 2:
418     if (myEditCurrentArgument == Group3->LineEdit1) {
419       if (!myShape->_is_nil() && myFaces.Extent() == 0)
420         Group3->PushButton2->click();
421     }
422     break;
423   default:
424     break;
425   }
426
427   //rnv: To fix the bug IPAL22041 TC5.1.5: "Fillet Construcion" dialog loses current selection.
428   // Restore selection of the main shape, if need,
429   // because it was canceled.
430   aSelMgr->selectedObjects(aSelList);
431   if (aSelList.Extent() == 0 && !myShape->_is_nil()) {
432     disconnect(myGeomGUI->getApp()->selectionMgr(), 0, this, 0);
433     ObjectList list;
434         list.push_back(myShape);
435     selectObjects(list);
436     connect(myGeomGUI->getApp()->selectionMgr(), SIGNAL(currentSelectionChanged()),
437             this, SLOT(SelectionIntoArgument()));
438   }
439 }
440
441 //=================================================================================
442 // function : SetEditCurrentArgument()
443 // purpose  :
444 //=================================================================================
445 void OperationGUI_FilletDlg::SetEditCurrentArgument()
446 {
447   QPushButton* send = (QPushButton*)sender();
448
449   if (send == Group1->PushButton1) {
450     myEditCurrentArgument = Group1->LineEdit1;
451   }
452   else if (send == Group2->PushButton1) {
453     myEditCurrentArgument = Group2->LineEdit1;
454     Group2->PushButton2->setDown(false);
455     Group2->LineEdit2->setEnabled(false);
456   }
457   else if (send == Group2->PushButton2) {
458     myEditCurrentArgument = Group2->LineEdit2;
459     Group2->PushButton1->setDown(false);
460     Group2->LineEdit1->setEnabled(false);
461   }
462   else if (send == Group3->PushButton1) {
463     myEditCurrentArgument = Group3->LineEdit1;
464     Group3->PushButton2->setDown(false);
465     Group3->LineEdit2->setEnabled(false);
466   }
467   else if (send == Group3->PushButton2) {
468     myEditCurrentArgument = Group3->LineEdit2;
469     Group3->PushButton1->setDown(false);
470     Group3->LineEdit1->setEnabled(false);
471   }
472
473   // enable line edit
474   myEditCurrentArgument->setEnabled(true);
475   myEditCurrentArgument->setFocus();
476   // after setFocus(), because it will be setDown(false) when loses focus
477   send->setDown(true);
478
479   activateSelection();
480
481   // seems we need it only to avoid preview disappearing, caused by selection mode change
482   processPreview();
483 }
484
485 //=================================================================================
486 // function : LineEditReturnPressed()
487 // purpose  :
488 //=================================================================================
489 void OperationGUI_FilletDlg::LineEditReturnPressed()
490 {
491   QLineEdit* send = (QLineEdit*)sender();
492
493   if (send == Group1->LineEdit1)
494     myEditCurrentArgument = Group1->LineEdit1;
495   else if (send == Group2->LineEdit1)
496     myEditCurrentArgument = Group2->LineEdit1;
497   else if (send == Group3->LineEdit1)
498     myEditCurrentArgument = Group3->LineEdit1;
499   else
500     return;
501
502   GEOMBase_Skeleton::LineEditReturnPressed();
503 }
504
505 //=================================================================================
506 // function : ActivateThisDialog()
507 // purpose  :
508 //=================================================================================
509 void OperationGUI_FilletDlg::ActivateThisDialog()
510 {
511   GEOMBase_Skeleton::ActivateThisDialog();
512   connect( myGeomGUI->getApp()->selectionMgr(), SIGNAL( currentSelectionChanged() ),
513            this, SLOT( SelectionIntoArgument() ) );
514
515   ConstructorsClicked( getConstructorId() );
516 }
517
518 //=================================================================================
519 // function : enterEvent()
520 // purpose  :
521 //=================================================================================
522 void OperationGUI_FilletDlg::enterEvent (QEvent*)
523 {
524   if (!mainFrame()->GroupConstructors->isEnabled())
525     this->ActivateThisDialog();
526 }
527
528 //=================================================================================
529 // function : ValueChangedInSpinBox()
530 // purpose  :
531 //=================================================================================
532 void OperationGUI_FilletDlg::ValueChangedInSpinBox (double)
533 {
534   processPreview();
535 }
536
537 //=================================================================================
538 // function : activateSelection
539 // purpose  : Activate selection in accordance with myEditCurrentArgument
540 //=================================================================================
541 void OperationGUI_FilletDlg::activateSelection()
542 {
543   disconnect(myGeomGUI->getApp()->selectionMgr(), 0, this, 0);
544
545   if (!myShape->_is_nil() && myEditCurrentArgument == Group2->LineEdit2)
546     localSelection(myShape, TopAbs_EDGE);
547   else if (!myShape->_is_nil() && myEditCurrentArgument == Group3->LineEdit2)
548     localSelection(myShape, TopAbs_FACE);
549   else {
550     TColStd_MapOfInteger aMap;
551     aMap.Add(GEOM_SHELL);
552     aMap.Add(GEOM_SOLID);
553     aMap.Add(GEOM_COMPOUND);
554     globalSelection(aMap);
555   }
556
557   connect(myGeomGUI->getApp()->selectionMgr(), SIGNAL(currentSelectionChanged()),
558           this, SLOT(SelectionIntoArgument()));
559 }
560
561 //=================================================================================
562 // function : enableWidgets
563 // purpose  : Enable widgets of faces in accordance with value of main object
564 //=================================================================================
565 void OperationGUI_FilletDlg::enableWidgets()
566 {
567   int anId = getConstructorId();
568
569   bool toEnable = !myShape->_is_nil();
570
571   if (anId == 1) {
572     //Group2->LineEdit2->setEnabled(toEnable);
573     Group2->PushButton2->setEnabled(toEnable);
574
575     if (!toEnable) {
576       Group2->LineEdit2->setText("");
577       myEdges.Clear();
578     }
579   }
580   else if (anId == 2) {
581     //Group3->LineEdit2->setEnabled(toEnable);
582     Group3->PushButton2->setEnabled(toEnable);
583
584     if (!toEnable) {
585       Group3->LineEdit2->setText("");
586       myFaces.Clear();
587     }
588   }
589 }
590
591 //=================================================================================
592 // function : createOperation
593 // purpose  :
594 //=================================================================================
595 GEOM::GEOM_IOperations_ptr OperationGUI_FilletDlg::createOperation()
596 {
597   return getGeomEngine()->GetILocalOperations();
598 }
599
600 //=================================================================================
601 // function : isValid()
602 // purpose  : Verify validity of input data
603 //=================================================================================
604 bool OperationGUI_FilletDlg::isValid (QString& msg)
605 {
606   bool ok = true;
607   switch (getConstructorId())
608   {
609     case 0:
610       ok = Group1->SpinBox_DX->isValid( msg, !IsPreview() ) && ok;
611       return !myShape->_is_nil() && ok;
612     case 1:
613       if (Group2->RadioButton1->isChecked())
614         ok = Group2->SpinBox_DX->isValid( msg, !IsPreview() );
615       else
616       {
617         ok = Group2->SpinBox_DY->isValid( msg, !IsPreview() ) && ok;
618         ok = Group2->SpinBox_DZ->isValid( msg, !IsPreview() ) && ok;
619       }
620       return !myShape->_is_nil() && myEdges.Extent() > 0 && ok;
621     case 2:
622       if (Group3->RadioButton1->isChecked())
623         ok = Group3->SpinBox_DX->isValid( msg, !IsPreview() );
624       else
625       {
626         ok = Group3->SpinBox_DY->isValid( msg, !IsPreview() ) && ok;
627         ok = Group3->SpinBox_DZ->isValid( msg, !IsPreview() ) && ok;
628       }
629       return !myShape->_is_nil() && myFaces.Extent() > 0 && ok;
630     default: return false;
631   }
632 }
633
634 //=================================================================================
635 // function : execute
636 // purpose  :
637 //=================================================================================
638 bool OperationGUI_FilletDlg::execute (ObjectList& objects)
639 {
640   QStringList aParameters;
641   GEOM::GEOM_Object_var anObj;
642
643   int anId = getConstructorId();
644
645   GEOM::GEOM_ILocalOperations_var anOper = GEOM::GEOM_ILocalOperations::_narrow(getOperation());
646
647   if (anId == 0) {
648     anObj = anOper->MakeFilletAll(myShape, getRadius());
649     if (!anObj->_is_nil())
650       aParameters << Group1->SpinBox_DX->text();
651   }
652   else if (anId == 1) {
653     GEOM::ListOfLong_var aList = new GEOM::ListOfLong;
654     aList->length(myEdges.Extent());
655
656     for (int i = 1, n = myEdges.Extent(); i <= n; i++)
657       aList[ i - 1 ] = myEdges(i);
658
659     if (Group2->RadioButton1->isChecked())
660     {
661       anObj = anOper->MakeFilletEdges(myShape, getRadius(), aList);
662       if (!anObj->_is_nil())
663         aParameters << Group2->SpinBox_DX->text();
664     }
665     else
666     {
667       anObj = anOper->MakeFilletEdgesR1R2(myShape,
668                                           Group2->SpinBox_DY->value(),
669                                           Group2->SpinBox_DZ->value(),
670                                           aList);
671       if (!anObj->_is_nil())
672       {
673         aParameters << Group2->SpinBox_DY->text();
674         aParameters << Group2->SpinBox_DZ->text();
675       }
676     }
677   }
678   else if (anId == 2) {
679     GEOM::ListOfLong_var aList = new GEOM::ListOfLong;
680     aList->length(myFaces.Extent());
681
682     for (int i = 1, n = myFaces.Extent(); i <= n; i++)
683       aList[ i - 1 ] = myFaces(i);
684
685     if (Group3->RadioButton1->isChecked()) {
686       anObj = anOper->MakeFilletFaces(myShape, getRadius(), aList);
687       if (!anObj->_is_nil())
688         aParameters << Group3->SpinBox_DX->text();
689     }
690     else {
691       anObj = anOper->MakeFilletFacesR1R2(myShape,
692                                           Group3->SpinBox_DY->value(),
693                                           Group3->SpinBox_DZ->value(), aList);
694       if (!anObj->_is_nil())
695       {
696         aParameters << Group3->SpinBox_DY->text();
697         aParameters << Group3->SpinBox_DZ->text();
698       }
699     }
700   }
701
702   if (!anObj->_is_nil())
703   {
704     if (!IsPreview())
705       anObj->SetParameters(aParameters.join(":").toUtf8().constData());
706     objects.push_back(anObj._retn());
707   }
708
709   return true;
710 }
711
712 //=================================================================================
713 // function : getRadius
714 // purpose  : Get radius
715 //=================================================================================
716 double OperationGUI_FilletDlg::getRadius() const
717 {
718   int anId = getConstructorId();
719   if      (anId == 0) return Group1->SpinBox_DX->value();
720   else if (anId == 1) return Group2->SpinBox_DX->value();
721   else                return Group3->SpinBox_DX->value();
722 }
723
724 //=================================================================================
725 // function : RadiobuttonClicked
726 // purpose  :
727 //=================================================================================
728 void OperationGUI_FilletDlg::RadioButtonClicked()
729 {
730   const QObject* s = sender();
731
732   bool flag = s == Group2->RadioButton1 || s == Group3->RadioButton1;
733
734   Group2->RadioButton1->blockSignals(true);
735   Group2->RadioButton2->blockSignals(true);
736   Group3->RadioButton1->blockSignals(true);
737   Group3->RadioButton2->blockSignals(true);
738
739   Group2->SpinBox_DX->setEnabled(flag);
740   Group2->SpinBox_DY->setEnabled(!flag);
741   Group2->SpinBox_DZ->setEnabled(!flag);
742   Group2->RadioButton1->setChecked(flag);
743   Group2->RadioButton2->setChecked(!flag);
744   Group3->SpinBox_DX->setEnabled(flag);
745   Group3->SpinBox_DY->setEnabled(!flag);
746   Group3->SpinBox_DZ->setEnabled(!flag);
747   Group3->RadioButton1->setChecked(flag);
748   Group3->RadioButton2->setChecked(!flag);
749
750   Group2->RadioButton1->blockSignals(false);
751   Group2->RadioButton2->blockSignals(false);
752   Group3->RadioButton1->blockSignals(false);
753   Group3->RadioButton2->blockSignals(false);
754
755   processPreview();
756 }
757
758 //=================================================================================
759 // function : getSourceObjects
760 // purpose  : virtual method to get source objects
761 //=================================================================================
762 QList<GEOM::GeomObjPtr> OperationGUI_FilletDlg::getSourceObjects()
763 {
764   QList<GEOM::GeomObjPtr> res;
765   GEOM::GeomObjPtr aGeomObjPtr(myShape);
766   res << aGeomObjPtr;
767   return res;
768 }