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