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