1 // GEOM GEOMGUI : GUI for Geometry component
3 // Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
22 // File : BasicGUI_PlaneDlg.cxx
23 // Author : Lucien PIGNOLONI, Open CASCADE S.A.S.
26 #include "BasicGUI_PlaneDlg.h"
30 #include <GeometryGUI.h>
33 #include <SUIT_ResourceMgr.h>
34 #include <SUIT_Session.h>
35 #include <SalomeApp_Application.h>
36 #include <LightApp_SelectionMgr.h>
38 #include <TColStd_MapOfInteger.hxx>
39 #include <TopoDS_Shape.hxx>
40 #include <TopoDS_Edge.hxx>
43 #include <TColStd_IndexedMapOfInteger.hxx>
44 #include <TopTools_IndexedMapOfShape.hxx>
46 #include <GEOMImpl_Types.hxx>
48 //=================================================================================
49 // class : BasicGUI_PlaneDlg()
50 // purpose : Constructs a BasicGUI_PlaneDlg which is a child of 'parent', with the
51 // name 'name' and widget flags set to 'f'.
52 // The dialog will by default be modeless, unless you set 'modal' to
53 // TRUE to construct a modal dialog.
54 //=================================================================================
55 BasicGUI_PlaneDlg::BasicGUI_PlaneDlg( GeometryGUI* theGeometryGUI, QWidget* parent,
56 bool modal, Qt::WindowFlags fl )
57 : GEOMBase_Skeleton( theGeometryGUI, parent, modal, fl )
59 QPixmap image0( SUIT_Session::session()->resourceMgr()->loadPixmap( "GEOM", tr( "ICON_DLG_PLANE_PV" ) ) );
60 QPixmap image1( SUIT_Session::session()->resourceMgr()->loadPixmap( "GEOM", tr( "ICON_DLG_PLANE_3PNTS" ) ) );
61 QPixmap image2( SUIT_Session::session()->resourceMgr()->loadPixmap( "GEOM", tr( "ICON_DLG_PLANE_FACE" ) ) );
62 QPixmap image3( SUIT_Session::session()->resourceMgr()->loadPixmap( "GEOM", tr( "ICON_SELECT" ) ) );
64 setWindowTitle( tr( "GEOM_PLANE_TITLE" ) );
66 /***************************************************************/
67 mainFrame()->GroupConstructors->setTitle( tr( "GEOM_PLANE" ) );
68 mainFrame()->RadioButton1->setIcon( image0 );
69 mainFrame()->RadioButton2->setIcon( image1 );
70 mainFrame()->RadioButton3->setIcon( image2 );
72 GroupPntDir = new DlgRef_2Sel1Spin( centralWidget() );
73 GroupPntDir->GroupBox1->setTitle( tr( "GEOM_PLANE_PV" ) );
74 GroupPntDir->TextLabel1->setText( tr( "GEOM_POINT" ) );
75 GroupPntDir->TextLabel2->setText( tr( "GEOM_VECTOR" ) );
76 GroupPntDir->TextLabel3->setText( tr( "GEOM_PLANE_SIZE" ) );
77 GroupPntDir->PushButton1->setIcon( image3 );
78 GroupPntDir->PushButton2->setIcon( image3 );
79 GroupPntDir->LineEdit1->setReadOnly( true );
80 GroupPntDir->LineEdit2->setReadOnly( true );
81 GroupPntDir->PushButton1->setDown( true );
82 GroupPntDir->LineEdit1->setEnabled( true );
83 GroupPntDir->LineEdit2->setEnabled( false );
85 Group3Pnts = new DlgRef_3Sel1Spin( centralWidget() );
86 Group3Pnts->GroupBox1->setTitle( tr( "GEOM_3_POINTS" ) );
87 Group3Pnts->TextLabel1->setText( tr( "GEOM_POINT1" ) );
88 Group3Pnts->TextLabel2->setText( tr( "GEOM_POINT2" ) );
89 Group3Pnts->TextLabel3->setText( tr( "GEOM_POINT3" ) );
90 Group3Pnts->TextLabel4->setText( tr( "GEOM_PLANE_SIZE" ) );
91 Group3Pnts->PushButton1->setIcon( image3 );
92 Group3Pnts->PushButton2->setIcon( image3 );
93 Group3Pnts->PushButton3->setIcon( image3 );
94 Group3Pnts->PushButton1->setDown( true );
96 Group3Pnts->LineEdit1->setReadOnly( true );
97 Group3Pnts->LineEdit2->setReadOnly( true );
98 Group3Pnts->LineEdit3->setReadOnly( true );
99 Group3Pnts->LineEdit1->setEnabled( true );
100 Group3Pnts->LineEdit2->setEnabled( false );
101 Group3Pnts->LineEdit3->setEnabled( false );
103 GroupFace = new DlgRef_1Sel1Spin( centralWidget() );
104 GroupFace->GroupBox1->setTitle( tr( "GEOM_FACE_OR_LCS" ) );
105 GroupFace->TextLabel1->setText( tr( "GEOM_SELECTION" ) );
106 GroupFace->TextLabel2->setText( tr( "GEOM_PLANE_SIZE" ) );
107 GroupFace->PushButton1->setIcon( image3 );
108 GroupFace->PushButton1->setDown( true );
110 GroupFace->LineEdit1->setReadOnly( true );
112 QVBoxLayout* layout = new QVBoxLayout( centralWidget() );
113 layout->setMargin( 0 ); layout->setSpacing( 6 );
114 layout->addWidget( GroupPntDir );
115 layout->addWidget( Group3Pnts );
116 layout->addWidget( GroupFace );
117 /***************************************************************/
119 setHelpFileName( "create_plane_page.html" );
125 //=================================================================================
126 // function : ~BasicGUI_PlaneDlg()
127 // purpose : Destroys the object and frees any allocated resources
128 //=================================================================================
129 BasicGUI_PlaneDlg::~BasicGUI_PlaneDlg()
134 //=================================================================================
137 //=================================================================================
138 void BasicGUI_PlaneDlg::Init()
141 myEditCurrentArgument = GroupPntDir->LineEdit1;
143 myPoint = myDir = myPoint1 = myPoint2 = myPoint3 = myFace = GEOM::GEOM_Object::_nil();
145 // myGeomGUI->SetState( 0 );
147 /* Get setting of step value from file configuration */
148 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
149 double aStep = resMgr->doubleValue( "Geometry", "SettingsGeomStep", 100 );
151 double aTrimSize = 2000.0;
153 /* min, max, step and decimals for spin boxes */
154 initSpinBox( GroupPntDir->SpinBox_DX, 0.001, COORD_MAX, aStep, 3 ); // VSR:TODO : DBL_DIGITS_DISPLAY
155 GroupPntDir->SpinBox_DX->setValue( aTrimSize );
156 initSpinBox( Group3Pnts->SpinBox_DX, 0.001, COORD_MAX, aStep, 3 ); // VSR:TODO : DBL_DIGITS_DISPLAY
157 Group3Pnts->SpinBox_DX->setValue( aTrimSize );
158 initSpinBox( GroupFace->SpinBox_DX, 0.001, COORD_MAX, aStep, 3 ); // VSR:TODO : DBL_DIGITS_DISPLAY
159 GroupFace->SpinBox_DX->setValue( aTrimSize );
161 /* signals and slots connections */
162 connect( myGeomGUI, SIGNAL( SignalDeactivateActiveDialog() ), this, SLOT( DeactivateActiveDialog() ) );
163 connect( myGeomGUI, SIGNAL( SignalCloseAllDialogs() ), this, SLOT( ClickOnCancel() ) );
165 connect( buttonOk(), SIGNAL( clicked() ), this, SLOT( ClickOnOk() ) );
166 connect( buttonApply(), SIGNAL( clicked() ), this, SLOT( ClickOnApply() ) );
168 connect( this, SIGNAL( constructorsClicked( int ) ), this, SLOT( ConstructorsClicked( int ) ) );
170 connect( GroupPntDir->PushButton1, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) );
171 connect( GroupPntDir->PushButton2, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) );
172 connect( Group3Pnts->PushButton1, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) );
173 connect( Group3Pnts->PushButton2, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) );
174 connect( Group3Pnts->PushButton3, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) );
175 connect( GroupFace->PushButton1, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) );
177 connect( GroupPntDir->LineEdit1, SIGNAL( returnPressed() ), this, SLOT( LineEditReturnPressed() ) );
178 connect( GroupPntDir->LineEdit2, SIGNAL( returnPressed() ), this, SLOT( LineEditReturnPressed() ) );
179 connect( Group3Pnts->LineEdit1, SIGNAL( returnPressed() ), this, SLOT( LineEditReturnPressed() ) );
180 connect( Group3Pnts->LineEdit2, SIGNAL( returnPressed() ), this, SLOT( LineEditReturnPressed() ) );
181 connect( Group3Pnts->LineEdit3, SIGNAL( returnPressed() ), this, SLOT( LineEditReturnPressed() ) );
182 connect( GroupFace->LineEdit1, SIGNAL( returnPressed() ), this, SLOT( LineEditReturnPressed() ) );
184 connect( GroupPntDir->SpinBox_DX, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
185 connect( Group3Pnts->SpinBox_DX, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
186 connect( GroupFace->SpinBox_DX, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
188 connect( myGeomGUI, SIGNAL( SignalDefaultStepValueChanged( double ) ), this, SLOT( SetDoubleSpinBoxStep( double ) ) );
190 connect( myGeomGUI->getApp()->selectionMgr(), SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) );
192 initName( tr( "GEOM_PLANE" ) );
194 ConstructorsClicked( 0 );
197 //=================================================================================
198 // function : SetDoubleSpinBoxStep()
199 // purpose : Double spin box management
200 //=================================================================================
201 void BasicGUI_PlaneDlg::SetDoubleSpinBoxStep( double step )
203 GroupPntDir->SpinBox_DX->setSingleStep(step);
204 Group3Pnts->SpinBox_DX->setSingleStep(step);
205 GroupFace->SpinBox_DX->setSingleStep(step);
209 //=================================================================================
210 // function : ConstructorsClicked()
211 // purpose : Radio button management
212 //=================================================================================
213 void BasicGUI_PlaneDlg::ConstructorsClicked( int constructorId )
215 disconnect( myGeomGUI->getApp()->selectionMgr(), 0, this, 0 );
216 myPoint = myDir = myPoint1 = myPoint2 = myPoint3 = myFace = GEOM::GEOM_Object::_nil();
218 switch ( constructorId ) {
219 case 0: /* plane from a point and a direction (vector, edge...) */
225 myEditCurrentArgument = GroupPntDir->LineEdit1;
226 GroupPntDir->LineEdit1->setText( "" );
227 GroupPntDir->LineEdit2->setText( "" );
228 GroupPntDir->PushButton1->setDown( true );
229 GroupPntDir->PushButton2->setDown( false );
230 GroupPntDir->LineEdit1->setEnabled( true );
231 GroupPntDir->LineEdit2->setEnabled( false );
233 /* for the first argument */
234 globalSelection(); // close local contexts, if any
235 localSelection( GEOM::GEOM_Object::_nil(), TopAbs_VERTEX );
238 case 1: /* plane from 3 points */
244 myEditCurrentArgument = Group3Pnts->LineEdit1;
245 Group3Pnts->LineEdit1->setText( "" );
246 Group3Pnts->LineEdit2->setText( "" );
247 Group3Pnts->LineEdit3->setText( "" );
248 Group3Pnts->PushButton1->setDown( true );
249 Group3Pnts->PushButton2->setDown( false );
250 Group3Pnts->PushButton3->setDown( false );
251 Group3Pnts->LineEdit1->setEnabled( true );
252 Group3Pnts->LineEdit2->setEnabled( false );
253 Group3Pnts->LineEdit3->setEnabled( false );
255 /* for the first argument */
256 globalSelection(); // close local contexts, if any
257 localSelection( GEOM::GEOM_Object::_nil(), TopAbs_VERTEX );
260 case 2: /* plane from a planar face selection */
266 myEditCurrentArgument = GroupFace->LineEdit1;
267 GroupFace->LineEdit1->setText( "" );
268 GroupFace->PushButton1->setDown( true );
270 /* for the first argument */
271 //globalSelection( GEOM_PLANE );
272 TColStd_MapOfInteger aMap;
273 aMap.Add( GEOM_PLANE );
274 aMap.Add( GEOM_MARKER );
275 globalSelection( aMap );
280 qApp->processEvents();
282 resize( minimumSize() );
284 myEditCurrentArgument->setFocus();
285 connect( myGeomGUI->getApp()->selectionMgr(), SIGNAL( currentSelectionChanged() ),
286 this, SLOT( SelectionIntoArgument() ) );
290 //=================================================================================
291 // function : ClickOnOk()
293 //=================================================================================
294 void BasicGUI_PlaneDlg::ClickOnOk()
296 if ( ClickOnApply() )
301 //=================================================================================
302 // function : ClickOnApply()
304 //=================================================================================
305 bool BasicGUI_PlaneDlg::ClickOnApply()
311 ConstructorsClicked( getConstructorId() );
315 //=================================================================================
316 // function : SelectionIntoArgument()
317 // purpose : Called when selection has changed
318 //=================================================================================
319 void BasicGUI_PlaneDlg::SelectionIntoArgument()
321 myEditCurrentArgument->setText("");
323 LightApp_SelectionMgr* aSelMgr = myGeomGUI->getApp()->selectionMgr();
324 SALOME_ListIO aSelList;
325 aSelMgr->selectedObjects(aSelList);
327 if (aSelList.Extent() != 1) {
328 if ( myEditCurrentArgument == GroupPntDir->LineEdit1 ) myPoint = GEOM::GEOM_Object::_nil();
329 else if ( myEditCurrentArgument == GroupPntDir->LineEdit2 ) myDir = GEOM::GEOM_Object::_nil();
330 else if ( myEditCurrentArgument == Group3Pnts->LineEdit1 ) myPoint1 = GEOM::GEOM_Object::_nil();
331 else if ( myEditCurrentArgument == Group3Pnts->LineEdit2 ) myPoint2 = GEOM::GEOM_Object::_nil();
332 else if ( myEditCurrentArgument == Group3Pnts->LineEdit3 ) myPoint3 = GEOM::GEOM_Object::_nil();
333 else if ( myEditCurrentArgument == GroupFace->LineEdit1 ) myFace = GEOM::GEOM_Object::_nil();
338 Standard_Boolean aRes = Standard_False;
339 GEOM::GEOM_Object_var aSelectedObject = GEOMBase::ConvertIOinGEOMObject(aSelList.First(), aRes);
340 if ( !CORBA::is_nil( aSelectedObject ) && aRes ) {
341 QString aName = GEOMBase::GetName( aSelectedObject );
342 TopAbs_ShapeEnum aNeedType = TopAbs_VERTEX;
343 if ( myEditCurrentArgument == GroupPntDir->LineEdit2 )
344 aNeedType = TopAbs_EDGE;
347 if ( GEOMBase::GetShape( aSelectedObject, aShape, TopAbs_SHAPE ) && !aShape.IsNull() ) {
348 TColStd_IndexedMapOfInteger aMap;
349 aSelMgr->GetIndexes(aSelList.First(), aMap);
350 if ( aMap.Extent() == 1 ) { // Local Selection
351 int anIndex = aMap( 1 );
352 if ( aNeedType == TopAbs_EDGE )
353 aName += QString( ":edge_%1" ).arg( anIndex );
354 else if (aNeedType == TopAbs_FACE)
355 aName += QString( ":face_%1" ).arg( anIndex );
357 aName += QString( ":vertex_%1" ).arg( anIndex );
359 //Find SubShape Object in Father
360 GEOM::GEOM_Object_var aFindedObject = GEOMBase_Helper::findObjectInFather( aSelectedObject, aName );
362 if ( aFindedObject == GEOM::GEOM_Object::_nil() ) { // Object not found in study
363 GEOM::GEOM_IShapesOperations_var aShapesOp = getGeomEngine()->GetIShapesOperations( getStudyId() );
364 aSelectedObject = aShapesOp->GetSubShape( aSelectedObject, anIndex );
367 aSelectedObject = aFindedObject; // get Object from study
370 else { // Global Selection
371 if ( aShape.ShapeType() != aNeedType ) {
372 aSelectedObject = GEOM::GEOM_Object::_nil();
378 myEditCurrentArgument->setText( aName );
380 if (!aSelectedObject->_is_nil()) { // clear selection if something selected
382 if ( myEditCurrentArgument == GroupFace->LineEdit1 ) {
383 TColStd_MapOfInteger aMap;
384 aMap.Add( GEOM_PLANE );
385 aMap.Add( GEOM_MARKER );
386 globalSelection( aMap );
389 localSelection( GEOM::GEOM_Object::_nil(), aNeedType );
392 if ( myEditCurrentArgument == GroupPntDir->LineEdit1 ) {
393 myPoint = aSelectedObject;
394 if ( !myPoint->_is_nil() && myDir->_is_nil() )
395 GroupPntDir->PushButton2->click();
397 else if ( myEditCurrentArgument == GroupPntDir->LineEdit2 ) {
398 myDir = aSelectedObject;
399 if ( !myDir->_is_nil() && myPoint->_is_nil() )
400 GroupPntDir->PushButton1->click();
402 else if ( myEditCurrentArgument == Group3Pnts->LineEdit1 ) {
403 myPoint1 = aSelectedObject;
404 if ( !myPoint1->_is_nil() && myPoint2->_is_nil() )
405 Group3Pnts->PushButton2->click();
407 else if ( myEditCurrentArgument == Group3Pnts->LineEdit2 ) {
408 myPoint2 = aSelectedObject;
409 if ( !myPoint2->_is_nil() && myPoint3->_is_nil() )
410 Group3Pnts->PushButton3->click();
412 else if ( myEditCurrentArgument == Group3Pnts->LineEdit3 ) {
413 myPoint3 = aSelectedObject;
414 if ( !myPoint3->_is_nil() && myPoint1->_is_nil() )
415 Group3Pnts->PushButton1->click();
417 else if ( myEditCurrentArgument == GroupFace->LineEdit1 )
418 myFace = aSelectedObject;
425 //=================================================================================
426 // function : SetEditCurrentArgument()
428 //=================================================================================
429 void BasicGUI_PlaneDlg::SetEditCurrentArgument()
431 QPushButton* send = (QPushButton*)sender();
432 globalSelection( GEOM_POINT );
434 if ( send == GroupPntDir->PushButton1 ) {
435 myEditCurrentArgument = GroupPntDir->LineEdit1;
436 GroupPntDir->PushButton2->setDown( false );
437 GroupPntDir->LineEdit1->setEnabled( true );
438 GroupPntDir->LineEdit2->setEnabled( false );
440 else if ( send == GroupPntDir->PushButton2 ) {
441 myEditCurrentArgument = GroupPntDir->LineEdit2;
442 GroupPntDir->PushButton1->setDown( false );
443 GroupPntDir->LineEdit1->setEnabled( false );
444 GroupPntDir->LineEdit2->setEnabled( true );
446 else if ( send == Group3Pnts->PushButton1 ) {
447 myEditCurrentArgument = Group3Pnts->LineEdit1;
448 Group3Pnts->PushButton2->setDown( false );
449 Group3Pnts->PushButton3->setDown( false );
450 Group3Pnts->LineEdit1->setEnabled( true );
451 Group3Pnts->LineEdit2->setEnabled( false );
452 Group3Pnts->LineEdit3->setEnabled( false );
454 else if ( send == Group3Pnts->PushButton2 ) {
455 myEditCurrentArgument = Group3Pnts->LineEdit2;
456 Group3Pnts->PushButton1->setDown( false );
457 Group3Pnts->PushButton3->setDown( false );
458 Group3Pnts->LineEdit1->setEnabled( false );
459 Group3Pnts->LineEdit2->setEnabled( true );
460 Group3Pnts->LineEdit3->setEnabled( false );
462 else if ( send == Group3Pnts->PushButton3 ) {
463 myEditCurrentArgument = Group3Pnts->LineEdit3;
464 Group3Pnts->PushButton1->setDown( false );
465 Group3Pnts->PushButton2->setDown( false );
466 Group3Pnts->LineEdit1->setEnabled( false );
467 Group3Pnts->LineEdit2->setEnabled( false );
468 Group3Pnts->LineEdit3->setEnabled( true );
470 else if ( send == GroupFace->PushButton1 ) {
471 myEditCurrentArgument = GroupFace->LineEdit1;
472 GroupFace->PushButton1->setDown( true );
475 myEditCurrentArgument->setFocus();
477 if ( myEditCurrentArgument == GroupPntDir->LineEdit2 ) {
478 localSelection( GEOM::GEOM_Object::_nil(), TopAbs_EDGE );
480 else if ( myEditCurrentArgument == GroupFace->LineEdit1 ) {
481 TColStd_MapOfInteger aMap;
482 aMap.Add( GEOM_PLANE );
483 aMap.Add( GEOM_MARKER );
484 globalSelection( aMap );
487 localSelection( GEOM::GEOM_Object::_nil(), TopAbs_VERTEX );
490 // SelectionIntoArgument();
491 myEditCurrentArgument->setFocus();
497 //=================================================================================
498 // function : LineEditReturnPressed()
500 //=================================================================================
501 void BasicGUI_PlaneDlg::LineEditReturnPressed()
503 QLineEdit* send = (QLineEdit*)sender();
504 if ( send == GroupPntDir->LineEdit1 ||
505 send == GroupPntDir->LineEdit2 ||
506 send == Group3Pnts->LineEdit1 ||
507 send == Group3Pnts->LineEdit2 ||
508 send == Group3Pnts->LineEdit3 ||
509 send == GroupFace->LineEdit1 ) {
510 myEditCurrentArgument = send;
511 GEOMBase_Skeleton::LineEditReturnPressed();
516 //=================================================================================
517 // function : ActivateThisDialog()
519 //=================================================================================
520 void BasicGUI_PlaneDlg::ActivateThisDialog()
522 GEOMBase_Skeleton::ActivateThisDialog();
523 connect( myGeomGUI->getApp()->selectionMgr(), SIGNAL( currentSelectionChanged() ),
524 this, SLOT( SelectionIntoArgument() ) );
526 ConstructorsClicked( getConstructorId() );
529 //=================================================================================
530 // function : DeactivateActiveDialog()
531 // purpose : public slot to deactivate if active
532 //=================================================================================
533 void BasicGUI_PlaneDlg::DeactivateActiveDialog()
535 GEOMBase_Skeleton::DeactivateActiveDialog();
538 //=================================================================================
539 // function : enterEvent()
541 //=================================================================================
542 void BasicGUI_PlaneDlg::enterEvent( QEvent* )
544 if ( !mainFrame()->GroupConstructors->isEnabled() )
545 ActivateThisDialog();
549 //=================================================================================
550 // function : ValueChangedInSpinBox()
552 //=================================================================================
553 void BasicGUI_PlaneDlg::ValueChangedInSpinBox( double newValue )
558 //=================================================================================
559 // function : getSize()
561 //=================================================================================
562 double BasicGUI_PlaneDlg::getSize() const
564 switch ( getConstructorId() ) {
565 case 0 : return GroupPntDir->SpinBox_DX->value();
566 case 1 : return Group3Pnts->SpinBox_DX->value();
567 case 2 : return GroupFace->SpinBox_DX->value();
572 //=================================================================================
573 // function : createOperation
575 //=================================================================================
576 GEOM::GEOM_IOperations_ptr BasicGUI_PlaneDlg::createOperation()
578 return myGeomGUI->GetGeomGen()->GetIBasicOperations( getStudyId() );
581 //=================================================================================
582 // function : isEqual
583 // purpose : it may also be needed to check for min distance between gp_Pnt-s...
584 //=================================================================================
585 static bool isEqual( const GEOM::GEOM_Object_var& thePnt1, const GEOM::GEOM_Object_var& thePnt2 )
587 return thePnt1->_is_equivalent( thePnt2 );
590 //=================================================================================
591 // function : isValid
593 //=================================================================================
594 bool BasicGUI_PlaneDlg::isValid( QString& msg )
596 const int id = getConstructorId();
597 if ( getSize() <= 0 ) {
598 msg = QString( "Please, enter size greater than 0." );
602 return !CORBA::is_nil( myPoint ) && !CORBA::is_nil( myDir );
604 return !CORBA::is_nil( myPoint1 ) && !CORBA::is_nil( myPoint2 ) && !CORBA::is_nil( myPoint3 ) &&
605 !isEqual( myPoint1, myPoint2 ) && !isEqual( myPoint1, myPoint3 ) && !isEqual( myPoint2, myPoint3 );
607 return !CORBA::is_nil( myFace );
611 //=================================================================================
612 // function : execute
614 //=================================================================================
615 bool BasicGUI_PlaneDlg::execute( ObjectList& objects )
619 GEOM::GEOM_Object_var anObj;
621 switch ( getConstructorId() ) {
623 anObj = GEOM::GEOM_IBasicOperations::_narrow( getOperation() )->MakePlanePntVec( myPoint, myDir, getSize() );
627 anObj = GEOM::GEOM_IBasicOperations::_narrow( getOperation() )->MakePlaneThreePnt( myPoint1, myPoint2, myPoint3, getSize() );
631 anObj = GEOM::GEOM_IBasicOperations::_narrow( getOperation() )->MakePlaneFace( myFace, getSize() );
636 if ( !anObj->_is_nil() )
637 objects.push_back( anObj._retn() );
641 //=================================================================================
642 // function : addSubshapeToStudy
643 // purpose : virtual method to add new SubObjects if local selection
644 //=================================================================================
645 void BasicGUI_PlaneDlg::addSubshapesToStudy()
647 QMap<QString, GEOM::GEOM_Object_var> objMap;
649 switch ( getConstructorId() ) {
651 objMap[GroupPntDir->LineEdit1->text()] = myPoint;
652 objMap[GroupPntDir->LineEdit2->text()] = myDir;
655 objMap[Group3Pnts->LineEdit1->text()] = myPoint1;
656 objMap[Group3Pnts->LineEdit2->text()] = myPoint2;
657 objMap[Group3Pnts->LineEdit3->text()] = myPoint3;
660 objMap[GroupFace->LineEdit1->text()] = myFace;
663 addSubshapesToFather( objMap );