Salome HOME
b3572a04c4684e25447d59459dfd157efcb65e52
[modules/geom.git] / src / BasicGUI / BasicGUI_PlaneDlg.cxx
1 // Copyright (C) 2007-2023  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, or (at your option) any later version.
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
23 // GEOM GEOMGUI : GUI for Geometry component
24 // File   : BasicGUI_PlaneDlg.cxx
25 // Author : Lucien PIGNOLONI, Open CASCADE S.A.S.
26 //
27 #include "BasicGUI_PlaneDlg.h"
28
29 #include <DlgRef.h>
30
31 #include <GeometryGUI.h>
32 #include <GEOMBase.h>
33
34 #include <SUIT_ResourceMgr.h>
35 #include <SUIT_Session.h>
36 #include <SalomeApp_Application.h>
37 #include <LightApp_SelectionMgr.h>
38
39 #include <TColStd_MapOfInteger.hxx>
40 #include <TopoDS_Shape.hxx>
41 #include <TopoDS_Edge.hxx>
42 #include <TopoDS.hxx>
43 #include <TopExp.hxx>
44 #include <TColStd_IndexedMapOfInteger.hxx>
45 #include <TopTools_IndexedMapOfShape.hxx>
46
47 #include <GEOMImpl_Types.hxx>
48
49 //=================================================================================
50 // class    : BasicGUI_PlaneDlg()
51 // purpose  : Constructs a BasicGUI_PlaneDlg which is a child of 'parent', with the
52 //            name 'name' and widget flags set to 'f'.
53 //            The dialog will by default be modeless, unless you set 'modal' to
54 //            TRUE to construct a modal dialog.
55 //=================================================================================
56 BasicGUI_PlaneDlg::BasicGUI_PlaneDlg( GeometryGUI* theGeometryGUI, QWidget* parent,
57                                       bool modal, Qt::WindowFlags fl )
58   : GEOMBase_Skeleton( theGeometryGUI, parent, modal, fl )
59 {
60   QPixmap image0( SUIT_Session::session()->resourceMgr()->loadPixmap( "GEOM", tr( "ICON_DLG_PLANE_PV" ) ) );
61   QPixmap image1( SUIT_Session::session()->resourceMgr()->loadPixmap( "GEOM", tr( "ICON_DLG_PLANE_3PNTS" ) ) );
62   QPixmap image2( SUIT_Session::session()->resourceMgr()->loadPixmap( "GEOM", tr( "ICON_DLG_PLANE_FACE" ) ) );
63   QPixmap image3( SUIT_Session::session()->resourceMgr()->loadPixmap( "GEOM", tr( "ICON_SELECT" ) ) );
64   QPixmap image4( SUIT_Session::session()->resourceMgr()->loadPixmap( "GEOM", tr( "ICON_DLG_WPLANE_VECTOR" ) ) );
65   QPixmap image5( SUIT_Session::session()->resourceMgr()->loadPixmap( "GEOM", tr( "ICON_DLG_WPLANE_ORIGIN" ) ) );
66
67   setWindowTitle( tr( "GEOM_PLANE_TITLE" ) );
68
69   /***************************************************************/
70   mainFrame()->GroupConstructors->setTitle( tr( "GEOM_PLANE" ) );
71   mainFrame()->RadioButton1->setIcon( image0 );
72   mainFrame()->RadioButton2->setIcon( image1 );
73   mainFrame()->RadioButton3->setIcon( image2 );
74   mainFrame()->RadioButton4->show();
75   mainFrame()->RadioButton4->setIcon( image4 );
76   mainFrame()->RadioButton5->show();
77   mainFrame()->RadioButton5->setIcon( image5 );
78
79   GroupPntDir = new DlgRef_2Sel1Spin( centralWidget() );
80   GroupPntDir->GroupBox1->setTitle( tr( "GEOM_PLANE_PV" ) );
81   GroupPntDir->TextLabel1->setText( tr( "GEOM_POINT" ) );
82   GroupPntDir->TextLabel2->setText( tr( "GEOM_VECTOR" ) );
83   GroupPntDir->TextLabel3->setText( tr( "GEOM_PLANE_SIZE" ) );
84   GroupPntDir->PushButton1->setIcon( image3 );
85   GroupPntDir->PushButton2->setIcon( image3 );
86   GroupPntDir->LineEdit1->setReadOnly( true );
87   GroupPntDir->LineEdit2->setReadOnly( true );
88   GroupPntDir->PushButton1->setDown( true );
89   GroupPntDir->LineEdit1->setEnabled( true );
90   GroupPntDir->LineEdit2->setEnabled( false );
91
92   Group3Pnts = new DlgRef_3Sel1Spin( centralWidget() );
93   Group3Pnts->GroupBox1->setTitle( tr( "GEOM_3_POINTS" ) );
94   Group3Pnts->TextLabel1->setText( tr( "GEOM_POINT1" ) );
95   Group3Pnts->TextLabel2->setText( tr( "GEOM_POINT2" ) );
96   Group3Pnts->TextLabel3->setText( tr( "GEOM_POINT3" ) );
97   Group3Pnts->TextLabel4->setText( tr( "GEOM_PLANE_SIZE" ) );
98   Group3Pnts->PushButton1->setIcon( image3 );
99   Group3Pnts->PushButton2->setIcon( image3 );
100   Group3Pnts->PushButton3->setIcon( image3 );
101   Group3Pnts->PushButton1->setDown( true );
102
103   Group3Pnts->LineEdit1->setReadOnly( true );
104   Group3Pnts->LineEdit2->setReadOnly( true );
105   Group3Pnts->LineEdit3->setReadOnly( true );
106   Group3Pnts->LineEdit1->setEnabled( true );
107   Group3Pnts->LineEdit2->setEnabled( false );
108   Group3Pnts->LineEdit3->setEnabled( false );
109
110   GroupFace = new DlgRef_1Sel1Spin( centralWidget() );
111   GroupFace->GroupBox1->setTitle( tr( "GEOM_FACE" ) );
112   GroupFace->TextLabel1->setText( tr( "GEOM_SELECTION" ) );
113   GroupFace->TextLabel2->setText( tr( "GEOM_PLANE_SIZE" ) );
114   GroupFace->PushButton1->setIcon( image3 );
115   GroupFace->PushButton1->setDown( true );
116
117   GroupFace->LineEdit1->setReadOnly( true );
118
119   Group2Vec = new DlgRef_2Sel1Spin( centralWidget() );
120
121   Group2Vec->GroupBox1->setTitle( tr( "GEOM_WPLANE_VECTOR" ) );
122   Group2Vec->TextLabel1->setText( tr( "GEOM_WPLANE_VX" ) );
123   Group2Vec->TextLabel2->setText( tr( "GEOM_WPLANE_VZ" ) );
124   Group2Vec->PushButton1->setIcon( image3 );
125   Group2Vec->PushButton2->setIcon( image3 );
126   Group2Vec->LineEdit1->setReadOnly( true );
127   Group2Vec->LineEdit2->setReadOnly( true );
128   Group2Vec->PushButton1->setDown( true );
129   Group2Vec->LineEdit1->setEnabled( true );
130   Group2Vec->LineEdit2->setEnabled( false );
131   Group2Vec->TextLabel3->setText( tr( "GEOM_PLANE_SIZE" ) );
132
133   GroupLCS = new DlgRef_3Radio1Sel1Spin( centralWidget() );
134   GroupLCS->GroupBox1->setTitle( tr( "GEOM_LCS" ) );
135   GroupLCS->TextLabel1->setText( tr( "GEOM_SELECTION" ) );
136   GroupLCS->TextLabel2->setText( tr( "GEOM_PLANE_SIZE" ) );
137   GroupLCS->RadioButton1->setText( tr( "GEOM_WPLANE_OXY" ) );
138   GroupLCS->RadioButton2->setText( tr( "GEOM_WPLANE_OYZ" ) );
139   GroupLCS->RadioButton3->setText( tr( "GEOM_WPLANE_OZX" ) );
140   GroupLCS->LineEdit1->setReadOnly( true );
141   GroupLCS->PushButton1->setIcon( image3 );
142   GroupLCS->PushButton1->setDown( true );
143
144   QVBoxLayout* layout = new QVBoxLayout( centralWidget() );
145   layout->setMargin( 0 ); layout->setSpacing( 6 );
146   layout->addWidget( GroupPntDir );
147   layout->addWidget( Group3Pnts );
148   layout->addWidget( GroupFace );
149   layout->addWidget( Group2Vec );
150   layout->addWidget( GroupLCS );
151   /***************************************************************/
152
153   setHelpFileName( "create_plane_page.html" );
154
155   Init();
156 }
157
158
159 //=================================================================================
160 // function : ~BasicGUI_PlaneDlg()
161 // purpose  : Destroys the object and frees any allocated resources
162 //=================================================================================
163 BasicGUI_PlaneDlg::~BasicGUI_PlaneDlg()
164 {
165 }
166
167
168 //=================================================================================
169 // function : Init()
170 // purpose  :
171 //=================================================================================
172 void BasicGUI_PlaneDlg::Init()
173 {
174   /* init variables */
175   myEditCurrentArgument = GroupPntDir->LineEdit1;
176
177   myPoint.nullify();
178   myDir.nullify();
179   myPoint1.nullify();
180   myPoint2.nullify();
181   myPoint3.nullify();
182   myFace.nullify();
183   myLCS.nullify();
184   myVec1.nullify();
185   myVec2.nullify();
186  
187   // myGeomGUI->SetState( 0 );
188   myOriginType = 1;
189
190   /* Get setting of step value from file configuration */
191   SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
192   double aStep = resMgr->doubleValue( "Geometry", "SettingsGeomStep", 100 );
193
194   double aTrimSize = 2000.0;
195
196   /* min, max, step and decimals for spin boxes */
197   initSpinBox( GroupPntDir->SpinBox_DX, 0.000001, COORD_MAX, aStep, "length_precision" );
198   GroupPntDir->SpinBox_DX->setValue( aTrimSize );
199   initSpinBox( Group3Pnts->SpinBox_DX, 0.000001, COORD_MAX, aStep, "length_precision" );
200   Group3Pnts->SpinBox_DX->setValue( aTrimSize );
201   initSpinBox( GroupFace->SpinBox_DX, 0.000001, COORD_MAX, aStep, "length_precision" );
202   GroupFace->SpinBox_DX->setValue( aTrimSize );
203   initSpinBox( Group2Vec->SpinBox_DX, 0.000001, COORD_MAX, aStep, "length_precision" );
204   Group2Vec->SpinBox_DX->setValue( aTrimSize );
205   initSpinBox( GroupLCS->SpinBox_DX, 0.000001, COORD_MAX, aStep, "length_precision" );
206   GroupLCS->SpinBox_DX->setValue( aTrimSize );
207
208   /* signals and slots connections */
209   connect( myGeomGUI, SIGNAL( SignalDeactivateActiveDialog() ), this, SLOT( DeactivateActiveDialog() ) );
210   connect( myGeomGUI, SIGNAL( SignalCloseAllDialogs() ),        this, SLOT( ClickOnCancel() ) );
211
212   connect( buttonOk(),     SIGNAL( clicked() ), this, SLOT( ClickOnOk() ) );
213   connect( buttonApply(),  SIGNAL( clicked() ), this, SLOT( ClickOnApply() ) );
214
215   connect( this,           SIGNAL( constructorsClicked( int ) ), this, SLOT( ConstructorsClicked( int ) ) );
216
217   connect( GroupPntDir->PushButton1, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) );
218   connect( GroupPntDir->PushButton2, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) );
219   connect( Group3Pnts->PushButton1,  SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) );
220   connect( Group3Pnts->PushButton2,  SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) );
221   connect( Group3Pnts->PushButton3,  SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) );
222   connect( GroupFace->PushButton1,   SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) );
223   connect( Group2Vec->PushButton1,   SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) );
224   connect( Group2Vec->PushButton2,   SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) );
225
226   connect( GroupLCS->RadioButton1,   SIGNAL( clicked() ), this, SLOT( GroupClicked() ) );
227   connect( GroupLCS->RadioButton2,   SIGNAL( clicked() ), this, SLOT( GroupClicked() ) );
228   connect( GroupLCS->RadioButton3,   SIGNAL( clicked() ), this, SLOT( GroupClicked() ) );
229
230   connect( GroupPntDir->SpinBox_DX, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
231   connect( Group3Pnts->SpinBox_DX,  SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
232   connect( GroupFace->SpinBox_DX,   SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
233   connect( Group2Vec->SpinBox_DX,   SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
234   connect( GroupLCS->SpinBox_DX,   SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
235
236   connect( myGeomGUI, SIGNAL( SignalDefaultStepValueChanged( double ) ), this, SLOT( SetDoubleSpinBoxStep( double ) ) );
237
238   connect( myGeomGUI->getApp()->selectionMgr(), SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) );
239
240   initName( tr( "GEOM_PLANE" ) );
241
242   ConstructorsClicked( 0 );
243 }
244
245 //=================================================================================
246 // function : SetDoubleSpinBoxStep()
247 // purpose  : Double spin box management
248 //=================================================================================
249 void BasicGUI_PlaneDlg::SetDoubleSpinBoxStep( double step )
250 {
251   GroupPntDir->SpinBox_DX->setSingleStep(step);
252   Group3Pnts->SpinBox_DX->setSingleStep(step);
253   GroupFace->SpinBox_DX->setSingleStep(step);
254   Group2Vec->SpinBox_DX->setSingleStep(step);
255   GroupLCS->SpinBox_DX->setSingleStep(step);
256 }
257
258 //=================================================================================
259 // function : ConstructorsClicked()
260 // purpose  : Radio button management
261 //=================================================================================
262 void BasicGUI_PlaneDlg::ConstructorsClicked( int constructorId )
263 {
264   disconnect( myGeomGUI->getApp()->selectionMgr(), 0, this, 0 );
265   myPoint.nullify();
266   myDir.nullify();
267   myPoint1.nullify();
268   myPoint2.nullify();
269   myPoint3.nullify();
270   myFace.nullify();
271   myLCS.nullify();
272   myVec1.nullify();
273   myVec2.nullify();
274
275   switch ( constructorId ) {
276   case 0: /* plane from a point and a direction (vector, edge...) */
277     {
278       Group3Pnts->hide();
279       GroupFace->hide();
280       GroupPntDir->show();
281       Group2Vec->hide();
282       GroupLCS->hide();
283       
284       myEditCurrentArgument = GroupPntDir->LineEdit1;
285       GroupPntDir->LineEdit1->setText( "" );
286       GroupPntDir->LineEdit2->setText( "" );
287       GroupPntDir->PushButton1->setDown( true );
288       GroupPntDir->PushButton2->setDown( false );
289       GroupPntDir->LineEdit1->setEnabled( true );
290       GroupPntDir->LineEdit2->setEnabled( false );
291       
292       /* for the first argument */
293       globalSelection(); // close local contexts, if any
294       localSelection( TopAbs_VERTEX );
295       break;
296     }
297   case 1: /* plane from 3 points */
298     {
299       GroupPntDir->hide();
300       GroupFace->hide();
301       Group3Pnts->show();
302       Group2Vec->hide();
303       GroupLCS->hide();
304       
305       myEditCurrentArgument = Group3Pnts->LineEdit1;
306       Group3Pnts->LineEdit1->setText( "" );
307       Group3Pnts->LineEdit2->setText( "" );
308       Group3Pnts->LineEdit3->setText( "" );
309       Group3Pnts->PushButton1->setDown( true );
310       Group3Pnts->PushButton2->setDown( false );
311       Group3Pnts->PushButton3->setDown( false );
312       Group3Pnts->LineEdit1->setEnabled( true );
313       Group3Pnts->LineEdit2->setEnabled( false );
314       Group3Pnts->LineEdit3->setEnabled( false );
315       
316       /* for the first argument */
317       globalSelection(); // close local contexts, if any
318       localSelection( TopAbs_VERTEX );
319       break;
320     }
321   case 2: /* plane from a planar face */
322     {
323       GroupPntDir->hide();
324       Group3Pnts->hide();
325       GroupFace->show();
326       Group2Vec->hide();
327       GroupLCS->hide();
328       
329       myEditCurrentArgument = GroupFace->LineEdit1;
330       GroupFace->LineEdit1->setText( "" );
331       GroupFace->PushButton1->setDown( true );
332       
333       globalSelection(); // close local contexts, if any
334       localSelection( TopAbs_FACE );
335       break;
336     }
337   case 3: /* plane from a 2 Vectors */
338     {
339       GroupPntDir->hide();
340       Group3Pnts->hide();
341       GroupFace->hide();
342       Group2Vec->show();
343       GroupLCS->hide();
344       
345       myEditCurrentArgument = Group2Vec->LineEdit1;
346       Group2Vec->LineEdit1->setText( "" );
347       Group2Vec->PushButton1->setDown( true );
348       
349       globalSelection(); // close local contexts, if any
350       localSelection( TopAbs_EDGE );
351       break;
352     }
353   case 4: /* plane from a LCS */
354     {
355       GroupPntDir->hide();
356       Group3Pnts->hide();
357       GroupFace->hide();
358       Group2Vec->hide();
359       GroupLCS->show();
360       
361       myEditCurrentArgument = GroupLCS->LineEdit1;
362       GroupLCS->LineEdit1->setText( "" );
363       GroupLCS->PushButton1->setDown( true );
364       GroupLCS->RadioButton1->setChecked( true );
365       myOriginType = 1;
366       
367       globalSelection(GEOM_MARKER);
368       break;
369     }
370   }
371   
372   qApp->processEvents();
373   updateGeometry();
374   resize( minimumSizeHint() );
375   SelectionIntoArgument();
376
377   myEditCurrentArgument->setFocus();
378   connect( myGeomGUI->getApp()->selectionMgr(), SIGNAL( currentSelectionChanged() ),
379            this, SLOT( SelectionIntoArgument() ) );
380   displayPreview(true);
381 }
382
383
384 //=================================================================================
385 // function : ClickOnOk()
386 // purpose  :
387 //=================================================================================
388 void BasicGUI_PlaneDlg::ClickOnOk()
389 {
390   setIsApplyAndClose( true );
391   if ( ClickOnApply() )
392     ClickOnCancel();
393 }
394
395
396 //=================================================================================
397 // function : ClickOnApply()
398 // purpose  :
399 //=================================================================================
400 bool BasicGUI_PlaneDlg::ClickOnApply()
401 {
402   if ( !onAccept() )
403     return false;
404
405   initName();
406   ConstructorsClicked( getConstructorId() );
407   return true;
408 }
409
410 //=================================================================================
411 // function : GroupClicked()
412 // purpose  : OX OY OZ Radio button management
413 //=================================================================================
414 void BasicGUI_PlaneDlg::GroupClicked()
415 {
416   QRadioButton* send = (QRadioButton*)sender();
417
418   if ( send == GroupLCS->RadioButton1 )
419     myOriginType = 1;
420   else if ( send == GroupLCS->RadioButton2 )
421     myOriginType = 2;
422   else if ( send == GroupLCS->RadioButton3 )
423     myOriginType = 3;
424   displayPreview(true);
425 }
426
427 //=================================================================================
428 // function : SelectionIntoArgument()
429 // purpose  : Called when selection has changed
430 //=================================================================================
431 void BasicGUI_PlaneDlg::SelectionIntoArgument()
432 {
433   myEditCurrentArgument->setText("");
434
435   LightApp_SelectionMgr* aSelMgr = myGeomGUI->getApp()->selectionMgr();
436   SALOME_ListIO aSelList;
437   aSelMgr->selectedObjects(aSelList);
438
439   if (aSelList.Extent() != 1) {
440     if      ( myEditCurrentArgument == GroupPntDir->LineEdit1 ) myPoint.nullify();
441     else if ( myEditCurrentArgument == GroupPntDir->LineEdit2 ) myDir.nullify();
442     else if ( myEditCurrentArgument == Group3Pnts->LineEdit1 )  myPoint1.nullify();
443     else if ( myEditCurrentArgument == Group3Pnts->LineEdit2 )  myPoint2.nullify();
444     else if ( myEditCurrentArgument == Group3Pnts->LineEdit3 )  myPoint3.nullify();
445     else if ( myEditCurrentArgument == GroupFace->LineEdit1 )   myFace.nullify();
446     else if ( myEditCurrentArgument == Group2Vec->LineEdit1 )   myVec1.nullify();
447     else if ( myEditCurrentArgument == Group2Vec->LineEdit2 )   myVec2.nullify();
448     else if ( myEditCurrentArgument == GroupLCS->LineEdit1 )    myLCS.nullify();
449     displayPreview(true);
450     return;
451   }
452
453   TopAbs_ShapeEnum aNeedType;
454   if ( myEditCurrentArgument == GroupPntDir->LineEdit2 || myEditCurrentArgument == Group2Vec->LineEdit1 || myEditCurrentArgument == Group2Vec->LineEdit2)
455     aNeedType = TopAbs_EDGE;
456   else if ( myEditCurrentArgument == GroupFace->LineEdit1 )
457     aNeedType = TopAbs_FACE;
458   else if ( myEditCurrentArgument == GroupLCS->LineEdit1 )
459     aNeedType = TopAbs_FACE;
460   else
461     aNeedType = TopAbs_VERTEX;
462   GEOM::GeomObjPtr aSelectedObject = getSelected( aNeedType );
463   TopoDS_Shape aShape;
464   if ( aSelectedObject && GEOMBase::GetShape( aSelectedObject.get(), aShape ) && !aShape.IsNull() ) {
465     QString aName = GEOMBase::GetName( aSelectedObject.get() );
466     myEditCurrentArgument->setText( aName );
467     if ( myEditCurrentArgument == GroupPntDir->LineEdit1 ) {
468       myPoint = aSelectedObject;
469       if ( myPoint && !myDir )
470         GroupPntDir->PushButton2->click();
471     }
472     else if ( myEditCurrentArgument == GroupPntDir->LineEdit2 ) {
473       myDir = aSelectedObject;
474       if ( myDir && !myPoint )
475         GroupPntDir->PushButton1->click();
476     }
477     else if ( myEditCurrentArgument == Group3Pnts->LineEdit1 ) {
478       myPoint1 = aSelectedObject;
479       if ( myPoint1 && !myPoint2 )
480         Group3Pnts->PushButton2->click();
481     }
482     else if ( myEditCurrentArgument == Group3Pnts->LineEdit2 ) {
483       myPoint2 = aSelectedObject;
484       if ( myPoint2 && !myPoint3 )
485         Group3Pnts->PushButton3->click();
486     }
487     else if ( myEditCurrentArgument == Group3Pnts->LineEdit3 ) {
488       myPoint3 = aSelectedObject;
489       if ( myPoint3 && !myPoint1 )
490         Group3Pnts->PushButton1->click();
491     }
492     else if ( myEditCurrentArgument == GroupFace->LineEdit1 )
493       myFace   = aSelectedObject;
494     else if ( myEditCurrentArgument == Group2Vec->LineEdit1 ) {
495       myVec1 = aSelectedObject;
496       if ( myVec1 && !myVec2 )
497         Group2Vec->PushButton2->click();
498     } else if ( myEditCurrentArgument == Group2Vec->LineEdit2 ) {
499       myVec2 = aSelectedObject;
500       if ( myVec2 && !myVec1 )
501         Group2Vec->PushButton1->click();
502     } else if ( myEditCurrentArgument == GroupLCS->LineEdit1 )
503       myLCS = aSelectedObject;
504   }
505
506   displayPreview(true);
507 }
508
509
510 //=================================================================================
511 // function : SetEditCurrentArgument()
512 // purpose  :
513 //=================================================================================
514 void BasicGUI_PlaneDlg::SetEditCurrentArgument()
515 {
516   QPushButton* send = (QPushButton*)sender();
517   globalSelection( GEOM_POINT );
518
519   if      ( send == GroupPntDir->PushButton1 ) {
520     myEditCurrentArgument = GroupPntDir->LineEdit1;
521     GroupPntDir->PushButton2->setDown( false );
522     GroupPntDir->LineEdit1->setEnabled( true );
523     GroupPntDir->LineEdit2->setEnabled( false );
524   }
525   else if ( send == GroupPntDir->PushButton2 ) {
526     myEditCurrentArgument = GroupPntDir->LineEdit2;
527     GroupPntDir->PushButton1->setDown( false );
528     GroupPntDir->LineEdit1->setEnabled( false );
529     GroupPntDir->LineEdit2->setEnabled( true );
530   }
531   else if ( send == Group3Pnts->PushButton1 ) {
532     myEditCurrentArgument = Group3Pnts->LineEdit1;
533     Group3Pnts->PushButton2->setDown( false );
534     Group3Pnts->PushButton3->setDown( false );
535     Group3Pnts->LineEdit1->setEnabled( true );
536     Group3Pnts->LineEdit2->setEnabled( false );
537     Group3Pnts->LineEdit3->setEnabled( false );
538   }
539   else if ( send == Group3Pnts->PushButton2 ) {
540     myEditCurrentArgument = Group3Pnts->LineEdit2;
541     Group3Pnts->PushButton1->setDown( false );
542     Group3Pnts->PushButton3->setDown( false );
543     Group3Pnts->LineEdit1->setEnabled( false );
544     Group3Pnts->LineEdit2->setEnabled( true );
545     Group3Pnts->LineEdit3->setEnabled( false );
546   }
547   else if ( send == Group3Pnts->PushButton3 ) {
548     myEditCurrentArgument = Group3Pnts->LineEdit3;
549     Group3Pnts->PushButton1->setDown( false );
550     Group3Pnts->PushButton2->setDown( false );
551     Group3Pnts->LineEdit1->setEnabled( false );
552     Group3Pnts->LineEdit2->setEnabled( false );
553     Group3Pnts->LineEdit3->setEnabled( true );
554   }
555   else if ( send == GroupFace->PushButton1 ) {
556     myEditCurrentArgument = GroupFace->LineEdit1;
557     GroupFace->PushButton1->setDown( true );
558   } else if ( send == Group2Vec->PushButton1 ) {
559     myEditCurrentArgument = Group2Vec->LineEdit1;
560     Group2Vec->PushButton2->setDown( false );
561     Group2Vec->LineEdit1->setEnabled( true );
562     Group2Vec->LineEdit2->setEnabled( false );
563   } else if ( send == Group2Vec->PushButton2 ) {
564     myEditCurrentArgument = Group2Vec->LineEdit2;
565     Group2Vec->PushButton1->setDown( false );
566     Group2Vec->LineEdit1->setEnabled( false );
567     Group2Vec->LineEdit2->setEnabled( true );
568   } else if ( send == GroupLCS->PushButton1 ) {
569     myEditCurrentArgument = GroupLCS->LineEdit1;
570     GroupLCS->LineEdit1->setEnabled( true );
571   }
572
573   myEditCurrentArgument->setFocus();
574
575   if ( myEditCurrentArgument == GroupPntDir->LineEdit2 || 
576        myEditCurrentArgument == Group2Vec->LineEdit1   ||
577        myEditCurrentArgument == Group2Vec->LineEdit2 ) {
578     localSelection( TopAbs_EDGE );
579   } else if ( myEditCurrentArgument == GroupFace->LineEdit1 ) {
580     TColStd_MapOfInteger aMap;
581     aMap.Add( GEOM_PLANE );
582     aMap.Add( GEOM_MARKER );
583     globalSelection( aMap );
584   } else if ( myEditCurrentArgument == GroupLCS->LineEdit1 ) {
585     globalSelection( GEOM_MARKER );
586   }
587   else { // 3 Pnts
588     localSelection( TopAbs_VERTEX );
589   }
590
591   //  SelectionIntoArgument();
592   myEditCurrentArgument->setFocus();
593   send->setDown(true);
594   displayPreview(true);
595 }
596
597
598 //=================================================================================
599 // function : ActivateThisDialog()
600 // purpose  :
601 //=================================================================================
602 void BasicGUI_PlaneDlg::ActivateThisDialog()
603 {
604   GEOMBase_Skeleton::ActivateThisDialog();
605   connect( myGeomGUI->getApp()->selectionMgr(), SIGNAL( currentSelectionChanged() ),
606            this, SLOT( SelectionIntoArgument() ) );
607
608   ConstructorsClicked( getConstructorId() );
609   SelectionIntoArgument();
610 }
611
612 //=================================================================================
613 // function : DeactivateActiveDialog()
614 // purpose  : public slot to deactivate if active
615 //=================================================================================
616 void BasicGUI_PlaneDlg::DeactivateActiveDialog()
617 {
618   GEOMBase_Skeleton::DeactivateActiveDialog();
619 }
620
621 //=================================================================================
622 // function : enterEvent()
623 // purpose  :
624 //=================================================================================
625 void BasicGUI_PlaneDlg::enterEvent( QEvent* )
626 {
627   if ( !mainFrame()->GroupConstructors->isEnabled() )
628     ActivateThisDialog();
629 }
630
631
632 //=================================================================================
633 // function : ValueChangedInSpinBox()
634 // purpose  :
635 //=================================================================================
636 void BasicGUI_PlaneDlg::ValueChangedInSpinBox( double /*newValue*/ )
637 {
638   displayPreview(true);
639 }
640
641 //=================================================================================
642 // function : getSize()
643 // purpose  :
644 //=================================================================================
645 double BasicGUI_PlaneDlg::getSize() const
646 {
647   switch ( getConstructorId() ) {
648   case 0 : return GroupPntDir->SpinBox_DX->value();
649   case 1 : return Group3Pnts->SpinBox_DX->value();
650   case 2 : return GroupFace->SpinBox_DX->value();
651   case 3 : return Group2Vec->SpinBox_DX->value();
652   case 4 : return GroupLCS->SpinBox_DX->value();
653   }
654   return 0.;
655 }
656
657 //=================================================================================
658 // function : getSize()
659 // purpose  :
660 //=================================================================================
661 QString BasicGUI_PlaneDlg::getSizeAsString() const
662 {
663   switch ( getConstructorId() ) {
664   case 0 : return GroupPntDir->SpinBox_DX->text();
665   case 1 : return Group3Pnts->SpinBox_DX->text();
666   case 2 : return GroupFace->SpinBox_DX->text();
667   case 3 : return Group2Vec->SpinBox_DX->text();
668   }
669   return QString();
670 }
671
672 //=================================================================================
673 // function : createOperation
674 // purpose  :
675 //=================================================================================
676 GEOM::GEOM_IOperations_ptr BasicGUI_PlaneDlg::createOperation()
677 {
678   return myGeomGUI->GetGeomGen()->GetIBasicOperations();
679 }
680
681 //=================================================================================
682 // function : isValid
683 // purpose  :
684 //=================================================================================
685 bool BasicGUI_PlaneDlg::isValid( QString& msg )
686 {
687   bool ok = false;
688   if ( getSize() <= 0 ) {
689     msg = QString( "Please, enter size greater than 0." );
690   }
691   else {
692     switch ( getConstructorId() ) {
693     case 0:
694       ok = GroupPntDir->SpinBox_DX->isValid( msg, !IsPreview() ) && myPoint && myDir;
695       break;
696     case 1:
697       ok = Group3Pnts->SpinBox_DX->isValid( msg, !IsPreview() ) &&
698            myPoint1 && myPoint2 && myPoint3 &&
699            myPoint1 != myPoint2 && myPoint1 != myPoint3 && myPoint2 != myPoint3;
700       break;
701     case 2:
702       ok = GroupFace->SpinBox_DX->isValid( msg, !IsPreview() ) && myFace;
703       break;
704     case 3:
705       ok = Group2Vec->SpinBox_DX->isValid( msg, !IsPreview() ) &&
706            myVec1 && myVec2 && myVec1 != myVec2;
707       break;
708     case 4:
709       ok = GroupLCS->SpinBox_DX->isValid( msg, !IsPreview() );
710       break;
711     default:
712       break;
713     }
714   }
715   return ok;
716 }
717
718 //=================================================================================
719 // function : execute
720 // purpose  :
721 //=================================================================================
722 bool BasicGUI_PlaneDlg::execute( ObjectList& objects )
723 {
724   bool res = false;
725
726   GEOM::GEOM_Object_var anObj;
727
728   GEOM::GEOM_IBasicOperations_var anOper = GEOM::GEOM_IBasicOperations::_narrow( getOperation() );
729
730   switch ( getConstructorId() ) {
731   case 0 :
732     anObj = anOper->MakePlanePntVec( myPoint.get(), myDir.get(), getSize() );
733     res = true;
734     break;
735   case 1 :
736     anObj = anOper->MakePlaneThreePnt( myPoint1.get(), myPoint2.get(), myPoint3.get(), getSize() );
737     res = true;
738     break;
739   case 2 :
740     anObj = anOper->MakePlaneFace( myFace.get(), getSize() );
741     res = true;
742     break;
743   case 3 :
744     anObj = anOper->MakePlane2Vec( myVec1.get(), myVec2.get(), getSize() );
745     res = true;
746     break;
747   case 4 :
748     anObj = anOper->MakePlaneLCS( myLCS.get(), getSize(), myOriginType );
749     res = true;
750     break;
751   }
752   
753   if ( !anObj->_is_nil() ) {
754     if ( !IsPreview() )
755       anObj->SetParameters(getSizeAsString().toUtf8().constData());
756     objects.push_back( anObj._retn() );
757   }
758   return res;
759 }
760 //=================================================================================
761 // function : addSubshapeToStudy
762 // purpose  : virtual method to add new SubObjects if local selection
763 //=================================================================================
764 void BasicGUI_PlaneDlg::addSubshapesToStudy()
765 {
766   switch ( getConstructorId() ) {
767   case 0:
768     GEOMBase::PublishSubObject( myPoint.get() );
769     GEOMBase::PublishSubObject( myDir.get() );
770     break;
771   case 1:
772     GEOMBase::PublishSubObject( myPoint1.get() );
773     GEOMBase::PublishSubObject( myPoint2.get() );
774     GEOMBase::PublishSubObject( myPoint3.get() );
775     break;
776   case 2:
777     GEOMBase::PublishSubObject( myFace.get() );
778     break;
779   case 3:
780     GEOMBase::PublishSubObject( myVec1.get() );
781     GEOMBase::PublishSubObject( myVec2.get() );
782     break;
783   case 4:
784     GEOMBase::PublishSubObject( myLCS.get() );
785     break;
786  default:
787    break;
788   }
789 }
790
791 //=================================================================================
792 // function : getSourceObjects
793 // purpose  : virtual method to get source objects
794 //=================================================================================
795 QList<GEOM::GeomObjPtr> BasicGUI_PlaneDlg::getSourceObjects()
796 {
797   QList<GEOM::GeomObjPtr> res;
798   res << myPoint << myDir << myPoint1 << myPoint2 << myPoint3
799       << myFace << myVec1 << myVec2 << myLCS;
800   return res;
801 }