Salome HOME
90af070cd3c473f9527c92482eb8cd62245496bd
[modules/geom.git] / src / BasicGUI / BasicGUI_PointDlg.cxx
1 //  Copyright (C) 2007-2010  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
23 //  GEOM GEOMGUI : GUI for Geometry component
24 //  File   : BasicGUI_PointDlg.cxx
25 //  Author : Lucien PIGNOLONI, Open CASCADE S.A.S.
26 //
27 #include "BasicGUI_PointDlg.h"
28
29 #include <SUIT_ResourceMgr.h>
30 #include <SUIT_Session.h>
31 #include <SalomeApp_Application.h>
32 #include <LightApp_SelectionMgr.h>
33
34 #include <GeometryGUI.h>
35 #include <GEOMBase.h>
36
37 #include <DlgRef.h>
38
39 #include <GEOMImpl_Types.hxx>
40
41 #include <QApplication>
42 #include <QButtonGroup>
43 #include <QHBoxLayout>
44 #include <QLabel>
45 #include <QRadioButton>
46 #include <QMenu>
47 #include <QTimer>
48
49 #include <gp_Pnt.hxx>
50 #include <TopoDS_Shape.hxx>
51 #include <TopAbs_ShapeEnum.hxx>
52 #include <TopoDS.hxx>
53 #include <BRep_Tool.hxx>
54 #include <TopExp.hxx>
55 #include <TColStd_IndexedMapOfInteger.hxx>
56 #include <TopTools_IndexedMapOfShape.hxx>
57
58 #define PARAM_VALUE 0
59 #define COORD_VALUE 1
60
61 #define GEOM_POINT_XYZ    0
62 #define GEOM_POINT_REF    1
63 #define GEOM_POINT_EDGE   2
64 #define GEOM_POINT_INTINT 3
65 #define GEOM_POINT_SURF   4
66
67 #define SPACING 6
68 #define MARGIN  9
69
70 //=================================================================================
71 // class    : BasicGUI_PointDlg()
72 // purpose  : Constructs a BasicGUI_PointDlg which is a child of 'parent', with the
73 //            name 'name' and widget flags set to 'f'.
74 //            The dialog will by default be modeless, unless you set 'modal' to
75 //            TRUE to construct a modal dialog.
76 //=================================================================================
77 BasicGUI_PointDlg::BasicGUI_PointDlg( GeometryGUI* theGeometryGUI, QWidget* parent,
78                                       bool modal, Qt::WindowFlags fl )
79   : GEOMBase_Skeleton( theGeometryGUI, parent, modal, fl ),
80     myBusy ( false )
81 {
82   QPixmap image0( SUIT_Session::session()->resourceMgr()->loadPixmap( "GEOM", tr( "ICON_DLG_POINT") ) );
83   QPixmap image1( SUIT_Session::session()->resourceMgr()->loadPixmap( "GEOM", tr( "ICON_DLG_POINT_EDGE" ) ) );
84   QPixmap image2( SUIT_Session::session()->resourceMgr()->loadPixmap( "GEOM", tr( "ICON_SELECT" ) ) );
85   QPixmap image3( SUIT_Session::session()->resourceMgr()->loadPixmap( "GEOM", tr( "ICON_DLG_POINT_REF" ) ) );
86   QPixmap image4( SUIT_Session::session()->resourceMgr()->loadPixmap( "GEOM", tr( "ICON_DLG_POINT_LINES") ) );
87   QPixmap image5( SUIT_Session::session()->resourceMgr()->loadPixmap( "GEOM", tr( "ICON_DLG_POINT_FACE" ) ) );
88   QPixmap image6( SUIT_Session::session()->resourceMgr()->loadPixmap( "GEOM", tr( "ICO_LINE" ) ) );
89   QPixmap image7( SUIT_Session::session()->resourceMgr()->loadPixmap( "GEOM", tr( "ICO_WIRE" ) ) );
90
91   setWindowTitle( tr( "GEOM_POINT_TITLE" ) );
92
93   /***************************************************************/
94   mainFrame()->GroupConstructors->setTitle( tr( "GEOM_POINTS" ) );
95   mainFrame()->RadioButton1->setIcon( image0 );
96   mainFrame()->RadioButton2->setIcon( image3 );
97   mainFrame()->RadioButton3->setIcon( image1 );
98   mainFrame()->RadioButton4->show();
99   mainFrame()->RadioButton4->setIcon( image4 );
100   mainFrame()->RadioButton5->show();
101   mainFrame()->RadioButton5->setIcon( image5 );
102
103   myParamGroup = new QGroupBox( centralWidget() );
104   myParamCoord = new QButtonGroup( myParamGroup );
105   QHBoxLayout* boxLayout = new QHBoxLayout( myParamGroup );
106   boxLayout->setMargin( MARGIN ); boxLayout->setSpacing( SPACING );
107   QRadioButton* btn = new QRadioButton( tr( "GEOM_PARAM_VALUE" ), myParamGroup );
108   myParamCoord->addButton( btn, PARAM_VALUE );
109   boxLayout->addWidget( btn );
110   btn = new QRadioButton( tr( "GEOM_COORD_VALUE" ), myParamGroup );
111   myParamCoord->addButton( btn, COORD_VALUE );
112   boxLayout->addWidget( btn );
113   myParamCoord->setExclusive( true );
114   myParamCoord->button( PARAM_VALUE )->setChecked( true );
115
116   GroupXYZ = new DlgRef_3Spin( centralWidget() );
117   GroupXYZ->GroupBox1->setTitle( tr( "GEOM_COORDINATES" ) );
118   GroupXYZ->TextLabel1->setText( tr( "GEOM_X" ) );
119   GroupXYZ->TextLabel2->setText( tr( "GEOM_Y" ) );
120   GroupXYZ->TextLabel3->setText( tr( "GEOM_Z" ) );
121
122   GroupOnCurve = new DlgRef_1Sel1Spin( centralWidget() );
123   GroupOnCurve->GroupBox1->setTitle( tr( "GEOM_POINT_ON_EDGE" ) );
124   GroupOnCurve->TextLabel1->setText( tr( "GEOM_EDGE" ) );
125   GroupOnCurve->TextLabel2->setText( tr( "GEOM_PARAMETER" ) );
126   GroupOnCurve->PushButton1->setIcon( image2 );
127
128   GroupOnSurface = new DlgRef_1Sel2Spin( centralWidget() );
129   GroupOnSurface->GroupBox1->setTitle( tr( "GEOM_POINT_ON_FACE" ) );
130   GroupOnSurface->TextLabel1->setText( tr( "GEOM_FACE" ) );
131   GroupOnSurface->TextLabel2->setText( tr( "GEOM_UPARAMETER" ) );
132   GroupOnSurface->TextLabel3->setText( tr( "GEOM_VPARAMETER" ) );
133   GroupOnSurface->PushButton1->setIcon( image2 );
134
135   GroupRefPoint = new DlgRef_1Sel3Spin( centralWidget() );
136   GroupRefPoint->GroupBox1->setTitle( tr( "GEOM_REF_POINT" ) );
137   GroupRefPoint->TextLabel1->setText( tr( "GEOM_POINT" ) );
138   GroupRefPoint->PushButton1->setIcon( image2 );
139   GroupRefPoint->TextLabel2->setText( tr( "GEOM_DX" ) );
140   GroupRefPoint->TextLabel3->setText( tr( "GEOM_DY" ) );
141   GroupRefPoint->TextLabel4->setText( tr( "GEOM_DZ" ) );
142
143   /* popup menu for line intersect buttons */
144   myBtnPopup = new QMenu(this);
145   QIcon ico_line = QIcon( image6 );
146   QIcon ico_wire = QIcon( image7 );
147   myActions[myBtnPopup->addAction( ico_line, tr( "GEOM_EDGE" ) )] = 0;
148   myActions[myBtnPopup->addAction( ico_wire, tr( "GEOM_WIRE" ) )] = 1;
149
150   GroupLineIntersection = new DlgRef_2Sel( centralWidget() );
151   GroupLineIntersection->GroupBox1->setTitle( tr( "GEOM_LINE_INTERSECTION" ) );
152   GroupLineIntersection->TextLabel1->setText( tr( "GEOM_LINE1" ) );
153   GroupLineIntersection->TextLabel2->setText( tr( "GEOM_LINE2" ) );
154   GroupLineIntersection->PushButton1->setIcon( image2 );
155   GroupLineIntersection->PushButton1->setMenu( myBtnPopup );
156   GroupLineIntersection->PushButton2->setIcon( image2 );
157   GroupLineIntersection->PushButton2->setMenu( myBtnPopup );
158   GroupLineIntersection->LineEdit2->setEnabled(false);
159
160   myCoordGrp = new QGroupBox( tr( "GEOM_COORDINATES_RES" ), centralWidget() );
161   QGridLayout* myCoordGrpLayout = new QGridLayout( myCoordGrp );
162   myCoordGrpLayout->addWidget( new QLabel( tr( "GEOM_X" ), myCoordGrp ), 0, 0 );
163   myX = new QLineEdit( myCoordGrp );
164   myCoordGrpLayout->addWidget( myX, 0, 1 );
165   myCoordGrpLayout->addWidget( new QLabel( tr( "GEOM_Y" ), myCoordGrp ), 1, 0 );
166   myY = new QLineEdit( myCoordGrp );
167   myCoordGrpLayout->addWidget( myY, 1, 1 );
168   myCoordGrpLayout->addWidget( new QLabel( tr( "GEOM_Z" ), myCoordGrp ), 2, 0 );
169   myZ = new QLineEdit( myCoordGrp );
170   myCoordGrpLayout->addWidget( myZ, 2, 1 );
171
172   QVBoxLayout* layout = new QVBoxLayout( centralWidget() );
173   layout->setMargin( 0 ); layout->setSpacing( 6 );
174   layout->addWidget( myParamGroup );
175   layout->addWidget( GroupXYZ );
176   layout->addWidget( GroupOnCurve );
177   layout->addWidget( GroupOnSurface );
178   layout->addWidget( GroupRefPoint );
179   layout->addWidget( GroupLineIntersection );
180   layout->addWidget( myCoordGrp );
181
182   myX->setReadOnly( true );
183   myY->setReadOnly( true );
184   myZ->setReadOnly( true );
185
186   myX->setEnabled( false );
187   myY->setEnabled( false );
188   myZ->setEnabled( false );
189
190   QPalette aPal = myX->palette();
191   aPal.setColor( QPalette::Disabled, QPalette::Text, QColor( 0, 0, 0 ) );
192   myX->setPalette( aPal );
193   myY->setPalette( aPal );
194   myZ->setPalette( aPal );
195
196   setHelpFileName( "create_point_page.html" );
197
198   Init();
199 }
200
201
202 //=================================================================================
203 // function : ~BasicGUI_PointDlg()
204 // purpose  : Destructor
205 //=================================================================================
206 BasicGUI_PointDlg::~BasicGUI_PointDlg()
207 {
208 }
209
210
211 //=================================================================================
212 // function : Init()
213 // purpose  :
214 //=================================================================================
215 void BasicGUI_PointDlg::Init()
216 {
217   GroupOnCurve->LineEdit1->setReadOnly( true );
218   GroupOnSurface->LineEdit1->setReadOnly( true );
219   GroupRefPoint->LineEdit1->setReadOnly( true );
220   GroupLineIntersection->LineEdit1->setReadOnly( true );
221   GroupLineIntersection->LineEdit2->setReadOnly( true );
222   GroupLineIntersection->LineEdit1->setEnabled( true );
223   GroupLineIntersection->LineEdit2->setEnabled( false );
224
225   myEdge = GEOM::GEOM_Object::_nil();
226   myRefPoint = GEOM::GEOM_Object::_nil();
227   myNeedType = TopAbs_VERTEX;
228
229   myEditCurrentArgument = 0;
230
231   /* Get setting of step value from file configuration */
232   SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
233   double step = resMgr->doubleValue( "Geometry", "SettingsGeomStep", 100 );
234
235   /* min, max, step and decimals for spin boxes */
236   initSpinBox( GroupXYZ->SpinBox_DX, COORD_MIN, COORD_MAX, step, "length_precision" );
237   initSpinBox( GroupXYZ->SpinBox_DY, COORD_MIN, COORD_MAX, step, "length_precision" );
238   initSpinBox( GroupXYZ->SpinBox_DZ, COORD_MIN, COORD_MAX, step, "length_precision" );
239   GroupXYZ->SpinBox_DX->setValue( 0.0 );
240   GroupXYZ->SpinBox_DY->setValue( 0.0 );
241   GroupXYZ->SpinBox_DZ->setValue( 0.0 );
242
243   initSpinBox( GroupRefPoint->SpinBox_DX, COORD_MIN, COORD_MAX, step, "length_precision" );
244   initSpinBox( GroupRefPoint->SpinBox_DY, COORD_MIN, COORD_MAX, step, "length_precision" );
245   initSpinBox( GroupRefPoint->SpinBox_DZ, COORD_MIN, COORD_MAX, step, "length_precision" );
246   GroupRefPoint->SpinBox_DX->setValue( 0.0 );
247   GroupRefPoint->SpinBox_DY->setValue( 0.0 );
248   GroupRefPoint->SpinBox_DZ->setValue( 0.0 );
249
250   step = 0.1;
251
252   initSpinBox( GroupOnCurve->SpinBox_DX, 0., 1., step, "parametric_precision" );
253   GroupOnCurve->SpinBox_DX->setValue( 0.5 );
254
255   initSpinBox( GroupOnSurface->SpinBox_DX, 0., 1., step, "parametric_precision" );
256   GroupOnSurface->SpinBox_DX->setValue( 0.5 );
257   initSpinBox( GroupOnSurface->SpinBox_DY, 0., 1., step, "parametric_precision" );
258   GroupOnSurface->SpinBox_DY->setValue( 0.5 );
259
260   /* signals and slots connections */
261   connect( myGeomGUI,      SIGNAL( SignalDeactivateActiveDialog() ), this, SLOT( DeactivateActiveDialog() ) );
262   connect( myGeomGUI,      SIGNAL( SignalCloseAllDialogs() ),        this, SLOT( ClickOnCancel() ) );
263
264   connect( buttonOk(),     SIGNAL( clicked() ), this, SLOT( ClickOnOk() ) );
265   connect( buttonApply(),  SIGNAL( clicked() ), this, SLOT( ClickOnApply() ) );
266
267   connect( this,           SIGNAL( constructorsClicked( int ) ), this, SLOT( ConstructorsClicked( int ) ) );
268
269   connect( myParamCoord,   SIGNAL( buttonClicked( int ) ), this, SLOT( ClickParamCoord( int ) ) );
270   connect( GroupOnCurve->PushButton1, SIGNAL( clicked() ),       this, SLOT( SetEditCurrentArgument() ) );
271   connect( GroupOnCurve->LineEdit1,   SIGNAL( returnPressed() ), this, SLOT( LineEditReturnPressed() ) );
272
273   connect( GroupOnSurface->PushButton1, SIGNAL( clicked() ),       this, SLOT( SetEditCurrentArgument() ) );
274   connect( GroupOnSurface->LineEdit1,   SIGNAL( returnPressed() ), this, SLOT( LineEditReturnPressed() ) );
275
276   connect( myBtnPopup, SIGNAL( triggered( QAction* ) ), SLOT( onBtnPopup( QAction* ) ) );
277   connect( GroupLineIntersection->PushButton1, SIGNAL( pressed() ),       this, SLOT( SetEditCurrentArgument() ) );
278   connect( GroupLineIntersection->PushButton2, SIGNAL( pressed() ),       this, SLOT( SetEditCurrentArgument() ) );
279   connect( GroupLineIntersection->LineEdit1,   SIGNAL( returnPressed() ), this, SLOT( LineEditReturnPressed() ) );
280   connect( GroupLineIntersection->LineEdit2,   SIGNAL( returnPressed() ), this, SLOT( LineEditReturnPressed() ) );
281
282   connect( GroupOnCurve->SpinBox_DX,   SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
283   connect( GroupOnSurface->SpinBox_DX, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
284   connect( GroupOnSurface->SpinBox_DY, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
285   connect( GroupXYZ->SpinBox_DX,       SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
286   connect( GroupXYZ->SpinBox_DY,       SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
287   connect( GroupXYZ->SpinBox_DZ,       SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
288   connect( GroupRefPoint->SpinBox_DX,  SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
289   connect( GroupRefPoint->SpinBox_DY,  SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
290   connect( GroupRefPoint->SpinBox_DZ,  SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
291
292   connect( myGeomGUI, SIGNAL( SignalDefaultStepValueChanged( double ) ), this,  SLOT( SetDoubleSpinBoxStep( double ) ) );
293
294   connect( myGeomGUI->getApp()->selectionMgr(), SIGNAL(currentSelectionChanged() ),
295            this,  SLOT(SelectionIntoArgument() ) );
296
297   initName( tr( "GEOM_VERTEX" ) );
298
299   ConstructorsClicked( 0 );
300 }
301
302 //=================================================================================
303 // function : SetDoubleSpinBoxStep()
304 // purpose  : Double spin box management
305 //=================================================================================
306 void BasicGUI_PointDlg::SetDoubleSpinBoxStep( double step )
307 {
308   GroupOnCurve->SpinBox_DX->setSingleStep(step);
309   GroupXYZ->SpinBox_DX->setSingleStep(step);
310   GroupXYZ->SpinBox_DY->setSingleStep(step);
311   GroupXYZ->SpinBox_DZ->setSingleStep(step);
312   GroupRefPoint->SpinBox_DX->setSingleStep(step);
313   GroupRefPoint->SpinBox_DY->setSingleStep(step);
314   GroupRefPoint->SpinBox_DZ->setSingleStep(step);
315 }
316
317
318 //=================================================================================
319 // function : ConstructorsClicked()
320 // purpose  : Radio button management
321 //=================================================================================
322 void BasicGUI_PointDlg::ConstructorsClicked(int constructorId)
323 {
324   switch ( constructorId ) {
325   case GEOM_POINT_XYZ:
326     {
327       globalSelection(); // close local contexts, if any
328       localSelection( GEOM::GEOM_Object::_nil(), TopAbs_VERTEX );
329
330       GroupRefPoint->hide();
331       GroupOnCurve->hide();
332       GroupLineIntersection->hide();
333       GroupOnSurface->hide();
334       myCoordGrp->hide();
335       myParamGroup->hide();
336       GroupXYZ->show();
337       break;
338     }
339   case GEOM_POINT_REF:
340     {
341       globalSelection(); // close local contexts, if any
342       localSelection( GEOM::GEOM_Object::_nil(), TopAbs_VERTEX );
343
344       myEditCurrentArgument = GroupRefPoint->LineEdit1;
345       myEditCurrentArgument->setText( "" );
346       myRefPoint = GEOM::GEOM_Object::_nil();
347       GroupRefPoint->PushButton1->setDown(true);
348       myParamGroup->hide();
349       GroupXYZ->hide();
350       GroupOnCurve->hide();
351       GroupLineIntersection->hide();
352       GroupOnSurface->hide();
353       GroupRefPoint->show();
354       myCoordGrp->show();
355       break;
356     }
357   case GEOM_POINT_EDGE:
358     {
359       globalSelection(); // close local contexts, if any
360       localSelection( GEOM::GEOM_Object::_nil(), TopAbs_EDGE );
361
362       myEditCurrentArgument = GroupOnCurve->LineEdit1;
363       myEditCurrentArgument->setText( "" );
364       myEdge = GEOM::GEOM_Object::_nil();
365       GroupOnCurve->PushButton1->setDown(true);
366       GroupRefPoint->hide();
367       GroupLineIntersection->hide();
368       GroupOnSurface->hide();
369       myParamGroup->show();
370       GroupOnCurve->show();
371       myCoordGrp->show();
372       updateParamCoord( false );
373       break;
374     }
375   case GEOM_POINT_INTINT:
376     {
377       globalSelection(); // close local contexts, if any
378       localSelection( GEOM::GEOM_Object::_nil(), TopAbs_EDGE );
379       myNeedType = TopAbs_EDGE;
380
381       myEditCurrentArgument = GroupLineIntersection->LineEdit1;
382       GroupLineIntersection->LineEdit1->setText( "" );
383       GroupLineIntersection->LineEdit2->setText( "" );
384       GroupLineIntersection->LineEdit1->setEnabled( true );
385       GroupLineIntersection->LineEdit2->setEnabled( false );
386       myLine1 = GEOM::GEOM_Object::_nil();
387       myLine2 = GEOM::GEOM_Object::_nil();
388       GroupLineIntersection->PushButton1->setDown(true);
389       GroupLineIntersection->PushButton2->setDown(false);
390       myParamGroup->hide();
391       GroupXYZ->hide();
392       GroupRefPoint->hide();
393       GroupOnCurve->hide();
394       GroupOnSurface->hide();
395       myCoordGrp->hide();
396       GroupLineIntersection->show();
397       break;
398     }
399   case GEOM_POINT_SURF:
400     {
401       globalSelection(); // close local contexts, if any
402       localSelection( GEOM::GEOM_Object::_nil(), TopAbs_FACE );
403
404       myEditCurrentArgument = GroupOnSurface->LineEdit1;
405       myEditCurrentArgument->setText( "" );
406       myFace = GEOM::GEOM_Object::_nil();
407       GroupOnSurface->PushButton1->setDown(true);
408       GroupRefPoint->hide();
409       GroupOnCurve->hide();
410       GroupLineIntersection->hide();
411       myParamGroup->show();
412       GroupOnSurface->show();
413       myCoordGrp->show();
414       updateParamCoord( false );
415       break;
416     }
417   }
418
419   myX->setText( "" );
420   myY->setText( "" );
421   myZ->setText( "" );
422
423   QTimer::singleShot(50, this, SLOT(updateSize()));
424
425   SelectionIntoArgument();
426 }
427
428
429 //=================================================================================
430 // function : ClickOnOk()
431 // purpose  :
432 //=================================================================================
433 void BasicGUI_PointDlg::ClickOnOk()
434 {
435   if ( onAccept() )
436     ClickOnCancel();
437 }
438
439
440 //=================================================================================
441 // function : ClickOnApply()
442 // purpose  :
443 //=================================================================================
444 bool BasicGUI_PointDlg::ClickOnApply()
445 {
446   if ( !onAccept() )
447     return false;
448
449   initName();
450   ConstructorsClicked( getConstructorId() );
451   return true;
452 }
453
454
455 //=================================================================================
456 // function : SelectionIntoArgument()
457 // purpose  : Called when selection as changed (for constructors not using local context)
458 //=================================================================================
459 void BasicGUI_PointDlg::SelectionIntoArgument()
460 {
461   erasePreview();
462   const int id = getConstructorId();
463
464   if ( ( id == GEOM_POINT_REF || id == GEOM_POINT_EDGE || id == GEOM_POINT_SURF ) && myEditCurrentArgument != 0 )
465   {
466     myEditCurrentArgument->setText( "" );
467     myX->setText( "" );
468     myY->setText( "" );
469     myZ->setText( "" );
470     myRefPoint = myEdge = myFace = GEOM::GEOM_Object::_nil();
471   } else if ( id == GEOM_POINT_INTINT ) {
472     myEditCurrentArgument->setText( "" );
473     if ( myEditCurrentArgument == GroupLineIntersection->LineEdit1 )
474       myLine1 = GEOM::GEOM_Object::_nil();
475     else if ( myEditCurrentArgument == GroupLineIntersection->LineEdit2 )
476       myLine2 = GEOM::GEOM_Object::_nil();
477   }
478
479   LightApp_SelectionMgr* aSelMgr = myGeomGUI->getApp()->selectionMgr();
480   SALOME_ListIO aSelList;
481   aSelMgr->selectedObjects(aSelList);
482
483   if (aSelList.Extent() == 1) {
484     Standard_Boolean aRes = Standard_False;
485     Handle(SALOME_InteractiveObject) anIO = aSelList.First();
486     GEOM::GEOM_Object_var aSelectedObject = GEOMBase::ConvertIOinGEOMObject( anIO, aRes );
487     if ( !CORBA::is_nil( aSelectedObject ) && aRes ) {
488       QString aName = GEOMBase::GetName(aSelectedObject);
489       TopoDS_Shape aShape;
490       if ( GEOMBase::GetShape( aSelectedObject, aShape, TopAbs_SHAPE ) && !aShape.IsNull() ) {
491         if ( id == GEOM_POINT_XYZ || id == GEOM_POINT_REF)
492           myNeedType = TopAbs_VERTEX;
493         else if ( id == GEOM_POINT_EDGE )
494           myNeedType = TopAbs_EDGE;
495         else if ( id == GEOM_POINT_SURF )
496           myNeedType = TopAbs_FACE;
497
498         TColStd_IndexedMapOfInteger aMap;
499         aSelMgr->GetIndexes(anIO, aMap);
500         if ( aMap.Extent() == 1 ) { // Local Selection
501           int anIndex = aMap( 1 );
502           if ( myNeedType == TopAbs_FACE )
503             aName += QString( ":face_%1" ).arg( anIndex );
504           else if ( myNeedType == TopAbs_WIRE )
505             aName += QString( ":wire_%1" ).arg( anIndex );
506           else if ( myNeedType == TopAbs_EDGE )
507             aName += QString( ":edge_%1" ).arg( anIndex );
508           else  if ( myNeedType == TopAbs_VERTEX )
509             aName += QString( ":vertex_%1" ).arg( anIndex );
510
511           //Find SubShape Object in Father
512           GEOM::GEOM_Object_var aFindedObject = GEOMBase_Helper::findObjectInFather(aSelectedObject, aName);
513           if ( aFindedObject->_is_nil() ) { // Object not found in study
514             GEOM::GEOM_IShapesOperations_var aShapesOp =
515               getGeomEngine()->GetIShapesOperations(getStudyId());
516             aSelectedObject = aShapesOp->GetSubShape(aSelectedObject, anIndex);
517           }
518           else {
519             aSelectedObject = aFindedObject; // get Object from study
520           }
521           GEOMBase::GetShape( aSelectedObject, aShape, TopAbs_SHAPE );
522         }
523         else { // Global Selection
524           if ( aShape.ShapeType() != myNeedType ) {
525             aSelectedObject = GEOM::GEOM_Object::_nil();
526             aName = "";
527             if ( id == GEOM_POINT_XYZ ) return;
528           }
529         }
530       }
531
532       if ( aShape.IsNull() || aShape.ShapeType() != myNeedType)
533         return;
534
535       myBusy = true;
536
537       if ( id == GEOM_POINT_XYZ ) {
538         gp_Pnt aPnt = BRep_Tool::Pnt( TopoDS::Vertex( aShape ) );
539         GroupXYZ->SpinBox_DX->setValue( aPnt.X() );
540         GroupXYZ->SpinBox_DY->setValue( aPnt.Y() );
541         GroupXYZ->SpinBox_DZ->setValue( aPnt.Z() );
542       }
543       else if ( id == GEOM_POINT_REF ) {
544         myRefPoint = aSelectedObject;
545         GroupRefPoint->LineEdit1->setText( aName );
546       }
547       else if ( id == GEOM_POINT_EDGE ) {
548         myEdge = aSelectedObject;
549         GroupOnCurve->LineEdit1->setText( aName );
550       }
551       else if ( id == GEOM_POINT_INTINT ) {
552         myEditCurrentArgument->setText( aName );
553         if ( myEditCurrentArgument == GroupLineIntersection->LineEdit1 ) {
554           myLine1 = aSelectedObject;
555           if ( !myLine1->_is_nil() && myLine2->_is_nil() ) {
556             GroupLineIntersection->PushButton2->setMenu( 0 );
557             GroupLineIntersection->PushButton2->click();
558             GroupLineIntersection->PushButton2->setDown(true);
559             GroupLineIntersection->PushButton2->setMenu( myBtnPopup );
560           }
561         }
562         else if ( myEditCurrentArgument == GroupLineIntersection->LineEdit2 ) {
563           myLine2 = aSelectedObject;
564           if ( !myLine2->_is_nil() && myLine1->_is_nil() ) {
565             GroupLineIntersection->PushButton1->setMenu( 0 );
566             GroupLineIntersection->PushButton1->click();
567             GroupLineIntersection->PushButton1->setDown(true);
568             GroupLineIntersection->PushButton1->setMenu( myBtnPopup );
569           }
570         }
571       }
572       else if ( id == GEOM_POINT_SURF )
573       {
574         myFace = aSelectedObject;
575         GroupOnSurface->LineEdit1->setText( aName );
576       }
577       myBusy = false;
578     }
579   }
580
581   displayPreview();
582 }
583
584
585 //=================================================================================
586 // function : LineEditReturnPressed()
587 // purpose  :
588 //=================================================================================
589 void BasicGUI_PointDlg::LineEditReturnPressed()
590 {
591   QLineEdit* send = (QLineEdit*)sender();
592   if ( send == GroupRefPoint->LineEdit1         ||
593        send == GroupOnCurve->LineEdit1          ||
594        send == GroupLineIntersection->LineEdit1 ||
595        send == GroupLineIntersection->LineEdit2  ) {
596     myEditCurrentArgument = send;
597     GEOMBase_Skeleton::LineEditReturnPressed();
598   }
599 }
600
601
602 //=================================================================================
603 // function : SetEditCurrentArgument()
604 // purpose  :
605 //=================================================================================
606 void BasicGUI_PointDlg::SetEditCurrentArgument()
607 {
608   QPushButton* send = (QPushButton*)sender();
609
610   if ( send == GroupRefPoint->PushButton1 ) {
611     GroupRefPoint->LineEdit1->setFocus();
612     myEditCurrentArgument = GroupRefPoint->LineEdit1;
613     globalSelection(); // close local contexts, if any
614     localSelection( GEOM::GEOM_Object::_nil(), TopAbs_VERTEX );
615   }
616   else if ( send == GroupOnCurve->PushButton1 ) {
617     GroupOnCurve->LineEdit1->setFocus();
618     myEditCurrentArgument = GroupOnCurve->LineEdit1;
619     globalSelection(); // close local contexts, if any
620     localSelection( GEOM::GEOM_Object::_nil(), TopAbs_EDGE );
621   }
622   else if ( send == GroupOnSurface->PushButton1 )
623   {
624     GroupOnSurface->LineEdit1->setFocus();
625     myEditCurrentArgument = GroupOnSurface->LineEdit1;
626     globalSelection(); // close local contexts, if any
627     localSelection( GEOM::GEOM_Object::_nil(), TopAbs_FACE );
628   }
629   else if ( send == GroupLineIntersection->PushButton1 ) {
630     GroupLineIntersection->LineEdit1->setFocus();
631     myEditCurrentArgument = GroupLineIntersection->LineEdit1;
632     GroupLineIntersection->PushButton2->setDown( false );
633     GroupLineIntersection->LineEdit1->setEnabled(true);
634     GroupLineIntersection->LineEdit2->setEnabled(false);
635   }
636   else if ( send == GroupLineIntersection->PushButton2 ) {
637     GroupLineIntersection->LineEdit2->setFocus();
638     myEditCurrentArgument = GroupLineIntersection->LineEdit2;
639     GroupLineIntersection->PushButton1->setDown( false );
640     GroupLineIntersection->LineEdit1->setEnabled(false);
641     GroupLineIntersection->LineEdit2->setEnabled(true);
642   }
643   send->setDown(true);
644
645   if ( ( send == GroupLineIntersection->PushButton1 ||
646          send == GroupLineIntersection->PushButton2 ) && !myBusy )
647     SelectionIntoArgument();
648 }
649
650
651 //=================================================================================
652 // function : enterEvent()
653 // purpose  : to reactivate this dialog box when mouse enter onto the window
654 //=================================================================================
655 void BasicGUI_PointDlg::enterEvent( QEvent* )
656 {
657   if ( !mainFrame()->GroupConstructors->isEnabled() )
658     ActivateThisDialog();
659 }
660
661
662 //=================================================================================
663 // function : ActivateThisDialog()
664 // purpose  :
665 //=================================================================================
666 void BasicGUI_PointDlg::ActivateThisDialog( )
667 {
668   GEOMBase_Skeleton::ActivateThisDialog();
669
670   connect( myGeomGUI->getApp()->selectionMgr(), SIGNAL( currentSelectionChanged() ),
671            this, SLOT( SelectionIntoArgument() ) );
672
673   ConstructorsClicked( getConstructorId() );
674 }
675
676
677 //=================================================================================
678 // function : DeactivateActiveDialog()
679 // purpose  : public slot to deactivate if active
680 //=================================================================================
681 void BasicGUI_PointDlg::DeactivateActiveDialog()
682 {
683   // myGeomGUI->SetState( -1 );
684   GEOMBase_Skeleton::DeactivateActiveDialog();
685 }
686
687
688 //=================================================================================
689 // function : ValueChangedInSpinBox()
690 // purpose  :
691 //=================================================================================
692 void BasicGUI_PointDlg::ValueChangedInSpinBox(double newValue)
693 {
694   displayPreview();
695 }
696
697 //=================================================================================
698 // funcion  : getParameter()
699 // purpose  :
700 //=================================================================================
701 double BasicGUI_PointDlg::getParameter() const
702 {
703   return GroupOnCurve->SpinBox_DX->value();
704 }
705
706
707 //=================================================================================
708 // funcion  : getUParameter()
709 // purpose  :
710 //=================================================================================
711 double BasicGUI_PointDlg::getUParameter() const
712 {
713   return GroupOnSurface->SpinBox_DX->value();
714 }
715
716
717 //=================================================================================
718 // funcion  : getVParameter()
719 // purpose  :
720 //=================================================================================
721 double BasicGUI_PointDlg::getVParameter() const
722 {
723   return GroupOnSurface->SpinBox_DY->value();
724 }
725
726
727 //=================================================================================
728 // function : OnPointSelected
729 // purpose  :
730 //=================================================================================
731 void BasicGUI_PointDlg::OnPointSelected( const gp_Pnt& thePnt )
732 {
733   if ( getConstructorId() == GEOM_POINT_XYZ ) {
734     GroupXYZ->SpinBox_DX->setValue( thePnt.X() );
735     GroupXYZ->SpinBox_DY->setValue( thePnt.Y() );
736     GroupXYZ->SpinBox_DZ->setValue( thePnt.Z() );
737
738     displayPreview();
739   }
740 }
741
742 //=================================================================================
743 // function : createOperation
744 // purpose  :
745 //=================================================================================
746 GEOM::GEOM_IOperations_ptr BasicGUI_PointDlg::createOperation()
747 {
748   return myGeomGUI->GetGeomGen()->GetIBasicOperations( getStudyId() );
749 }
750
751 //=================================================================================
752 // function : isValid
753 // purpose  :
754 //=================================================================================
755 bool BasicGUI_PointDlg::isValid( QString& msg )
756 {
757   const int id = getConstructorId();
758   if ( id == GEOM_POINT_XYZ ) {
759     bool ok = true;
760     ok = GroupXYZ->SpinBox_DX->isValid( msg, !IsPreview() ) && ok;
761     ok = GroupXYZ->SpinBox_DY->isValid( msg, !IsPreview() ) && ok;
762     ok = GroupXYZ->SpinBox_DZ->isValid( msg, !IsPreview() ) && ok;
763     return ok;
764   }
765   else if ( id == GEOM_POINT_REF ) {
766     bool ok = true;
767     ok = GroupRefPoint->SpinBox_DX->isValid( msg, !IsPreview() ) && ok;
768     ok = GroupRefPoint->SpinBox_DY->isValid( msg, !IsPreview() ) && ok;
769     ok = GroupRefPoint->SpinBox_DZ->isValid( msg, !IsPreview() ) && ok;
770
771     return !myRefPoint->_is_nil() && ok;
772   }
773   else if ( id == GEOM_POINT_EDGE ) {
774     bool ok = true;
775     if ( myParamCoord->checkedId() == PARAM_VALUE )
776       ok = GroupOnCurve->SpinBox_DX->isValid( msg, !IsPreview() );
777     else {
778       ok = GroupXYZ->SpinBox_DX->isValid( msg, !IsPreview() ) && ok;
779       ok = GroupXYZ->SpinBox_DY->isValid( msg, !IsPreview() ) && ok;
780       ok = GroupXYZ->SpinBox_DZ->isValid( msg, !IsPreview() ) && ok;
781     }
782     return !myEdge->_is_nil() && ok;
783   }
784   else if ( id == GEOM_POINT_INTINT )
785     return ( !myLine1->_is_nil() && !myLine2->_is_nil() );
786   else if ( id == GEOM_POINT_SURF ) {
787     bool ok = true;
788     if ( myParamCoord->checkedId() == PARAM_VALUE ) {
789       ok = GroupOnSurface->SpinBox_DX->isValid( msg, !IsPreview() ) && ok;
790       ok = GroupOnSurface->SpinBox_DY->isValid( msg, !IsPreview() ) && ok;
791     }
792     else {
793       ok = GroupXYZ->SpinBox_DX->isValid( msg, !IsPreview() ) && ok;
794       ok = GroupXYZ->SpinBox_DY->isValid( msg, !IsPreview() ) && ok;
795       ok = GroupXYZ->SpinBox_DZ->isValid( msg, !IsPreview() ) && ok;
796     }
797     return !myFace->_is_nil() && ok;
798   }
799   return false;
800 }
801
802 //=================================================================================
803 // function : execute
804 // purpose  :
805 //=================================================================================
806 bool BasicGUI_PointDlg::execute( ObjectList& objects )
807 {
808   bool res = false;
809
810   GEOM::GEOM_Object_var anObj;
811   QStringList aParameters;
812
813   GEOM::GEOM_IBasicOperations_var anOper = GEOM::GEOM_IBasicOperations::_narrow( getOperation() );
814
815   switch ( getConstructorId() ) {
816   case GEOM_POINT_XYZ :
817     {
818       double x = GroupXYZ->SpinBox_DX->value();
819       double y = GroupXYZ->SpinBox_DY->value();
820       double z = GroupXYZ->SpinBox_DZ->value();
821
822       aParameters << GroupXYZ->SpinBox_DX->text();
823       aParameters << GroupXYZ->SpinBox_DY->text();
824       aParameters << GroupXYZ->SpinBox_DZ->text();
825
826       anObj = anOper->MakePointXYZ( x, y, z );
827       res = true;
828       break;
829     }
830   case GEOM_POINT_REF :
831     {
832       double dx = GroupRefPoint->SpinBox_DX->value();
833       double dy = GroupRefPoint->SpinBox_DY->value();
834       double dz = GroupRefPoint->SpinBox_DZ->value();
835
836       aParameters << GroupRefPoint->SpinBox_DX->text();
837       aParameters << GroupRefPoint->SpinBox_DY->text();
838       aParameters << GroupRefPoint->SpinBox_DZ->text();
839
840       anObj = anOper->MakePointWithReference( myRefPoint, dx, dy, dz );
841       res = true;
842       break;
843     }
844   case GEOM_POINT_EDGE :
845     {
846       if ( myParamCoord->checkedId() == PARAM_VALUE ) {
847         anObj = anOper->MakePointOnCurve( myEdge, getParameter() );
848         aParameters<<GroupOnCurve->SpinBox_DX->text();
849       } else {
850         double x = GroupXYZ->SpinBox_DX->value();
851         double y = GroupXYZ->SpinBox_DY->value();
852         double z = GroupXYZ->SpinBox_DZ->value();
853
854         aParameters << GroupXYZ->SpinBox_DX->text();
855         aParameters << GroupXYZ->SpinBox_DY->text();
856         aParameters << GroupXYZ->SpinBox_DZ->text();
857
858         anObj = anOper->MakePointOnCurveByCoord( myEdge, x, y, z );
859       }
860       res = true;
861       break;
862     }
863   case GEOM_POINT_INTINT :
864     anObj = anOper->MakePointOnLinesIntersection( myLine1, myLine2 );
865     if ( !anObj->_is_nil() ) {
866       QString aName = getNewObjectName();
867       if ( anObj->GetShapeType() == GEOM::COMPOUND && aName.startsWith("Vertex") )
868         initName( tr( "GEOM_COMPOUND" ) );
869       else if (  anObj->GetShapeType() == GEOM::VERTEX && aName.startsWith("Compound"))
870         initName( tr( "GEOM_VERTEX" ) );
871     }
872     res = true;
873     break;
874   case GEOM_POINT_SURF :
875     {
876       if ( myParamCoord->checkedId() == PARAM_VALUE ) {
877         anObj = anOper->MakePointOnSurface( myFace, getUParameter(), getVParameter() );
878         aParameters<<GroupOnSurface->SpinBox_DX->text();
879         aParameters<<GroupOnSurface->SpinBox_DY->text();
880       } else {
881         double x = GroupXYZ->SpinBox_DX->value();
882         double y = GroupXYZ->SpinBox_DY->value();
883         double z = GroupXYZ->SpinBox_DZ->value();
884
885         aParameters << GroupXYZ->SpinBox_DX->text();
886         aParameters << GroupXYZ->SpinBox_DY->text();
887         aParameters << GroupXYZ->SpinBox_DZ->text();
888
889         anObj = anOper->MakePointOnSurfaceByCoord( myFace, x, y, z );
890       }
891       res = true;
892       break;
893     }
894   }
895
896   const int id = getConstructorId();
897   if(!anObj->_is_nil() && !IsPreview() && (id == GEOM_POINT_XYZ ||
898                                            id == GEOM_POINT_REF ||
899                                            id == GEOM_POINT_EDGE ||
900                                            id == GEOM_POINT_SURF) ) {
901       anObj->SetParameters(aParameters.join(":").toLatin1().constData());
902   }
903
904   if ( id == GEOM_POINT_REF || id == GEOM_POINT_EDGE || id == GEOM_POINT_SURF ) {
905     TopoDS_Shape aShape;
906     if ( GEOMBase::GetShape( anObj, aShape ) && !aShape.IsNull() &&
907          aShape.ShapeType() == TopAbs_VERTEX ) {
908       gp_Pnt aPnt = BRep_Tool::Pnt( TopoDS::Vertex( aShape ) );
909       SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
910       int aPrecision = resMgr->integerValue( "Geometry", "length_precision", 6 );
911       myX->setText( DlgRef::PrintDoubleValue( aPnt.X(), aPrecision ) );
912       myY->setText( DlgRef::PrintDoubleValue( aPnt.Y(), aPrecision ) );
913       myZ->setText( DlgRef::PrintDoubleValue( aPnt.Z(), aPrecision ) );
914     }
915     else {
916       myX->setText( "" );
917       myY->setText( "" );
918       myZ->setText( "" );
919     }
920   }
921
922   if ( !anObj->_is_nil() ) {
923     objects.push_back( anObj._retn() );
924   }
925
926   return res;
927 }
928
929 //=================================================================================
930 // function : addSubshapeToStudy
931 // purpose  : virtual method to add new SubObjects if local selection
932 //=================================================================================
933 void BasicGUI_PointDlg::addSubshapesToStudy()
934 {
935   QMap<QString, GEOM::GEOM_Object_var> objMap;
936
937   switch ( getConstructorId() ) {
938   case GEOM_POINT_XYZ:
939     break;
940   case GEOM_POINT_REF:
941     objMap[GroupRefPoint->LineEdit1->text()] = myRefPoint;
942     break;
943   case GEOM_POINT_EDGE:
944     objMap[GroupOnCurve->LineEdit1->text()] = myEdge;
945     break;
946   case GEOM_POINT_INTINT:
947     objMap[GroupLineIntersection->LineEdit1->text()] = myLine1;
948     objMap[GroupLineIntersection->LineEdit2->text()] = myLine2;
949     break;
950   case GEOM_POINT_SURF:
951     objMap[GroupOnSurface->LineEdit1->text()] = myFace;
952     break;
953   }
954   addSubshapesToFather( objMap );
955 }
956
957 //=================================================================================
958 // function : ClickParamCoord()
959 // purpose  :
960 //=================================================================================
961 void BasicGUI_PointDlg::ClickParamCoord( int id )
962 {
963   updateParamCoord( true );
964   displayPreview();
965 }
966
967 //=================================================================================
968 // function : updateParamCoord
969 // purpose  :
970 //=================================================================================
971 void BasicGUI_PointDlg::updateParamCoord(bool theIsUpdate)
972 {
973   bool isParam = myParamCoord->checkedId() == PARAM_VALUE;
974
975   const int id = getConstructorId();
976   if ( id == GEOM_POINT_EDGE ) {
977     GroupOnCurve->TextLabel2->setShown( isParam );
978     GroupOnCurve->SpinBox_DX->setShown( isParam );
979   }
980   else if ( id == GEOM_POINT_SURF ) {
981     GroupOnSurface->TextLabel2->setShown( isParam );
982     GroupOnSurface->TextLabel3->setShown( isParam );
983     GroupOnSurface->SpinBox_DX->setShown( isParam );
984     GroupOnSurface->SpinBox_DY->setShown( isParam );
985   }
986
987   GroupXYZ->setShown( !isParam );
988
989   if ( theIsUpdate )
990     QTimer::singleShot(50, this, SLOT(updateSize()));
991 }
992
993 //=================================================================================
994 // function : onBtnPopup()
995 // purpose  :
996 //=================================================================================
997 void BasicGUI_PointDlg::onBtnPopup( QAction* a )
998 {
999   int index = myActions[a];
1000   globalSelection(); // close local contexts, if any
1001   QString type;
1002   if ( index == 0 )
1003     myNeedType = TopAbs_EDGE;
1004   else 
1005     myNeedType = TopAbs_WIRE;
1006   
1007   localSelection( GEOM::GEOM_Object::_nil(), myNeedType );
1008 }
1009
1010 //=================================================================================
1011 // function : updateSize
1012 // purpose  : adjust dialog size to minimum
1013 //=================================================================================
1014 void BasicGUI_PointDlg::updateSize() 
1015 {
1016   qApp->processEvents();
1017   updateGeometry();
1018   resize( minimumSizeHint() );
1019 }