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>
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 );
115 GroupLineIntersection->LineEdit2->setEnabled(false);
117 myCoordGrp = new QGroupBox( tr( "GEOM_COORDINATES" ), centralWidget() );
118 QGridLayout* myCoordGrpLayout = new QGridLayout( myCoordGrp );
119 myCoordGrpLayout->addWidget( new QLabel( tr( "GEOM_X" ), myCoordGrp ), 0, 0 );
120 myX = new QLineEdit( myCoordGrp );
121 myCoordGrpLayout->addWidget( myX, 0, 1 );
122 myCoordGrpLayout->addWidget( new QLabel( tr( "GEOM_Y" ), myCoordGrp ), 1, 0 );
123 myY = new QLineEdit( myCoordGrp );
124 myCoordGrpLayout->addWidget( myY, 1, 1 );
125 myCoordGrpLayout->addWidget( new QLabel( tr( "GEOM_Z" ), myCoordGrp ), 2, 0 );
126 myZ = new QLineEdit( myCoordGrp );
127 myCoordGrpLayout->addWidget( myZ, 2, 1 );
129 QVBoxLayout* layout = new QVBoxLayout( centralWidget() );
130 layout->setMargin( 0 ); layout->setSpacing( 6 );
131 layout->addWidget( GroupXYZ );
132 layout->addWidget( GroupOnCurve );
133 layout->addWidget( GroupOnSurface );
134 layout->addWidget( GroupRefPoint );
135 layout->addWidget( GroupLineIntersection );
136 layout->addWidget( myCoordGrp );
138 myX->setReadOnly( true );
139 myY->setReadOnly( true );
140 myZ->setReadOnly( true );
142 myX->setEnabled( false );
143 myY->setEnabled( false );
144 myZ->setEnabled( false );
146 QPalette aPal = myX->palette();
147 aPal.setColor( QPalette::Disabled, QPalette::Text, QColor( 0, 0, 0 ) ) ;
148 myX->setPalette( aPal );
149 myY->setPalette( aPal );
150 myZ->setPalette( aPal );
152 setHelpFileName( "create_point_page.html" );
158 //=================================================================================
159 // function : ~BasicGUI_PointDlg()
160 // purpose : Destructor
161 //=================================================================================
162 BasicGUI_PointDlg::~BasicGUI_PointDlg()
167 //=================================================================================
170 //=================================================================================
171 void BasicGUI_PointDlg::Init()
173 GroupOnCurve->LineEdit1->setReadOnly( true );
174 GroupOnSurface->LineEdit1->setReadOnly( true );
175 GroupRefPoint->LineEdit1->setReadOnly( true );
176 GroupLineIntersection->LineEdit1->setReadOnly( true );
177 GroupLineIntersection->LineEdit2->setReadOnly( true );
178 GroupLineIntersection->LineEdit1->setEnabled( true );
179 GroupLineIntersection->LineEdit2->setEnabled( false );
181 myEdge = GEOM::GEOM_Object::_nil();
182 myRefPoint = GEOM::GEOM_Object::_nil();
184 myEditCurrentArgument = 0;
186 /* Get setting of step value from file configuration */
187 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
188 double step = resMgr->doubleValue( "Geometry", "SettingsGeomStep", 100 );
190 /* min, max, step and decimals for spin boxes */
191 initSpinBox( GroupXYZ->SpinBox_DX, COORD_MIN, COORD_MAX, step, 6 ); // VSR: TODO: DBL_DIGITS_DISPLAY
192 initSpinBox( GroupXYZ->SpinBox_DY, COORD_MIN, COORD_MAX, step, 6 ); // VSR: TODO: DBL_DIGITS_DISPLAY
193 initSpinBox( GroupXYZ->SpinBox_DZ, COORD_MIN, COORD_MAX, step, 6 ); // VSR: TODO: DBL_DIGITS_DISPLAY
194 GroupXYZ->SpinBox_DX->setValue( 0.0 );
195 GroupXYZ->SpinBox_DY->setValue( 0.0 );
196 GroupXYZ->SpinBox_DZ->setValue( 0.0 );
198 initSpinBox( GroupRefPoint->SpinBox_DX, COORD_MIN, COORD_MAX, step, 6 ); // VSR: TODO: DBL_DIGITS_DISPLAY
199 initSpinBox( GroupRefPoint->SpinBox_DY, COORD_MIN, COORD_MAX, step, 6 ); // VSR: TODO: DBL_DIGITS_DISPLAY
200 initSpinBox( GroupRefPoint->SpinBox_DZ, COORD_MIN, COORD_MAX, step, 6 ); // VSR: TODO: DBL_DIGITS_DISPLAY
201 GroupRefPoint->SpinBox_DX->setValue( 0.0 );
202 GroupRefPoint->SpinBox_DY->setValue( 0.0 );
203 GroupRefPoint->SpinBox_DZ->setValue( 0.0 );
207 initSpinBox( GroupOnCurve->SpinBox_DX, 0., 1., step, 6 ); // VSR:TODO : DBL_DIGITS_DISPLAY
208 GroupOnCurve->SpinBox_DX->setValue( 0.5 );
210 initSpinBox( GroupOnSurface->SpinBox_DX, 0., 1., step, 6 ); // VSR:TODO : DBL_DIGITS_DISPLAY
211 GroupOnSurface->SpinBox_DX->setValue( 0.5 );
212 initSpinBox( GroupOnSurface->SpinBox_DY, 0., 1., step, 6 ); // VSR:TODO : DBL_DIGITS_DISPLAY
213 GroupOnSurface->SpinBox_DY->setValue( 0.5 );
215 /* signals and slots connections */
216 connect( myGeomGUI, SIGNAL( SignalDeactivateActiveDialog() ), this, SLOT( DeactivateActiveDialog() ) );
217 connect( myGeomGUI, SIGNAL( SignalCloseAllDialogs() ), this, SLOT( ClickOnCancel() ) );
219 connect( buttonOk(), SIGNAL( clicked() ), this, SLOT( ClickOnOk() ) );
220 connect( buttonApply(), SIGNAL( clicked() ), this, SLOT( ClickOnApply() ) );
222 connect( this, SIGNAL( constructorsClicked( int ) ), this, SLOT( ConstructorsClicked( int ) ) );
224 connect( GroupOnCurve->PushButton1, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) );
225 connect( GroupOnCurve->LineEdit1, SIGNAL( returnPressed() ), this, SLOT( LineEditReturnPressed() ) );
227 connect( GroupOnSurface->PushButton1, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) );
228 connect( GroupOnSurface->LineEdit1, SIGNAL( returnPressed() ), this, SLOT( LineEditReturnPressed() ) );
230 connect( GroupLineIntersection->PushButton1, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) );
231 connect( GroupLineIntersection->PushButton2, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) );
232 connect( GroupLineIntersection->LineEdit1, SIGNAL( returnPressed() ), this, SLOT( LineEditReturnPressed() ) );
233 connect( GroupLineIntersection->LineEdit2, SIGNAL( returnPressed() ), this, SLOT( LineEditReturnPressed() ) );
235 connect( GroupOnCurve->SpinBox_DX, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
236 connect( GroupOnSurface->SpinBox_DX, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
237 connect( GroupOnSurface->SpinBox_DY, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
238 connect( GroupXYZ->SpinBox_DX, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
239 connect( GroupXYZ->SpinBox_DY, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
240 connect( GroupXYZ->SpinBox_DZ, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
241 connect( GroupRefPoint->SpinBox_DX, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
242 connect( GroupRefPoint->SpinBox_DY, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
243 connect( GroupRefPoint->SpinBox_DZ, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
245 connect( myGeomGUI, SIGNAL( SignalDefaultStepValueChanged( double ) ), this, SLOT( SetDoubleSpinBoxStep( double ) ) );
247 connect( myGeomGUI->getApp()->selectionMgr(), SIGNAL(currentSelectionChanged() ),
248 this, SLOT(SelectionIntoArgument() ) );
251 initName( tr( "GEOM_VERTEX" ) );
253 ConstructorsClicked( 0 );
256 //=================================================================================
257 // function : SetDoubleSpinBoxStep()
258 // purpose : Double spin box management
259 //=================================================================================
260 void BasicGUI_PointDlg::SetDoubleSpinBoxStep( double step )
262 GroupOnCurve->SpinBox_DX->setSingleStep(step);
263 GroupXYZ->SpinBox_DX->setSingleStep(step);
264 GroupXYZ->SpinBox_DY->setSingleStep(step);
265 GroupXYZ->SpinBox_DZ->setSingleStep(step);
266 GroupRefPoint->SpinBox_DX->setSingleStep(step);
267 GroupRefPoint->SpinBox_DY->setSingleStep(step);
268 GroupRefPoint->SpinBox_DZ->setSingleStep(step);
269 GroupOnSurface->SpinBox_DX->setSingleStep(step);
270 GroupOnSurface->SpinBox_DY->setSingleStep(step);
274 //=================================================================================
275 // function : ConstructorsClicked()
276 // purpose : Radio button management
277 //=================================================================================
278 void BasicGUI_PointDlg::ConstructorsClicked(int constructorId)
280 globalSelection(); // close local contexts, if any
282 switch ( constructorId ) {
285 localSelection( GEOM::GEOM_Object::_nil(), TopAbs_VERTEX );
287 GroupRefPoint->hide();
288 GroupOnCurve->hide();
289 GroupLineIntersection->hide();
290 GroupOnSurface->hide();
299 myEditCurrentArgument = GroupRefPoint->LineEdit1;
300 myEditCurrentArgument->setText( "" );
301 myRefPoint = GEOM::GEOM_Object::_nil();
302 GroupRefPoint->PushButton1->setDown(true);
303 localSelection( GEOM::GEOM_Object::_nil(), TopAbs_VERTEX );
306 GroupOnCurve->hide();
307 GroupLineIntersection->hide();
308 GroupOnSurface->hide();
310 GroupRefPoint->show();
317 myEditCurrentArgument = GroupOnCurve->LineEdit1;
318 myEditCurrentArgument->setText( "" );
319 myEdge = GEOM::GEOM_Object::_nil();
320 GroupOnCurve->PushButton1->setDown(true);
321 localSelection( GEOM::GEOM_Object::_nil(), TopAbs_EDGE );
324 GroupRefPoint->hide();
325 GroupLineIntersection->hide();
326 GroupOnSurface->hide();
328 GroupOnCurve->show();
335 myEditCurrentArgument = GroupLineIntersection->LineEdit1;
336 GroupLineIntersection->LineEdit1->setText( "" );
337 GroupLineIntersection->LineEdit2->setText( "" );
338 GroupLineIntersection->LineEdit1->setEnabled( true );
339 GroupLineIntersection->LineEdit2->setEnabled( false );
340 myLine1 = GEOM::GEOM_Object::_nil();
341 myLine2 = GEOM::GEOM_Object::_nil();
342 GroupLineIntersection->PushButton1->setDown(true);
343 GroupLineIntersection->PushButton2->setDown(false);
345 localSelection( GEOM::GEOM_Object::_nil(), TopAbs_EDGE );
348 GroupRefPoint->hide();
349 GroupOnCurve->hide();
350 GroupOnSurface->hide();
354 GroupLineIntersection->show();
359 myEditCurrentArgument = GroupOnSurface->LineEdit1;
360 myEditCurrentArgument->setText( "" );
361 myFace = GEOM::GEOM_Object::_nil();
362 GroupOnSurface->PushButton1->setDown(true);
363 localSelection( GEOM::GEOM_Object::_nil(), TopAbs_FACE );
366 GroupRefPoint->hide();
367 GroupOnCurve->hide();
368 GroupLineIntersection->hide();
370 GroupOnSurface->show();
381 qApp->processEvents();
383 resize( minimumSizeHint() );
385 SelectionIntoArgument();
389 //=================================================================================
390 // function : ClickOnOk()
392 //=================================================================================
393 void BasicGUI_PointDlg::ClickOnOk()
400 //=================================================================================
401 // function : ClickOnApply()
403 //=================================================================================
404 bool BasicGUI_PointDlg::ClickOnApply()
410 ConstructorsClicked( getConstructorId() );
415 //=================================================================================
416 // function : SelectionIntoArgument()
417 // purpose : Called when selection as changed (for constructors not using local context)
418 //=================================================================================
419 void BasicGUI_PointDlg::SelectionIntoArgument()
421 const int id = getConstructorId();
423 if ( ( id == 1 || id == 2 || id == 4 ) && myEditCurrentArgument != 0 )
425 myEditCurrentArgument->setText( "" );
429 myRefPoint = myEdge = myFace = GEOM::GEOM_Object::_nil();
432 LightApp_SelectionMgr* aSelMgr = myGeomGUI->getApp()->selectionMgr();
433 SALOME_ListIO aSelList;
434 aSelMgr->selectedObjects(aSelList);
436 if (aSelList.Extent() == 1) {
437 Standard_Boolean aRes = Standard_False;
438 Handle(SALOME_InteractiveObject) anIO = aSelList.First();
439 GEOM::GEOM_Object_var aSelectedObject = GEOMBase::ConvertIOinGEOMObject( anIO, aRes );
440 if ( !CORBA::is_nil( aSelectedObject ) && aRes ) {
441 QString aName = GEOMBase::GetName(aSelectedObject);
442 TopAbs_ShapeEnum aNeedType = TopAbs_VERTEX;
444 if ( GEOMBase::GetShape( aSelectedObject, aShape, TopAbs_SHAPE ) && !aShape.IsNull() ) {
445 if ( id == 2 || id == 3 )
446 aNeedType = TopAbs_EDGE;
448 aNeedType = TopAbs_FACE;
450 TColStd_IndexedMapOfInteger aMap;
451 aSelMgr->GetIndexes(anIO, aMap);
452 if ( aMap.Extent() == 1 ) { // Local Selection
453 int anIndex = aMap( 1 );
454 if ( aNeedType == TopAbs_EDGE )
455 aName += QString( ":edge_%1" ).arg( anIndex );
457 aName += QString( ":vertex_%1" ).arg( anIndex );
459 //Find SubShape Object in Father
460 GEOM::GEOM_Object_var aFindedObject = GEOMBase_Helper::findObjectInFather(aSelectedObject, aName);
462 if ( aFindedObject == GEOM::GEOM_Object::_nil() ) { // Object not found in study
463 GEOM::GEOM_IShapesOperations_var aShapesOp =
464 getGeomEngine()->GetIShapesOperations(getStudyId());
465 aSelectedObject = aShapesOp->GetSubShape(aSelectedObject, anIndex);
468 aSelectedObject = aFindedObject; // get Object from study
470 GEOMBase::GetShape( aSelectedObject, aShape, TopAbs_SHAPE );
472 else { // Global Selection
473 if ( aShape.ShapeType() != aNeedType ) {
474 aSelectedObject = GEOM::GEOM_Object::_nil();
476 if ( id == 0 ) return;
481 if ( aShape.IsNull() || aShape.ShapeType() != aNeedType)
485 gp_Pnt aPnt = BRep_Tool::Pnt( TopoDS::Vertex( aShape ) );
486 GroupXYZ->SpinBox_DX->setValue( aPnt.X() );
487 GroupXYZ->SpinBox_DY->setValue( aPnt.Y() );
488 GroupXYZ->SpinBox_DZ->setValue( aPnt.Z() );
490 else if ( id == 1 ) {
491 myRefPoint = aSelectedObject;
492 GroupRefPoint->LineEdit1->setText( aName );
494 else if ( id == 2 ) {
495 myEdge = aSelectedObject;
496 GroupOnCurve->LineEdit1->setText( aName );
498 else if ( id == 3 ) {
499 myEditCurrentArgument->setText( aName );
501 localSelection( GEOM::GEOM_Object::_nil(), TopAbs_EDGE );
502 if ( myEditCurrentArgument == GroupLineIntersection->LineEdit1 ) {
503 myLine1 = aSelectedObject;
504 if ( !myLine1->_is_nil() && myLine2->_is_nil() )
505 GroupLineIntersection->PushButton2->click();
507 else if ( myEditCurrentArgument == GroupLineIntersection->LineEdit2 ) {
508 myLine2 = aSelectedObject;
509 if ( !myLine2->_is_nil() && myLine1->_is_nil() )
510 GroupLineIntersection->PushButton1->click();
515 myFace = aSelectedObject;
516 GroupOnSurface->LineEdit1->setText( aName );
525 //=================================================================================
526 // function : LineEditReturnPressed()
528 //=================================================================================
529 void BasicGUI_PointDlg::LineEditReturnPressed()
531 QLineEdit* send = (QLineEdit*)sender();
532 if ( send == GroupRefPoint->LineEdit1 ||
533 send == GroupOnCurve->LineEdit1 ||
534 send == GroupLineIntersection->LineEdit1 ||
535 send == GroupLineIntersection->LineEdit2 ) {
536 myEditCurrentArgument = send;
537 GEOMBase_Skeleton::LineEditReturnPressed();
542 //=================================================================================
543 // function : SetEditCurrentArgument()
545 //=================================================================================
546 void BasicGUI_PointDlg::SetEditCurrentArgument()
548 globalSelection(); // close local contexts, if any
550 QPushButton* send = (QPushButton*)sender();
552 if ( send == GroupRefPoint->PushButton1 ) {
553 GroupRefPoint->LineEdit1->setFocus();
554 myEditCurrentArgument = GroupRefPoint->LineEdit1;
556 localSelection( GEOM::GEOM_Object::_nil(), TopAbs_VERTEX );
558 else if ( send == GroupOnCurve->PushButton1 ) {
559 GroupOnCurve->LineEdit1->setFocus();
560 myEditCurrentArgument = GroupOnCurve->LineEdit1;
562 localSelection( GEOM::GEOM_Object::_nil(), TopAbs_EDGE );
564 else if ( send == GroupOnSurface->PushButton1 )
566 GroupOnSurface->LineEdit1->setFocus();
567 myEditCurrentArgument = GroupOnSurface->LineEdit1;
569 localSelection( GEOM::GEOM_Object::_nil(), TopAbs_FACE );
571 else if ( send == GroupLineIntersection->PushButton1 ) {
572 GroupLineIntersection->LineEdit1->setFocus();
573 myEditCurrentArgument = GroupLineIntersection->LineEdit1;
574 GroupLineIntersection->PushButton2->setDown( false );
575 GroupLineIntersection->LineEdit1->setEnabled(true);
576 GroupLineIntersection->LineEdit2->setEnabled(false);
577 localSelection( GEOM::GEOM_Object::_nil(), TopAbs_EDGE );
579 else if ( send == GroupLineIntersection->PushButton2 ) {
580 GroupLineIntersection->LineEdit2->setFocus();
581 myEditCurrentArgument = GroupLineIntersection->LineEdit2;
582 GroupLineIntersection->PushButton1->setDown( false );
583 GroupLineIntersection->LineEdit1->setEnabled(false);
584 GroupLineIntersection->LineEdit2->setEnabled(true);
585 localSelection( GEOM::GEOM_Object::_nil(), TopAbs_EDGE );
591 //=================================================================================
592 // function : enterEvent()
593 // purpose : to reactivate this dialog box when mouse enter onto the window
594 //=================================================================================
595 void BasicGUI_PointDlg::enterEvent( QEvent* )
597 if ( !mainFrame()->GroupConstructors->isEnabled() )
598 ActivateThisDialog();
602 //=================================================================================
603 // function : ActivateThisDialog()
605 //=================================================================================
606 void BasicGUI_PointDlg::ActivateThisDialog( )
608 GEOMBase_Skeleton::ActivateThisDialog();
609 // myGeomGUI->SetState( 0 );
610 ConstructorsClicked( getConstructorId() );
614 //=================================================================================
615 // function : DeactivateActiveDialog()
616 // purpose : public slot to deactivate if active
617 //=================================================================================
618 void BasicGUI_PointDlg::DeactivateActiveDialog()
620 // myGeomGUI->SetState( -1 );
621 GEOMBase_Skeleton::DeactivateActiveDialog();
625 //=================================================================================
626 // function : ValueChangedInSpinBox()
628 //=================================================================================
629 void BasicGUI_PointDlg::ValueChangedInSpinBox(double newValue)
634 //=================================================================================
635 // funcion : getParameter()
637 //=================================================================================
638 double BasicGUI_PointDlg::getParameter() const
640 return GroupOnCurve->SpinBox_DX->value();
644 //=================================================================================
645 // funcion : getUParameter()
647 //=================================================================================
648 double BasicGUI_PointDlg::getUParameter() const
650 return GroupOnSurface->SpinBox_DX->value();
654 //=================================================================================
655 // funcion : getVParameter()
657 //=================================================================================
658 double BasicGUI_PointDlg::getVParameter() const
660 return GroupOnSurface->SpinBox_DY->value();
664 //=================================================================================
665 // function : OnPointSelected
667 //=================================================================================
668 void BasicGUI_PointDlg::OnPointSelected( const gp_Pnt& thePnt )
670 if ( getConstructorId() == 0 ) {
671 GroupXYZ->SpinBox_DX->setValue( thePnt.X() );
672 GroupXYZ->SpinBox_DY->setValue( thePnt.Y() );
673 GroupXYZ->SpinBox_DZ->setValue( thePnt.Z() );
679 //=================================================================================
680 // function : createOperation
682 //=================================================================================
683 GEOM::GEOM_IOperations_ptr BasicGUI_PointDlg::createOperation()
685 return myGeomGUI->GetGeomGen()->GetIBasicOperations( getStudyId() );
688 //=================================================================================
689 // function : isValid
691 //=================================================================================
692 bool BasicGUI_PointDlg::isValid( QString& msg )
694 const int id = getConstructorId();
697 ok = GroupXYZ->SpinBox_DX->isValid( msg, !IsPreview() ) && ok;
698 ok = GroupXYZ->SpinBox_DY->isValid( msg, !IsPreview() ) && ok;
699 ok = GroupXYZ->SpinBox_DZ->isValid( msg, !IsPreview() ) && ok;
702 else if ( id == 1 ) {
704 ok = GroupRefPoint->SpinBox_DX->isValid( msg, !IsPreview() ) && ok;
705 ok = GroupRefPoint->SpinBox_DY->isValid( msg, !IsPreview() ) && ok;
706 ok = GroupRefPoint->SpinBox_DZ->isValid( msg, !IsPreview() ) && ok;
708 return !myRefPoint->_is_nil() && ok;
710 else if ( id == 2 ) {
711 bool ok = GroupOnCurve->SpinBox_DX->isValid( msg, !IsPreview() );
712 return !myEdge->_is_nil() && ok;
715 return ( !myLine1->_is_nil() && !myLine2->_is_nil() );
716 else if ( id == 4 ) {
718 ok = GroupOnSurface->SpinBox_DX->isValid( msg, !IsPreview() ) && ok;
719 ok = GroupOnSurface->SpinBox_DY->isValid( msg, !IsPreview() ) && ok;
720 return !myFace->_is_nil() && ok;
726 //=================================================================================
727 // function : execute
729 //=================================================================================
730 bool BasicGUI_PointDlg::execute( ObjectList& objects )
734 GEOM::GEOM_Object_var anObj;
735 QStringList aParameters;
737 switch ( getConstructorId() ) {
740 double x = GroupXYZ->SpinBox_DX->value();
741 double y = GroupXYZ->SpinBox_DY->value();
742 double z = GroupXYZ->SpinBox_DZ->value();
744 aParameters << GroupXYZ->SpinBox_DX->text();
745 aParameters << GroupXYZ->SpinBox_DY->text();
746 aParameters << GroupXYZ->SpinBox_DZ->text();
748 anObj = GEOM::GEOM_IBasicOperations::_narrow( getOperation() )->MakePointXYZ( x, y, z );
754 double dx = GroupRefPoint->SpinBox_DX->value();
755 double dy = GroupRefPoint->SpinBox_DY->value();
756 double dz = GroupRefPoint->SpinBox_DZ->value();
758 aParameters << GroupRefPoint->SpinBox_DX->text();
759 aParameters << GroupRefPoint->SpinBox_DY->text();
760 aParameters << GroupRefPoint->SpinBox_DZ->text();
762 anObj = GEOM::GEOM_IBasicOperations::_narrow( getOperation() )->
763 MakePointWithReference( myRefPoint, dx, dy, dz );
768 anObj = GEOM::GEOM_IBasicOperations::_narrow( getOperation() )->
769 MakePointOnCurve( myEdge, getParameter() );
770 aParameters<<GroupOnCurve->SpinBox_DX->text();
774 anObj = GEOM::GEOM_IBasicOperations::_narrow( getOperation() )->
775 MakePointOnLinesIntersection( myLine1, myLine2 );
779 anObj = GEOM::GEOM_IBasicOperations::_narrow( getOperation() )->
780 MakePointOnSurface( myFace, getUParameter(), getVParameter() );
781 aParameters<<GroupOnSurface->SpinBox_DX->text();
782 aParameters<<GroupOnSurface->SpinBox_DY->text();
787 if(!anObj->_is_nil() && !IsPreview() && (getConstructorId()==0 ||
788 getConstructorId() == 1 ||
789 getConstructorId() == 2 ||
790 getConstructorId() == 4) ) {
791 anObj->SetParameters(GeometryGUI::JoinObjectParameters(aParameters));
795 if ( getConstructorId() == 1 || getConstructorId() == 2 ||
796 getConstructorId() == 4 ) {
798 if ( GEOMBase::GetShape( anObj, aShape ) && !aShape.IsNull() &&
799 aShape.ShapeType() == TopAbs_VERTEX ) {
800 gp_Pnt aPnt = BRep_Tool::Pnt( TopoDS::Vertex( aShape ) );
801 myX->setText( QString( "%1" ).arg( aPnt.X() ) );
802 myY->setText( QString( "%1" ).arg( aPnt.Y() ) );
803 myZ->setText( QString( "%1" ).arg( aPnt.Z() ) );
812 if ( !anObj->_is_nil() ) {
813 objects.push_back( anObj._retn() );
819 //=================================================================================
820 // function : addSubshapeToStudy
821 // purpose : virtual method to add new SubObjects if local selection
822 //=================================================================================
823 void BasicGUI_PointDlg::addSubshapesToStudy()
825 QMap<QString, GEOM::GEOM_Object_var> objMap;
827 switch ( getConstructorId() ) {
831 objMap[GroupRefPoint->LineEdit1->text()] = myRefPoint;
834 objMap[GroupOnCurve->LineEdit1->text()] = myEdge;
837 objMap[GroupLineIntersection->LineEdit1->text()] = myLine1;
838 objMap[GroupLineIntersection->LineEdit2->text()] = myLine2;
841 objMap[GroupOnSurface->LineEdit1->text()] = myFace;
844 addSubshapesToFather( objMap );