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