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