1 // GEOM GEOMGUI : GUI for Geometry component
3 // Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
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.
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.
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
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
24 // File : BasicGUI_PointDlg.cxx
25 // Author : Lucien PIGNOLONI
29 #include "BasicGUI_PointDlg.h"
31 #include "SUIT_Session.h"
32 #include "SalomeApp_Application.h"
33 #include "LightApp_SelectionMgr.h"
35 #include "GEOMImpl_Types.hxx"
39 #include "utilities.h"
42 #include <TopoDS_Shape.hxx>
43 #include <TopoDS_Vertex.hxx>
44 #include <TopAbs_ShapeEnum.hxx>
46 #include <BRep_Tool.hxx>
48 #include <TColStd_IndexedMapOfInteger.hxx>
49 #include <TopTools_IndexedMapOfShape.hxx>
51 #include <qapplication.h>
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 )
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")));
73 setCaption(tr("GEOM_POINT_TITLE"));
75 QGroupBox* aFrame = new QGroupBox( 1, Qt::Horizontal, this );
76 aFrame->setInsideMargin( 0 );
77 aFrame->setFrameStyle( QFrame::NoFrame );
79 /***************************************************************/
80 GroupConstructors->setTitle(tr("GEOM_POINTS"));
81 RadioButton1->setPixmap(image0);
82 RadioButton2->setPixmap(image3);
83 RadioButton3->setPixmap(image1);
85 RadioButton4->setPixmap(image4);
87 RadioButton5->setPixmap(image5);
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"));
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);
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);
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"));
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);
123 Layout1->addWidget( aFrame, 2, 0 );
124 /***************************************************************/
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 );
134 myX->setReadOnly( true );
135 myY->setReadOnly( true );
136 myZ->setReadOnly( true );
138 myX->setEnabled( false );
139 myY->setEnabled( false );
140 myZ->setEnabled( false );
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 );
148 setHelpFileName("create_point_page.html");
153 //=================================================================================
154 // function : ~BasicGUI_PointDlg()
155 // purpose : Destructor
156 //=================================================================================
157 BasicGUI_PointDlg::~BasicGUI_PointDlg()
161 //=================================================================================
164 //=================================================================================
165 void BasicGUI_PointDlg::Init()
167 GroupOnCurve->LineEdit1->setReadOnly( true );
168 GroupOnSurface->LineEdit1->setReadOnly( true );
169 GroupRefPoint->LineEdit1->setReadOnly( true );
170 GroupLineIntersection->LineEdit1->setReadOnly( true );
171 GroupLineIntersection->LineEdit2->setReadOnly( true );
173 myEdge = GEOM::GEOM_Object::_nil();
174 myRefPoint = GEOM::GEOM_Object::_nil();
176 myEditCurrentArgument = 0;
178 /* Get setting of step value from file configuration */
179 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
180 double step = resMgr->doubleValue( "Geometry", "SettingsGeomStep", 100);
182 /* min, max, step and decimals for spin boxes */
183 GroupXYZ->SpinBox_DX->RangeStepAndValidator(COORD_MIN, COORD_MAX, step, DBL_DIGITS_DISPLAY);
184 GroupXYZ->SpinBox_DY->RangeStepAndValidator(COORD_MIN, COORD_MAX, step, DBL_DIGITS_DISPLAY);
185 GroupXYZ->SpinBox_DZ->RangeStepAndValidator(COORD_MIN, COORD_MAX, step, DBL_DIGITS_DISPLAY);
186 GroupXYZ->SpinBox_DX->SetValue(0.0);
187 GroupXYZ->SpinBox_DY->SetValue(0.0);
188 GroupXYZ->SpinBox_DZ->SetValue(0.0);
190 GroupRefPoint->SpinBox_DX->RangeStepAndValidator(COORD_MIN, COORD_MAX, step, DBL_DIGITS_DISPLAY);
191 GroupRefPoint->SpinBox_DY->RangeStepAndValidator(COORD_MIN, COORD_MAX, step, DBL_DIGITS_DISPLAY);
192 GroupRefPoint->SpinBox_DZ->RangeStepAndValidator(COORD_MIN, COORD_MAX, step, DBL_DIGITS_DISPLAY);
193 GroupRefPoint->SpinBox_DX->SetValue(0.0);
194 GroupRefPoint->SpinBox_DY->SetValue(0.0);
195 GroupRefPoint->SpinBox_DZ->SetValue(0.0);
198 GroupOnCurve->SpinBox_DX->RangeStepAndValidator(0., 1., step, DBL_DIGITS_DISPLAY);
199 GroupOnCurve->SpinBox_DX->SetValue( 0.5 );
201 GroupOnSurface->SpinBox_DX->RangeStepAndValidator(0., 1., step, DBL_DIGITS_DISPLAY);
202 GroupOnSurface->SpinBox_DX->SetValue( 0.5 );
203 GroupOnSurface->SpinBox_DY->RangeStepAndValidator(0., 1., step, DBL_DIGITS_DISPLAY);
204 GroupOnSurface->SpinBox_DY->SetValue( 0.5 );
206 /* signals and slots connections */
207 connect(buttonCancel, SIGNAL(clicked()), this, SLOT(ClickOnCancel()));
208 connect(myGeomGUI, SIGNAL(SignalDeactivateActiveDialog()), this, SLOT(DeactivateActiveDialog()));
209 connect(myGeomGUI, SIGNAL(SignalCloseAllDialogs()), this, SLOT(ClickOnCancel()));
211 connect(buttonOk, SIGNAL(clicked()), this, SLOT(ClickOnOk()));
212 connect(buttonApply, SIGNAL(clicked()), this, SLOT(ClickOnApply()));
213 connect(GroupConstructors, SIGNAL(clicked(int)), this, SLOT(ConstructorsClicked(int)));
215 connect(GroupOnCurve->PushButton1, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
216 connect(GroupOnCurve->LineEdit1, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed()));
217 connect(GroupOnSurface->PushButton1, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
218 connect(GroupOnSurface->LineEdit1, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed()));
219 connect(GroupLineIntersection->PushButton1, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
220 connect(GroupLineIntersection->PushButton2, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
221 connect(GroupLineIntersection->LineEdit1, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed()));
222 connect(GroupLineIntersection->LineEdit2, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed()));
224 connect(GroupOnCurve->SpinBox_DX, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double)));
225 connect(GroupOnSurface->SpinBox_DX, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double)));
226 connect(GroupOnSurface->SpinBox_DY, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double)));
227 connect(GroupXYZ->SpinBox_DX, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double)));
228 connect(GroupXYZ->SpinBox_DY, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double)));
229 connect(GroupXYZ->SpinBox_DZ, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double)));
230 connect(GroupRefPoint->SpinBox_DX, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double)));
231 connect(GroupRefPoint->SpinBox_DY, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double)));
232 connect(GroupRefPoint->SpinBox_DZ, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double)));
234 connect(myGeomGUI, SIGNAL(SignalDefaultStepValueChanged(double)),
235 GroupOnCurve->SpinBox_DX, SLOT(SetStep(double)));
236 connect(myGeomGUI, SIGNAL(SignalDefaultStepValueChanged(double)),
237 GroupOnSurface->SpinBox_DX, SLOT(SetStep(double)));
238 connect(myGeomGUI, SIGNAL(SignalDefaultStepValueChanged(double)),
239 GroupOnSurface->SpinBox_DY, SLOT(SetStep(double)));
240 connect(myGeomGUI, SIGNAL(SignalDefaultStepValueChanged(double)),
241 GroupXYZ->SpinBox_DX, SLOT(SetStep(double)));
242 connect(myGeomGUI, SIGNAL(SignalDefaultStepValueChanged(double)),
243 GroupXYZ->SpinBox_DY, SLOT(SetStep(double)));
244 connect(myGeomGUI, SIGNAL(SignalDefaultStepValueChanged(double)),
245 GroupXYZ->SpinBox_DZ, SLOT(SetStep(double)));
246 connect(myGeomGUI, SIGNAL(SignalDefaultStepValueChanged(double)),
247 GroupRefPoint->SpinBox_DX, SLOT(SetStep(double)));
248 connect(myGeomGUI, SIGNAL(SignalDefaultStepValueChanged(double)),
249 GroupRefPoint->SpinBox_DY, SLOT(SetStep(double)));
250 connect(myGeomGUI, SIGNAL(SignalDefaultStepValueChanged(double)),
251 GroupRefPoint->SpinBox_DZ, SLOT(SetStep(double)));
253 connect(myGeomGUI->getApp()->selectionMgr(), SIGNAL(currentSelectionChanged()),
254 this, SLOT(SelectionIntoArgument()));
256 initName( tr("GEOM_VERTEX") );
258 ConstructorsClicked( 0 );
261 //=================================================================================
262 // function : ConstructorsClicked()
263 // purpose : Radio button management
264 //=================================================================================
265 void BasicGUI_PointDlg::ConstructorsClicked (int constructorId)
267 globalSelection(); // close local contexts, if any
269 switch (constructorId)
273 localSelection(GEOM::GEOM_Object::_nil(), TopAbs_VERTEX);
275 GroupRefPoint->hide();
276 GroupOnCurve->hide();
277 GroupLineIntersection->hide();
279 GroupOnSurface->hide();
285 myEditCurrentArgument = GroupRefPoint->LineEdit1;
286 myEditCurrentArgument->setText("");
287 myRefPoint = GEOM::GEOM_Object::_nil();
289 localSelection(GEOM::GEOM_Object::_nil(), TopAbs_VERTEX);
292 GroupOnCurve->hide();
293 GroupRefPoint->show();
294 GroupLineIntersection->hide();
295 GroupOnSurface->hide();
301 myEditCurrentArgument = GroupOnCurve->LineEdit1;
302 myEditCurrentArgument->setText("");
303 myEdge = GEOM::GEOM_Object::_nil();
305 localSelection(GEOM::GEOM_Object::_nil(), TopAbs_EDGE);
308 GroupRefPoint->hide();
309 GroupOnCurve->show();
310 GroupLineIntersection->hide();
311 GroupOnSurface->hide();
317 myEditCurrentArgument = GroupLineIntersection->LineEdit1;
318 GroupLineIntersection->LineEdit1->setText("");
319 GroupLineIntersection->LineEdit2->setText("");
320 myLine1 = GEOM::GEOM_Object::_nil();
321 myLine2 = GEOM::GEOM_Object::_nil();
323 localSelection(GEOM::GEOM_Object::_nil(), TopAbs_EDGE);
326 GroupRefPoint->hide();
327 GroupOnCurve->hide();
328 GroupLineIntersection->show();
329 GroupOnSurface->hide();
335 myEditCurrentArgument = GroupOnSurface->LineEdit1;
336 myEditCurrentArgument->setText("");
337 myFace = GEOM::GEOM_Object::_nil();
339 localSelection(GEOM::GEOM_Object::_nil(), TopAbs_FACE);
342 GroupRefPoint->hide();
343 GroupOnCurve->hide();
344 GroupLineIntersection->hide();
345 GroupOnSurface->show();
355 qApp->processEvents();
357 resize( minimumSize() );
359 SelectionIntoArgument();
362 //=================================================================================
363 // function : ClickOnOk()
365 //=================================================================================
366 void BasicGUI_PointDlg::ClickOnOk()
372 //=================================================================================
373 // function : ClickOnApply()
375 //=================================================================================
376 bool BasicGUI_PointDlg::ClickOnApply()
382 ConstructorsClicked(getConstructorId());
386 //=================================================================================
387 // function : ClickOnCancel()
389 //=================================================================================
390 void BasicGUI_PointDlg::ClickOnCancel()
392 GEOMBase_Skeleton::ClickOnCancel();
395 //=================================================================================
396 // function : SelectionIntoArgument()
397 // purpose : Called when selection as changed (for constructors not using local context)
398 //=================================================================================
399 void BasicGUI_PointDlg::SelectionIntoArgument()
401 const int id = getConstructorId();
403 if ((id == 1 || id == 2 || id == 4 ) && myEditCurrentArgument != 0)
405 myEditCurrentArgument->setText("");
409 myRefPoint = myEdge = myFace = GEOM::GEOM_Object::_nil();
412 if (IObjectCount() == 1)
414 Standard_Boolean aRes = Standard_False;
415 Handle(SALOME_InteractiveObject) anIO = firstIObject();
416 GEOM::GEOM_Object_var aSelectedObject = GEOMBase::ConvertIOinGEOMObject(anIO, aRes);
417 if (!CORBA::is_nil(aSelectedObject) && aRes)
419 QString aName = GEOMBase::GetName(aSelectedObject);
422 if (GEOMBase::GetShape(aSelectedObject, aShape, TopAbs_SHAPE) && !aShape.IsNull())
424 TopAbs_ShapeEnum aNeedType = TopAbs_VERTEX;
425 if (id == 2 || id == 3)
426 aNeedType = TopAbs_EDGE;
428 aNeedType = TopAbs_FACE;
430 LightApp_SelectionMgr* aSelMgr = myGeomGUI->getApp()->selectionMgr();
431 TColStd_IndexedMapOfInteger aMap;
432 aSelMgr->GetIndexes(firstIObject(), aMap);
433 if (aMap.Extent() == 1) // Local Selection
435 int anIndex = aMap(1);
436 if (aNeedType == TopAbs_EDGE)
437 aName += QString(":edge_%1").arg(anIndex);
439 aName += QString(":vertex_%1").arg(anIndex);
441 //Find SubShape Object in Father
442 GEOM::GEOM_Object_var aFindedObject = GEOMBase_Helper::findObjectInFather(aSelectedObject, aName);
444 if ( aFindedObject == GEOM::GEOM_Object::_nil() ) { // Object not found in study
445 GEOM::GEOM_IShapesOperations_var aShapesOp = getGeomEngine()->GetIShapesOperations(getStudyId());
446 aSelectedObject = aShapesOp->GetSubShape(aSelectedObject, anIndex);
449 aSelectedObject = aFindedObject; // get Object from study
451 else // Global Selection
453 if (aShape.ShapeType() != aNeedType) {
454 aSelectedObject = GEOM::GEOM_Object::_nil();
463 if (aShape.IsNull()) return;
464 gp_Pnt aPnt = BRep_Tool::Pnt( TopoDS::Vertex( aShape ) );
465 GroupXYZ->SpinBox_DX->SetValue( aPnt.X() );
466 GroupXYZ->SpinBox_DY->SetValue( aPnt.Y() );
467 GroupXYZ->SpinBox_DZ->SetValue( aPnt.Z() );
471 myRefPoint = aSelectedObject;
472 GroupRefPoint->LineEdit1->setText(aName);
476 myEdge = aSelectedObject;
477 GroupOnCurve->LineEdit1->setText(aName);
481 if (myEditCurrentArgument == GroupLineIntersection->LineEdit1) {
482 myLine1 = aSelectedObject;
483 myEditCurrentArgument->setText(aName);
485 else if (myEditCurrentArgument == GroupLineIntersection->LineEdit2) {
486 myLine2 = aSelectedObject;
487 myEditCurrentArgument->setText(aName);
492 myFace = aSelectedObject;
493 GroupOnSurface->LineEdit1->setText(aName);
501 //=================================================================================
502 // function : LineEditReturnPressed()
504 //=================================================================================
505 void BasicGUI_PointDlg::LineEditReturnPressed()
507 QLineEdit* send = (QLineEdit*)sender();
508 if ( send == GroupRefPoint->LineEdit1 || send == GroupOnCurve->LineEdit1 ||
509 send == GroupLineIntersection->LineEdit1 || send == GroupLineIntersection->LineEdit2 )
511 myEditCurrentArgument = send;
512 GEOMBase_Skeleton::LineEditReturnPressed();
516 //=================================================================================
517 // function : SetEditCurrentArgument()
519 //=================================================================================
520 void BasicGUI_PointDlg::SetEditCurrentArgument()
522 globalSelection(); // close local contexts, if any
524 QPushButton* send = (QPushButton*)sender();
525 globalSelection( GEOM_POINT); // to break previous local selection
527 if ( send == GroupRefPoint->PushButton1 )
529 GroupRefPoint->LineEdit1->setFocus();
530 myEditCurrentArgument = GroupRefPoint->LineEdit1;
532 localSelection( GEOM::GEOM_Object::_nil(), TopAbs_VERTEX );
534 else if ( send == GroupOnCurve->PushButton1 )
536 GroupOnCurve->LineEdit1->setFocus();
537 myEditCurrentArgument = GroupOnCurve->LineEdit1;
539 localSelection( GEOM::GEOM_Object::_nil(), TopAbs_EDGE );
541 else if ( send == GroupOnSurface->PushButton1 )
543 GroupOnSurface->LineEdit1->setFocus();
544 myEditCurrentArgument = GroupOnSurface->LineEdit1;
546 localSelection( GEOM::GEOM_Object::_nil(), TopAbs_FACE );
548 else if ( send == GroupLineIntersection->PushButton1 )
550 GroupLineIntersection->LineEdit1->setFocus();
551 myEditCurrentArgument = GroupLineIntersection->LineEdit1;
553 localSelection( GEOM::GEOM_Object::_nil(), TopAbs_EDGE );
555 else if ( send == GroupLineIntersection->PushButton2 )
557 GroupLineIntersection->LineEdit2->setFocus();
558 myEditCurrentArgument = GroupLineIntersection->LineEdit2;
560 localSelection( GEOM::GEOM_Object::_nil(), TopAbs_EDGE );
564 //=================================================================================
565 // function : enterEvent()
566 // purpose : to reactivate this dialog box when mouse enter onto the window
567 //=================================================================================
568 void BasicGUI_PointDlg::enterEvent(QEvent* e)
570 if ( !GroupConstructors->isEnabled() )
571 ActivateThisDialog();
574 //=================================================================================
575 // function : ActivateThisDialog()
577 //=================================================================================
578 void BasicGUI_PointDlg::ActivateThisDialog( )
580 GEOMBase_Skeleton::ActivateThisDialog();
581 // myGeomGUI->SetState( 0 );
582 ConstructorsClicked( getConstructorId() );
585 //=================================================================================
586 // function : DeactivateActiveDialog()
587 // purpose : public slot to deactivate if active
588 //=================================================================================
589 void BasicGUI_PointDlg::DeactivateActiveDialog()
591 // myGeomGUI->SetState( -1 );
592 GEOMBase_Skeleton::DeactivateActiveDialog();
595 //=================================================================================
596 // function : ValueChangedInSpinBox()
598 //=================================================================================
599 void BasicGUI_PointDlg::ValueChangedInSpinBox(double newValue)
604 //=================================================================================
605 // funcion : getParameter()
607 //=================================================================================
608 double BasicGUI_PointDlg::getParameter() const
610 return GroupOnCurve->SpinBox_DX->GetValue();
614 //=================================================================================
615 // funcion : getUParameter()
617 //=================================================================================
618 double BasicGUI_PointDlg::getUParameter() const
620 return GroupOnSurface->SpinBox_DX->GetValue();
624 //=================================================================================
625 // funcion : getVParameter()
627 //=================================================================================
628 double BasicGUI_PointDlg::getVParameter() const
630 return GroupOnSurface->SpinBox_DY->GetValue();
634 //=================================================================================
635 // function : OnPointSelected
637 //=================================================================================
638 void BasicGUI_PointDlg::OnPointSelected( const gp_Pnt& thePnt )
640 if ( getConstructorId() == 0 )
642 GroupXYZ->SpinBox_DX->SetValue( thePnt.X() );
643 GroupXYZ->SpinBox_DY->SetValue( thePnt.Y() );
644 GroupXYZ->SpinBox_DZ->SetValue( thePnt.Z() );
650 //=================================================================================
651 // function : createOperation
653 //=================================================================================
654 GEOM::GEOM_IOperations_ptr BasicGUI_PointDlg::createOperation()
656 return myGeomGUI->GetGeomGen()->GetIBasicOperations( getStudyId() );
659 //=================================================================================
660 // function : isValid
662 //=================================================================================
663 bool BasicGUI_PointDlg::isValid( QString& msg )
665 const int id = getConstructorId();
669 return !myRefPoint->_is_nil();
671 return !myEdge->_is_nil();
673 return ( !myLine1->_is_nil() && !myLine2->_is_nil() );
675 return !myFace->_is_nil();
679 //=================================================================================
680 // function : execute
682 //=================================================================================
683 bool BasicGUI_PointDlg::execute( ObjectList& objects )
687 GEOM::GEOM_Object_var anObj;
689 switch ( getConstructorId() )
693 double x = GroupXYZ->SpinBox_DX->GetValue();
694 double y = GroupXYZ->SpinBox_DY->GetValue();
695 double z = GroupXYZ->SpinBox_DZ->GetValue();
697 anObj = GEOM::GEOM_IBasicOperations::_narrow( getOperation() )->MakePointXYZ( x,y,z );
703 double dx = GroupRefPoint->SpinBox_DX->GetValue();
704 double dy = GroupRefPoint->SpinBox_DY->GetValue();
705 double dz = GroupRefPoint->SpinBox_DZ->GetValue();
707 anObj = GEOM::GEOM_IBasicOperations::_narrow( getOperation() )->
708 MakePointWithReference( myRefPoint, dx, dy, dz );
713 anObj = GEOM::GEOM_IBasicOperations::_narrow( getOperation() )->
714 MakePointOnCurve( myEdge, getParameter() );
718 anObj = GEOM::GEOM_IBasicOperations::_narrow( getOperation() )->
719 MakePointOnLinesIntersection( myLine1, myLine2 );
723 anObj = GEOM::GEOM_IBasicOperations::_narrow( getOperation() )->
724 MakePointOnSurface( myFace, getUParameter(), getVParameter() );
729 if ( getConstructorId() == 1 || getConstructorId() == 2 ||
730 getConstructorId() == 4 ) {
732 if ( GEOMBase::GetShape( anObj, aShape ) && !aShape.IsNull() &&
733 aShape.ShapeType() == TopAbs_VERTEX ) {
734 gp_Pnt aPnt = BRep_Tool::Pnt( TopoDS::Vertex( aShape ) );
735 myX->setText( QString( "%1" ).arg( aPnt.X() ) );
736 myY->setText( QString( "%1" ).arg( aPnt.Y() ) );
737 myZ->setText( QString( "%1" ).arg( aPnt.Z() ) );
746 if ( !anObj->_is_nil() )
748 //printf( "--> a valid point is created\n" );
749 objects.push_back( anObj._retn() );
755 //=================================================================================
756 // function : closeEvent
758 //=================================================================================
759 void BasicGUI_PointDlg::closeEvent( QCloseEvent* e )
761 GEOMBase_Skeleton::closeEvent( e );
764 //=================================================================================
765 // function : addSubshapeToStudy
766 // purpose : virtual method to add new SubObjects if local selection
767 //=================================================================================
768 void BasicGUI_PointDlg::addSubshapesToStudy()
770 QMap<QString, GEOM::GEOM_Object_var> objMap;
772 switch (getConstructorId())
777 objMap[GroupRefPoint->LineEdit1->text()] = myRefPoint;
780 objMap[GroupOnCurve->LineEdit1->text()] = myEdge;
783 objMap[GroupLineIntersection->LineEdit1->text()] = myLine1;
784 objMap[GroupLineIntersection->LineEdit2->text()] = myLine2;
787 objMap[GroupOnSurface->LineEdit1->text()] = myFace;
790 addSubshapesToFather( objMap );