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