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
22 // File : BasicGUI_PointDlg.cxx
23 // Author : Lucien PIGNOLONI, Open CASCADE S.A.S.
26 #include "BasicGUI_PointDlg.h"
28 #include <SUIT_ResourceMgr.h>
29 #include <SUIT_Session.h>
30 #include <SalomeApp_Application.h>
31 #include <LightApp_SelectionMgr.h>
33 #include <GeometryGUI.h>
38 #include <GEOMImpl_Types.hxx>
40 #include <QApplication>
44 #include <TopoDS_Shape.hxx>
45 #include <TopAbs_ShapeEnum.hxx>
47 #include <BRep_Tool.hxx>
49 #include <TColStd_IndexedMapOfInteger.hxx>
50 #include <TopTools_IndexedMapOfShape.hxx>
52 //=================================================================================
53 // class : BasicGUI_PointDlg()
54 // purpose : Constructs a BasicGUI_PointDlg which is a child of 'parent', with the
55 // name 'name' and widget flags set to 'f'.
56 // The dialog will by default be modeless, unless you set 'modal' to
57 // TRUE to construct a modal dialog.
58 //=================================================================================
59 BasicGUI_PointDlg::BasicGUI_PointDlg( GeometryGUI* theGeometryGUI, QWidget* parent,
60 bool modal, Qt::WindowFlags fl )
61 : GEOMBase_Skeleton( theGeometryGUI, parent, modal, fl )
63 QPixmap image0( SUIT_Session::session()->resourceMgr()->loadPixmap( "GEOM", tr( "ICON_DLG_POINT") ) );
64 QPixmap image1( SUIT_Session::session()->resourceMgr()->loadPixmap( "GEOM", tr( "ICON_DLG_POINT_EDGE" ) ) );
65 QPixmap image2( SUIT_Session::session()->resourceMgr()->loadPixmap( "GEOM", tr( "ICON_SELECT" ) ) );
66 QPixmap image3( SUIT_Session::session()->resourceMgr()->loadPixmap( "GEOM", tr( "ICON_DLG_POINT_REF" ) ) );
67 QPixmap image4( SUIT_Session::session()->resourceMgr()->loadPixmap( "GEOM", tr( "ICON_DLG_POINT_LINES") ) );
68 QPixmap image5( SUIT_Session::session()->resourceMgr()->loadPixmap( "GEOM", tr( "ICON_DLG_POINT_FACE" ) ) );
70 setWindowTitle( tr( "GEOM_POINT_TITLE" ) );
72 /***************************************************************/
73 mainFrame()->GroupConstructors->setTitle( tr( "GEOM_POINTS" ) );
74 mainFrame()->RadioButton1->setIcon( image0 );
75 mainFrame()->RadioButton2->setIcon( image3 );
76 mainFrame()->RadioButton3->setIcon( image1 );
77 mainFrame()->RadioButton4->show();
78 mainFrame()->RadioButton4->setIcon( image4 );
79 mainFrame()->RadioButton5->show();
80 mainFrame()->RadioButton5->setIcon( image5 );
82 GroupXYZ = new DlgRef_3Spin( centralWidget() );
83 GroupXYZ->GroupBox1->setTitle( tr( "GEOM_COORDINATES" ) );
84 GroupXYZ->TextLabel1->setText( tr( "GEOM_X" ) );
85 GroupXYZ->TextLabel2->setText( tr( "GEOM_Y" ) );
86 GroupXYZ->TextLabel3->setText( tr( "GEOM_Z" ) );
88 GroupOnCurve = new DlgRef_1Sel1Spin( centralWidget() );
89 GroupOnCurve->GroupBox1->setTitle( tr( "GEOM_PARAM_POINT" ) );
90 GroupOnCurve->TextLabel1->setText( tr( "GEOM_EDGE" ) );
91 GroupOnCurve->TextLabel2->setText( tr( "GEOM_PARAMETER" ) );
92 GroupOnCurve->PushButton1->setIcon( image2 );
94 GroupOnSurface = new DlgRef_1Sel2Spin( centralWidget() );
95 GroupOnSurface->GroupBox1->setTitle( tr( "GEOM_PARAM_POINT" ) );
96 GroupOnSurface->TextLabel1->setText( tr( "GEOM_FACE" ) );
97 GroupOnSurface->TextLabel2->setText( tr( "GEOM_UPARAMETER" ) );
98 GroupOnSurface->TextLabel3->setText( tr( "GEOM_VPARAMETER" ) );
99 GroupOnSurface->PushButton1->setIcon( image2 );
101 GroupRefPoint = new DlgRef_1Sel3Spin( centralWidget() );
102 GroupRefPoint->GroupBox1->setTitle( tr( "GEOM_REF_POINT" ) );
103 GroupRefPoint->TextLabel1->setText( tr( "GEOM_POINT" ) );
104 GroupRefPoint->PushButton1->setIcon( image2 );
105 GroupRefPoint->TextLabel2->setText( tr( "GEOM_DX" ) );
106 GroupRefPoint->TextLabel3->setText( tr( "GEOM_DY" ) );
107 GroupRefPoint->TextLabel4->setText( tr( "GEOM_DZ" ) );
109 GroupLineIntersection = new DlgRef_2Sel( centralWidget() );
110 GroupLineIntersection->GroupBox1->setTitle( tr( "GEOM_LINE_INTERSECTION" ) );
111 GroupLineIntersection->TextLabel1->setText( tr( "GEOM_LINE1" ) );
112 GroupLineIntersection->TextLabel2->setText( tr( "GEOM_LINE2" ) );
113 GroupLineIntersection->PushButton1->setIcon( image2 );
114 GroupLineIntersection->PushButton2->setIcon( image2 );
116 myCoordGrp = new QGroupBox( tr( "GEOM_COORDINATES" ), centralWidget() );
117 QGridLayout* myCoordGrpLayout = new QGridLayout( myCoordGrp );
118 myCoordGrpLayout->addWidget( new QLabel( tr( "GEOM_X" ), myCoordGrp ), 0, 0 );
119 myX = new QLineEdit( myCoordGrp );
120 myCoordGrpLayout->addWidget( myX, 0, 1 );
121 myCoordGrpLayout->addWidget( new QLabel( tr( "GEOM_Y" ), myCoordGrp ), 1, 0 );
122 myY = new QLineEdit( myCoordGrp );
123 myCoordGrpLayout->addWidget( myY, 1, 1 );
124 myCoordGrpLayout->addWidget( new QLabel( tr( "GEOM_Z" ), myCoordGrp ), 2, 0 );
125 myZ = new QLineEdit( myCoordGrp );
126 myCoordGrpLayout->addWidget( myZ, 2, 1 );
128 QVBoxLayout* layout = new QVBoxLayout( centralWidget() );
129 layout->setMargin( 0 ); layout->setSpacing( 6 );
130 layout->addWidget( GroupXYZ );
131 layout->addWidget( GroupOnCurve );
132 layout->addWidget( GroupOnSurface );
133 layout->addWidget( GroupRefPoint );
134 layout->addWidget( GroupLineIntersection );
135 layout->addWidget( myCoordGrp );
137 myX->setReadOnly( true );
138 myY->setReadOnly( true );
139 myZ->setReadOnly( true );
141 myX->setEnabled( false );
142 myY->setEnabled( false );
143 myZ->setEnabled( false );
145 QPalette aPal = myX->palette();
146 aPal.setColor( QPalette::Disabled, QPalette::Text, QColor( 0, 0, 0 ) ) ;
147 myX->setPalette( aPal );
148 myY->setPalette( aPal );
149 myZ->setPalette( aPal );
151 setHelpFileName( "create_point_page.html" );
157 //=================================================================================
158 // function : ~BasicGUI_PointDlg()
159 // purpose : Destructor
160 //=================================================================================
161 BasicGUI_PointDlg::~BasicGUI_PointDlg()
166 //=================================================================================
169 //=================================================================================
170 void BasicGUI_PointDlg::Init()
172 GroupOnCurve->LineEdit1->setReadOnly( true );
173 GroupOnSurface->LineEdit1->setReadOnly( true );
174 GroupRefPoint->LineEdit1->setReadOnly( true );
175 GroupLineIntersection->LineEdit1->setReadOnly( true );
176 GroupLineIntersection->LineEdit2->setReadOnly( true );
178 myEdge = GEOM::GEOM_Object::_nil();
179 myRefPoint = GEOM::GEOM_Object::_nil();
181 myEditCurrentArgument = 0;
183 /* Get setting of step value from file configuration */
184 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
185 double step = resMgr->doubleValue( "Geometry", "SettingsGeomStep", 100 );
187 /* min, max, step and decimals for spin boxes */
188 initSpinBox( GroupXYZ->SpinBox_DX, COORD_MIN, COORD_MAX, step, 3 ); // VSR:TODO : DBL_DIGITS_DISPLAY
189 initSpinBox( GroupXYZ->SpinBox_DY, COORD_MIN, COORD_MAX, step, 3 ); // VSR:TODO : DBL_DIGITS_DISPLAY
190 initSpinBox( GroupXYZ->SpinBox_DZ, COORD_MIN, COORD_MAX, step, 3 ); // VSR:TODO : DBL_DIGITS_DISPLAY
191 GroupXYZ->SpinBox_DX->setValue( 0.0 );
192 GroupXYZ->SpinBox_DY->setValue( 0.0 );
193 GroupXYZ->SpinBox_DZ->setValue( 0.0 );
195 initSpinBox( GroupRefPoint->SpinBox_DX, COORD_MIN, COORD_MAX, step, 3 ); // VSR:TODO : DBL_DIGITS_DISPLAY
196 initSpinBox( GroupRefPoint->SpinBox_DY, COORD_MIN, COORD_MAX, step, 3 ); // VSR:TODO : DBL_DIGITS_DISPLAY
197 initSpinBox( GroupRefPoint->SpinBox_DZ, COORD_MIN, COORD_MAX, step, 3 ); // VSR:TODO : DBL_DIGITS_DISPLAY
198 GroupRefPoint->SpinBox_DX->setValue( 0.0 );
199 GroupRefPoint->SpinBox_DY->setValue( 0.0 );
200 GroupRefPoint->SpinBox_DZ->setValue( 0.0 );
204 initSpinBox( GroupOnCurve->SpinBox_DX, 0., 1., step, 3 ); // VSR:TODO : DBL_DIGITS_DISPLAY
205 GroupOnCurve->SpinBox_DX->setValue( 0.5 );
207 initSpinBox( GroupOnSurface->SpinBox_DX, 0., 1., step, 3 ); // VSR:TODO : DBL_DIGITS_DISPLAY
208 GroupOnSurface->SpinBox_DX->setValue( 0.5 );
209 initSpinBox( GroupOnSurface->SpinBox_DY, 0., 1., step, 3 ); // VSR:TODO : DBL_DIGITS_DISPLAY
210 GroupOnSurface->SpinBox_DY->setValue( 0.5 );
212 /* signals and slots connections */
213 connect( myGeomGUI, SIGNAL( SignalDeactivateActiveDialog() ), this, SLOT( DeactivateActiveDialog() ) );
214 connect( myGeomGUI, SIGNAL( SignalCloseAllDialogs() ), this, SLOT( ClickOnCancel() ) );
216 connect( buttonOk(), SIGNAL( clicked() ), this, SLOT( ClickOnOk() ) );
217 connect( buttonApply(), SIGNAL( clicked() ), this, SLOT( ClickOnApply() ) );
219 connect( this, SIGNAL( constructorsClicked( int ) ), this, SLOT( ConstructorsClicked( int ) ) );
221 connect( GroupOnCurve->PushButton1, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) );
222 connect( GroupOnCurve->LineEdit1, SIGNAL( returnPressed() ), this, SLOT( LineEditReturnPressed() ) );
224 connect( GroupOnSurface->PushButton1, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) );
225 connect( GroupOnSurface->LineEdit1, SIGNAL( returnPressed() ), this, SLOT( LineEditReturnPressed() ) );
227 connect( GroupLineIntersection->PushButton1, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) );
228 connect( GroupLineIntersection->PushButton2, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) );
229 connect( GroupLineIntersection->LineEdit1, SIGNAL( returnPressed() ), this, SLOT( LineEditReturnPressed() ) );
230 connect( GroupLineIntersection->LineEdit2, SIGNAL( returnPressed() ), this, SLOT( LineEditReturnPressed() ) );
232 connect( GroupOnCurve->SpinBox_DX, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
233 connect( GroupOnSurface->SpinBox_DX, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
234 connect( GroupOnSurface->SpinBox_DY, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
235 connect( GroupXYZ->SpinBox_DX, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
236 connect( GroupXYZ->SpinBox_DY, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
237 connect( GroupXYZ->SpinBox_DZ, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
238 connect( GroupRefPoint->SpinBox_DX, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
239 connect( GroupRefPoint->SpinBox_DY, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
240 connect( GroupRefPoint->SpinBox_DZ, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
242 connect( myGeomGUI, SIGNAL( SignalDefaultStepValueChanged( double ) ), this, SLOT( SetDoubleSpinBoxStep( double ) ) );
244 connect( myGeomGUI->getApp()->selectionMgr(), SIGNAL(currentSelectionChanged() ),
245 this, SLOT(SelectionIntoArgument() ) );
248 initName( tr( "GEOM_VERTEX" ) );
250 ConstructorsClicked( 0 );
253 //=================================================================================
254 // function : SetDoubleSpinBoxStep()
255 // purpose : Double spin box management
256 //=================================================================================
257 void BasicGUI_PointDlg::SetDoubleSpinBoxStep( double step )
259 GroupOnCurve->SpinBox_DX->setSingleStep(step);
260 GroupXYZ->SpinBox_DX->setSingleStep(step);
261 GroupXYZ->SpinBox_DY->setSingleStep(step);
262 GroupXYZ->SpinBox_DZ->setSingleStep(step);
263 GroupRefPoint->SpinBox_DX->setSingleStep(step);
264 GroupRefPoint->SpinBox_DY->setSingleStep(step);
265 GroupRefPoint->SpinBox_DZ->setSingleStep(step);
266 GroupOnSurface->SpinBox_DX->setSingleStep(step);
267 GroupOnSurface->SpinBox_DY->setSingleStep(step);
271 //=================================================================================
272 // function : ConstructorsClicked()
273 // purpose : Radio button management
274 //=================================================================================
275 void BasicGUI_PointDlg::ConstructorsClicked(int constructorId)
277 globalSelection(); // close local contexts, if any
279 switch ( constructorId ) {
282 localSelection( GEOM::GEOM_Object::_nil(), TopAbs_VERTEX );
284 GroupRefPoint->hide();
285 GroupOnCurve->hide();
286 GroupLineIntersection->hide();
287 GroupOnSurface->hide();
296 myEditCurrentArgument = GroupRefPoint->LineEdit1;
297 myEditCurrentArgument->setText( "" );
298 myRefPoint = GEOM::GEOM_Object::_nil();
300 localSelection( GEOM::GEOM_Object::_nil(), TopAbs_VERTEX );
303 GroupOnCurve->hide();
304 GroupLineIntersection->hide();
305 GroupOnSurface->hide();
307 GroupRefPoint->show();
314 myEditCurrentArgument = GroupOnCurve->LineEdit1;
315 myEditCurrentArgument->setText( "" );
316 myEdge = GEOM::GEOM_Object::_nil();
318 localSelection( GEOM::GEOM_Object::_nil(), TopAbs_EDGE );
321 GroupRefPoint->hide();
322 GroupLineIntersection->hide();
323 GroupOnSurface->hide();
325 GroupOnCurve->show();
332 myEditCurrentArgument = GroupLineIntersection->LineEdit1;
333 GroupLineIntersection->LineEdit1->setText( "" );
334 GroupLineIntersection->LineEdit2->setText( "" );
335 myLine1 = GEOM::GEOM_Object::_nil();
336 myLine2 = GEOM::GEOM_Object::_nil();
338 localSelection( GEOM::GEOM_Object::_nil(), TopAbs_EDGE );
341 GroupRefPoint->hide();
342 GroupOnCurve->hide();
343 GroupOnSurface->hide();
347 GroupLineIntersection->show();
352 myEditCurrentArgument = GroupOnSurface->LineEdit1;
353 myEditCurrentArgument->setText( "" );
354 myFace = GEOM::GEOM_Object::_nil();
356 localSelection( GEOM::GEOM_Object::_nil(), TopAbs_FACE );
359 GroupRefPoint->hide();
360 GroupOnCurve->hide();
361 GroupLineIntersection->hide();
363 GroupOnSurface->show();
374 qApp->processEvents();
376 resize( minimumSize() );
378 SelectionIntoArgument();
382 //=================================================================================
383 // function : ClickOnOk()
385 //=================================================================================
386 void BasicGUI_PointDlg::ClickOnOk()
393 //=================================================================================
394 // function : ClickOnApply()
396 //=================================================================================
397 bool BasicGUI_PointDlg::ClickOnApply()
403 ConstructorsClicked( getConstructorId() );
408 //=================================================================================
409 // function : SelectionIntoArgument()
410 // purpose : Called when selection as changed (for constructors not using local context)
411 //=================================================================================
412 void BasicGUI_PointDlg::SelectionIntoArgument()
414 const int id = getConstructorId();
416 if ( ( id == 1 || id == 2 || id == 4 ) && myEditCurrentArgument != 0 )
418 myEditCurrentArgument->setText( "" );
422 myRefPoint = myEdge = myFace = GEOM::GEOM_Object::_nil();
425 if ( IObjectCount() == 1 ) {
426 Standard_Boolean aRes = Standard_False;
427 Handle(SALOME_InteractiveObject) anIO = firstIObject();
428 GEOM::GEOM_Object_var aSelectedObject = GEOMBase::ConvertIOinGEOMObject( anIO, aRes );
429 if ( !CORBA::is_nil( aSelectedObject ) && aRes ) {
430 QString aName = GEOMBase::GetName(aSelectedObject);
433 if ( GEOMBase::GetShape( aSelectedObject, aShape, TopAbs_SHAPE ) && !aShape.IsNull() ) {
434 TopAbs_ShapeEnum aNeedType = TopAbs_VERTEX;
435 if ( id == 2 || id == 3 )
436 aNeedType = TopAbs_EDGE;
438 aNeedType = TopAbs_FACE;
440 LightApp_SelectionMgr* aSelMgr = myGeomGUI->getApp()->selectionMgr();
441 TColStd_IndexedMapOfInteger aMap;
442 aSelMgr->GetIndexes(firstIObject(), aMap);
443 if ( aMap.Extent() == 1 ) { // Local Selection
444 int anIndex = aMap( 1 );
445 if ( aNeedType == TopAbs_EDGE )
446 aName += QString( ":edge_%1" ).arg( anIndex );
448 aName += QString( ":vertex_%1" ).arg( anIndex );
450 //Find SubShape Object in Father
451 GEOM::GEOM_Object_var aFindedObject = GEOMBase_Helper::findObjectInFather( aSelectedObject, aName );
453 if ( aFindedObject == GEOM::GEOM_Object::_nil() ) { // Object not found in study
454 GEOM::GEOM_IShapesOperations_var aShapesOp = getGeomEngine()->GetIShapesOperations( getStudyId() );
455 aSelectedObject = aShapesOp->GetSubShape( aSelectedObject, anIndex );
458 aSelectedObject = aFindedObject; // get Object from study
461 else { // Global Selection
462 if ( aShape.ShapeType() != aNeedType ) {
463 aSelectedObject = GEOM::GEOM_Object::_nil();
465 if ( id == 0 ) return;
471 if ( aShape.IsNull() ) return;
472 gp_Pnt aPnt = BRep_Tool::Pnt( TopoDS::Vertex( aShape ) );
473 GroupXYZ->SpinBox_DX->setValue( aPnt.X() );
474 GroupXYZ->SpinBox_DY->setValue( aPnt.Y() );
475 GroupXYZ->SpinBox_DZ->setValue( aPnt.Z() );
477 else if ( id == 1 ) {
478 myRefPoint = aSelectedObject;
479 GroupRefPoint->LineEdit1->setText( aName );
481 else if ( id == 2 ) {
482 myEdge = aSelectedObject;
483 GroupOnCurve->LineEdit1->setText( aName );
485 else if ( id == 3 ) {
486 if ( myEditCurrentArgument == GroupLineIntersection->LineEdit1 ) {
487 myLine1 = aSelectedObject;
488 myEditCurrentArgument->setText( aName );
490 else if ( myEditCurrentArgument == GroupLineIntersection->LineEdit2 ) {
491 myLine2 = aSelectedObject;
492 myEditCurrentArgument->setText( aName );
497 myFace = aSelectedObject;
498 GroupOnSurface->LineEdit1->setText( aName );
507 //=================================================================================
508 // function : LineEditReturnPressed()
510 //=================================================================================
511 void BasicGUI_PointDlg::LineEditReturnPressed()
513 QLineEdit* send = (QLineEdit*)sender();
514 if ( send == GroupRefPoint->LineEdit1 ||
515 send == GroupOnCurve->LineEdit1 ||
516 send == GroupLineIntersection->LineEdit1 ||
517 send == GroupLineIntersection->LineEdit2 ) {
518 myEditCurrentArgument = send;
519 GEOMBase_Skeleton::LineEditReturnPressed();
524 //=================================================================================
525 // function : SetEditCurrentArgument()
527 //=================================================================================
528 void BasicGUI_PointDlg::SetEditCurrentArgument()
530 globalSelection(); // close local contexts, if any
532 QPushButton* send = (QPushButton*)sender();
533 globalSelection( GEOM_POINT ); // to break previous local selection
535 if ( send == GroupRefPoint->PushButton1 ) {
536 GroupRefPoint->LineEdit1->setFocus();
537 myEditCurrentArgument = GroupRefPoint->LineEdit1;
539 localSelection( GEOM::GEOM_Object::_nil(), TopAbs_VERTEX );
541 else if ( send == GroupOnCurve->PushButton1 ) {
542 GroupOnCurve->LineEdit1->setFocus();
543 myEditCurrentArgument = GroupOnCurve->LineEdit1;
545 localSelection( GEOM::GEOM_Object::_nil(), TopAbs_EDGE );
547 else if ( send == GroupOnSurface->PushButton1 )
549 GroupOnSurface->LineEdit1->setFocus();
550 myEditCurrentArgument = GroupOnSurface->LineEdit1;
552 localSelection( GEOM::GEOM_Object::_nil(), TopAbs_FACE );
554 else if ( send == GroupLineIntersection->PushButton1 ) {
555 GroupLineIntersection->LineEdit1->setFocus();
556 myEditCurrentArgument = GroupLineIntersection->LineEdit1;
558 localSelection( GEOM::GEOM_Object::_nil(), TopAbs_EDGE );
560 else if ( send == GroupLineIntersection->PushButton2 ) {
561 GroupLineIntersection->LineEdit2->setFocus();
562 myEditCurrentArgument = GroupLineIntersection->LineEdit2;
564 localSelection( GEOM::GEOM_Object::_nil(), TopAbs_EDGE );
569 //=================================================================================
570 // function : enterEvent()
571 // purpose : to reactivate this dialog box when mouse enter onto the window
572 //=================================================================================
573 void BasicGUI_PointDlg::enterEvent( QEvent* )
575 if ( !mainFrame()->GroupConstructors->isEnabled() )
576 ActivateThisDialog();
580 //=================================================================================
581 // function : ActivateThisDialog()
583 //=================================================================================
584 void BasicGUI_PointDlg::ActivateThisDialog( )
586 GEOMBase_Skeleton::ActivateThisDialog();
587 // myGeomGUI->SetState( 0 );
588 ConstructorsClicked( getConstructorId() );
592 //=================================================================================
593 // function : DeactivateActiveDialog()
594 // purpose : public slot to deactivate if active
595 //=================================================================================
596 void BasicGUI_PointDlg::DeactivateActiveDialog()
598 // myGeomGUI->SetState( -1 );
599 GEOMBase_Skeleton::DeactivateActiveDialog();
603 //=================================================================================
604 // function : ValueChangedInSpinBox()
606 //=================================================================================
607 void BasicGUI_PointDlg::ValueChangedInSpinBox(double newValue)
612 //=================================================================================
613 // funcion : getParameter()
615 //=================================================================================
616 double BasicGUI_PointDlg::getParameter() const
618 return GroupOnCurve->SpinBox_DX->value();
622 //=================================================================================
623 // funcion : getUParameter()
625 //=================================================================================
626 double BasicGUI_PointDlg::getUParameter() const
628 return GroupOnSurface->SpinBox_DX->value();
632 //=================================================================================
633 // funcion : getVParameter()
635 //=================================================================================
636 double BasicGUI_PointDlg::getVParameter() const
638 return GroupOnSurface->SpinBox_DY->value();
642 //=================================================================================
643 // function : OnPointSelected
645 //=================================================================================
646 void BasicGUI_PointDlg::OnPointSelected( const gp_Pnt& thePnt )
648 if ( getConstructorId() == 0 ) {
649 GroupXYZ->SpinBox_DX->setValue( thePnt.X() );
650 GroupXYZ->SpinBox_DY->setValue( thePnt.Y() );
651 GroupXYZ->SpinBox_DZ->setValue( thePnt.Z() );
657 //=================================================================================
658 // function : createOperation
660 //=================================================================================
661 GEOM::GEOM_IOperations_ptr BasicGUI_PointDlg::createOperation()
663 return myGeomGUI->GetGeomGen()->GetIBasicOperations( getStudyId() );
666 //=================================================================================
667 // function : isValid
669 //=================================================================================
670 bool BasicGUI_PointDlg::isValid( QString& /*msg*/ )
672 const int id = getConstructorId();
676 return !myRefPoint->_is_nil();
678 return !myEdge->_is_nil();
680 return ( !myLine1->_is_nil() && !myLine2->_is_nil() );
682 return !myFace->_is_nil();
686 //=================================================================================
687 // function : execute
689 //=================================================================================
690 bool BasicGUI_PointDlg::execute( ObjectList& objects )
694 GEOM::GEOM_Object_var anObj;
696 switch ( getConstructorId() ) {
699 double x = GroupXYZ->SpinBox_DX->value();
700 double y = GroupXYZ->SpinBox_DY->value();
701 double z = GroupXYZ->SpinBox_DZ->value();
703 anObj = GEOM::GEOM_IBasicOperations::_narrow( getOperation() )->MakePointXYZ( x, y, z );
709 double dx = GroupRefPoint->SpinBox_DX->value();
710 double dy = GroupRefPoint->SpinBox_DY->value();
711 double dz = GroupRefPoint->SpinBox_DZ->value();
713 anObj = GEOM::GEOM_IBasicOperations::_narrow( getOperation() )->
714 MakePointWithReference( myRefPoint, dx, dy, dz );
719 anObj = GEOM::GEOM_IBasicOperations::_narrow( getOperation() )->
720 MakePointOnCurve( myEdge, getParameter() );
724 anObj = GEOM::GEOM_IBasicOperations::_narrow( getOperation() )->
725 MakePointOnLinesIntersection( myLine1, myLine2 );
729 anObj = GEOM::GEOM_IBasicOperations::_narrow( getOperation() )->
730 MakePointOnSurface( myFace, getUParameter(), getVParameter() );
735 if ( getConstructorId() == 1 || getConstructorId() == 2 ||
736 getConstructorId() == 4 ) {
738 if ( GEOMBase::GetShape( anObj, aShape ) && !aShape.IsNull() &&
739 aShape.ShapeType() == TopAbs_VERTEX ) {
740 gp_Pnt aPnt = BRep_Tool::Pnt( TopoDS::Vertex( aShape ) );
741 myX->setText( QString( "%1" ).arg( aPnt.X() ) );
742 myY->setText( QString( "%1" ).arg( aPnt.Y() ) );
743 myZ->setText( QString( "%1" ).arg( aPnt.Z() ) );
752 if ( !anObj->_is_nil() ) {
753 objects.push_back( anObj._retn() );
759 //=================================================================================
760 // function : addSubshapeToStudy
761 // purpose : virtual method to add new SubObjects if local selection
762 //=================================================================================
763 void BasicGUI_PointDlg::addSubshapesToStudy()
765 QMap<QString, GEOM::GEOM_Object_var> objMap;
767 switch ( getConstructorId() ) {
771 objMap[GroupRefPoint->LineEdit1->text()] = myRefPoint;
774 objMap[GroupOnCurve->LineEdit1->text()] = myEdge;
777 objMap[GroupLineIntersection->LineEdit1->text()] = myLine1;
778 objMap[GroupLineIntersection->LineEdit2->text()] = myLine2;
781 objMap[GroupOnSurface->LineEdit1->text()] = myFace;
784 addSubshapesToFather( objMap );