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