Salome HOME
Code refactoring
[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   GEOM::GEOM_Object_var aSelectedObject = GEOMBase::ConvertIOinGEOMObject( anIO );
313
314   if ( CORBA::is_nil(aSelectedObject) )
315     return;
316
317   QString aName = GEOMBase::GetName(aSelectedObject);
318
319   // If selected Vertex or Edge on the some Shape Get selection Subshape
320   TopoDS_Shape aShape;
321   if (GEOMBase::GetShape(aSelectedObject, aShape, TopAbs_SHAPE) && !aShape.IsNull())
322   {
323     TopAbs_ShapeEnum aNeedType = TopAbs_VERTEX;
324     if (myEditCurrentArgument == GroupPntVecR->LineEdit2)
325       aNeedType = TopAbs_EDGE;
326
327     TColStd_IndexedMapOfInteger aMap;
328     aSelMgr->GetIndexes(anIO, aMap);
329     if (aMap.Extent() == 1) { // Local Selection
330       int anIndex = aMap(1);
331       if (aNeedType == TopAbs_EDGE)
332         aName += QString(":edge_%1").arg(anIndex);
333       else
334         aName += QString(":vertex_%1").arg(anIndex);
335
336       //Find SubShape Object in Father
337       GEOM::GEOM_Object_var aFindedObject = GEOMBase_Helper::findObjectInFather(aSelectedObject, aName);
338
339       if (aFindedObject->_is_nil()) { // Object not found in study
340         GEOM::GEOM_IShapesOperations_var aShapesOp = getGeomEngine()->GetIShapesOperations(getStudyId());
341         aSelectedObject = aShapesOp->GetSubShape(aSelectedObject, anIndex);
342       }
343       else {
344         aSelectedObject = aFindedObject; // get Object from study
345       }
346     }
347     else { // Global Selection
348       if (aShape.ShapeType() != aNeedType) {
349         aSelectedObject = GEOM::GEOM_Object::_nil();
350         aName = "";
351       }
352     }
353   }
354
355   myEditCurrentArgument->setText(aName);
356
357   // clear selection
358   disconnect(myGeomGUI->getApp()->selectionMgr(), 0, this, 0);
359   myGeomGUI->getApp()->selectionMgr()->clearSelected();
360   connect(myGeomGUI->getApp()->selectionMgr(), SIGNAL(currentSelectionChanged()),
361           this, SLOT(SelectionIntoArgument()));
362
363   if (myEditCurrentArgument == GroupPntVecR->LineEdit1) {
364     myPoint = aSelectedObject;
365     if (!myPoint->_is_nil() && myDir->_is_nil())
366       GroupPntVecR->PushButton2->click();
367   }
368   else if (myEditCurrentArgument == GroupPntVecR->LineEdit2) {
369     myDir = aSelectedObject;
370     if (!myDir->_is_nil() && myPoint->_is_nil())
371       GroupPntVecR->PushButton1->click();
372   }
373   else if (myEditCurrentArgument == Group3Pnts->LineEdit1) {
374     myPoint1 = aSelectedObject;
375     if (!myPoint1->_is_nil() && myPoint2->_is_nil())
376       Group3Pnts->PushButton2->click();
377   }
378   else if (myEditCurrentArgument == Group3Pnts->LineEdit2) {
379     myPoint2 = aSelectedObject;
380     if (!myPoint2->_is_nil() && myPoint3->_is_nil())
381       Group3Pnts->PushButton3->click();
382   }
383   else if (myEditCurrentArgument == Group3Pnts->LineEdit3) {
384     myPoint3 = aSelectedObject;
385     if (!myPoint3->_is_nil() && myPoint1->_is_nil())
386       Group3Pnts->PushButton1->click();
387   }
388
389   displayPreview();
390 }
391
392 //=================================================================================
393 // function : SetEditCurrentArgument()
394 // purpose  :
395 //=================================================================================
396 void PrimitiveGUI_DiskDlg::SetEditCurrentArgument()
397 {
398   QPushButton* send = (QPushButton*)sender();
399
400   if (send == GroupPntVecR->PushButton1) {
401     myEditCurrentArgument = GroupPntVecR->LineEdit1;
402
403     GroupPntVecR->PushButton2->setDown(false);
404     GroupPntVecR->LineEdit2->setEnabled(false);
405   }
406   else if (send == GroupPntVecR->PushButton2) {
407     myEditCurrentArgument = GroupPntVecR->LineEdit2;
408
409     GroupPntVecR->PushButton1->setDown(false);
410     GroupPntVecR->LineEdit1->setEnabled(false);
411   }
412   else if (send == Group3Pnts->PushButton1) {
413     myEditCurrentArgument = Group3Pnts->LineEdit1;
414
415     Group3Pnts->PushButton2->setDown(false);
416     Group3Pnts->PushButton3->setDown(false);
417     Group3Pnts->LineEdit2->setEnabled(false);
418     Group3Pnts->LineEdit3->setEnabled(false);
419   }
420   else if (send == Group3Pnts->PushButton2) {
421     myEditCurrentArgument = Group3Pnts->LineEdit2;
422
423     Group3Pnts->PushButton1->setDown(false);
424     Group3Pnts->PushButton3->setDown(false);
425     Group3Pnts->LineEdit1->setEnabled(false);
426     Group3Pnts->LineEdit3->setEnabled(false);
427   }
428   else if (send == Group3Pnts->PushButton3) {
429     myEditCurrentArgument = Group3Pnts->LineEdit3;
430
431     Group3Pnts->PushButton1->setDown(false);
432     Group3Pnts->PushButton2->setDown(false);
433     Group3Pnts->LineEdit1->setEnabled(false);
434     Group3Pnts->LineEdit2->setEnabled(false);
435   }
436
437   disconnect(myGeomGUI->getApp()->selectionMgr(), 0, this, 0);
438   if (myEditCurrentArgument == GroupPntVecR->LineEdit2) {
439     globalSelection(); // close local contexts, if any
440     localSelection(GEOM::GEOM_Object::_nil(), TopAbs_EDGE);
441   }
442   else {
443     globalSelection(); // close local contexts, if any
444     localSelection(GEOM::GEOM_Object::_nil(), TopAbs_VERTEX);
445   }
446   connect(myGeomGUI->getApp()->selectionMgr(), SIGNAL(currentSelectionChanged()),
447           this, SLOT(SelectionIntoArgument()));
448
449   // enable line edit
450   myEditCurrentArgument->setEnabled(true);
451   myEditCurrentArgument->setFocus();
452   // after setFocus(), because it will be setDown(false) when loses focus
453   send->setDown(true);
454
455   // seems we need it only to avoid preview disappearing, caused by selection mode change
456   displayPreview();
457 }
458
459 //=================================================================================
460 // function : LineEditReturnPressed()
461 // purpose  :
462 //=================================================================================
463 void PrimitiveGUI_DiskDlg::LineEditReturnPressed()
464 {
465 QLineEdit* send = (QLineEdit*)sender();
466   if (send == GroupPntVecR->LineEdit1 ||
467       send == GroupPntVecR->LineEdit2 ||
468       send == Group3Pnts->LineEdit1 ||
469       send == Group3Pnts->LineEdit2 ||
470       send == Group3Pnts->LineEdit3) {
471     myEditCurrentArgument = send;
472     GEOMBase_Skeleton::LineEditReturnPressed();
473   }
474 }
475
476 //=================================================================================
477 // function : ActivateThisDialog()
478 // purpose  :
479 //=================================================================================
480 void PrimitiveGUI_DiskDlg::ActivateThisDialog()
481 {
482   GEOMBase_Skeleton::ActivateThisDialog();
483   connect( myGeomGUI->getApp()->selectionMgr(), SIGNAL( currentSelectionChanged() ),
484            this, SLOT( SelectionIntoArgument() ) );
485
486   ConstructorsClicked( getConstructorId() );
487 }
488
489 //=================================================================================
490 // function : enterEvent()
491 // purpose  :
492 //=================================================================================
493 void PrimitiveGUI_DiskDlg::enterEvent (QEvent*)
494 {
495   if (!mainFrame()->GroupConstructors->isEnabled())
496     ActivateThisDialog();
497 }
498
499 //=================================================================================
500 // function : ValueChangedInSpinBox()
501 // purpose  :
502 //=================================================================================
503 void PrimitiveGUI_DiskDlg::ValueChangedInSpinBox()
504 {
505   displayPreview();
506 }
507
508 //=================================================================================
509 // function : createOperation
510 // purpose  :
511 //=================================================================================
512 GEOM::GEOM_IOperations_ptr PrimitiveGUI_DiskDlg::createOperation()
513 {
514   return getGeomEngine()->GetI3DPrimOperations(getStudyId());
515 }
516
517 //=================================================================================
518 // function : isEqual
519 // purpose  : it may also be needed to check for min distance between gp_Pnt-s...
520 //=================================================================================
521 static bool isEqual (const GEOM::GEOM_Object_var& thePnt1, const GEOM::GEOM_Object_var& thePnt2)
522 {
523   return thePnt1->_is_equivalent(thePnt2);
524 }
525
526 //=================================================================================
527 // function : isValid
528 // purpose  :
529 //=================================================================================
530 bool PrimitiveGUI_DiskDlg::isValid (QString& msg)
531 {
532   bool ok = true;
533   if( getConstructorId() == 0 )
534     ok = GroupDimensions->SpinBox_DX->isValid( msg, !IsPreview() ) && ok;
535   else if( getConstructorId() == 1 )
536     ok = GroupPntVecR->SpinBox_DX->isValid( msg, !IsPreview() ) && ok;
537
538   const int id = getConstructorId();
539   if (id == 0)
540     return ok;
541   else if (id == 1)
542     return !myPoint->_is_nil() && !myDir->_is_nil() && getRadius() > 0 && ok;
543   else if (id == 2)
544     return !myPoint1->_is_nil() && !myPoint2->_is_nil() && !myPoint3->_is_nil() &&
545       !isEqual(myPoint1, myPoint2) && !isEqual(myPoint1, myPoint3) && !isEqual(myPoint2, myPoint3);
546   return false;
547 }
548
549 //=================================================================================
550 // function : execute
551 // purpose  :
552 //=================================================================================
553 bool PrimitiveGUI_DiskDlg::execute (ObjectList& objects)
554 {
555   bool res = false;
556   QStringList aParameters;
557
558   GEOM::GEOM_Object_var anObj;
559
560   GEOM::GEOM_I3DPrimOperations_var anOper = GEOM::GEOM_I3DPrimOperations::_narrow(getOperation());
561
562   switch (getConstructorId()) {
563   case 0:
564     anObj = anOper->MakeDiskR(getRadius(), myOrientationType);
565     if (!anObj->_is_nil() && !IsPreview())
566     {
567       aParameters << GroupDimensions->SpinBox_DX->text();
568       anObj->SetParameters(aParameters.join(":").toLatin1().constData());
569     }
570     res = true;
571     break;
572   case 1:
573     anObj = anOper->MakeDiskPntVecR(myPoint, myDir, getRadius());
574     if (!anObj->_is_nil() && !IsPreview())
575     {
576       aParameters << GroupPntVecR->SpinBox_DX->text();
577       anObj->SetParameters(aParameters.join(":").toLatin1().constData());
578     }
579     res = true;
580     break;
581   case 2:
582     anObj = anOper->MakeDiskThreePnt(myPoint1, myPoint2, myPoint3);
583     res = true;
584     break;
585   }
586
587   if (!anObj->_is_nil())
588     objects.push_back(anObj._retn());
589
590   return res;
591 }
592
593 //=================================================================================
594 // function : getRadius()
595 // purpose  :
596 //=================================================================================
597 double PrimitiveGUI_DiskDlg::getRadius() const
598 {
599   double r = 0.;
600   switch (getConstructorId()) {
601   case 0:
602     r = GroupDimensions->SpinBox_DX->value(); break;
603   case 1:
604     r = GroupPntVecR->SpinBox_DX->value(); break;
605   }
606   return r;
607 }
608
609 //=================================================================================
610 // function : addSubshapeToStudy
611 // purpose  : virtual method to add new SubObjects if local selection
612 //=================================================================================
613 void PrimitiveGUI_DiskDlg::addSubshapesToStudy()
614 {
615   QMap<QString, GEOM::GEOM_Object_var> objMap;
616
617   switch (getConstructorId()) {
618   case 1:
619     objMap[GroupPntVecR->LineEdit1->text()] = myPoint;
620     objMap[GroupPntVecR->LineEdit2->text()] = myDir;
621     break;
622   case 2:
623     objMap[Group3Pnts->LineEdit1->text()] = myPoint1;
624     objMap[Group3Pnts->LineEdit2->text()] = myPoint2;
625     objMap[Group3Pnts->LineEdit3->text()] = myPoint3;
626     break;
627   }
628   addSubshapesToFather(objMap);
629 }