Salome HOME
Merge from BR_WIN_INDUS_514 04/10/2010
[modules/geom.git] / src / PrimitiveGUI / PrimitiveGUI_DiskDlg.cxx
1 //  Copyright (C) 2007-2010  CEA/DEN, EDF R&D, OPEN CASCADE
2 //
3 //  This library is free software; you can redistribute it and/or
4 //  modify it under the terms of the GNU Lesser General Public
5 //  License as published by the Free Software Foundation; either
6 //  version 2.1 of the License.
7 //
8 //  This library is distributed in the hope that it will be useful,
9 //  but WITHOUT ANY WARRANTY; without even the implied warranty of
10 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11 //  Lesser General Public License for more details.
12 //
13 //  You should have received a copy of the GNU Lesser General Public
14 //  License along with this library; if not, write to the Free Software
15 //  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
16 //
17 //  See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18 //
19
20 // GEOM GEOMGUI : GUI for Geometry component
21 // File   : PrimitiveGUI_DiskDlg.cxx
22 // Author : Lucien PIGNOLONI, Open CASCADE S.A.S.
23 //
24 #include "PrimitiveGUI_DiskDlg.h"
25
26 #include <DlgRef.h>
27 #include <GeometryGUI.h>
28 #include <GEOMBase.h>
29
30 #include <SUIT_Session.h>
31 #include <SUIT_ResourceMgr.h>
32 #include <SalomeApp_Application.h>
33 #include <LightApp_SelectionMgr.h>
34
35 // OCCT Includes
36 #include <TopoDS_Shape.hxx>
37 #include <TopoDS_Edge.hxx>
38 #include <TopoDS.hxx>
39 #include <TopExp.hxx>
40 #include <TColStd_IndexedMapOfInteger.hxx>
41 #include <TopTools_IndexedMapOfShape.hxx>
42
43 //=================================================================================
44 // class    : PrimitiveGUI_DiskDlg()
45 // purpose  : Constructs a PrimitiveGUI_DiskDlg which is a child of 'parent', with the
46 //            name 'name' and widget flags set to 'f'.
47 //            The dialog will by default be modeless, unless you set 'modal' to
48 //            TRUE to construct a modal dialog.
49 //=================================================================================
50 PrimitiveGUI_DiskDlg::PrimitiveGUI_DiskDlg (GeometryGUI* theGeometryGUI, QWidget* parent,
51                                             bool modal, Qt::WindowFlags fl)
52   : GEOMBase_Skeleton(theGeometryGUI, parent, modal, fl)
53 {
54   SUIT_ResourceMgr* aResMgr = SUIT_Session::session()->resourceMgr();
55   QPixmap image0 (aResMgr->loadPixmap("GEOM", tr("ICON_DLG_DISK_PNT_VEC_R")));
56   QPixmap image1 (aResMgr->loadPixmap("GEOM", tr("ICON_SELECT")));
57   QPixmap image2 (aResMgr->loadPixmap("GEOM", tr("ICON_DLG_DISK_THREE_POINTS")));
58   QPixmap image3 (aResMgr->loadPixmap("GEOM", tr("ICON_DLG_DISK_R")));
59
60   setWindowTitle(tr("GEOM_DISK_TITLE"));
61
62   /***************************************************************/
63   mainFrame()->GroupConstructors->setTitle(tr("GEOM_DISK"));
64   mainFrame()->RadioButton1->setIcon(image3);
65   mainFrame()->RadioButton2->setIcon(image0);
66   mainFrame()->RadioButton3->setIcon(image2);
67
68   GroupPntVecR = new DlgRef_2Sel1Spin(centralWidget());
69   GroupPntVecR->GroupBox1->setTitle(tr("GEOM_ARGUMENTS"));
70   GroupPntVecR->TextLabel1->setText(tr("GEOM_CENTER_POINT"));
71   GroupPntVecR->TextLabel2->setText(tr("GEOM_VECTOR"));
72   GroupPntVecR->TextLabel3->setText(tr("GEOM_RADIUS"));
73   GroupPntVecR->PushButton1->setIcon(image1);
74   GroupPntVecR->PushButton2->setIcon(image1);
75   GroupPntVecR->LineEdit1->setReadOnly(true);
76   GroupPntVecR->LineEdit2->setReadOnly(true);
77
78   Group3Pnts = new DlgRef_3Sel(centralWidget());
79   Group3Pnts->GroupBox1->setTitle(tr("GEOM_ARGUMENTS"));
80   Group3Pnts->TextLabel1->setText(tr("GEOM_POINT1"));
81   Group3Pnts->TextLabel2->setText(tr("GEOM_POINT2"));
82   Group3Pnts->TextLabel3->setText(tr("GEOM_POINT3"));
83   Group3Pnts->PushButton1->setIcon(image1);
84   Group3Pnts->PushButton2->setIcon(image1);
85   Group3Pnts->PushButton3->setIcon(image1);
86   Group3Pnts->LineEdit1->setReadOnly(true);
87   Group3Pnts->LineEdit2->setReadOnly(true);
88   Group3Pnts->LineEdit3->setReadOnly(true);
89
90   GroupDimensions = new DlgRef_1Spin(centralWidget());
91   GroupDimensions->GroupBox1->setTitle(tr("GEOM_ARGUMENTS"));
92   GroupDimensions->TextLabel1->setText(tr("GEOM_RADIUS"));
93
94   GroupOrientation = new DlgRef_3Radio(centralWidget());
95   GroupOrientation->GroupBox1->setTitle(tr("GEOM_ORIENTATION"));
96   GroupOrientation->RadioButton1->setText(tr("GEOM_WPLANE_OXY"));
97   GroupOrientation->RadioButton2->setText(tr("GEOM_WPLANE_OYZ"));
98   GroupOrientation->RadioButton3->setText(tr("GEOM_WPLANE_OZX"));
99
100   QVBoxLayout* layout = new QVBoxLayout(centralWidget());
101   layout->setMargin(0); layout->setSpacing(6);
102   layout->addWidget(GroupPntVecR);
103   layout->addWidget(Group3Pnts);
104   layout->addWidget(GroupDimensions);
105   layout->addWidget(GroupOrientation);
106   /***************************************************************/
107
108   setHelpFileName("create_disk_page.html");
109
110   Init();
111 }
112
113 //=================================================================================
114 // function : ~PrimitiveGUI_DiskDlg()
115 // purpose  : Destroys the object and frees any allocated resources
116 //=================================================================================
117 PrimitiveGUI_DiskDlg::~PrimitiveGUI_DiskDlg()
118 {
119 }
120
121 //=================================================================================
122 // function : Init()
123 // purpose  :
124 //=================================================================================
125 void PrimitiveGUI_DiskDlg::Init()
126 {
127   // Get setting of step value from file configuration
128   SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
129   double aStep = resMgr->doubleValue("Geometry", "SettingsGeomStep", 100);
130
131   // min, max, step and decimals for spin boxes & initial values
132   initSpinBox(GroupPntVecR->SpinBox_DX, 0.00001, COORD_MAX, aStep, "length_precision" );
133   initSpinBox(GroupDimensions->SpinBox_DX, 0.00001, COORD_MAX, aStep, "length_precision" );
134
135   // init variables
136   myEditCurrentArgument = GroupPntVecR->LineEdit1;
137   myOrientationType = 1;
138   GroupOrientation->RadioButton1->setChecked(true);
139
140   GroupPntVecR->LineEdit1->setText("");
141   GroupPntVecR->LineEdit2->setText("");
142   Group3Pnts->LineEdit1->setText("");
143   Group3Pnts->LineEdit2->setText("");
144   Group3Pnts->LineEdit3->setText("");
145   myPoint = myDir = myPoint1 = myPoint2 = myPoint3 = GEOM::GEOM_Object::_nil();
146
147   GroupPntVecR->SpinBox_DX->setValue(100);
148   GroupDimensions->SpinBox_DX->setValue(100);
149
150   // signals and slots connections
151   connect(buttonOk(),    SIGNAL(clicked()), this, SLOT(ClickOnOk()));
152   connect(buttonApply(), SIGNAL(clicked()), this, SLOT(ClickOnApply()));
153
154   connect(this,          SIGNAL(constructorsClicked(int)), this, SLOT(ConstructorsClicked(int)));
155
156   connect(GroupPntVecR->PushButton1, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
157   connect(GroupPntVecR->PushButton2, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
158
159   connect(GroupPntVecR->LineEdit1, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed()));
160   connect(GroupPntVecR->LineEdit2, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed()));
161
162   connect(Group3Pnts->PushButton1,   SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
163   connect(Group3Pnts->PushButton2,   SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
164   connect(Group3Pnts->PushButton3,   SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
165
166   connect(Group3Pnts->LineEdit1, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed()));
167   connect(Group3Pnts->LineEdit2, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed()));
168   connect(Group3Pnts->LineEdit3, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed()));
169
170   connect(GroupPntVecR->SpinBox_DX,    SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox()));
171   connect(GroupDimensions->SpinBox_DX, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox()));
172
173   connect(GroupOrientation->RadioButton1, SIGNAL(clicked()), this, SLOT(RadioButtonClicked()));
174   connect(GroupOrientation->RadioButton2, SIGNAL(clicked()), this, SLOT(RadioButtonClicked()));
175   connect(GroupOrientation->RadioButton3, SIGNAL(clicked()), this, SLOT(RadioButtonClicked()));
176
177   connect(myGeomGUI, SIGNAL(SignalDefaultStepValueChanged(double)), this, SLOT(SetDoubleSpinBoxStep(double)));
178   connect(myGeomGUI, SIGNAL(SignalCloseAllDialogs()),               this, SLOT(ClickOnCancel()));
179
180   initName(tr("GEOM_DISK"));
181
182   ConstructorsClicked(0);
183 }
184
185 //=================================================================================
186 // function : SetDoubleSpinBoxStep()
187 // purpose  : Double spin box management
188 //=================================================================================
189 void PrimitiveGUI_DiskDlg::SetDoubleSpinBoxStep (double step)
190 {
191   GroupDimensions->SpinBox_DX->setSingleStep(step);
192   GroupPntVecR->SpinBox_DX->setSingleStep(step);
193 }
194
195 //=================================================================================
196 // function : RadioBittonClicked()
197 // purpose  : Radio button management
198 //=================================================================================
199 void PrimitiveGUI_DiskDlg::RadioButtonClicked()
200 {
201   if (GroupOrientation->RadioButton1->isChecked())
202     myOrientationType = 1;
203   else if (GroupOrientation->RadioButton2->isChecked())
204     myOrientationType = 2;
205   else if (GroupOrientation->RadioButton3->isChecked())
206     myOrientationType = 3;
207   displayPreview();
208 }
209
210 //=================================================================================
211 // function : ConstructorsClicked()
212 // purpose  : Radio button management
213 //=================================================================================
214 void PrimitiveGUI_DiskDlg::ConstructorsClicked (int constructorId)
215 {
216   disconnect(myGeomGUI->getApp()->selectionMgr(), 0, this, 0);
217
218   switch (constructorId) {
219   case 0:
220     {
221       GroupPntVecR->hide();
222       Group3Pnts->hide();
223       GroupDimensions->show();
224       GroupOrientation->show();
225
226       disconnect(myGeomGUI->getApp()->selectionMgr(), 0, this, 0);
227       globalSelection(); // close local contexts, if any
228       break;
229     }
230   case 1:
231     {
232       GroupDimensions->hide();
233       GroupOrientation->hide();
234       GroupPntVecR->show();
235       Group3Pnts->hide();
236
237       GroupPntVecR->PushButton1->click();
238       break;
239     }
240   case 2:
241     {
242       GroupDimensions->hide();
243       GroupOrientation->hide();
244       GroupPntVecR->hide();
245       Group3Pnts->show();
246
247       Group3Pnts->PushButton1->click();
248       break;
249     }
250   }
251
252   qApp->processEvents();
253   updateGeometry();
254   resize(minimumSizeHint());
255   SelectionIntoArgument();
256
257   displayPreview();
258 }
259
260 //=================================================================================
261 // function : ClickOnOk()
262 // purpose  :
263 //=================================================================================
264 void PrimitiveGUI_DiskDlg::ClickOnOk()
265 {
266   if (ClickOnApply())
267     ClickOnCancel();
268 }
269
270 //=================================================================================
271 // function : ClickOnApply()
272 // purpose  :
273 //=================================================================================
274 bool PrimitiveGUI_DiskDlg::ClickOnApply()
275 {
276   if (!onAccept())
277     return false;
278
279   initName();
280   // activate selection and connect selection manager
281   ConstructorsClicked(getConstructorId());
282   return true;
283 }
284
285 //=================================================================================
286 // function : SelectionIntoArgument()
287 // purpose  : Called when selection is changed or on dialog initialization or activation
288 //=================================================================================
289 void PrimitiveGUI_DiskDlg::SelectionIntoArgument()
290 {
291   if (getConstructorId() == 0)
292     return;
293
294   erasePreview();
295   myEditCurrentArgument->setText("");
296
297   LightApp_SelectionMgr* aSelMgr = myGeomGUI->getApp()->selectionMgr();
298   SALOME_ListIO aSelList;
299   aSelMgr->selectedObjects(aSelList);
300
301   if (aSelList.Extent() != 1) {
302     if      (myEditCurrentArgument == GroupPntVecR->LineEdit1) myPoint  = GEOM::GEOM_Object::_nil();
303     else if (myEditCurrentArgument == GroupPntVecR->LineEdit2) myDir    = GEOM::GEOM_Object::_nil();
304     else if (myEditCurrentArgument == Group3Pnts->LineEdit1)   myPoint1 = GEOM::GEOM_Object::_nil();
305     else if (myEditCurrentArgument == Group3Pnts->LineEdit2)   myPoint2 = GEOM::GEOM_Object::_nil();
306     else if (myEditCurrentArgument == Group3Pnts->LineEdit3)   myPoint3 = GEOM::GEOM_Object::_nil();
307     return;
308   }
309
310   // nbSel == 1
311   Handle(SALOME_InteractiveObject) anIO = aSelList.First();
312   Standard_Boolean testResult = Standard_False;
313   GEOM::GEOM_Object_var aSelectedObject = GEOMBase::ConvertIOinGEOMObject(anIO, testResult);
314
315   if (!testResult || CORBA::is_nil(aSelectedObject))
316     return;
317
318   QString aName = GEOMBase::GetName(aSelectedObject);
319
320   // If selected Vertex or Edge on the some Shape Get selection Subshape
321   TopoDS_Shape aShape;
322   if (GEOMBase::GetShape(aSelectedObject, aShape, TopAbs_SHAPE) && !aShape.IsNull())
323   {
324     TopAbs_ShapeEnum aNeedType = TopAbs_VERTEX;
325     if (myEditCurrentArgument == GroupPntVecR->LineEdit2)
326       aNeedType = TopAbs_EDGE;
327
328     TColStd_IndexedMapOfInteger aMap;
329     aSelMgr->GetIndexes(anIO, aMap);
330     if (aMap.Extent() == 1) { // Local Selection
331       int anIndex = aMap(1);
332       if (aNeedType == TopAbs_EDGE)
333         aName += QString(":edge_%1").arg(anIndex);
334       else
335         aName += QString(":vertex_%1").arg(anIndex);
336
337       //Find SubShape Object in Father
338       GEOM::GEOM_Object_var aFindedObject = GEOMBase_Helper::findObjectInFather(aSelectedObject, aName);
339
340       if (aFindedObject->_is_nil()) { // Object not found in study
341         GEOM::GEOM_IShapesOperations_var aShapesOp = getGeomEngine()->GetIShapesOperations(getStudyId());
342         aSelectedObject = aShapesOp->GetSubShape(aSelectedObject, anIndex);
343       }
344       else {
345         aSelectedObject = aFindedObject; // get Object from study
346       }
347     }
348     else { // Global Selection
349       if (aShape.ShapeType() != aNeedType) {
350         aSelectedObject = GEOM::GEOM_Object::_nil();
351         aName = "";
352       }
353     }
354   }
355
356   myEditCurrentArgument->setText(aName);
357
358   // clear selection
359   disconnect(myGeomGUI->getApp()->selectionMgr(), 0, this, 0);
360   myGeomGUI->getApp()->selectionMgr()->clearSelected();
361   connect(myGeomGUI->getApp()->selectionMgr(), SIGNAL(currentSelectionChanged()),
362           this, SLOT(SelectionIntoArgument()));
363
364   if (myEditCurrentArgument == GroupPntVecR->LineEdit1) {
365     myPoint = aSelectedObject;
366     if (!myPoint->_is_nil() && myDir->_is_nil())
367       GroupPntVecR->PushButton2->click();
368   }
369   else if (myEditCurrentArgument == GroupPntVecR->LineEdit2) {
370     myDir = aSelectedObject;
371     if (!myDir->_is_nil() && myPoint->_is_nil())
372       GroupPntVecR->PushButton1->click();
373   }
374   else if (myEditCurrentArgument == Group3Pnts->LineEdit1) {
375     myPoint1 = aSelectedObject;
376     if (!myPoint1->_is_nil() && myPoint2->_is_nil())
377       Group3Pnts->PushButton2->click();
378   }
379   else if (myEditCurrentArgument == Group3Pnts->LineEdit2) {
380     myPoint2 = aSelectedObject;
381     if (!myPoint2->_is_nil() && myPoint3->_is_nil())
382       Group3Pnts->PushButton3->click();
383   }
384   else if (myEditCurrentArgument == Group3Pnts->LineEdit3) {
385     myPoint3 = aSelectedObject;
386     if (!myPoint3->_is_nil() && myPoint1->_is_nil())
387       Group3Pnts->PushButton1->click();
388   }
389
390   displayPreview();
391 }
392
393 //=================================================================================
394 // function : SetEditCurrentArgument()
395 // purpose  :
396 //=================================================================================
397 void PrimitiveGUI_DiskDlg::SetEditCurrentArgument()
398 {
399   QPushButton* send = (QPushButton*)sender();
400
401   if (send == GroupPntVecR->PushButton1) {
402     myEditCurrentArgument = GroupPntVecR->LineEdit1;
403
404     GroupPntVecR->PushButton2->setDown(false);
405     GroupPntVecR->LineEdit2->setEnabled(false);
406   }
407   else if (send == GroupPntVecR->PushButton2) {
408     myEditCurrentArgument = GroupPntVecR->LineEdit2;
409
410     GroupPntVecR->PushButton1->setDown(false);
411     GroupPntVecR->LineEdit1->setEnabled(false);
412   }
413   else if (send == Group3Pnts->PushButton1) {
414     myEditCurrentArgument = Group3Pnts->LineEdit1;
415
416     Group3Pnts->PushButton2->setDown(false);
417     Group3Pnts->PushButton3->setDown(false);
418     Group3Pnts->LineEdit2->setEnabled(false);
419     Group3Pnts->LineEdit3->setEnabled(false);
420   }
421   else if (send == Group3Pnts->PushButton2) {
422     myEditCurrentArgument = Group3Pnts->LineEdit2;
423
424     Group3Pnts->PushButton1->setDown(false);
425     Group3Pnts->PushButton3->setDown(false);
426     Group3Pnts->LineEdit1->setEnabled(false);
427     Group3Pnts->LineEdit3->setEnabled(false);
428   }
429   else if (send == Group3Pnts->PushButton3) {
430     myEditCurrentArgument = Group3Pnts->LineEdit3;
431
432     Group3Pnts->PushButton1->setDown(false);
433     Group3Pnts->PushButton2->setDown(false);
434     Group3Pnts->LineEdit1->setEnabled(false);
435     Group3Pnts->LineEdit2->setEnabled(false);
436   }
437
438   disconnect(myGeomGUI->getApp()->selectionMgr(), 0, this, 0);
439   if (myEditCurrentArgument == GroupPntVecR->LineEdit2) {
440     globalSelection(); // close local contexts, if any
441     localSelection(GEOM::GEOM_Object::_nil(), TopAbs_EDGE);
442   }
443   else {
444     globalSelection(); // close local contexts, if any
445     localSelection(GEOM::GEOM_Object::_nil(), TopAbs_VERTEX);
446   }
447   connect(myGeomGUI->getApp()->selectionMgr(), SIGNAL(currentSelectionChanged()),
448           this, SLOT(SelectionIntoArgument()));
449
450   // enable line edit
451   myEditCurrentArgument->setEnabled(true);
452   myEditCurrentArgument->setFocus();
453   // after setFocus(), because it will be setDown(false) when loses focus
454   send->setDown(true);
455
456   // seems we need it only to avoid preview disappearing, caused by selection mode change
457   displayPreview();
458 }
459
460 //=================================================================================
461 // function : LineEditReturnPressed()
462 // purpose  :
463 //=================================================================================
464 void PrimitiveGUI_DiskDlg::LineEditReturnPressed()
465 {
466 QLineEdit* send = (QLineEdit*)sender();
467   if (send == GroupPntVecR->LineEdit1 ||
468       send == GroupPntVecR->LineEdit2 ||
469       send == Group3Pnts->LineEdit1 ||
470       send == Group3Pnts->LineEdit2 ||
471       send == Group3Pnts->LineEdit3) {
472     myEditCurrentArgument = send;
473     GEOMBase_Skeleton::LineEditReturnPressed();
474   }
475 }
476
477 //=================================================================================
478 // function : ActivateThisDialog()
479 // purpose  :
480 //=================================================================================
481 void PrimitiveGUI_DiskDlg::ActivateThisDialog()
482 {
483   GEOMBase_Skeleton::ActivateThisDialog();
484   connect( myGeomGUI->getApp()->selectionMgr(), SIGNAL( currentSelectionChanged() ),
485            this, SLOT( SelectionIntoArgument() ) );
486
487   ConstructorsClicked( getConstructorId() );
488 }
489
490 //=================================================================================
491 // function : enterEvent()
492 // purpose  :
493 //=================================================================================
494 void PrimitiveGUI_DiskDlg::enterEvent (QEvent*)
495 {
496   if (!mainFrame()->GroupConstructors->isEnabled())
497     ActivateThisDialog();
498 }
499
500 //=================================================================================
501 // function : ValueChangedInSpinBox()
502 // purpose  :
503 //=================================================================================
504 void PrimitiveGUI_DiskDlg::ValueChangedInSpinBox()
505 {
506   displayPreview();
507 }
508
509 //=================================================================================
510 // function : createOperation
511 // purpose  :
512 //=================================================================================
513 GEOM::GEOM_IOperations_ptr PrimitiveGUI_DiskDlg::createOperation()
514 {
515   return getGeomEngine()->GetI3DPrimOperations(getStudyId());
516 }
517
518 //=================================================================================
519 // function : isEqual
520 // purpose  : it may also be needed to check for min distance between gp_Pnt-s...
521 //=================================================================================
522 static bool isEqual (const GEOM::GEOM_Object_var& thePnt1, const GEOM::GEOM_Object_var& thePnt2)
523 {
524   return thePnt1->_is_equivalent(thePnt2);
525 }
526
527 //=================================================================================
528 // function : isValid
529 // purpose  :
530 //=================================================================================
531 bool PrimitiveGUI_DiskDlg::isValid (QString& msg)
532 {
533   bool ok = true;
534   if( getConstructorId() == 0 )
535     ok = GroupDimensions->SpinBox_DX->isValid( msg, !IsPreview() ) && ok;
536   else if( getConstructorId() == 1 )
537     ok = GroupPntVecR->SpinBox_DX->isValid( msg, !IsPreview() ) && ok;
538
539   const int id = getConstructorId();
540   if (id == 0)
541     return ok;
542   else if (id == 1)
543     return !myPoint->_is_nil() && !myDir->_is_nil() && getRadius() > 0 && ok;
544   else if (id == 2)
545     return !myPoint1->_is_nil() && !myPoint2->_is_nil() && !myPoint3->_is_nil() &&
546       !isEqual(myPoint1, myPoint2) && !isEqual(myPoint1, myPoint3) && !isEqual(myPoint2, myPoint3);
547   return false;
548 }
549
550 //=================================================================================
551 // function : execute
552 // purpose  :
553 //=================================================================================
554 bool PrimitiveGUI_DiskDlg::execute (ObjectList& objects)
555 {
556   bool res = false;
557   QStringList aParameters;
558
559   GEOM::GEOM_Object_var anObj;
560
561   GEOM::GEOM_I3DPrimOperations_var anOper = GEOM::GEOM_I3DPrimOperations::_narrow(getOperation());
562
563   switch (getConstructorId()) {
564   case 0:
565     anObj = anOper->MakeDiskR(getRadius(), myOrientationType);
566     if (!anObj->_is_nil() && !IsPreview())
567     {
568       aParameters << GroupDimensions->SpinBox_DX->text();
569       anObj->SetParameters(aParameters.join(":").toLatin1().constData());
570     }
571     res = true;
572     break;
573   case 1:
574     anObj = anOper->MakeDiskPntVecR(myPoint, myDir, getRadius());
575     if (!anObj->_is_nil() && !IsPreview())
576     {
577       aParameters << GroupPntVecR->SpinBox_DX->text();
578       anObj->SetParameters(aParameters.join(":").toLatin1().constData());
579     }
580     res = true;
581     break;
582   case 2:
583     anObj = anOper->MakeDiskThreePnt(myPoint1, myPoint2, myPoint3);
584     res = true;
585     break;
586   }
587
588   if (!anObj->_is_nil())
589     objects.push_back(anObj._retn());
590
591   return res;
592 }
593
594 //=================================================================================
595 // function : getRadius()
596 // purpose  :
597 //=================================================================================
598 double PrimitiveGUI_DiskDlg::getRadius() const
599 {
600   double r = 0.;
601   switch (getConstructorId()) {
602   case 0:
603     r = GroupDimensions->SpinBox_DX->value(); break;
604   case 1:
605     r = GroupPntVecR->SpinBox_DX->value(); break;
606   }
607   return r;
608 }
609
610 //=================================================================================
611 // function : addSubshapeToStudy
612 // purpose  : virtual method to add new SubObjects if local selection
613 //=================================================================================
614 void PrimitiveGUI_DiskDlg::addSubshapesToStudy()
615 {
616   QMap<QString, GEOM::GEOM_Object_var> objMap;
617
618   switch (getConstructorId()) {
619   case 1:
620     objMap[GroupPntVecR->LineEdit1->text()] = myPoint;
621     objMap[GroupPntVecR->LineEdit2->text()] = myDir;
622     break;
623   case 2:
624     objMap[Group3Pnts->LineEdit1->text()] = myPoint1;
625     objMap[Group3Pnts->LineEdit2->text()] = myPoint2;
626     objMap[Group3Pnts->LineEdit3->text()] = myPoint3;
627     break;
628   }
629   addSubshapesToFather(objMap);
630 }