Salome HOME
IPAL19834: Incorrect result after make Partition of 2 objects. A fix by PKV.
[modules/geom.git] / src / BasicGUI / BasicGUI_PointDlg.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_PointDlg.cxx
23 // Author : Lucien PIGNOLONI, Open CASCADE S.A.S.
24 //
25
26 #include "BasicGUI_PointDlg.h"
27
28 #include <SUIT_ResourceMgr.h>
29 #include <SUIT_Session.h>
30 #include <SalomeApp_Application.h>
31 #include <LightApp_SelectionMgr.h>
32
33 #include <GeometryGUI.h>
34 #include <GEOMBase.h>
35
36 #include <DlgRef.h>
37
38 #include <GEOMImpl_Types.hxx>
39
40 #include <QApplication>
41 #include <QLabel>
42
43 #include <gp_Pnt.hxx>
44 #include <TopoDS_Shape.hxx>
45 #include <TopAbs_ShapeEnum.hxx>
46 #include <TopoDS.hxx>
47 #include <BRep_Tool.hxx>
48 #include <TopExp.hxx>
49 #include <TColStd_IndexedMapOfInteger.hxx>
50 #include <TopTools_IndexedMapOfShape.hxx>
51
52 //=================================================================================
53 // class    : BasicGUI_PointDlg()
54 // purpose  : Constructs a BasicGUI_PointDlg which is a child of 'parent', with the 
55 //            name 'name' and widget flags set to 'f'.
56 //            The dialog will by default be modeless, unless you set 'modal' to
57 //            TRUE to construct a modal dialog.
58 //=================================================================================
59 BasicGUI_PointDlg::BasicGUI_PointDlg( GeometryGUI* theGeometryGUI, QWidget* parent,
60                                       bool modal, Qt::WindowFlags fl )
61   : GEOMBase_Skeleton( theGeometryGUI, parent, modal, fl )
62 {
63   QPixmap image0( SUIT_Session::session()->resourceMgr()->loadPixmap( "GEOM", tr( "ICON_DLG_POINT") ) );
64   QPixmap image1( SUIT_Session::session()->resourceMgr()->loadPixmap( "GEOM", tr( "ICON_DLG_POINT_EDGE" ) ) );
65   QPixmap image2( SUIT_Session::session()->resourceMgr()->loadPixmap( "GEOM", tr( "ICON_SELECT" ) ) );
66   QPixmap image3( SUIT_Session::session()->resourceMgr()->loadPixmap( "GEOM", tr( "ICON_DLG_POINT_REF" ) ) );
67   QPixmap image4( SUIT_Session::session()->resourceMgr()->loadPixmap( "GEOM", tr( "ICON_DLG_POINT_LINES") ) );
68   QPixmap image5( SUIT_Session::session()->resourceMgr()->loadPixmap( "GEOM", tr( "ICON_DLG_POINT_FACE" ) ) );
69
70   setWindowTitle( tr( "GEOM_POINT_TITLE" ) );
71
72   /***************************************************************/
73   mainFrame()->GroupConstructors->setTitle( tr( "GEOM_POINTS" ) );
74   mainFrame()->RadioButton1->setIcon( image0 );
75   mainFrame()->RadioButton2->setIcon( image3 );
76   mainFrame()->RadioButton3->setIcon( image1 );
77   mainFrame()->RadioButton4->show();
78   mainFrame()->RadioButton4->setIcon( image4 );
79   mainFrame()->RadioButton5->show();
80   mainFrame()->RadioButton5->setIcon( image5 );
81
82   GroupXYZ = new DlgRef_3Spin( centralWidget() );
83   GroupXYZ->GroupBox1->setTitle( tr( "GEOM_COORDINATES" ) );
84   GroupXYZ->TextLabel1->setText( tr( "GEOM_X" ) );
85   GroupXYZ->TextLabel2->setText( tr( "GEOM_Y" ) );
86   GroupXYZ->TextLabel3->setText( tr( "GEOM_Z" ) );
87
88   GroupOnCurve = new DlgRef_1Sel1Spin( centralWidget() );
89   GroupOnCurve->GroupBox1->setTitle( tr( "GEOM_PARAM_POINT" ) );
90   GroupOnCurve->TextLabel1->setText( tr( "GEOM_EDGE" ) );
91   GroupOnCurve->TextLabel2->setText( tr( "GEOM_PARAMETER" ) );
92   GroupOnCurve->PushButton1->setIcon( image2 );
93
94   GroupOnSurface = new DlgRef_1Sel2Spin( centralWidget() );
95   GroupOnSurface->GroupBox1->setTitle( tr( "GEOM_PARAM_POINT" ) );
96   GroupOnSurface->TextLabel1->setText( tr( "GEOM_FACE" ) );
97   GroupOnSurface->TextLabel2->setText( tr( "GEOM_UPARAMETER" ) );
98   GroupOnSurface->TextLabel3->setText( tr( "GEOM_VPARAMETER" ) );
99   GroupOnSurface->PushButton1->setIcon( image2 );
100
101   GroupRefPoint = new DlgRef_1Sel3Spin( centralWidget() );
102   GroupRefPoint->GroupBox1->setTitle( tr( "GEOM_REF_POINT" ) );
103   GroupRefPoint->TextLabel1->setText( tr( "GEOM_POINT" ) );
104   GroupRefPoint->PushButton1->setIcon( image2 );
105   GroupRefPoint->TextLabel2->setText( tr( "GEOM_DX" ) );
106   GroupRefPoint->TextLabel3->setText( tr( "GEOM_DY" ) );
107   GroupRefPoint->TextLabel4->setText( tr( "GEOM_DZ" ) );
108
109   GroupLineIntersection = new DlgRef_2Sel( centralWidget() );
110   GroupLineIntersection->GroupBox1->setTitle( tr( "GEOM_LINE_INTERSECTION" ) );
111   GroupLineIntersection->TextLabel1->setText( tr( "GEOM_LINE1" ) );
112   GroupLineIntersection->TextLabel2->setText( tr( "GEOM_LINE2" ) );
113   GroupLineIntersection->PushButton1->setIcon( image2 );
114   GroupLineIntersection->PushButton2->setIcon( image2 );
115
116   myCoordGrp = new QGroupBox( tr( "GEOM_COORDINATES" ), centralWidget() );
117   QGridLayout* myCoordGrpLayout = new QGridLayout( myCoordGrp );
118   myCoordGrpLayout->addWidget( new QLabel( tr( "GEOM_X" ), myCoordGrp ), 0, 0 );
119   myX = new QLineEdit( myCoordGrp );
120   myCoordGrpLayout->addWidget( myX, 0, 1 );
121   myCoordGrpLayout->addWidget( new QLabel( tr( "GEOM_Y" ), myCoordGrp ), 1, 0 );
122   myY = new QLineEdit( myCoordGrp );
123   myCoordGrpLayout->addWidget( myY, 1, 1 );
124   myCoordGrpLayout->addWidget( new QLabel( tr( "GEOM_Z" ), myCoordGrp ), 2, 0 );
125   myZ = new QLineEdit( myCoordGrp );
126   myCoordGrpLayout->addWidget( myZ, 2, 1 );
127
128   QVBoxLayout* layout = new QVBoxLayout( centralWidget() );
129   layout->setMargin( 0 ); layout->setSpacing( 6 );
130   layout->addWidget( GroupXYZ );
131   layout->addWidget( GroupOnCurve );
132   layout->addWidget( GroupOnSurface );
133   layout->addWidget( GroupRefPoint );
134   layout->addWidget( GroupLineIntersection );
135   layout->addWidget( myCoordGrp );
136
137   myX->setReadOnly( true );
138   myY->setReadOnly( true );
139   myZ->setReadOnly( true );
140
141   myX->setEnabled( false );
142   myY->setEnabled( false );
143   myZ->setEnabled( false );
144
145   QPalette aPal = myX->palette();
146   aPal.setColor( QPalette::Disabled, QPalette::Text, QColor( 0, 0, 0 ) ) ;
147   myX->setPalette( aPal );
148   myY->setPalette( aPal );
149   myZ->setPalette( aPal );
150
151   setHelpFileName( "create_point_page.html" );
152  
153   Init();
154 }
155
156
157 //=================================================================================
158 // function : ~BasicGUI_PointDlg()
159 // purpose  : Destructor
160 //=================================================================================
161 BasicGUI_PointDlg::~BasicGUI_PointDlg()
162 {
163 }
164
165
166 //=================================================================================
167 // function : Init()
168 // purpose  :
169 //=================================================================================
170 void BasicGUI_PointDlg::Init()
171 {
172   GroupOnCurve->LineEdit1->setReadOnly( true );
173   GroupOnSurface->LineEdit1->setReadOnly( true );
174   GroupRefPoint->LineEdit1->setReadOnly( true );
175   GroupLineIntersection->LineEdit1->setReadOnly( true );
176   GroupLineIntersection->LineEdit2->setReadOnly( true );
177
178   myEdge = GEOM::GEOM_Object::_nil();
179   myRefPoint = GEOM::GEOM_Object::_nil();
180
181   myEditCurrentArgument = 0;
182
183   /* Get setting of step value from file configuration */
184   SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
185   double step = resMgr->doubleValue( "Geometry", "SettingsGeomStep", 100 );
186   
187   /* min, max, step and decimals for spin boxes */
188   initSpinBox( GroupXYZ->SpinBox_DX, COORD_MIN, COORD_MAX, step, 3 ); // VSR:TODO : DBL_DIGITS_DISPLAY
189   initSpinBox( GroupXYZ->SpinBox_DY, COORD_MIN, COORD_MAX, step, 3 ); // VSR:TODO : DBL_DIGITS_DISPLAY
190   initSpinBox( GroupXYZ->SpinBox_DZ, COORD_MIN, COORD_MAX, step, 3 ); // VSR:TODO : DBL_DIGITS_DISPLAY
191   GroupXYZ->SpinBox_DX->setValue( 0.0 );
192   GroupXYZ->SpinBox_DY->setValue( 0.0 );
193   GroupXYZ->SpinBox_DZ->setValue( 0.0 );
194
195   initSpinBox( GroupRefPoint->SpinBox_DX, COORD_MIN, COORD_MAX, step, 3 ); // VSR:TODO : DBL_DIGITS_DISPLAY
196   initSpinBox( GroupRefPoint->SpinBox_DY, COORD_MIN, COORD_MAX, step, 3 ); // VSR:TODO : DBL_DIGITS_DISPLAY
197   initSpinBox( GroupRefPoint->SpinBox_DZ, COORD_MIN, COORD_MAX, step, 3 ); // VSR:TODO : DBL_DIGITS_DISPLAY
198   GroupRefPoint->SpinBox_DX->setValue( 0.0 );
199   GroupRefPoint->SpinBox_DY->setValue( 0.0 );
200   GroupRefPoint->SpinBox_DZ->setValue( 0.0 );
201
202   step = 0.1;
203
204   initSpinBox( GroupOnCurve->SpinBox_DX, 0., 1., step, 3 ); // VSR:TODO : DBL_DIGITS_DISPLAY
205   GroupOnCurve->SpinBox_DX->setValue( 0.5 );
206
207   initSpinBox( GroupOnSurface->SpinBox_DX, 0., 1., step, 3 ); // VSR:TODO : DBL_DIGITS_DISPLAY
208   GroupOnSurface->SpinBox_DX->setValue( 0.5 );
209   initSpinBox( GroupOnSurface->SpinBox_DY, 0., 1., step, 3 ); // VSR:TODO : DBL_DIGITS_DISPLAY
210   GroupOnSurface->SpinBox_DY->setValue( 0.5 );
211
212   /* signals and slots connections */
213   connect( myGeomGUI,      SIGNAL( SignalDeactivateActiveDialog() ), this, SLOT( DeactivateActiveDialog() ) );
214   connect( myGeomGUI,      SIGNAL( SignalCloseAllDialogs() ),        this, SLOT( ClickOnCancel() ) );
215
216   connect( buttonOk(),     SIGNAL( clicked() ), this, SLOT( ClickOnOk() ) );
217   connect( buttonApply(),  SIGNAL( clicked() ), this, SLOT( ClickOnApply() ) );
218
219   connect( this,           SIGNAL( constructorsClicked( int ) ), this, SLOT( ConstructorsClicked( int ) ) );
220
221   connect( GroupOnCurve->PushButton1, SIGNAL( clicked() ),       this, SLOT( SetEditCurrentArgument() ) );
222   connect( GroupOnCurve->LineEdit1,   SIGNAL( returnPressed() ), this, SLOT( LineEditReturnPressed() ) );
223
224   connect( GroupOnSurface->PushButton1, SIGNAL( clicked() ),       this, SLOT( SetEditCurrentArgument() ) );
225   connect( GroupOnSurface->LineEdit1,   SIGNAL( returnPressed() ), this, SLOT( LineEditReturnPressed() ) );
226
227   connect( GroupLineIntersection->PushButton1, SIGNAL( clicked() ),       this, SLOT( SetEditCurrentArgument() ) );
228   connect( GroupLineIntersection->PushButton2, SIGNAL( clicked() ),       this, SLOT( SetEditCurrentArgument() ) );
229   connect( GroupLineIntersection->LineEdit1,   SIGNAL( returnPressed() ), this, SLOT( LineEditReturnPressed() ) );
230   connect( GroupLineIntersection->LineEdit2,   SIGNAL( returnPressed() ), this, SLOT( LineEditReturnPressed() ) );
231
232   connect( GroupOnCurve->SpinBox_DX,   SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
233   connect( GroupOnSurface->SpinBox_DX, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
234   connect( GroupOnSurface->SpinBox_DY, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
235   connect( GroupXYZ->SpinBox_DX,       SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
236   connect( GroupXYZ->SpinBox_DY,       SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
237   connect( GroupXYZ->SpinBox_DZ,       SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
238   connect( GroupRefPoint->SpinBox_DX,  SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
239   connect( GroupRefPoint->SpinBox_DY,  SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
240   connect( GroupRefPoint->SpinBox_DZ,  SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
241
242   connect( myGeomGUI, SIGNAL( SignalDefaultStepValueChanged( double ) ), this,  SLOT( SetDoubleSpinBoxStep( double ) ) );
243
244   connect( myGeomGUI->getApp()->selectionMgr(), SIGNAL(currentSelectionChanged() ),
245            this,  SLOT(SelectionIntoArgument() ) );
246
247   
248   initName( tr( "GEOM_VERTEX" ) );
249   
250   ConstructorsClicked( 0 );
251 }
252
253 //=================================================================================
254 // function : SetDoubleSpinBoxStep()
255 // purpose  : Double spin box management
256 //=================================================================================
257 void BasicGUI_PointDlg::SetDoubleSpinBoxStep( double step )
258 {
259   GroupOnCurve->SpinBox_DX->setSingleStep(step);
260   GroupXYZ->SpinBox_DX->setSingleStep(step);
261   GroupXYZ->SpinBox_DY->setSingleStep(step);
262   GroupXYZ->SpinBox_DZ->setSingleStep(step);
263   GroupRefPoint->SpinBox_DX->setSingleStep(step);
264   GroupRefPoint->SpinBox_DY->setSingleStep(step);
265   GroupRefPoint->SpinBox_DZ->setSingleStep(step);
266   GroupOnSurface->SpinBox_DX->setSingleStep(step);
267   GroupOnSurface->SpinBox_DY->setSingleStep(step);
268 }
269
270
271 //=================================================================================
272 // function : ConstructorsClicked()
273 // purpose  : Radio button management
274 //=================================================================================
275 void BasicGUI_PointDlg::ConstructorsClicked(int constructorId)
276 {  
277   globalSelection(); // close local contexts, if any
278
279   switch ( constructorId ) {
280   case 0:
281     {
282       localSelection( GEOM::GEOM_Object::_nil(), TopAbs_VERTEX );
283       
284       GroupRefPoint->hide();
285       GroupOnCurve->hide();
286       GroupLineIntersection->hide();
287       GroupOnSurface->hide();
288
289       myCoordGrp->hide();
290
291       GroupXYZ->show();
292       break;
293     }
294   case 1:
295     {
296       myEditCurrentArgument = GroupRefPoint->LineEdit1;
297       myEditCurrentArgument->setText( "" );
298       myRefPoint = GEOM::GEOM_Object::_nil();
299       
300       localSelection( GEOM::GEOM_Object::_nil(), TopAbs_VERTEX );
301       
302       GroupXYZ->hide();
303       GroupOnCurve->hide();
304       GroupLineIntersection->hide();
305       GroupOnSurface->hide();
306       
307       GroupRefPoint->show();
308       
309       myCoordGrp->show();
310       break;
311     }
312   case 2:
313     {
314       myEditCurrentArgument = GroupOnCurve->LineEdit1;
315       myEditCurrentArgument->setText( "" );
316       myEdge = GEOM::GEOM_Object::_nil();
317
318       localSelection( GEOM::GEOM_Object::_nil(), TopAbs_EDGE );
319
320       GroupXYZ->hide();
321       GroupRefPoint->hide();
322       GroupLineIntersection->hide();
323       GroupOnSurface->hide();
324
325       GroupOnCurve->show();
326       
327       myCoordGrp->show();
328       break;
329     }
330   case 3:
331     {
332       myEditCurrentArgument = GroupLineIntersection->LineEdit1;
333       GroupLineIntersection->LineEdit1->setText( "" );
334       GroupLineIntersection->LineEdit2->setText( "" );
335       myLine1 = GEOM::GEOM_Object::_nil();
336       myLine2 = GEOM::GEOM_Object::_nil();
337
338       localSelection( GEOM::GEOM_Object::_nil(), TopAbs_EDGE );
339
340       GroupXYZ->hide();
341       GroupRefPoint->hide();
342       GroupOnCurve->hide();
343       GroupOnSurface->hide();
344
345       myCoordGrp->hide();
346
347       GroupLineIntersection->show();
348       break;
349     }
350   case 4:
351     {
352       myEditCurrentArgument = GroupOnSurface->LineEdit1;
353       myEditCurrentArgument->setText( "" );
354       myFace = GEOM::GEOM_Object::_nil();
355
356       localSelection( GEOM::GEOM_Object::_nil(), TopAbs_FACE );
357
358       GroupXYZ->hide();
359       GroupRefPoint->hide();
360       GroupOnCurve->hide();
361       GroupLineIntersection->hide();
362
363       GroupOnSurface->show();
364
365       myCoordGrp->show();
366       break;
367     }
368   }
369
370   myX->setText( "" );
371   myY->setText( "" );
372   myZ->setText( "" );
373
374   qApp->processEvents();
375   updateGeometry();
376   resize( minimumSize() );
377
378   SelectionIntoArgument();
379 }
380
381
382 //=================================================================================
383 // function : ClickOnOk()
384 // purpose  :
385 //=================================================================================
386 void BasicGUI_PointDlg::ClickOnOk()
387 {
388   if ( onAccept() )
389     ClickOnCancel();
390 }
391
392
393 //=================================================================================
394 // function : ClickOnApply()
395 // purpose  :
396 //=================================================================================
397 bool BasicGUI_PointDlg::ClickOnApply()
398 {
399   if ( !onAccept() )
400     return false;
401   
402   initName();
403   ConstructorsClicked( getConstructorId() );
404   return true;
405 }
406
407
408 //=================================================================================
409 // function : SelectionIntoArgument()
410 // purpose  : Called when selection as changed (for constructors not using local context)
411 //=================================================================================
412 void BasicGUI_PointDlg::SelectionIntoArgument()
413 {
414   const int id = getConstructorId();
415
416   if ( ( id == 1 || id == 2 || id == 4 ) && myEditCurrentArgument != 0 )
417   {
418     myEditCurrentArgument->setText( "" );
419     myX->setText( "" );
420     myY->setText( "" );
421     myZ->setText( "" );
422     myRefPoint = myEdge = myFace = GEOM::GEOM_Object::_nil();
423   }
424
425   if ( IObjectCount() == 1 ) {
426     Standard_Boolean aRes = Standard_False;
427     Handle(SALOME_InteractiveObject) anIO = firstIObject();
428     GEOM::GEOM_Object_var aSelectedObject = GEOMBase::ConvertIOinGEOMObject( anIO, aRes );
429     if ( !CORBA::is_nil( aSelectedObject ) && aRes ) {
430       QString aName = GEOMBase::GetName(aSelectedObject);
431
432       TopoDS_Shape aShape;
433       if ( GEOMBase::GetShape( aSelectedObject, aShape, TopAbs_SHAPE ) && !aShape.IsNull() ) {
434         TopAbs_ShapeEnum aNeedType = TopAbs_VERTEX;
435         if ( id == 2 || id == 3 )
436           aNeedType = TopAbs_EDGE;
437         else if ( id == 4 )
438           aNeedType = TopAbs_FACE;
439
440         LightApp_SelectionMgr* aSelMgr = myGeomGUI->getApp()->selectionMgr();
441         TColStd_IndexedMapOfInteger aMap;
442         aSelMgr->GetIndexes(firstIObject(), aMap);
443         if ( aMap.Extent() == 1 ) { // Local Selection
444           int anIndex = aMap( 1 );
445           if ( aNeedType == TopAbs_EDGE )
446             aName += QString( ":edge_%1" ).arg( anIndex );
447           else
448             aName += QString( ":vertex_%1" ).arg( anIndex );
449
450           //Find SubShape Object in Father
451           GEOM::GEOM_Object_var aFindedObject = GEOMBase_Helper::findObjectInFather( aSelectedObject, aName );
452           
453           if ( aFindedObject == GEOM::GEOM_Object::_nil() ) { // Object not found in study
454             GEOM::GEOM_IShapesOperations_var aShapesOp = getGeomEngine()->GetIShapesOperations( getStudyId() );
455             aSelectedObject = aShapesOp->GetSubShape( aSelectedObject, anIndex );
456           }
457           else {
458             aSelectedObject = aFindedObject; // get Object from study
459           }
460         }
461         else { // Global Selection
462           if ( aShape.ShapeType() != aNeedType ) {
463             aSelectedObject = GEOM::GEOM_Object::_nil();
464             aName = "";
465             if ( id == 0 ) return;
466           }
467         }
468       }
469
470       if ( id == 0 ) {
471         if ( aShape.IsNull() ) return;
472         gp_Pnt aPnt = BRep_Tool::Pnt( TopoDS::Vertex( aShape ) );
473         GroupXYZ->SpinBox_DX->setValue( aPnt.X() );
474         GroupXYZ->SpinBox_DY->setValue( aPnt.Y() );
475         GroupXYZ->SpinBox_DZ->setValue( aPnt.Z() );
476       }
477       else if ( id == 1 ) {
478         myRefPoint = aSelectedObject;
479         GroupRefPoint->LineEdit1->setText( aName );
480       }
481       else if ( id == 2 ) {
482         myEdge = aSelectedObject;
483         GroupOnCurve->LineEdit1->setText( aName );
484       }
485       else if ( id == 3 ) {
486         if ( myEditCurrentArgument == GroupLineIntersection->LineEdit1 ) {
487           myLine1 = aSelectedObject;
488           myEditCurrentArgument->setText( aName );
489         }
490         else if ( myEditCurrentArgument == GroupLineIntersection->LineEdit2 ) {
491           myLine2 = aSelectedObject;
492           myEditCurrentArgument->setText( aName );
493         }
494       }
495       else if ( id == 4 )
496       {
497         myFace = aSelectedObject;
498         GroupOnSurface->LineEdit1->setText( aName );
499       }
500     }
501   }
502   
503   displayPreview();
504 }
505
506
507 //=================================================================================
508 // function : LineEditReturnPressed()
509 // purpose  :
510 //=================================================================================
511 void BasicGUI_PointDlg::LineEditReturnPressed()
512 {
513   QLineEdit* send = (QLineEdit*)sender();
514   if ( send == GroupRefPoint->LineEdit1         || 
515        send == GroupOnCurve->LineEdit1          ||
516        send == GroupLineIntersection->LineEdit1 || 
517        send == GroupLineIntersection->LineEdit2  ) {
518     myEditCurrentArgument = send;
519     GEOMBase_Skeleton::LineEditReturnPressed();
520   }
521 }
522
523
524 //=================================================================================
525 // function : SetEditCurrentArgument()
526 // purpose  :
527 //=================================================================================
528 void BasicGUI_PointDlg::SetEditCurrentArgument()
529 {
530   globalSelection(); // close local contexts, if any
531
532   QPushButton* send = (QPushButton*)sender();
533   globalSelection( GEOM_POINT ); // to break previous local selection
534
535   if ( send == GroupRefPoint->PushButton1 ) {
536     GroupRefPoint->LineEdit1->setFocus();
537     myEditCurrentArgument = GroupRefPoint->LineEdit1;
538     
539     localSelection( GEOM::GEOM_Object::_nil(), TopAbs_VERTEX );
540   }
541   else if ( send == GroupOnCurve->PushButton1 ) {
542     GroupOnCurve->LineEdit1->setFocus();
543     myEditCurrentArgument = GroupOnCurve->LineEdit1;
544     
545     localSelection( GEOM::GEOM_Object::_nil(), TopAbs_EDGE );
546   }
547   else if ( send == GroupOnSurface->PushButton1 )
548   {
549     GroupOnSurface->LineEdit1->setFocus();
550     myEditCurrentArgument = GroupOnSurface->LineEdit1;
551
552     localSelection( GEOM::GEOM_Object::_nil(), TopAbs_FACE );
553   }
554   else if ( send == GroupLineIntersection->PushButton1 ) {
555     GroupLineIntersection->LineEdit1->setFocus();
556     myEditCurrentArgument = GroupLineIntersection->LineEdit1;
557
558     localSelection( GEOM::GEOM_Object::_nil(), TopAbs_EDGE );
559   }
560   else if ( send == GroupLineIntersection->PushButton2 ) {
561     GroupLineIntersection->LineEdit2->setFocus();
562     myEditCurrentArgument = GroupLineIntersection->LineEdit2;
563
564     localSelection( GEOM::GEOM_Object::_nil(), TopAbs_EDGE );
565   }
566 }
567
568
569 //=================================================================================
570 // function : enterEvent()
571 // purpose  : to reactivate this dialog box when mouse enter onto the window
572 //=================================================================================
573 void BasicGUI_PointDlg::enterEvent( QEvent* )
574 {
575   if ( !mainFrame()->GroupConstructors->isEnabled() )
576     ActivateThisDialog();
577 }
578
579
580 //=================================================================================
581 // function : ActivateThisDialog()
582 // purpose  :
583 //=================================================================================
584 void BasicGUI_PointDlg::ActivateThisDialog( )
585 {
586   GEOMBase_Skeleton::ActivateThisDialog();
587   // myGeomGUI->SetState( 0 );
588   ConstructorsClicked( getConstructorId() );
589 }
590
591
592 //=================================================================================
593 // function : DeactivateActiveDialog()
594 // purpose  : public slot to deactivate if active
595 //=================================================================================
596 void BasicGUI_PointDlg::DeactivateActiveDialog()
597 {
598   // myGeomGUI->SetState( -1 );
599   GEOMBase_Skeleton::DeactivateActiveDialog();
600 }
601
602
603 //=================================================================================
604 // function : ValueChangedInSpinBox()
605 // purpose  :
606 //=================================================================================
607 void BasicGUI_PointDlg::ValueChangedInSpinBox(double newValue)
608 {
609   displayPreview();
610 }
611
612 //=================================================================================
613 // funcion  : getParameter()
614 // purpose  :
615 //=================================================================================
616 double BasicGUI_PointDlg::getParameter() const
617 {
618   return GroupOnCurve->SpinBox_DX->value();
619 }
620
621
622 //=================================================================================
623 // funcion  : getUParameter()
624 // purpose  :
625 //=================================================================================
626 double BasicGUI_PointDlg::getUParameter() const
627 {
628   return GroupOnSurface->SpinBox_DX->value();
629 }
630
631
632 //=================================================================================
633 // funcion  : getVParameter()
634 // purpose  :
635 //=================================================================================
636 double BasicGUI_PointDlg::getVParameter() const
637 {
638   return GroupOnSurface->SpinBox_DY->value();
639 }
640
641
642 //=================================================================================
643 // function : OnPointSelected
644 // purpose  :
645 //=================================================================================
646 void BasicGUI_PointDlg::OnPointSelected( const gp_Pnt& thePnt )
647 {
648   if ( getConstructorId() == 0 ) {
649     GroupXYZ->SpinBox_DX->setValue( thePnt.X() );
650     GroupXYZ->SpinBox_DY->setValue( thePnt.Y() );
651     GroupXYZ->SpinBox_DZ->setValue( thePnt.Z() );
652
653     displayPreview();
654   }
655 }
656
657 //=================================================================================
658 // function : createOperation
659 // purpose  :
660 //=================================================================================
661 GEOM::GEOM_IOperations_ptr BasicGUI_PointDlg::createOperation()
662 {
663   return myGeomGUI->GetGeomGen()->GetIBasicOperations( getStudyId() );
664 }
665
666 //=================================================================================
667 // function : isValid
668 // purpose  :
669 //=================================================================================
670 bool BasicGUI_PointDlg::isValid( QString& /*msg*/ )
671 {
672   const int id = getConstructorId();
673   if ( id == 0 )
674     return true;
675   else if ( id == 1 )
676     return !myRefPoint->_is_nil();
677   else if ( id == 2 )
678     return !myEdge->_is_nil();
679   else if ( id == 3 )
680     return ( !myLine1->_is_nil() && !myLine2->_is_nil() );
681   else if ( id == 4 )
682     return !myFace->_is_nil();
683   return false;
684 }
685
686 //=================================================================================
687 // function : execute
688 // purpose  :
689 //=================================================================================
690 bool BasicGUI_PointDlg::execute( ObjectList& objects )
691 {
692   bool res = false;
693
694   GEOM::GEOM_Object_var anObj;
695
696   switch ( getConstructorId() ) {
697   case 0 :
698     {
699       double x = GroupXYZ->SpinBox_DX->value();
700       double y = GroupXYZ->SpinBox_DY->value();
701       double z = GroupXYZ->SpinBox_DZ->value();
702       
703       anObj = GEOM::GEOM_IBasicOperations::_narrow( getOperation() )->MakePointXYZ( x, y, z );
704       res = true;
705       break;
706     }
707   case 1 :
708     {
709       double dx = GroupRefPoint->SpinBox_DX->value();
710       double dy = GroupRefPoint->SpinBox_DY->value();
711       double dz = GroupRefPoint->SpinBox_DZ->value();
712       
713       anObj = GEOM::GEOM_IBasicOperations::_narrow( getOperation() )->
714         MakePointWithReference( myRefPoint, dx, dy, dz );
715       res = true;
716       break;
717     }
718   case 2 :
719     anObj = GEOM::GEOM_IBasicOperations::_narrow( getOperation() )->
720       MakePointOnCurve( myEdge, getParameter() );
721     res = true;
722     break;
723   case 3 :
724     anObj = GEOM::GEOM_IBasicOperations::_narrow( getOperation() )->
725       MakePointOnLinesIntersection( myLine1, myLine2 );
726     res = true;
727     break;
728   case 4 :
729     anObj = GEOM::GEOM_IBasicOperations::_narrow( getOperation() )->
730       MakePointOnSurface( myFace, getUParameter(), getVParameter() );
731     res = true;
732     break;
733   }
734   
735   if ( getConstructorId() == 1 || getConstructorId() == 2 ||
736        getConstructorId() == 4 ) {
737     TopoDS_Shape aShape;
738     if ( GEOMBase::GetShape( anObj, aShape ) && !aShape.IsNull() &&
739          aShape.ShapeType() == TopAbs_VERTEX ) {
740       gp_Pnt aPnt = BRep_Tool::Pnt( TopoDS::Vertex( aShape ) );
741       myX->setText( QString( "%1" ).arg( aPnt.X() ) );
742       myY->setText( QString( "%1" ).arg( aPnt.Y() ) );
743       myZ->setText( QString( "%1" ).arg( aPnt.Z() ) );
744     }
745     else {
746       myX->setText( "" );
747       myY->setText( "" );
748       myZ->setText( "" );
749     }
750   }
751   
752   if ( !anObj->_is_nil() ) {
753     objects.push_back( anObj._retn() );
754   }
755   
756   return res;
757 }
758
759 //=================================================================================
760 // function : addSubshapeToStudy
761 // purpose  : virtual method to add new SubObjects if local selection
762 //=================================================================================
763 void BasicGUI_PointDlg::addSubshapesToStudy()
764 {
765   QMap<QString, GEOM::GEOM_Object_var> objMap;
766
767   switch ( getConstructorId() ) {
768   case 0:
769     break;
770   case 1:
771     objMap[GroupRefPoint->LineEdit1->text()] = myRefPoint;
772     break;
773   case 2:
774     objMap[GroupOnCurve->LineEdit1->text()] = myEdge;
775     break;
776   case 3:
777     objMap[GroupLineIntersection->LineEdit1->text()] = myLine1;
778     objMap[GroupLineIntersection->LineEdit2->text()] = myLine2;
779     break;
780   case 4:
781     objMap[GroupOnSurface->LineEdit1->text()] = myFace;
782     break;
783   }
784   addSubshapesToFather( objMap );
785 }