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 <LightApp_SelectionMgr.h>
33 #include <GeometryGUI.h>
38 #include <GEOMImpl_Types.hxx>
40 #include <QApplication>
41 #include <QButtonGroup>
42 #include <QHBoxLayout>
44 #include <QRadioButton>
47 #include <TopoDS_Shape.hxx>
48 #include <TopAbs_ShapeEnum.hxx>
50 #include <BRep_Tool.hxx>
52 #include <TColStd_IndexedMapOfInteger.hxx>
53 #include <TopTools_IndexedMapOfShape.hxx>
61 #define POINT_INTINT 3
65 //=================================================================================
66 // class : BasicGUI_PointDlg()
67 // purpose : Constructs a BasicGUI_PointDlg which is a child of 'parent', with the
68 // name 'name' and widget flags set to 'f'.
69 // The dialog will by default be modeless, unless you set 'modal' to
70 // TRUE to construct a modal dialog.
71 //=================================================================================
72 BasicGUI_PointDlg::BasicGUI_PointDlg( GeometryGUI* theGeometryGUI, QWidget* parent,
73 bool modal, Qt::WindowFlags fl )
74 : GEOMBase_Skeleton( theGeometryGUI, parent, modal, fl )
76 QPixmap image0( SUIT_Session::session()->resourceMgr()->loadPixmap( "GEOM", tr( "ICON_DLG_POINT") ) );
77 QPixmap image1( SUIT_Session::session()->resourceMgr()->loadPixmap( "GEOM", tr( "ICON_DLG_POINT_EDGE" ) ) );
78 QPixmap image2( SUIT_Session::session()->resourceMgr()->loadPixmap( "GEOM", tr( "ICON_SELECT" ) ) );
79 QPixmap image3( SUIT_Session::session()->resourceMgr()->loadPixmap( "GEOM", tr( "ICON_DLG_POINT_REF" ) ) );
80 QPixmap image4( SUIT_Session::session()->resourceMgr()->loadPixmap( "GEOM", tr( "ICON_DLG_POINT_LINES") ) );
81 QPixmap image5( SUIT_Session::session()->resourceMgr()->loadPixmap( "GEOM", tr( "ICON_DLG_POINT_FACE" ) ) );
83 setWindowTitle( tr( "GEOM_POINT_TITLE" ) );
85 /***************************************************************/
86 mainFrame()->GroupConstructors->setTitle( tr( "GEOM_POINTS" ) );
87 mainFrame()->RadioButton1->setIcon( image0 );
88 mainFrame()->RadioButton2->setIcon( image3 );
89 mainFrame()->RadioButton3->setIcon( image1 );
90 mainFrame()->RadioButton4->show();
91 mainFrame()->RadioButton4->setIcon( image4 );
92 mainFrame()->RadioButton5->show();
93 mainFrame()->RadioButton5->setIcon( image5 );
95 QGroupBox* paramGrp = new QGroupBox( centralWidget() );
96 myParamCoord = new QButtonGroup( paramGrp );
97 QHBoxLayout* boxLayout = new QHBoxLayout( paramGrp );
98 boxLayout->setMargin( 0 ); boxLayout->setSpacing( 6 );
99 QRadioButton* btn = new QRadioButton( tr( "GEOM_PARAM_VALUE" ), paramGrp );
100 myParamCoord->addButton( btn, PARAM_VALUE );
101 boxLayout->addWidget( btn );
102 btn = new QRadioButton( tr( "GEOM_COORD_VALUE" ), paramGrp );
103 myParamCoord->addButton( btn, COORD_VALUE );
104 boxLayout->addWidget( btn );
105 myParamCoord->setExclusive( true );
106 myParamCoord->button( PARAM_VALUE )->setChecked( true );
108 GroupXYZ = new DlgRef_3Spin( centralWidget() );
109 GroupXYZ->GroupBox1->setTitle( tr( "GEOM_COORDINATES" ) );
110 GroupXYZ->TextLabel1->setText( tr( "GEOM_X" ) );
111 GroupXYZ->TextLabel2->setText( tr( "GEOM_Y" ) );
112 GroupXYZ->TextLabel3->setText( tr( "GEOM_Z" ) );
114 GroupOnCurve = new DlgRef_1Sel1Spin( centralWidget() );
115 GroupOnCurve->GroupBox1->setTitle( tr( "GEOM_POINT_ON_EDGE" ) );
116 GroupOnCurve->TextLabel1->setText( tr( "GEOM_EDGE" ) );
117 GroupOnCurve->TextLabel2->setText( tr( "GEOM_PARAMETER" ) );
118 GroupOnCurve->PushButton1->setIcon( image2 );
120 GroupOnSurface = new DlgRef_1Sel2Spin( centralWidget() );
121 GroupOnSurface->GroupBox1->setTitle( tr( "GEOM_POINT_ON_FACE" ) );
122 GroupOnSurface->TextLabel1->setText( tr( "GEOM_FACE" ) );
123 GroupOnSurface->TextLabel2->setText( tr( "GEOM_UPARAMETER" ) );
124 GroupOnSurface->TextLabel3->setText( tr( "GEOM_VPARAMETER" ) );
125 GroupOnSurface->PushButton1->setIcon( image2 );
127 GroupRefPoint = new DlgRef_1Sel3Spin( centralWidget() );
128 GroupRefPoint->GroupBox1->setTitle( tr( "GEOM_REF_POINT" ) );
129 GroupRefPoint->TextLabel1->setText( tr( "GEOM_POINT" ) );
130 GroupRefPoint->PushButton1->setIcon( image2 );
131 GroupRefPoint->TextLabel2->setText( tr( "GEOM_DX" ) );
132 GroupRefPoint->TextLabel3->setText( tr( "GEOM_DY" ) );
133 GroupRefPoint->TextLabel4->setText( tr( "GEOM_DZ" ) );
135 GroupLineIntersection = new DlgRef_2Sel( centralWidget() );
136 GroupLineIntersection->GroupBox1->setTitle( tr( "GEOM_LINE_INTERSECTION" ) );
137 GroupLineIntersection->TextLabel1->setText( tr( "GEOM_LINE1" ) );
138 GroupLineIntersection->TextLabel2->setText( tr( "GEOM_LINE2" ) );
139 GroupLineIntersection->PushButton1->setIcon( image2 );
140 GroupLineIntersection->PushButton2->setIcon( image2 );
141 GroupLineIntersection->LineEdit2->setEnabled(false);
143 myCoordGrp = new QGroupBox( tr( "GEOM_COORDINATES_RES" ), centralWidget() );
144 QGridLayout* myCoordGrpLayout = new QGridLayout( myCoordGrp );
145 myCoordGrpLayout->addWidget( new QLabel( tr( "GEOM_X" ), myCoordGrp ), 0, 0 );
146 myX = new QLineEdit( myCoordGrp );
147 myCoordGrpLayout->addWidget( myX, 0, 1 );
148 myCoordGrpLayout->addWidget( new QLabel( tr( "GEOM_Y" ), myCoordGrp ), 1, 0 );
149 myY = new QLineEdit( myCoordGrp );
150 myCoordGrpLayout->addWidget( myY, 1, 1 );
151 myCoordGrpLayout->addWidget( new QLabel( tr( "GEOM_Z" ), myCoordGrp ), 2, 0 );
152 myZ = new QLineEdit( myCoordGrp );
153 myCoordGrpLayout->addWidget( myZ, 2, 1 );
155 QVBoxLayout* layout = new QVBoxLayout( centralWidget() );
156 layout->setMargin( 0 ); layout->setSpacing( 6 );
157 layout->addWidget( paramGrp );
158 layout->addWidget( GroupXYZ );
159 layout->addWidget( GroupOnCurve );
160 layout->addWidget( GroupOnSurface );
161 layout->addWidget( GroupRefPoint );
162 layout->addWidget( GroupLineIntersection );
163 layout->addWidget( myCoordGrp );
165 myX->setReadOnly( true );
166 myY->setReadOnly( true );
167 myZ->setReadOnly( true );
169 myX->setEnabled( false );
170 myY->setEnabled( false );
171 myZ->setEnabled( false );
173 QPalette aPal = myX->palette();
174 aPal.setColor( QPalette::Disabled, QPalette::Text, QColor( 0, 0, 0 ) ) ;
175 myX->setPalette( aPal );
176 myY->setPalette( aPal );
177 myZ->setPalette( aPal );
179 setHelpFileName( "create_point_page.html" );
185 //=================================================================================
186 // function : ~BasicGUI_PointDlg()
187 // purpose : Destructor
188 //=================================================================================
189 BasicGUI_PointDlg::~BasicGUI_PointDlg()
194 //=================================================================================
197 //=================================================================================
198 void BasicGUI_PointDlg::Init()
200 GroupOnCurve->LineEdit1->setReadOnly( true );
201 GroupOnSurface->LineEdit1->setReadOnly( true );
202 GroupRefPoint->LineEdit1->setReadOnly( true );
203 GroupLineIntersection->LineEdit1->setReadOnly( true );
204 GroupLineIntersection->LineEdit2->setReadOnly( true );
205 GroupLineIntersection->LineEdit1->setEnabled( true );
206 GroupLineIntersection->LineEdit2->setEnabled( false );
208 myEdge = GEOM::GEOM_Object::_nil();
209 myRefPoint = GEOM::GEOM_Object::_nil();
211 myEditCurrentArgument = 0;
213 /* Get setting of step value from file configuration */
214 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
215 double step = resMgr->doubleValue( "Geometry", "SettingsGeomStep", 100 );
217 /* min, max, step and decimals for spin boxes */
218 initSpinBox( GroupXYZ->SpinBox_DX, COORD_MIN, COORD_MAX, step, 6 ); // VSR: TODO: DBL_DIGITS_DISPLAY
219 initSpinBox( GroupXYZ->SpinBox_DY, COORD_MIN, COORD_MAX, step, 6 ); // VSR: TODO: DBL_DIGITS_DISPLAY
220 initSpinBox( GroupXYZ->SpinBox_DZ, COORD_MIN, COORD_MAX, step, 6 ); // VSR: TODO: DBL_DIGITS_DISPLAY
221 GroupXYZ->SpinBox_DX->setValue( 0.0 );
222 GroupXYZ->SpinBox_DY->setValue( 0.0 );
223 GroupXYZ->SpinBox_DZ->setValue( 0.0 );
225 initSpinBox( GroupRefPoint->SpinBox_DX, COORD_MIN, COORD_MAX, step, 6 ); // VSR: TODO: DBL_DIGITS_DISPLAY
226 initSpinBox( GroupRefPoint->SpinBox_DY, COORD_MIN, COORD_MAX, step, 6 ); // VSR: TODO: DBL_DIGITS_DISPLAY
227 initSpinBox( GroupRefPoint->SpinBox_DZ, COORD_MIN, COORD_MAX, step, 6 ); // VSR: TODO: DBL_DIGITS_DISPLAY
228 GroupRefPoint->SpinBox_DX->setValue( 0.0 );
229 GroupRefPoint->SpinBox_DY->setValue( 0.0 );
230 GroupRefPoint->SpinBox_DZ->setValue( 0.0 );
234 initSpinBox( GroupOnCurve->SpinBox_DX, 0., 1., step, 6 ); // VSR:TODO : DBL_DIGITS_DISPLAY
235 GroupOnCurve->SpinBox_DX->setValue( 0.5 );
237 initSpinBox( GroupOnSurface->SpinBox_DX, 0., 1., step, 6 ); // VSR:TODO : DBL_DIGITS_DISPLAY
238 GroupOnSurface->SpinBox_DX->setValue( 0.5 );
239 initSpinBox( GroupOnSurface->SpinBox_DY, 0., 1., step, 6 ); // VSR:TODO : DBL_DIGITS_DISPLAY
240 GroupOnSurface->SpinBox_DY->setValue( 0.5 );
242 /* signals and slots connections */
243 connect( myGeomGUI, SIGNAL( SignalDeactivateActiveDialog() ), this, SLOT( DeactivateActiveDialog() ) );
244 connect( myGeomGUI, SIGNAL( SignalCloseAllDialogs() ), this, SLOT( ClickOnCancel() ) );
246 connect( buttonOk(), SIGNAL( clicked() ), this, SLOT( ClickOnOk() ) );
247 connect( buttonApply(), SIGNAL( clicked() ), this, SLOT( ClickOnApply() ) );
249 connect( this, SIGNAL( constructorsClicked( int ) ), this, SLOT( ConstructorsClicked( int ) ) );
252 connect( myParamCoord->button( PARAM_VALUE ), SIGNAL( clicked() ), this, SLOT( ClickParamCoord() ) );
253 connect( myParamCoord->button( COORD_VALUE ), SIGNAL( clicked() ), this, SLOT( ClickParamCoord() ) );
254 connect( GroupOnCurve->PushButton1, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) );
255 connect( GroupOnCurve->LineEdit1, SIGNAL( returnPressed() ), this, SLOT( LineEditReturnPressed() ) );
257 connect( GroupOnSurface->PushButton1, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) );
258 connect( GroupOnSurface->LineEdit1, SIGNAL( returnPressed() ), this, SLOT( LineEditReturnPressed() ) );
260 connect( GroupLineIntersection->PushButton1, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) );
261 connect( GroupLineIntersection->PushButton2, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) );
262 connect( GroupLineIntersection->LineEdit1, SIGNAL( returnPressed() ), this, SLOT( LineEditReturnPressed() ) );
263 connect( GroupLineIntersection->LineEdit2, SIGNAL( returnPressed() ), this, SLOT( LineEditReturnPressed() ) );
265 connect( GroupOnCurve->SpinBox_DX, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
266 connect( GroupOnSurface->SpinBox_DX, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
267 connect( GroupOnSurface->SpinBox_DY, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
268 connect( GroupXYZ->SpinBox_DX, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
269 connect( GroupXYZ->SpinBox_DY, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
270 connect( GroupXYZ->SpinBox_DZ, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
271 connect( GroupRefPoint->SpinBox_DX, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
272 connect( GroupRefPoint->SpinBox_DY, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
273 connect( GroupRefPoint->SpinBox_DZ, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
275 connect( myGeomGUI, SIGNAL( SignalDefaultStepValueChanged( double ) ), this, SLOT( SetDoubleSpinBoxStep( double ) ) );
277 connect( myGeomGUI->getApp()->selectionMgr(), SIGNAL(currentSelectionChanged() ),
278 this, SLOT(SelectionIntoArgument() ) );
281 initName( tr( "GEOM_VERTEX" ) );
283 ConstructorsClicked( 0 );
286 //=================================================================================
287 // function : SetDoubleSpinBoxStep()
288 // purpose : Double spin box management
289 //=================================================================================
290 void BasicGUI_PointDlg::SetDoubleSpinBoxStep( double step )
292 GroupOnCurve->SpinBox_DX->setSingleStep(step);
293 GroupXYZ->SpinBox_DX->setSingleStep(step);
294 GroupXYZ->SpinBox_DY->setSingleStep(step);
295 GroupXYZ->SpinBox_DZ->setSingleStep(step);
296 GroupRefPoint->SpinBox_DX->setSingleStep(step);
297 GroupRefPoint->SpinBox_DY->setSingleStep(step);
298 GroupRefPoint->SpinBox_DZ->setSingleStep(step);
299 GroupOnSurface->SpinBox_DX->setSingleStep(step);
300 GroupOnSurface->SpinBox_DY->setSingleStep(step);
304 //=================================================================================
305 // function : ConstructorsClicked()
306 // purpose : Radio button management
307 //=================================================================================
308 void BasicGUI_PointDlg::ConstructorsClicked(int constructorId)
310 globalSelection(); // close local contexts, if any
312 switch ( constructorId ) {
315 localSelection( GEOM::GEOM_Object::_nil(), TopAbs_VERTEX );
317 GroupRefPoint->hide();
318 GroupOnCurve->hide();
319 GroupLineIntersection->hide();
320 GroupOnSurface->hide();
324 myParamCoord->button( PARAM_VALUE )->hide();
325 myParamCoord->button( COORD_VALUE )->hide();
331 myEditCurrentArgument = GroupRefPoint->LineEdit1;
332 myEditCurrentArgument->setText( "" );
333 myRefPoint = GEOM::GEOM_Object::_nil();
334 GroupRefPoint->PushButton1->setDown(true);
335 localSelection( GEOM::GEOM_Object::_nil(), TopAbs_VERTEX );
337 myParamCoord->button( PARAM_VALUE )->hide();
338 myParamCoord->button( COORD_VALUE )->hide();
340 GroupOnCurve->hide();
341 GroupLineIntersection->hide();
342 GroupOnSurface->hide();
344 GroupRefPoint->show();
351 myEditCurrentArgument = GroupOnCurve->LineEdit1;
352 myEditCurrentArgument->setText( "" );
353 myEdge = GEOM::GEOM_Object::_nil();
354 GroupOnCurve->PushButton1->setDown(true);
355 localSelection( GEOM::GEOM_Object::_nil(), TopAbs_EDGE );
357 GroupRefPoint->hide();
358 GroupLineIntersection->hide();
359 GroupOnSurface->hide();
361 myParamCoord->button( PARAM_VALUE )->show();
362 myParamCoord->button( COORD_VALUE )->show();
363 GroupOnCurve->show();
366 updateParamCoord( false );
371 myEditCurrentArgument = GroupLineIntersection->LineEdit1;
372 GroupLineIntersection->LineEdit1->setText( "" );
373 GroupLineIntersection->LineEdit2->setText( "" );
374 GroupLineIntersection->LineEdit1->setEnabled( true );
375 GroupLineIntersection->LineEdit2->setEnabled( false );
376 myLine1 = GEOM::GEOM_Object::_nil();
377 myLine2 = GEOM::GEOM_Object::_nil();
378 GroupLineIntersection->PushButton1->setDown(true);
379 GroupLineIntersection->PushButton2->setDown(false);
381 localSelection( GEOM::GEOM_Object::_nil(), TopAbs_EDGE );
383 myParamCoord->button( PARAM_VALUE )->hide();
384 myParamCoord->button( COORD_VALUE )->hide();
386 GroupRefPoint->hide();
387 GroupOnCurve->hide();
388 GroupOnSurface->hide();
392 GroupLineIntersection->show();
397 myEditCurrentArgument = GroupOnSurface->LineEdit1;
398 myEditCurrentArgument->setText( "" );
399 myFace = GEOM::GEOM_Object::_nil();
400 GroupOnSurface->PushButton1->setDown(true);
401 localSelection( GEOM::GEOM_Object::_nil(), TopAbs_FACE );
403 GroupRefPoint->hide();
404 GroupOnCurve->hide();
405 GroupLineIntersection->hide();
407 myParamCoord->button( PARAM_VALUE )->show();
408 myParamCoord->button( COORD_VALUE )->show();
409 GroupOnSurface->show();
412 updateParamCoord( false );
421 qApp->processEvents();
423 resize( minimumSizeHint() );
425 SelectionIntoArgument();
429 //=================================================================================
430 // function : ClickOnOk()
432 //=================================================================================
433 void BasicGUI_PointDlg::ClickOnOk()
440 //=================================================================================
441 // function : ClickOnApply()
443 //=================================================================================
444 bool BasicGUI_PointDlg::ClickOnApply()
450 ConstructorsClicked( getConstructorId() );
455 //=================================================================================
456 // function : SelectionIntoArgument()
457 // purpose : Called when selection as changed (for constructors not using local context)
458 //=================================================================================
459 void BasicGUI_PointDlg::SelectionIntoArgument()
461 const int id = getConstructorId();
463 if ( ( id == POINT_REF || id == POINT_EDGE || id == POINT_SURF ) && myEditCurrentArgument != 0 )
465 myEditCurrentArgument->setText( "" );
469 myRefPoint = myEdge = myFace = GEOM::GEOM_Object::_nil();
472 LightApp_SelectionMgr* aSelMgr = myGeomGUI->getApp()->selectionMgr();
473 SALOME_ListIO aSelList;
474 aSelMgr->selectedObjects(aSelList);
476 if (aSelList.Extent() == 1) {
477 Standard_Boolean aRes = Standard_False;
478 Handle(SALOME_InteractiveObject) anIO = aSelList.First();
479 GEOM::GEOM_Object_var aSelectedObject = GEOMBase::ConvertIOinGEOMObject( anIO, aRes );
480 if ( !CORBA::is_nil( aSelectedObject ) && aRes ) {
481 QString aName = GEOMBase::GetName(aSelectedObject);
482 TopAbs_ShapeEnum aNeedType = TopAbs_VERTEX;
484 if ( GEOMBase::GetShape( aSelectedObject, aShape, TopAbs_SHAPE ) && !aShape.IsNull() ) {
485 if ( id == POINT_EDGE || id == POINT_INTINT )
486 aNeedType = TopAbs_EDGE;
487 else if ( id == POINT_SURF )
488 aNeedType = TopAbs_FACE;
490 TColStd_IndexedMapOfInteger aMap;
491 aSelMgr->GetIndexes(anIO, aMap);
492 if ( aMap.Extent() == 1 ) { // Local Selection
493 int anIndex = aMap( 1 );
494 if ( aNeedType == TopAbs_EDGE )
495 aName += QString( ":edge_%1" ).arg( anIndex );
497 aName += QString( ":vertex_%1" ).arg( anIndex );
499 //Find SubShape Object in Father
500 GEOM::GEOM_Object_var aFindedObject = GEOMBase_Helper::findObjectInFather(aSelectedObject, aName);
502 if ( aFindedObject == GEOM::GEOM_Object::_nil() ) { // Object not found in study
503 GEOM::GEOM_IShapesOperations_var aShapesOp =
504 getGeomEngine()->GetIShapesOperations(getStudyId());
505 aSelectedObject = aShapesOp->GetSubShape(aSelectedObject, anIndex);
508 aSelectedObject = aFindedObject; // get Object from study
510 GEOMBase::GetShape( aSelectedObject, aShape, TopAbs_SHAPE );
512 else { // Global Selection
513 if ( aShape.ShapeType() != aNeedType ) {
514 aSelectedObject = GEOM::GEOM_Object::_nil();
516 if ( id == POINT_XYZ ) return;
521 if ( aShape.IsNull() || aShape.ShapeType() != aNeedType)
524 if ( id == POINT_XYZ ) {
525 gp_Pnt aPnt = BRep_Tool::Pnt( TopoDS::Vertex( aShape ) );
526 GroupXYZ->SpinBox_DX->setValue( aPnt.X() );
527 GroupXYZ->SpinBox_DY->setValue( aPnt.Y() );
528 GroupXYZ->SpinBox_DZ->setValue( aPnt.Z() );
530 else if ( id == POINT_REF ) {
531 myRefPoint = aSelectedObject;
532 GroupRefPoint->LineEdit1->setText( aName );
534 else if ( id == POINT_EDGE ) {
535 myEdge = aSelectedObject;
536 GroupOnCurve->LineEdit1->setText( aName );
538 else if ( id == POINT_INTINT ) {
539 myEditCurrentArgument->setText( aName );
541 localSelection( GEOM::GEOM_Object::_nil(), TopAbs_EDGE );
542 if ( myEditCurrentArgument == GroupLineIntersection->LineEdit1 ) {
543 myLine1 = aSelectedObject;
544 if ( !myLine1->_is_nil() && myLine2->_is_nil() )
545 GroupLineIntersection->PushButton2->click();
547 else if ( myEditCurrentArgument == GroupLineIntersection->LineEdit2 ) {
548 myLine2 = aSelectedObject;
549 if ( !myLine2->_is_nil() && myLine1->_is_nil() )
550 GroupLineIntersection->PushButton1->click();
553 else if ( id == POINT_SURF )
555 myFace = aSelectedObject;
556 GroupOnSurface->LineEdit1->setText( aName );
565 //=================================================================================
566 // function : LineEditReturnPressed()
568 //=================================================================================
569 void BasicGUI_PointDlg::LineEditReturnPressed()
571 QLineEdit* send = (QLineEdit*)sender();
572 if ( send == GroupRefPoint->LineEdit1 ||
573 send == GroupOnCurve->LineEdit1 ||
574 send == GroupLineIntersection->LineEdit1 ||
575 send == GroupLineIntersection->LineEdit2 ) {
576 myEditCurrentArgument = send;
577 GEOMBase_Skeleton::LineEditReturnPressed();
582 //=================================================================================
583 // function : SetEditCurrentArgument()
585 //=================================================================================
586 void BasicGUI_PointDlg::SetEditCurrentArgument()
588 globalSelection(); // close local contexts, if any
590 QPushButton* send = (QPushButton*)sender();
592 if ( send == GroupRefPoint->PushButton1 ) {
593 GroupRefPoint->LineEdit1->setFocus();
594 myEditCurrentArgument = GroupRefPoint->LineEdit1;
596 localSelection( GEOM::GEOM_Object::_nil(), TopAbs_VERTEX );
598 else if ( send == GroupOnCurve->PushButton1 ) {
599 GroupOnCurve->LineEdit1->setFocus();
600 myEditCurrentArgument = GroupOnCurve->LineEdit1;
602 localSelection( GEOM::GEOM_Object::_nil(), TopAbs_EDGE );
604 else if ( send == GroupOnSurface->PushButton1 )
606 GroupOnSurface->LineEdit1->setFocus();
607 myEditCurrentArgument = GroupOnSurface->LineEdit1;
609 localSelection( GEOM::GEOM_Object::_nil(), TopAbs_FACE );
611 else if ( send == GroupLineIntersection->PushButton1 ) {
612 GroupLineIntersection->LineEdit1->setFocus();
613 myEditCurrentArgument = GroupLineIntersection->LineEdit1;
614 GroupLineIntersection->PushButton2->setDown( false );
615 GroupLineIntersection->LineEdit1->setEnabled(true);
616 GroupLineIntersection->LineEdit2->setEnabled(false);
617 localSelection( GEOM::GEOM_Object::_nil(), TopAbs_EDGE );
619 else if ( send == GroupLineIntersection->PushButton2 ) {
620 GroupLineIntersection->LineEdit2->setFocus();
621 myEditCurrentArgument = GroupLineIntersection->LineEdit2;
622 GroupLineIntersection->PushButton1->setDown( false );
623 GroupLineIntersection->LineEdit1->setEnabled(false);
624 GroupLineIntersection->LineEdit2->setEnabled(true);
625 localSelection( GEOM::GEOM_Object::_nil(), TopAbs_EDGE );
631 //=================================================================================
632 // function : enterEvent()
633 // purpose : to reactivate this dialog box when mouse enter onto the window
634 //=================================================================================
635 void BasicGUI_PointDlg::enterEvent( QEvent* )
637 if ( !mainFrame()->GroupConstructors->isEnabled() )
638 ActivateThisDialog();
642 //=================================================================================
643 // function : ActivateThisDialog()
645 //=================================================================================
646 void BasicGUI_PointDlg::ActivateThisDialog( )
648 GEOMBase_Skeleton::ActivateThisDialog();
649 // myGeomGUI->SetState( 0 );
650 ConstructorsClicked( getConstructorId() );
654 //=================================================================================
655 // function : DeactivateActiveDialog()
656 // purpose : public slot to deactivate if active
657 //=================================================================================
658 void BasicGUI_PointDlg::DeactivateActiveDialog()
660 // myGeomGUI->SetState( -1 );
661 GEOMBase_Skeleton::DeactivateActiveDialog();
665 //=================================================================================
666 // function : ValueChangedInSpinBox()
668 //=================================================================================
669 void BasicGUI_PointDlg::ValueChangedInSpinBox(double newValue)
674 //=================================================================================
675 // funcion : getParameter()
677 //=================================================================================
678 double BasicGUI_PointDlg::getParameter() const
680 return GroupOnCurve->SpinBox_DX->value();
684 //=================================================================================
685 // funcion : getUParameter()
687 //=================================================================================
688 double BasicGUI_PointDlg::getUParameter() const
690 return GroupOnSurface->SpinBox_DX->value();
694 //=================================================================================
695 // funcion : getVParameter()
697 //=================================================================================
698 double BasicGUI_PointDlg::getVParameter() const
700 return GroupOnSurface->SpinBox_DY->value();
704 //=================================================================================
705 // function : OnPointSelected
707 //=================================================================================
708 void BasicGUI_PointDlg::OnPointSelected( const gp_Pnt& thePnt )
710 if ( getConstructorId() == POINT_XYZ ) {
711 GroupXYZ->SpinBox_DX->setValue( thePnt.X() );
712 GroupXYZ->SpinBox_DY->setValue( thePnt.Y() );
713 GroupXYZ->SpinBox_DZ->setValue( thePnt.Z() );
719 //=================================================================================
720 // function : createOperation
722 //=================================================================================
723 GEOM::GEOM_IOperations_ptr BasicGUI_PointDlg::createOperation()
725 return myGeomGUI->GetGeomGen()->GetIBasicOperations( getStudyId() );
728 //=================================================================================
729 // function : isValid
731 //=================================================================================
732 bool BasicGUI_PointDlg::isValid( QString& msg )
734 const int id = getConstructorId();
735 if ( id == POINT_XYZ ) {
737 ok = GroupXYZ->SpinBox_DX->isValid( msg, !IsPreview() ) && ok;
738 ok = GroupXYZ->SpinBox_DY->isValid( msg, !IsPreview() ) && ok;
739 ok = GroupXYZ->SpinBox_DZ->isValid( msg, !IsPreview() ) && ok;
742 else if ( id == POINT_REF ) {
744 ok = GroupRefPoint->SpinBox_DX->isValid( msg, !IsPreview() ) && ok;
745 ok = GroupRefPoint->SpinBox_DY->isValid( msg, !IsPreview() ) && ok;
746 ok = GroupRefPoint->SpinBox_DZ->isValid( msg, !IsPreview() ) && ok;
748 return !myRefPoint->_is_nil() && ok;
750 else if ( id == POINT_EDGE ) {
752 if ( myParamCoord->checkedId() == PARAM_VALUE )
753 ok = GroupOnCurve->SpinBox_DX->isValid( msg, !IsPreview() );
755 ok = GroupXYZ->SpinBox_DX->isValid( msg, !IsPreview() ) && ok;
756 ok = GroupXYZ->SpinBox_DY->isValid( msg, !IsPreview() ) && ok;
757 ok = GroupXYZ->SpinBox_DZ->isValid( msg, !IsPreview() ) && ok;
759 return !myEdge->_is_nil() && ok;
761 else if ( id == POINT_INTINT )
762 return ( !myLine1->_is_nil() && !myLine2->_is_nil() );
763 else if ( id == POINT_SURF ) {
765 if ( myParamCoord->checkedId() == PARAM_VALUE ) {
766 ok = GroupOnSurface->SpinBox_DX->isValid( msg, !IsPreview() ) && ok;
767 ok = GroupOnSurface->SpinBox_DY->isValid( msg, !IsPreview() ) && ok;
770 ok = GroupXYZ->SpinBox_DX->isValid( msg, !IsPreview() ) && ok;
771 ok = GroupXYZ->SpinBox_DY->isValid( msg, !IsPreview() ) && ok;
772 ok = GroupXYZ->SpinBox_DZ->isValid( msg, !IsPreview() ) && ok;
774 return !myFace->_is_nil() && ok;
780 //=================================================================================
781 // function : execute
783 //=================================================================================
784 bool BasicGUI_PointDlg::execute( ObjectList& objects )
788 GEOM::GEOM_Object_var anObj;
789 QStringList aParameters;
791 switch ( getConstructorId() ) {
794 double x = GroupXYZ->SpinBox_DX->value();
795 double y = GroupXYZ->SpinBox_DY->value();
796 double z = GroupXYZ->SpinBox_DZ->value();
798 aParameters << GroupXYZ->SpinBox_DX->text();
799 aParameters << GroupXYZ->SpinBox_DY->text();
800 aParameters << GroupXYZ->SpinBox_DZ->text();
802 anObj = GEOM::GEOM_IBasicOperations::_narrow( getOperation() )->MakePointXYZ( x, y, z );
808 double dx = GroupRefPoint->SpinBox_DX->value();
809 double dy = GroupRefPoint->SpinBox_DY->value();
810 double dz = GroupRefPoint->SpinBox_DZ->value();
812 aParameters << GroupRefPoint->SpinBox_DX->text();
813 aParameters << GroupRefPoint->SpinBox_DY->text();
814 aParameters << GroupRefPoint->SpinBox_DZ->text();
816 anObj = GEOM::GEOM_IBasicOperations::_narrow( getOperation() )->
817 MakePointWithReference( myRefPoint, dx, dy, dz );
823 GEOM::GEOM_IBasicOperations_ptr anOp =
824 GEOM::GEOM_IBasicOperations::_narrow( getOperation() );
825 if ( myParamCoord->checkedId() == PARAM_VALUE ) {
826 anObj = anOp->MakePointOnCurve( myEdge, getParameter() );
827 aParameters<<GroupOnCurve->SpinBox_DX->text();
829 double x = GroupXYZ->SpinBox_DX->value();
830 double y = GroupXYZ->SpinBox_DY->value();
831 double z = GroupXYZ->SpinBox_DZ->value();
833 aParameters << GroupXYZ->SpinBox_DX->text();
834 aParameters << GroupXYZ->SpinBox_DY->text();
835 aParameters << GroupXYZ->SpinBox_DZ->text();
837 anObj = anOp->MakePointOnCurveByCoord( myEdge, x, y, z );
843 anObj = GEOM::GEOM_IBasicOperations::_narrow( getOperation() )->
844 MakePointOnLinesIntersection( myLine1, myLine2 );
849 GEOM::GEOM_IBasicOperations_ptr anOp =
850 GEOM::GEOM_IBasicOperations::_narrow( getOperation() );
851 if ( myParamCoord->checkedId() == PARAM_VALUE ) {
852 anObj = anOp->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 = anOp->MakePointOnSurfaceByCoord( myFace, x, y, z );
871 const int id = getConstructorId();
872 if(!anObj->_is_nil() && !IsPreview() && (id == POINT_XYZ ||
875 id == POINT_SURF) ) {
876 anObj->SetParameters(GeometryGUI::JoinObjectParameters(aParameters));
880 if ( id == POINT_REF || id == POINT_EDGE || id == 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;
918 objMap[GroupOnCurve->LineEdit1->text()] = myEdge;
921 objMap[GroupLineIntersection->LineEdit1->text()] = myLine1;
922 objMap[GroupLineIntersection->LineEdit2->text()] = myLine2;
925 objMap[GroupOnSurface->LineEdit1->text()] = myFace;
928 addSubshapesToFather( objMap );
931 //=================================================================================
932 // function : ClickParamCoord()
934 //=================================================================================
935 void BasicGUI_PointDlg::ClickParamCoord()
937 updateParamCoord( true );
940 //=================================================================================
941 // function : updateParamCoord
943 //=================================================================================
944 void BasicGUI_PointDlg::updateParamCoord(bool theIsUpdate)
946 bool isParam = myParamCoord->checkedId() == PARAM_VALUE;
947 GroupXYZ->setShown( !isParam );
949 const int id = getConstructorId();
950 if ( id == POINT_EDGE ) {
951 GroupOnCurve->TextLabel2->setShown( isParam );
952 GroupOnCurve->SpinBox_DX->setShown( isParam );
954 else if ( id == POINT_SURF ) {
955 GroupOnSurface->TextLabel2->setShown( isParam );
956 GroupOnSurface->TextLabel3->setShown( isParam );
957 GroupOnSurface->SpinBox_DX->setShown( isParam );
958 GroupOnSurface->SpinBox_DY->setShown( isParam );
961 qApp->processEvents();
963 resize( minimumSizeHint() );