1 // Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 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 // GEOM GEOMGUI : GUI for Geometry component
23 // File : BasicGUI_PointDlg.cxx
24 // 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 <SalomeApp_Notebook.h>
32 #include <LightApp_SelectionMgr.h>
34 #include <GeometryGUI.h>
39 #include <GEOMImpl_Types.hxx>
41 #include <QApplication>
42 #include <QButtonGroup>
43 #include <QHBoxLayout>
45 #include <QRadioButton>
48 #include <TopoDS_Shape.hxx>
49 #include <TopAbs_ShapeEnum.hxx>
51 #include <BRep_Tool.hxx>
53 #include <TColStd_IndexedMapOfInteger.hxx>
54 #include <TopTools_IndexedMapOfShape.hxx>
59 #define GEOM_POINT_XYZ 0
60 #define GEOM_POINT_REF 1
61 #define GEOM_POINT_EDGE 2
62 #define GEOM_POINT_INTINT 3
63 #define GEOM_POINT_SURF 4
66 //=================================================================================
67 // class : BasicGUI_PointDlg()
68 // purpose : Constructs a BasicGUI_PointDlg which is a child of 'parent', with the
69 // name 'name' and widget flags set to 'f'.
70 // The dialog will by default be modeless, unless you set 'modal' to
71 // TRUE to construct a modal dialog.
72 //=================================================================================
73 BasicGUI_PointDlg::BasicGUI_PointDlg( GeometryGUI* theGeometryGUI, QWidget* parent,
74 bool modal, Qt::WindowFlags fl )
75 : GEOMBase_Skeleton( theGeometryGUI, parent, modal, fl )
77 QPixmap image0( SUIT_Session::session()->resourceMgr()->loadPixmap( "GEOM", tr( "ICON_DLG_POINT") ) );
78 QPixmap image1( SUIT_Session::session()->resourceMgr()->loadPixmap( "GEOM", tr( "ICON_DLG_POINT_EDGE" ) ) );
79 QPixmap image2( SUIT_Session::session()->resourceMgr()->loadPixmap( "GEOM", tr( "ICON_SELECT" ) ) );
80 QPixmap image3( SUIT_Session::session()->resourceMgr()->loadPixmap( "GEOM", tr( "ICON_DLG_POINT_REF" ) ) );
81 QPixmap image4( SUIT_Session::session()->resourceMgr()->loadPixmap( "GEOM", tr( "ICON_DLG_POINT_LINES") ) );
82 QPixmap image5( SUIT_Session::session()->resourceMgr()->loadPixmap( "GEOM", tr( "ICON_DLG_POINT_FACE" ) ) );
84 setWindowTitle( tr( "GEOM_POINT_TITLE" ) );
86 /***************************************************************/
87 mainFrame()->GroupConstructors->setTitle( tr( "GEOM_POINTS" ) );
88 mainFrame()->RadioButton1->setIcon( image0 );
89 mainFrame()->RadioButton2->setIcon( image3 );
90 mainFrame()->RadioButton3->setIcon( image1 );
91 mainFrame()->RadioButton4->show();
92 mainFrame()->RadioButton4->setIcon( image4 );
93 mainFrame()->RadioButton5->show();
94 mainFrame()->RadioButton5->setIcon( image5 );
96 QGroupBox* paramGrp = new QGroupBox( centralWidget() );
97 myParamCoord = new QButtonGroup( paramGrp );
98 QHBoxLayout* boxLayout = new QHBoxLayout( paramGrp );
99 boxLayout->setMargin( 0 ); boxLayout->setSpacing( 6 );
100 QRadioButton* btn = new QRadioButton( tr( "GEOM_PARAM_VALUE" ), paramGrp );
101 myParamCoord->addButton( btn, PARAM_VALUE );
102 boxLayout->addWidget( btn );
103 btn = new QRadioButton( tr( "GEOM_COORD_VALUE" ), paramGrp );
104 myParamCoord->addButton( btn, COORD_VALUE );
105 boxLayout->addWidget( btn );
106 myParamCoord->setExclusive( true );
107 myParamCoord->button( PARAM_VALUE )->setChecked( true );
109 GroupXYZ = new DlgRef_3Spin( centralWidget() );
110 GroupXYZ->GroupBox1->setTitle( tr( "GEOM_COORDINATES" ) );
111 GroupXYZ->TextLabel1->setText( tr( "GEOM_X" ) );
112 GroupXYZ->TextLabel2->setText( tr( "GEOM_Y" ) );
113 GroupXYZ->TextLabel3->setText( tr( "GEOM_Z" ) );
115 GroupOnCurve = new DlgRef_1Sel1Spin( centralWidget() );
116 GroupOnCurve->GroupBox1->setTitle( tr( "GEOM_POINT_ON_EDGE" ) );
117 GroupOnCurve->TextLabel1->setText( tr( "GEOM_EDGE" ) );
118 GroupOnCurve->TextLabel2->setText( tr( "GEOM_PARAMETER" ) );
119 GroupOnCurve->PushButton1->setIcon( image2 );
121 GroupOnSurface = new DlgRef_1Sel2Spin( centralWidget() );
122 GroupOnSurface->GroupBox1->setTitle( tr( "GEOM_POINT_ON_FACE" ) );
123 GroupOnSurface->TextLabel1->setText( tr( "GEOM_FACE" ) );
124 GroupOnSurface->TextLabel2->setText( tr( "GEOM_UPARAMETER" ) );
125 GroupOnSurface->TextLabel3->setText( tr( "GEOM_VPARAMETER" ) );
126 GroupOnSurface->PushButton1->setIcon( image2 );
128 GroupRefPoint = new DlgRef_1Sel3Spin( centralWidget() );
129 GroupRefPoint->GroupBox1->setTitle( tr( "GEOM_REF_POINT" ) );
130 GroupRefPoint->TextLabel1->setText( tr( "GEOM_POINT" ) );
131 GroupRefPoint->PushButton1->setIcon( image2 );
132 GroupRefPoint->TextLabel2->setText( tr( "GEOM_DX" ) );
133 GroupRefPoint->TextLabel3->setText( tr( "GEOM_DY" ) );
134 GroupRefPoint->TextLabel4->setText( tr( "GEOM_DZ" ) );
136 GroupLineIntersection = new DlgRef_2Sel( centralWidget() );
137 GroupLineIntersection->GroupBox1->setTitle( tr( "GEOM_LINE_INTERSECTION" ) );
138 GroupLineIntersection->TextLabel1->setText( tr( "GEOM_LINE1" ) );
139 GroupLineIntersection->TextLabel2->setText( tr( "GEOM_LINE2" ) );
140 GroupLineIntersection->PushButton1->setIcon( image2 );
141 GroupLineIntersection->PushButton2->setIcon( image2 );
142 GroupLineIntersection->LineEdit2->setEnabled(false);
144 myCoordGrp = new QGroupBox( tr( "GEOM_COORDINATES_RES" ), centralWidget() );
145 QGridLayout* myCoordGrpLayout = new QGridLayout( myCoordGrp );
146 myCoordGrpLayout->addWidget( new QLabel( tr( "GEOM_X" ), myCoordGrp ), 0, 0 );
147 myX = new QLineEdit( myCoordGrp );
148 myCoordGrpLayout->addWidget( myX, 0, 1 );
149 myCoordGrpLayout->addWidget( new QLabel( tr( "GEOM_Y" ), myCoordGrp ), 1, 0 );
150 myY = new QLineEdit( myCoordGrp );
151 myCoordGrpLayout->addWidget( myY, 1, 1 );
152 myCoordGrpLayout->addWidget( new QLabel( tr( "GEOM_Z" ), myCoordGrp ), 2, 0 );
153 myZ = new QLineEdit( myCoordGrp );
154 myCoordGrpLayout->addWidget( myZ, 2, 1 );
156 QVBoxLayout* layout = new QVBoxLayout( centralWidget() );
157 layout->setMargin( 0 ); layout->setSpacing( 6 );
158 layout->addWidget( paramGrp );
159 layout->addWidget( GroupXYZ );
160 layout->addWidget( GroupOnCurve );
161 layout->addWidget( GroupOnSurface );
162 layout->addWidget( GroupRefPoint );
163 layout->addWidget( GroupLineIntersection );
164 layout->addWidget( myCoordGrp );
166 myX->setReadOnly( true );
167 myY->setReadOnly( true );
168 myZ->setReadOnly( true );
170 myX->setEnabled( false );
171 myY->setEnabled( false );
172 myZ->setEnabled( false );
174 QPalette aPal = myX->palette();
175 aPal.setColor( QPalette::Disabled, QPalette::Text, QColor( 0, 0, 0 ) ) ;
176 myX->setPalette( aPal );
177 myY->setPalette( aPal );
178 myZ->setPalette( aPal );
180 setHelpFileName( "create_point_page.html" );
186 //=================================================================================
187 // function : ~BasicGUI_PointDlg()
188 // purpose : Destructor
189 //=================================================================================
190 BasicGUI_PointDlg::~BasicGUI_PointDlg()
195 //=================================================================================
198 //=================================================================================
199 void BasicGUI_PointDlg::Init()
201 GroupOnCurve->LineEdit1->setReadOnly( true );
202 GroupOnSurface->LineEdit1->setReadOnly( true );
203 GroupRefPoint->LineEdit1->setReadOnly( true );
204 GroupLineIntersection->LineEdit1->setReadOnly( true );
205 GroupLineIntersection->LineEdit2->setReadOnly( true );
206 GroupLineIntersection->LineEdit1->setEnabled( true );
207 GroupLineIntersection->LineEdit2->setEnabled( false );
209 myEdge = GEOM::GEOM_Object::_nil();
210 myRefPoint = GEOM::GEOM_Object::_nil();
212 myEditCurrentArgument = 0;
214 /* Get setting of step value from file configuration */
215 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
216 double step = resMgr->doubleValue( "Geometry", "SettingsGeomStep", 100 );
218 /* min, max, step and decimals for spin boxes */
219 initSpinBox( GroupXYZ->SpinBox_DX, COORD_MIN, COORD_MAX, step, 6 ); // VSR: TODO: DBL_DIGITS_DISPLAY
220 initSpinBox( GroupXYZ->SpinBox_DY, COORD_MIN, COORD_MAX, step, 6 ); // VSR: TODO: DBL_DIGITS_DISPLAY
221 initSpinBox( GroupXYZ->SpinBox_DZ, COORD_MIN, COORD_MAX, step, 6 ); // VSR: TODO: DBL_DIGITS_DISPLAY
222 GroupXYZ->SpinBox_DX->setValue( 0.0 );
223 GroupXYZ->SpinBox_DY->setValue( 0.0 );
224 GroupXYZ->SpinBox_DZ->setValue( 0.0 );
226 initSpinBox( GroupRefPoint->SpinBox_DX, COORD_MIN, COORD_MAX, step, 6 ); // VSR: TODO: DBL_DIGITS_DISPLAY
227 initSpinBox( GroupRefPoint->SpinBox_DY, COORD_MIN, COORD_MAX, step, 6 ); // VSR: TODO: DBL_DIGITS_DISPLAY
228 initSpinBox( GroupRefPoint->SpinBox_DZ, COORD_MIN, COORD_MAX, step, 6 ); // VSR: TODO: DBL_DIGITS_DISPLAY
229 GroupRefPoint->SpinBox_DX->setValue( 0.0 );
230 GroupRefPoint->SpinBox_DY->setValue( 0.0 );
231 GroupRefPoint->SpinBox_DZ->setValue( 0.0 );
235 initSpinBox( GroupOnCurve->SpinBox_DX, 0., 1., step, 6 ); // VSR:TODO : DBL_DIGITS_DISPLAY
236 GroupOnCurve->SpinBox_DX->setValue( 0.5 );
238 initSpinBox( GroupOnSurface->SpinBox_DX, 0., 1., step, 6 ); // VSR:TODO : DBL_DIGITS_DISPLAY
239 GroupOnSurface->SpinBox_DX->setValue( 0.5 );
240 initSpinBox( GroupOnSurface->SpinBox_DY, 0., 1., step, 6 ); // VSR:TODO : DBL_DIGITS_DISPLAY
241 GroupOnSurface->SpinBox_DY->setValue( 0.5 );
243 /* signals and slots connections */
244 connect( myGeomGUI, SIGNAL( SignalDeactivateActiveDialog() ), this, SLOT( DeactivateActiveDialog() ) );
245 connect( myGeomGUI, SIGNAL( SignalCloseAllDialogs() ), this, SLOT( ClickOnCancel() ) );
247 connect( buttonOk(), SIGNAL( clicked() ), this, SLOT( ClickOnOk() ) );
248 connect( buttonApply(), SIGNAL( clicked() ), this, SLOT( ClickOnApply() ) );
250 connect( this, SIGNAL( constructorsClicked( int ) ), this, SLOT( ConstructorsClicked( int ) ) );
253 connect( myParamCoord->button( PARAM_VALUE ), SIGNAL( clicked() ), this, SLOT( ClickParamCoord() ) );
254 connect( myParamCoord->button( COORD_VALUE ), SIGNAL( clicked() ), this, SLOT( ClickParamCoord() ) );
255 connect( GroupOnCurve->PushButton1, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) );
256 connect( GroupOnCurve->LineEdit1, SIGNAL( returnPressed() ), this, SLOT( LineEditReturnPressed() ) );
258 connect( GroupOnSurface->PushButton1, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) );
259 connect( GroupOnSurface->LineEdit1, SIGNAL( returnPressed() ), this, SLOT( LineEditReturnPressed() ) );
261 connect( GroupLineIntersection->PushButton1, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) );
262 connect( GroupLineIntersection->PushButton2, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) );
263 connect( GroupLineIntersection->LineEdit1, SIGNAL( returnPressed() ), this, SLOT( LineEditReturnPressed() ) );
264 connect( GroupLineIntersection->LineEdit2, SIGNAL( returnPressed() ), this, SLOT( LineEditReturnPressed() ) );
266 connect( GroupOnCurve->SpinBox_DX, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
267 connect( GroupOnSurface->SpinBox_DX, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
268 connect( GroupOnSurface->SpinBox_DY, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
269 connect( GroupXYZ->SpinBox_DX, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
270 connect( GroupXYZ->SpinBox_DY, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
271 connect( GroupXYZ->SpinBox_DZ, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
272 connect( GroupRefPoint->SpinBox_DX, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
273 connect( GroupRefPoint->SpinBox_DY, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
274 connect( GroupRefPoint->SpinBox_DZ, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
276 connect( myGeomGUI, SIGNAL( SignalDefaultStepValueChanged( double ) ), this, SLOT( SetDoubleSpinBoxStep( double ) ) );
278 connect( myGeomGUI->getApp()->selectionMgr(), SIGNAL(currentSelectionChanged() ),
279 this, SLOT(SelectionIntoArgument() ) );
282 initName( tr( "GEOM_VERTEX" ) );
284 ConstructorsClicked( 0 );
287 //=================================================================================
288 // function : SetDoubleSpinBoxStep()
289 // purpose : Double spin box management
290 //=================================================================================
291 void BasicGUI_PointDlg::SetDoubleSpinBoxStep( double step )
293 GroupOnCurve->SpinBox_DX->setSingleStep(step);
294 GroupXYZ->SpinBox_DX->setSingleStep(step);
295 GroupXYZ->SpinBox_DY->setSingleStep(step);
296 GroupXYZ->SpinBox_DZ->setSingleStep(step);
297 GroupRefPoint->SpinBox_DX->setSingleStep(step);
298 GroupRefPoint->SpinBox_DY->setSingleStep(step);
299 GroupRefPoint->SpinBox_DZ->setSingleStep(step);
300 GroupOnSurface->SpinBox_DX->setSingleStep(step);
301 GroupOnSurface->SpinBox_DY->setSingleStep(step);
305 //=================================================================================
306 // function : ConstructorsClicked()
307 // purpose : Radio button management
308 //=================================================================================
309 void BasicGUI_PointDlg::ConstructorsClicked(int constructorId)
311 globalSelection(); // close local contexts, if any
313 switch ( constructorId ) {
316 localSelection( GEOM::GEOM_Object::_nil(), TopAbs_VERTEX );
318 GroupRefPoint->hide();
319 GroupOnCurve->hide();
320 GroupLineIntersection->hide();
321 GroupOnSurface->hide();
325 myParamCoord->button( PARAM_VALUE )->hide();
326 myParamCoord->button( COORD_VALUE )->hide();
332 myEditCurrentArgument = GroupRefPoint->LineEdit1;
333 myEditCurrentArgument->setText( "" );
334 myRefPoint = GEOM::GEOM_Object::_nil();
335 GroupRefPoint->PushButton1->setDown(true);
336 localSelection( GEOM::GEOM_Object::_nil(), TopAbs_VERTEX );
338 myParamCoord->button( PARAM_VALUE )->hide();
339 myParamCoord->button( COORD_VALUE )->hide();
341 GroupOnCurve->hide();
342 GroupLineIntersection->hide();
343 GroupOnSurface->hide();
345 GroupRefPoint->show();
350 case GEOM_POINT_EDGE:
352 myEditCurrentArgument = GroupOnCurve->LineEdit1;
353 myEditCurrentArgument->setText( "" );
354 myEdge = GEOM::GEOM_Object::_nil();
355 GroupOnCurve->PushButton1->setDown(true);
356 localSelection( GEOM::GEOM_Object::_nil(), TopAbs_EDGE );
358 GroupRefPoint->hide();
359 GroupLineIntersection->hide();
360 GroupOnSurface->hide();
362 myParamCoord->button( PARAM_VALUE )->show();
363 myParamCoord->button( COORD_VALUE )->show();
364 GroupOnCurve->show();
367 updateParamCoord( false );
370 case GEOM_POINT_INTINT:
372 myEditCurrentArgument = GroupLineIntersection->LineEdit1;
373 GroupLineIntersection->LineEdit1->setText( "" );
374 GroupLineIntersection->LineEdit2->setText( "" );
375 GroupLineIntersection->LineEdit1->setEnabled( true );
376 GroupLineIntersection->LineEdit2->setEnabled( false );
377 myLine1 = GEOM::GEOM_Object::_nil();
378 myLine2 = GEOM::GEOM_Object::_nil();
379 GroupLineIntersection->PushButton1->setDown(true);
380 GroupLineIntersection->PushButton2->setDown(false);
382 localSelection( GEOM::GEOM_Object::_nil(), TopAbs_EDGE );
384 myParamCoord->button( PARAM_VALUE )->hide();
385 myParamCoord->button( COORD_VALUE )->hide();
387 GroupRefPoint->hide();
388 GroupOnCurve->hide();
389 GroupOnSurface->hide();
393 GroupLineIntersection->show();
396 case GEOM_POINT_SURF:
398 myEditCurrentArgument = GroupOnSurface->LineEdit1;
399 myEditCurrentArgument->setText( "" );
400 myFace = GEOM::GEOM_Object::_nil();
401 GroupOnSurface->PushButton1->setDown(true);
402 localSelection( GEOM::GEOM_Object::_nil(), TopAbs_FACE );
404 GroupRefPoint->hide();
405 GroupOnCurve->hide();
406 GroupLineIntersection->hide();
408 myParamCoord->button( PARAM_VALUE )->show();
409 myParamCoord->button( COORD_VALUE )->show();
410 GroupOnSurface->show();
413 updateParamCoord( false );
422 qApp->processEvents();
424 resize( minimumSizeHint() );
426 SelectionIntoArgument();
430 //=================================================================================
431 // function : ClickOnOk()
433 //=================================================================================
434 void BasicGUI_PointDlg::ClickOnOk()
441 //=================================================================================
442 // function : ClickOnApply()
444 //=================================================================================
445 bool BasicGUI_PointDlg::ClickOnApply()
451 ConstructorsClicked( getConstructorId() );
456 //=================================================================================
457 // function : SelectionIntoArgument()
458 // purpose : Called when selection as changed (for constructors not using local context)
459 //=================================================================================
460 void BasicGUI_PointDlg::SelectionIntoArgument()
462 const int id = getConstructorId();
464 if ( ( id == GEOM_POINT_REF || id == GEOM_POINT_EDGE || id == GEOM_POINT_SURF ) && myEditCurrentArgument != 0 )
466 myEditCurrentArgument->setText( "" );
470 myRefPoint = myEdge = myFace = GEOM::GEOM_Object::_nil();
473 LightApp_SelectionMgr* aSelMgr = myGeomGUI->getApp()->selectionMgr();
474 SALOME_ListIO aSelList;
475 aSelMgr->selectedObjects(aSelList);
477 if (aSelList.Extent() == 1) {
478 Standard_Boolean aRes = Standard_False;
479 Handle(SALOME_InteractiveObject) anIO = aSelList.First();
480 GEOM::GEOM_Object_var aSelectedObject = GEOMBase::ConvertIOinGEOMObject( anIO, aRes );
481 if ( !CORBA::is_nil( aSelectedObject ) && aRes ) {
482 QString aName = GEOMBase::GetName(aSelectedObject);
483 TopAbs_ShapeEnum aNeedType = TopAbs_VERTEX;
485 if ( GEOMBase::GetShape( aSelectedObject, aShape, TopAbs_SHAPE ) && !aShape.IsNull() ) {
486 if ( id == GEOM_POINT_EDGE || id == GEOM_POINT_INTINT )
487 aNeedType = TopAbs_EDGE;
488 else if ( id == GEOM_POINT_SURF )
489 aNeedType = TopAbs_FACE;
491 TColStd_IndexedMapOfInteger aMap;
492 aSelMgr->GetIndexes(anIO, aMap);
493 if ( aMap.Extent() == 1 ) { // Local Selection
494 int anIndex = aMap( 1 );
495 if ( aNeedType == TopAbs_EDGE )
496 aName += QString( ":edge_%1" ).arg( anIndex );
498 aName += QString( ":vertex_%1" ).arg( anIndex );
500 //Find SubShape Object in Father
501 GEOM::GEOM_Object_var aFindedObject = GEOMBase_Helper::findObjectInFather(aSelectedObject, aName);
503 if ( aFindedObject == GEOM::GEOM_Object::_nil() ) { // Object not found in study
504 GEOM::GEOM_IShapesOperations_var aShapesOp =
505 getGeomEngine()->GetIShapesOperations(getStudyId());
506 aSelectedObject = aShapesOp->GetSubShape(aSelectedObject, anIndex);
509 aSelectedObject = aFindedObject; // get Object from study
511 GEOMBase::GetShape( aSelectedObject, aShape, TopAbs_SHAPE );
513 else { // Global Selection
514 if ( aShape.ShapeType() != aNeedType ) {
515 aSelectedObject = GEOM::GEOM_Object::_nil();
517 if ( id == GEOM_POINT_XYZ ) return;
522 if ( aShape.IsNull() || aShape.ShapeType() != aNeedType)
525 if ( id == GEOM_POINT_XYZ ) {
526 gp_Pnt aPnt = BRep_Tool::Pnt( TopoDS::Vertex( aShape ) );
527 GroupXYZ->SpinBox_DX->setValue( aPnt.X() );
528 GroupXYZ->SpinBox_DY->setValue( aPnt.Y() );
529 GroupXYZ->SpinBox_DZ->setValue( aPnt.Z() );
531 else if ( id == GEOM_POINT_REF ) {
532 myRefPoint = aSelectedObject;
533 GroupRefPoint->LineEdit1->setText( aName );
535 else if ( id == GEOM_POINT_EDGE ) {
536 myEdge = aSelectedObject;
537 GroupOnCurve->LineEdit1->setText( aName );
539 else if ( id == GEOM_POINT_INTINT ) {
540 myEditCurrentArgument->setText( aName );
542 localSelection( GEOM::GEOM_Object::_nil(), TopAbs_EDGE );
543 if ( myEditCurrentArgument == GroupLineIntersection->LineEdit1 ) {
544 myLine1 = aSelectedObject;
545 if ( !myLine1->_is_nil() && myLine2->_is_nil() )
546 GroupLineIntersection->PushButton2->click();
548 else if ( myEditCurrentArgument == GroupLineIntersection->LineEdit2 ) {
549 myLine2 = aSelectedObject;
550 if ( !myLine2->_is_nil() && myLine1->_is_nil() )
551 GroupLineIntersection->PushButton1->click();
554 else if ( id == GEOM_POINT_SURF )
556 myFace = aSelectedObject;
557 GroupOnSurface->LineEdit1->setText( aName );
566 //=================================================================================
567 // function : LineEditReturnPressed()
569 //=================================================================================
570 void BasicGUI_PointDlg::LineEditReturnPressed()
572 QLineEdit* send = (QLineEdit*)sender();
573 if ( send == GroupRefPoint->LineEdit1 ||
574 send == GroupOnCurve->LineEdit1 ||
575 send == GroupLineIntersection->LineEdit1 ||
576 send == GroupLineIntersection->LineEdit2 ) {
577 myEditCurrentArgument = send;
578 GEOMBase_Skeleton::LineEditReturnPressed();
583 //=================================================================================
584 // function : SetEditCurrentArgument()
586 //=================================================================================
587 void BasicGUI_PointDlg::SetEditCurrentArgument()
589 globalSelection(); // close local contexts, if any
591 QPushButton* send = (QPushButton*)sender();
593 if ( send == GroupRefPoint->PushButton1 ) {
594 GroupRefPoint->LineEdit1->setFocus();
595 myEditCurrentArgument = GroupRefPoint->LineEdit1;
597 localSelection( GEOM::GEOM_Object::_nil(), TopAbs_VERTEX );
599 else if ( send == GroupOnCurve->PushButton1 ) {
600 GroupOnCurve->LineEdit1->setFocus();
601 myEditCurrentArgument = GroupOnCurve->LineEdit1;
603 localSelection( GEOM::GEOM_Object::_nil(), TopAbs_EDGE );
605 else if ( send == GroupOnSurface->PushButton1 )
607 GroupOnSurface->LineEdit1->setFocus();
608 myEditCurrentArgument = GroupOnSurface->LineEdit1;
610 localSelection( GEOM::GEOM_Object::_nil(), TopAbs_FACE );
612 else if ( send == GroupLineIntersection->PushButton1 ) {
613 GroupLineIntersection->LineEdit1->setFocus();
614 myEditCurrentArgument = GroupLineIntersection->LineEdit1;
615 GroupLineIntersection->PushButton2->setDown( false );
616 GroupLineIntersection->LineEdit1->setEnabled(true);
617 GroupLineIntersection->LineEdit2->setEnabled(false);
618 localSelection( GEOM::GEOM_Object::_nil(), TopAbs_EDGE );
620 else if ( send == GroupLineIntersection->PushButton2 ) {
621 GroupLineIntersection->LineEdit2->setFocus();
622 myEditCurrentArgument = GroupLineIntersection->LineEdit2;
623 GroupLineIntersection->PushButton1->setDown( false );
624 GroupLineIntersection->LineEdit1->setEnabled(false);
625 GroupLineIntersection->LineEdit2->setEnabled(true);
626 localSelection( GEOM::GEOM_Object::_nil(), TopAbs_EDGE );
632 //=================================================================================
633 // function : enterEvent()
634 // purpose : to reactivate this dialog box when mouse enter onto the window
635 //=================================================================================
636 void BasicGUI_PointDlg::enterEvent( QEvent* )
638 if ( !mainFrame()->GroupConstructors->isEnabled() )
639 ActivateThisDialog();
643 //=================================================================================
644 // function : ActivateThisDialog()
646 //=================================================================================
647 void BasicGUI_PointDlg::ActivateThisDialog( )
649 GEOMBase_Skeleton::ActivateThisDialog();
651 connect( myGeomGUI->getApp()->selectionMgr(), SIGNAL( currentSelectionChanged() ),
652 this, SLOT( SelectionIntoArgument() ) );
654 ConstructorsClicked( getConstructorId() );
658 //=================================================================================
659 // function : DeactivateActiveDialog()
660 // purpose : public slot to deactivate if active
661 //=================================================================================
662 void BasicGUI_PointDlg::DeactivateActiveDialog()
664 // myGeomGUI->SetState( -1 );
665 GEOMBase_Skeleton::DeactivateActiveDialog();
669 //=================================================================================
670 // function : ValueChangedInSpinBox()
672 //=================================================================================
673 void BasicGUI_PointDlg::ValueChangedInSpinBox(double newValue)
678 //=================================================================================
679 // funcion : getParameter()
681 //=================================================================================
682 double BasicGUI_PointDlg::getParameter() const
684 return GroupOnCurve->SpinBox_DX->value();
688 //=================================================================================
689 // funcion : getUParameter()
691 //=================================================================================
692 double BasicGUI_PointDlg::getUParameter() const
694 return GroupOnSurface->SpinBox_DX->value();
698 //=================================================================================
699 // funcion : getVParameter()
701 //=================================================================================
702 double BasicGUI_PointDlg::getVParameter() const
704 return GroupOnSurface->SpinBox_DY->value();
708 //=================================================================================
709 // function : OnPointSelected
711 //=================================================================================
712 void BasicGUI_PointDlg::OnPointSelected( const gp_Pnt& thePnt )
714 if ( getConstructorId() == GEOM_POINT_XYZ ) {
715 GroupXYZ->SpinBox_DX->setValue( thePnt.X() );
716 GroupXYZ->SpinBox_DY->setValue( thePnt.Y() );
717 GroupXYZ->SpinBox_DZ->setValue( thePnt.Z() );
723 //=================================================================================
724 // function : createOperation
726 //=================================================================================
727 GEOM::GEOM_IOperations_ptr BasicGUI_PointDlg::createOperation()
729 return myGeomGUI->GetGeomGen()->GetIBasicOperations( getStudyId() );
732 //=================================================================================
733 // function : isValid
735 //=================================================================================
736 bool BasicGUI_PointDlg::isValid( QString& msg )
738 const int id = getConstructorId();
739 if ( id == GEOM_POINT_XYZ ) {
741 ok = GroupXYZ->SpinBox_DX->isValid( msg, !IsPreview() ) && ok;
742 ok = GroupXYZ->SpinBox_DY->isValid( msg, !IsPreview() ) && ok;
743 ok = GroupXYZ->SpinBox_DZ->isValid( msg, !IsPreview() ) && ok;
746 else if ( id == GEOM_POINT_REF ) {
748 ok = GroupRefPoint->SpinBox_DX->isValid( msg, !IsPreview() ) && ok;
749 ok = GroupRefPoint->SpinBox_DY->isValid( msg, !IsPreview() ) && ok;
750 ok = GroupRefPoint->SpinBox_DZ->isValid( msg, !IsPreview() ) && ok;
752 return !myRefPoint->_is_nil() && ok;
754 else if ( id == GEOM_POINT_EDGE ) {
756 if ( myParamCoord->checkedId() == PARAM_VALUE )
757 ok = GroupOnCurve->SpinBox_DX->isValid( msg, !IsPreview() );
759 ok = GroupXYZ->SpinBox_DX->isValid( msg, !IsPreview() ) && ok;
760 ok = GroupXYZ->SpinBox_DY->isValid( msg, !IsPreview() ) && ok;
761 ok = GroupXYZ->SpinBox_DZ->isValid( msg, !IsPreview() ) && ok;
763 return !myEdge->_is_nil() && ok;
765 else if ( id == GEOM_POINT_INTINT )
766 return ( !myLine1->_is_nil() && !myLine2->_is_nil() );
767 else if ( id == GEOM_POINT_SURF ) {
769 if ( myParamCoord->checkedId() == PARAM_VALUE ) {
770 ok = GroupOnSurface->SpinBox_DX->isValid( msg, !IsPreview() ) && ok;
771 ok = GroupOnSurface->SpinBox_DY->isValid( msg, !IsPreview() ) && ok;
774 ok = GroupXYZ->SpinBox_DX->isValid( msg, !IsPreview() ) && ok;
775 ok = GroupXYZ->SpinBox_DY->isValid( msg, !IsPreview() ) && ok;
776 ok = GroupXYZ->SpinBox_DZ->isValid( msg, !IsPreview() ) && ok;
778 return !myFace->_is_nil() && ok;
784 //=================================================================================
785 // function : execute
787 //=================================================================================
788 bool BasicGUI_PointDlg::execute( ObjectList& objects )
792 GEOM::GEOM_Object_var anObj;
793 QStringList aParameters;
795 GEOM::GEOM_IBasicOperations_var anOper = GEOM::GEOM_IBasicOperations::_narrow( getOperation() );
797 switch ( getConstructorId() ) {
798 case GEOM_POINT_XYZ :
800 double x = GroupXYZ->SpinBox_DX->value();
801 double y = GroupXYZ->SpinBox_DY->value();
802 double z = GroupXYZ->SpinBox_DZ->value();
804 aParameters << GroupXYZ->SpinBox_DX->text();
805 aParameters << GroupXYZ->SpinBox_DY->text();
806 aParameters << GroupXYZ->SpinBox_DZ->text();
808 anObj = anOper->MakePointXYZ( x, y, z );
812 case GEOM_POINT_REF :
814 double dx = GroupRefPoint->SpinBox_DX->value();
815 double dy = GroupRefPoint->SpinBox_DY->value();
816 double dz = GroupRefPoint->SpinBox_DZ->value();
818 aParameters << GroupRefPoint->SpinBox_DX->text();
819 aParameters << GroupRefPoint->SpinBox_DY->text();
820 aParameters << GroupRefPoint->SpinBox_DZ->text();
822 anObj = anOper->MakePointWithReference( myRefPoint, dx, dy, dz );
826 case GEOM_POINT_EDGE :
828 if ( myParamCoord->checkedId() == PARAM_VALUE ) {
829 anObj = anOper->MakePointOnCurve( myEdge, getParameter() );
830 aParameters<<GroupOnCurve->SpinBox_DX->text();
832 double x = GroupXYZ->SpinBox_DX->value();
833 double y = GroupXYZ->SpinBox_DY->value();
834 double z = GroupXYZ->SpinBox_DZ->value();
836 aParameters << GroupXYZ->SpinBox_DX->text();
837 aParameters << GroupXYZ->SpinBox_DY->text();
838 aParameters << GroupXYZ->SpinBox_DZ->text();
840 anObj = anOper->MakePointOnCurveByCoord( myEdge, x, y, z );
845 case GEOM_POINT_INTINT :
846 anOper->MakePointOnLinesIntersection( myLine1, myLine2 );
849 case GEOM_POINT_SURF :
851 if ( myParamCoord->checkedId() == PARAM_VALUE ) {
852 anObj = anOper->MakePointOnSurface( myFace, getUParameter(), getVParameter() );
853 aParameters<<GroupOnSurface->SpinBox_DX->text();
854 aParameters<<GroupOnSurface->SpinBox_DY->text();
856 double x = GroupXYZ->SpinBox_DX->value();
857 double y = GroupXYZ->SpinBox_DY->value();
858 double z = GroupXYZ->SpinBox_DZ->value();
860 aParameters << GroupXYZ->SpinBox_DX->text();
861 aParameters << GroupXYZ->SpinBox_DY->text();
862 aParameters << GroupXYZ->SpinBox_DZ->text();
864 anObj = anOper->MakePointOnSurfaceByCoord( myFace, x, y, z );
871 const int id = getConstructorId();
872 if(!anObj->_is_nil() && !IsPreview() && (id == GEOM_POINT_XYZ ||
873 id == GEOM_POINT_REF ||
874 id == GEOM_POINT_EDGE ||
875 id == GEOM_POINT_SURF) ) {
876 myNoteBook->setParameters(anObj, aParameters);
880 if ( id == GEOM_POINT_REF || id == GEOM_POINT_EDGE || id == GEOM_POINT_SURF ) {
882 if ( GEOMBase::GetShape( anObj, aShape ) && !aShape.IsNull() &&
883 aShape.ShapeType() == TopAbs_VERTEX ) {
884 gp_Pnt aPnt = BRep_Tool::Pnt( TopoDS::Vertex( aShape ) );
885 myX->setText( QString( "%1" ).arg( aPnt.X() ) );
886 myY->setText( QString( "%1" ).arg( aPnt.Y() ) );
887 myZ->setText( QString( "%1" ).arg( aPnt.Z() ) );
896 if ( !anObj->_is_nil() ) {
897 objects.push_back( anObj._retn() );
903 //=================================================================================
904 // function : addSubshapeToStudy
905 // purpose : virtual method to add new SubObjects if local selection
906 //=================================================================================
907 void BasicGUI_PointDlg::addSubshapesToStudy()
909 QMap<QString, GEOM::GEOM_Object_var> objMap;
911 switch ( getConstructorId() ) {
915 objMap[GroupRefPoint->LineEdit1->text()] = myRefPoint;
917 case GEOM_POINT_EDGE:
918 objMap[GroupOnCurve->LineEdit1->text()] = myEdge;
920 case GEOM_POINT_INTINT:
921 objMap[GroupLineIntersection->LineEdit1->text()] = myLine1;
922 objMap[GroupLineIntersection->LineEdit2->text()] = myLine2;
924 case GEOM_POINT_SURF:
925 objMap[GroupOnSurface->LineEdit1->text()] = myFace;
928 addSubshapesToFather( objMap );
931 //=================================================================================
932 // function : ClickParamCoord()
934 //=================================================================================
935 void BasicGUI_PointDlg::ClickParamCoord()
937 updateParamCoord( true );
941 //=================================================================================
942 // function : updateParamCoord
944 //=================================================================================
945 void BasicGUI_PointDlg::updateParamCoord(bool theIsUpdate)
947 bool isParam = myParamCoord->checkedId() == PARAM_VALUE;
948 GroupXYZ->setShown( !isParam );
950 const int id = getConstructorId();
951 if ( id == GEOM_POINT_EDGE ) {
952 GroupOnCurve->TextLabel2->setShown( isParam );
953 GroupOnCurve->SpinBox_DX->setShown( isParam );
955 else if ( id == GEOM_POINT_SURF ) {
956 GroupOnSurface->TextLabel2->setShown( isParam );
957 GroupOnSurface->TextLabel3->setShown( isParam );
958 GroupOnSurface->SpinBox_DX->setShown( isParam );
959 GroupOnSurface->SpinBox_DY->setShown( isParam );
962 qApp->processEvents();
964 resize( minimumSizeHint() );