Salome HOME
Bug 0020374: Partition operation leads to missing volume. A fix by PKV.
[modules/geom.git] / src / BasicGUI / BasicGUI_PlaneDlg.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   : BasicGUI_PlaneDlg.cxx
24 //  Author : Lucien PIGNOLONI
25 //  Module : GEOM
26 //  $Header$
27 //
28 #include "BasicGUI_PlaneDlg.h"
29
30 #include "SUIT_Desktop.h"
31 #include "SUIT_Session.h"
32 #include "SalomeApp_Application.h"
33 #include "LightApp_SelectionMgr.h"
34
35 #include <TColStd_MapOfInteger.hxx>
36
37 #include <TopoDS_Shape.hxx>
38 #include <TopoDS_Edge.hxx>
39 #include <TopoDS.hxx>
40 #include <TopExp.hxx>
41 #include <TColStd_IndexedMapOfInteger.hxx>
42 #include <TopTools_IndexedMapOfShape.hxx>
43
44 #include <qlabel.h>
45
46 #include "GEOMImpl_Types.hxx"
47
48 using namespace std;
49
50 //=================================================================================
51 // class    : BasicGUI_PlaneDlg()
52 // purpose  : Constructs a BasicGUI_PlaneDlg which is a child of 'parent', with the
53 //            name 'name' and widget flags set to 'f'.
54 //            The dialog will by default be modeless, unless you set 'modal' to
55 //            TRUE to construct a modal dialog.
56 //=================================================================================
57 BasicGUI_PlaneDlg::BasicGUI_PlaneDlg(GeometryGUI* theGeometryGUI, QWidget* parent,
58                                      const char* name, bool modal, WFlags fl)
59   :GEOMBase_Skeleton(theGeometryGUI, parent, name, modal, WStyle_Customize |
60                      WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu)
61 {
62   QPixmap image0(SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM",tr("ICON_DLG_PLANE_PV")));
63   QPixmap image1(SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM",tr("ICON_DLG_PLANE_3PNTS")));
64   QPixmap image2(SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM",tr("ICON_DLG_PLANE_FACE")));
65   QPixmap image3(SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM",tr("ICON_SELECT")));
66
67   setCaption(tr("GEOM_PLANE_TITLE"));
68
69   /***************************************************************/
70   GroupConstructors->setTitle(tr("GEOM_PLANE"));
71   RadioButton1->setPixmap(image0);
72   RadioButton2->setPixmap(image1);
73   RadioButton3->setPixmap(image2);
74
75   GroupPntDir = new DlgRef_2Sel1Spin(this, "GroupPointDirection");
76   GroupPntDir->GroupBox1->setTitle(tr("GEOM_PLANE_PV"));
77   GroupPntDir->TextLabel1->setText(tr("GEOM_POINT"));
78   GroupPntDir->TextLabel2->setText(tr("GEOM_VECTOR"));
79   GroupPntDir->TextLabel3->setText(tr("GEOM_PLANE_SIZE"));
80   GroupPntDir->PushButton1->setPixmap(image3);
81   GroupPntDir->PushButton2->setPixmap(image3);
82   GroupPntDir->LineEdit1->setReadOnly( true );
83   GroupPntDir->LineEdit2->setReadOnly( true );
84
85   Group3Pnts = new DlgRef_3Sel1Spin(this, "Group3Pnts");
86   Group3Pnts->GroupBox1->setTitle(tr("GEOM_3_POINTS"));
87   Group3Pnts->TextLabel1->setText(tr("GEOM_POINT1"));
88   Group3Pnts->TextLabel2->setText(tr("GEOM_POINT2"));
89   Group3Pnts->TextLabel3->setText(tr("GEOM_POINT3"));
90   Group3Pnts->TextLabel4->setText(tr("GEOM_PLANE_SIZE"));
91   Group3Pnts->PushButton1->setPixmap(image3);
92   Group3Pnts->PushButton2->setPixmap(image3);
93   Group3Pnts->PushButton3->setPixmap(image3);
94
95   Group3Pnts->LineEdit1->setReadOnly( true );
96   Group3Pnts->LineEdit2->setReadOnly( true );
97   Group3Pnts->LineEdit3->setReadOnly( true );
98
99   GroupFace = new DlgRef_1Sel1Spin(this, "GroupFace");
100   GroupFace->GroupBox1->setTitle(tr("GEOM_FACE_OR_LCS"));
101   GroupFace->TextLabel1->setText(tr("GEOM_SELECTION"));
102   GroupFace->TextLabel2->setText(tr("GEOM_PLANE_SIZE"));
103   GroupFace->PushButton1->setPixmap(image3);
104
105   GroupFace->LineEdit1->setReadOnly( true );
106
107   Layout1->addWidget(GroupPntDir, 2, 0);
108   Layout1->addWidget(Group3Pnts, 2, 0);
109   Layout1->addWidget(GroupFace, 2, 0);
110   /***************************************************************/
111
112   setHelpFileName("create_plane_page.html");
113
114   Init();
115 }
116
117
118 //=================================================================================
119 // function : ~BasicGUI_PlaneDlg()
120 // purpose  : Destroys the object and frees any allocated resources
121 //=================================================================================
122 BasicGUI_PlaneDlg::~BasicGUI_PlaneDlg()
123 {
124 }
125
126
127 //=================================================================================
128 // function : Init()
129 // purpose  :
130 //=================================================================================
131 void BasicGUI_PlaneDlg::Init()
132 {
133   /* init variables */
134   myEditCurrentArgument = GroupPntDir->LineEdit1;
135
136   myPoint = myDir = myPoint1 = myPoint2 = myPoint3 = myFace = GEOM::GEOM_Object::_nil();
137
138   // myGeomGUI->SetState( 0 );
139
140   /* Get setting of step value from file configuration */
141   SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
142   double aStep = resMgr->doubleValue( "Geometry", "SettingsGeomStep", 100);
143
144   double aTrimSize = 2000.0;
145
146   /* min, max, step and decimals for spin boxes */
147   GroupPntDir->SpinBox_DX->RangeStepAndValidator(0.001, COORD_MAX, aStep, DBL_DIGITS_DISPLAY);
148   GroupPntDir->SpinBox_DX->SetValue( aTrimSize );
149   Group3Pnts->SpinBox_DX->RangeStepAndValidator(0.001, COORD_MAX, aStep, DBL_DIGITS_DISPLAY);
150   Group3Pnts->SpinBox_DX->SetValue( aTrimSize );
151   GroupFace->SpinBox_DX->RangeStepAndValidator(0.001, COORD_MAX, aStep, DBL_DIGITS_DISPLAY);
152   GroupFace->SpinBox_DX->SetValue( aTrimSize );
153
154   /* signals and slots connections */
155   connect(buttonCancel, SIGNAL(clicked()), this, SLOT(ClickOnCancel()));
156   connect(myGeomGUI, SIGNAL(SignalDeactivateActiveDialog()), this, SLOT(DeactivateActiveDialog()));
157   connect(myGeomGUI, SIGNAL(SignalCloseAllDialogs()), this, SLOT(ClickOnCancel()));
158
159   connect(buttonOk, SIGNAL(clicked()), this, SLOT(ClickOnOk()));
160   connect(buttonApply, SIGNAL(clicked()), this, SLOT(ClickOnApply()));
161   connect(GroupConstructors, SIGNAL(clicked(int)), this, SLOT(ConstructorsClicked(int)));
162
163   connect(GroupPntDir->PushButton1, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
164   connect(GroupPntDir->PushButton2, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
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   connect(GroupFace->PushButton1, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
169
170   connect(GroupPntDir->LineEdit1, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed()));
171   connect(GroupPntDir->LineEdit2, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed()));
172   connect(Group3Pnts->LineEdit1, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed()));
173   connect(Group3Pnts->LineEdit2, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed()));
174   connect(Group3Pnts->LineEdit3, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed()));
175   connect(GroupFace->LineEdit1, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed()));
176
177   connect(GroupPntDir->SpinBox_DX, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double)));
178   connect(Group3Pnts->SpinBox_DX, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double)));
179   connect(GroupFace->SpinBox_DX, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double)));
180
181   connect(myGeomGUI, SIGNAL(SignalDefaultStepValueChanged(double)), GroupPntDir->SpinBox_DX, SLOT(SetStep(double)));
182   connect(myGeomGUI, SIGNAL(SignalDefaultStepValueChanged(double)), Group3Pnts->SpinBox_DX, SLOT(SetStep(double)));
183   connect(myGeomGUI, SIGNAL(SignalDefaultStepValueChanged(double)), GroupFace->SpinBox_DX, SLOT(SetStep(double)));
184
185   connect(myGeomGUI->getApp()->selectionMgr(), SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument()));
186
187   initName( tr( "GEOM_PLANE" ) );
188
189   Group3Pnts->hide();
190   GroupFace->hide();
191   ConstructorsClicked( 0 );
192 }
193
194
195 //=================================================================================
196 // function : ConstructorsClicked()
197 // purpose  : Radio button management
198 //=================================================================================
199 void BasicGUI_PlaneDlg::ConstructorsClicked(int constructorId)
200 {
201   disconnect(myGeomGUI->getApp()->selectionMgr(), 0, this, 0);
202   myPoint = myDir = myPoint1 = myPoint2 = myPoint3 = myFace = GEOM::GEOM_Object::_nil();
203
204   switch (constructorId)
205   {
206   case 0: /* plane from a point and a direction (vector, edge...) */
207     {
208       Group3Pnts->hide();
209       GroupFace->hide();
210       resize(0, 0);
211       GroupPntDir->show();
212
213       myEditCurrentArgument = GroupPntDir->LineEdit1;
214       GroupPntDir->LineEdit1->setText(tr(""));
215       GroupPntDir->LineEdit2->setText(tr(""));
216
217       /* for the first argument */
218       globalSelection(); // close local contexts, if any
219       localSelection( GEOM::GEOM_Object::_nil(), TopAbs_VERTEX );
220       break;
221     }
222   case 1: /* plane from 3 points */
223     {
224       GroupPntDir->hide();
225       GroupFace->hide();
226       resize(0, 0);
227       Group3Pnts->show();
228
229       myEditCurrentArgument = Group3Pnts->LineEdit1;
230       Group3Pnts->LineEdit1->setText("");
231       Group3Pnts->LineEdit2->setText("");
232       Group3Pnts->LineEdit3->setText("");
233
234       /* for the first argument */
235       globalSelection(); // close local contexts, if any
236       localSelection( GEOM::GEOM_Object::_nil(), TopAbs_VERTEX );
237       break;
238     }
239   case 2: /* plane from a planar face selection */
240     {
241       GroupPntDir->hide();
242       Group3Pnts->hide();
243       resize(0, 0);
244       GroupFace->show();
245
246       myEditCurrentArgument = GroupFace->LineEdit1;
247       GroupFace->LineEdit1->setText(tr(""));
248
249       /* for the first argument */
250       //globalSelection( GEOM_PLANE );
251       TColStd_MapOfInteger aMap;
252       aMap.Add( GEOM_PLANE );
253       aMap.Add( GEOM_MARKER );
254       globalSelection( aMap );
255       break;
256     }
257   }
258
259   myEditCurrentArgument->setFocus();
260   connect(myGeomGUI->getApp()->selectionMgr(), SIGNAL(currentSelectionChanged()),
261           this, SLOT(SelectionIntoArgument()));
262 }
263
264 //=================================================================================
265 // function : ClickOnOk()
266 // purpose  :
267 //=================================================================================
268 void BasicGUI_PlaneDlg::ClickOnOk()
269 {
270   if ( ClickOnApply() )
271     ClickOnCancel();
272 }
273
274 //=================================================================================
275 // function : ClickOnApply()
276 // purpose  :
277 //=================================================================================
278 bool BasicGUI_PlaneDlg::ClickOnApply()
279 {
280   if ( !onAccept() )
281     return false;
282
283   initName();
284   ConstructorsClicked( getConstructorId() );
285   return true;
286 }
287
288 //=======================================================================
289 // function : ClickOnCancel()
290 // purpose  :
291 //=======================================================================
292 void BasicGUI_PlaneDlg::ClickOnCancel()
293 {
294   GEOMBase_Skeleton::ClickOnCancel();
295 }
296
297 //=================================================================================
298 // function : SelectionIntoArgument()
299 // purpose  : Called when selection has changed
300 //=================================================================================
301 void BasicGUI_PlaneDlg::SelectionIntoArgument()
302 {
303   myEditCurrentArgument->setText("");
304
305   if (IObjectCount() != 1)
306   {
307     if      ( myEditCurrentArgument == GroupPntDir->LineEdit1 ) myPoint  = GEOM::GEOM_Object::_nil();
308     else if ( myEditCurrentArgument == GroupPntDir->LineEdit2 ) myDir    = GEOM::GEOM_Object::_nil();
309     else if ( myEditCurrentArgument == Group3Pnts->LineEdit1 )  myPoint1 = GEOM::GEOM_Object::_nil();
310     else if ( myEditCurrentArgument == Group3Pnts->LineEdit2 )  myPoint2 = GEOM::GEOM_Object::_nil();
311     else if ( myEditCurrentArgument == Group3Pnts->LineEdit3 )  myPoint3 = GEOM::GEOM_Object::_nil();
312     else if ( myEditCurrentArgument == GroupFace->LineEdit1 )   myFace   = GEOM::GEOM_Object::_nil();
313     return;
314   }
315
316   // nbSel == 1
317   Standard_Boolean aRes = Standard_False;
318   GEOM::GEOM_Object_var aSelectedObject = GEOMBase::ConvertIOinGEOMObject(firstIObject(), aRes);
319   if (!CORBA::is_nil(aSelectedObject) && aRes)
320   {
321     QString aName = GEOMBase::GetName(aSelectedObject);
322
323     TopoDS_Shape aShape;
324     if (GEOMBase::GetShape(aSelectedObject, aShape, TopAbs_SHAPE) && !aShape.IsNull())
325     {
326       TopAbs_ShapeEnum aNeedType = TopAbs_VERTEX;
327       if (myEditCurrentArgument == GroupPntDir->LineEdit2)
328         aNeedType = TopAbs_EDGE;
329       else if (myEditCurrentArgument == GroupFace->LineEdit1)
330         aNeedType = TopAbs_FACE;
331
332       LightApp_SelectionMgr* aSelMgr = myGeomGUI->getApp()->selectionMgr();
333       TColStd_IndexedMapOfInteger aMap;
334       aSelMgr->GetIndexes(firstIObject(), aMap);
335       if (aMap.Extent() == 1) // Local Selection
336       {
337
338         int anIndex = aMap(1);
339         if (aNeedType == TopAbs_EDGE)
340           aName += QString(":edge_%1").arg(anIndex);
341         else if (aNeedType == TopAbs_FACE)
342           aName += QString(":face_%1").arg(anIndex);
343         else
344           aName += QString(":vertex_%1").arg(anIndex);
345
346         //Find SubShape Object in Father
347         GEOM::GEOM_Object_var aFindedObject = GEOMBase_Helper::findObjectInFather(aSelectedObject, aName);
348
349         if ( aFindedObject == GEOM::GEOM_Object::_nil() ) { // Object not found in study
350         GEOM::GEOM_IShapesOperations_var aShapesOp = getGeomEngine()->GetIShapesOperations(getStudyId());
351         aSelectedObject = aShapesOp->GetSubShape(aSelectedObject, anIndex);
352         } 
353         else
354           aSelectedObject = aFindedObject; // get Object from study
355       }
356       else // Global Selection
357       {
358         if (aShape.ShapeType() != aNeedType) {
359           aSelectedObject = GEOM::GEOM_Object::_nil();
360           aName = "";
361         }
362       }
363     }
364
365     myEditCurrentArgument->setText(aName);
366
367     if      ( myEditCurrentArgument == GroupPntDir->LineEdit1 ) myPoint  = aSelectedObject;
368     else if ( myEditCurrentArgument == GroupPntDir->LineEdit2 ) myDir    = aSelectedObject;
369     else if ( myEditCurrentArgument == Group3Pnts->LineEdit1 )  myPoint1 = aSelectedObject;
370     else if ( myEditCurrentArgument == Group3Pnts->LineEdit2 )  myPoint2 = aSelectedObject;
371     else if ( myEditCurrentArgument == Group3Pnts->LineEdit3 )  myPoint3 = aSelectedObject;
372     else if ( myEditCurrentArgument == GroupFace->LineEdit1 )   myFace   = aSelectedObject;
373   }
374
375   displayPreview();
376 }
377
378
379 //=================================================================================
380 // function : SetEditCurrentArgument()
381 // purpose  :
382 //=================================================================================
383 void BasicGUI_PlaneDlg::SetEditCurrentArgument()
384 {
385   QPushButton* send = (QPushButton*)sender();
386   globalSelection( GEOM_POINT );
387
388   if      ( send == GroupPntDir->PushButton1 ) myEditCurrentArgument = GroupPntDir->LineEdit1;
389   else if ( send == GroupPntDir->PushButton2 ) myEditCurrentArgument = GroupPntDir->LineEdit2;
390   else if ( send == Group3Pnts->PushButton1 )  myEditCurrentArgument = Group3Pnts->LineEdit1;
391   else if ( send == Group3Pnts->PushButton2 )  myEditCurrentArgument = Group3Pnts->LineEdit2;
392   else if ( send == Group3Pnts->PushButton3 )  myEditCurrentArgument = Group3Pnts->LineEdit3;
393   else if ( send == GroupFace->PushButton1 )   myEditCurrentArgument = GroupFace->LineEdit1;
394
395   myEditCurrentArgument->setFocus();
396
397   if (myEditCurrentArgument == GroupPntDir->LineEdit2) {
398     globalSelection(); // close local contexts, if any
399     localSelection(GEOM::GEOM_Object::_nil(), TopAbs_EDGE);
400   }
401   else if (myEditCurrentArgument == GroupFace->LineEdit1) {
402     TColStd_MapOfInteger aMap;
403     aMap.Add( GEOM_PLANE );
404     aMap.Add( GEOM_MARKER );
405     globalSelection( aMap );
406   }
407   else { // 3 Pnts
408     globalSelection(); // close local contexts, if any
409     localSelection(GEOM::GEOM_Object::_nil(), TopAbs_VERTEX);
410   }
411
412   SelectionIntoArgument();
413 }
414
415 //=================================================================================
416 // function : LineEditReturnPressed()
417 // purpose  :
418 //=================================================================================
419 void BasicGUI_PlaneDlg::LineEditReturnPressed()
420 {
421   QLineEdit* send = (QLineEdit*)sender();
422   if ( send == GroupPntDir->LineEdit1 ||
423        send == GroupPntDir->LineEdit2 ||
424        send == Group3Pnts->LineEdit1 ||
425        send == Group3Pnts->LineEdit2 ||
426        send == Group3Pnts->LineEdit3 ||
427        send == GroupFace->LineEdit1 )
428   {
429     myEditCurrentArgument = send;
430     GEOMBase_Skeleton::LineEditReturnPressed();
431   }
432 }
433
434 //=================================================================================
435 // function : ActivateThisDialog()
436 // purpose  :
437 //=================================================================================
438 void BasicGUI_PlaneDlg::ActivateThisDialog()
439 {
440   GEOMBase_Skeleton::ActivateThisDialog();
441   connect(myGeomGUI->getApp()->selectionMgr(), SIGNAL(currentSelectionChanged()),
442           this, SLOT(SelectionIntoArgument()));
443
444   ConstructorsClicked(getConstructorId());
445 }
446
447 //=================================================================================
448 // function : DeactivateActiveDialog()
449 // purpose  : public slot to deactivate if active
450 //=================================================================================
451 void BasicGUI_PlaneDlg::DeactivateActiveDialog()
452 {
453   GEOMBase_Skeleton::DeactivateActiveDialog();
454 }
455
456 //=================================================================================
457 // function : enterEvent()
458 // purpose  :
459 //=================================================================================
460 void BasicGUI_PlaneDlg::enterEvent(QEvent* e)
461 {
462   if ( !GroupConstructors->isEnabled() )
463     ActivateThisDialog();
464 }
465
466
467 //=================================================================================
468 // function : ValueChangedInSpinBox()
469 // purpose  :
470 //=================================================================================
471 void BasicGUI_PlaneDlg::ValueChangedInSpinBox(double newValue)
472 {
473   displayPreview();
474 }
475
476 //=================================================================================
477 // function : getSize()
478 // purpose  :
479 //=================================================================================
480 double BasicGUI_PlaneDlg::getSize() const
481 {
482   switch ( getConstructorId() )
483   {
484   case 0 : return GroupPntDir->SpinBox_DX->GetValue();
485   case 1 : return Group3Pnts->SpinBox_DX->GetValue();
486   case 2 : return GroupFace->SpinBox_DX->GetValue();
487   }
488   return 0.;
489 }
490
491 //=================================================================================
492 // function : createOperation
493 // purpose  :
494 //=================================================================================
495 GEOM::GEOM_IOperations_ptr BasicGUI_PlaneDlg::createOperation()
496 {
497   return myGeomGUI->GetGeomGen()->GetIBasicOperations( getStudyId() );
498 }
499
500 //=================================================================================
501 // function : isEqual
502 // purpose  : it may also be needed to check for min distance between gp_Pnt-s...
503 //=================================================================================
504 static bool isEqual( const GEOM::GEOM_Object_var& thePnt1, const GEOM::GEOM_Object_var& thePnt2 )
505 {
506         return thePnt1->_is_equivalent( thePnt2 );
507 }
508
509 //=================================================================================
510 // function : isValid
511 // purpose  :
512 //=================================================================================
513 bool BasicGUI_PlaneDlg::isValid( QString& msg )
514 {
515         const int id = getConstructorId();
516         if ( getSize() <= 0 )
517         {
518                 msg = QString( "Please, enter size greater than 0." );
519                 return false;
520         }
521         if ( id == 0 )
522                 return !CORBA::is_nil( myPoint ) && !CORBA::is_nil( myDir );
523         else if ( id == 1 )
524                 return !CORBA::is_nil( myPoint1  ) && !CORBA::is_nil( myPoint2 ) && !CORBA::is_nil( myPoint3 ) &&
525                        !isEqual( myPoint1, myPoint2 ) && !isEqual( myPoint1, myPoint3 ) && !isEqual( myPoint2, myPoint3 );
526         else if ( id == 2 )
527                 return !CORBA::is_nil( myFace );
528         return false;
529 }
530
531 //=================================================================================
532 // function : execute
533 // purpose  :
534 //=================================================================================
535 bool BasicGUI_PlaneDlg::execute( ObjectList& objects )
536 {
537   bool res = false;
538
539   GEOM::GEOM_Object_var anObj;
540
541   switch ( getConstructorId() )
542   {
543   case 0 :
544     anObj = GEOM::GEOM_IBasicOperations::_narrow( getOperation() )->MakePlanePntVec( myPoint, myDir, getSize() );
545     res = true;
546     break;
547   case 1 :
548     anObj = GEOM::GEOM_IBasicOperations::_narrow( getOperation() )->MakePlaneThreePnt( myPoint1, myPoint2, myPoint3, getSize() );
549     res = true;
550     break;
551   case 2 :
552     anObj = GEOM::GEOM_IBasicOperations::_narrow( getOperation() )->MakePlaneFace( myFace, getSize() );
553     res = true;
554     break;
555   }
556
557   if ( !anObj->_is_nil() )
558     objects.push_back( anObj._retn() );
559
560   return res;
561 }
562
563 //=================================================================================
564 // function : closeEvent
565 // purpose  :
566 //=================================================================================
567 void BasicGUI_PlaneDlg::closeEvent( QCloseEvent* e )
568 {
569   GEOMBase_Skeleton::closeEvent( e );
570 }
571
572 //=================================================================================
573 // function : addSubshapeToStudy
574 // purpose  : virtual method to add new SubObjects if local selection
575 //=================================================================================
576 void BasicGUI_PlaneDlg::addSubshapesToStudy()
577 {
578   QMap<QString, GEOM::GEOM_Object_var> objMap;
579
580 switch (getConstructorId())
581   {
582   case 0:
583     objMap[GroupPntDir->LineEdit1->text()] = myPoint;
584     objMap[GroupPntDir->LineEdit2->text()] = myDir;
585     break;
586   case 1:
587     objMap[Group3Pnts->LineEdit1->text()] = myPoint1;
588     objMap[Group3Pnts->LineEdit2->text()] = myPoint2;
589     objMap[Group3Pnts->LineEdit3->text()] = myPoint3;
590     break;
591   case 2:
592     objMap[GroupFace->LineEdit1->text()] = myFace;
593     break;
594   }
595  addSubshapesToFather( objMap );
596 }