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_PlaneDlg.cxx
24 // 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_3Radio1Sel1Spin( centralWidget() );
104 GroupFace->RadioButton1->setText(tr("GEOM_FACE"));
105 GroupFace->RadioButton2->setText(tr("GEOM_LCS"));
106 GroupFace->RadioButton3->setAttribute( Qt::WA_DeleteOnClose );
107 GroupFace->RadioButton3->close();
108 GroupFace->GroupBox1->setTitle( tr( "GEOM_FACE_OR_LCS" ) );
109 GroupFace->TextLabel1->setText( tr( "GEOM_SELECTION" ) );
110 GroupFace->TextLabel2->setText( tr( "GEOM_PLANE_SIZE" ) );
111 GroupFace->PushButton1->setIcon( image3 );
112 GroupFace->PushButton1->setDown( true );
114 GroupFace->LineEdit1->setReadOnly( true );
116 QVBoxLayout* layout = new QVBoxLayout( centralWidget() );
117 layout->setMargin( 0 ); layout->setSpacing( 6 );
118 layout->addWidget( GroupPntDir );
119 layout->addWidget( Group3Pnts );
120 layout->addWidget( GroupFace );
121 /***************************************************************/
123 setHelpFileName( "create_plane_page.html" );
129 //=================================================================================
130 // function : ~BasicGUI_PlaneDlg()
131 // purpose : Destroys the object and frees any allocated resources
132 //=================================================================================
133 BasicGUI_PlaneDlg::~BasicGUI_PlaneDlg()
138 //=================================================================================
141 //=================================================================================
142 void BasicGUI_PlaneDlg::Init()
145 myEditCurrentArgument = GroupPntDir->LineEdit1;
146 GroupFace->RadioButton1->setChecked(true);
148 myPoint = myDir = myPoint1 = myPoint2 = myPoint3 = myFace = GEOM::GEOM_Object::_nil();
150 // myGeomGUI->SetState( 0 );
152 /* Get setting of step value from file configuration */
153 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
154 double aStep = resMgr->doubleValue( "Geometry", "SettingsGeomStep", 100 );
156 double aTrimSize = 2000.0;
158 /* min, max, step and decimals for spin boxes */
159 initSpinBox( GroupPntDir->SpinBox_DX, 0.000001, COORD_MAX, aStep, 6 ); // VSR: TODO: DBL_DIGITS_DISPLAY
160 GroupPntDir->SpinBox_DX->setValue( aTrimSize );
161 initSpinBox( Group3Pnts->SpinBox_DX, 0.000001, COORD_MAX, aStep, 6 ); // VSR: TODO: DBL_DIGITS_DISPLAY
162 Group3Pnts->SpinBox_DX->setValue( aTrimSize );
163 initSpinBox( GroupFace->SpinBox_DX, 0.000001, COORD_MAX, aStep, 6 ); // VSR: TODO: DBL_DIGITS_DISPLAY
164 GroupFace->SpinBox_DX->setValue( aTrimSize );
166 /* signals and slots connections */
167 connect( myGeomGUI, SIGNAL( SignalDeactivateActiveDialog() ), this, SLOT( DeactivateActiveDialog() ) );
168 connect( myGeomGUI, SIGNAL( SignalCloseAllDialogs() ), this, SLOT( ClickOnCancel() ) );
170 connect( buttonOk(), SIGNAL( clicked() ), this, SLOT( ClickOnOk() ) );
171 connect( buttonApply(), SIGNAL( clicked() ), this, SLOT( ClickOnApply() ) );
173 connect( this, SIGNAL( constructorsClicked( int ) ), this, SLOT( ConstructorsClicked( int ) ) );
175 connect( GroupPntDir->PushButton1, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) );
176 connect( GroupPntDir->PushButton2, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) );
177 connect( Group3Pnts->PushButton1, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) );
178 connect( Group3Pnts->PushButton2, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) );
179 connect( Group3Pnts->PushButton3, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) );
180 connect( GroupFace->PushButton1, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) );
182 connect( GroupPntDir->LineEdit1, SIGNAL( returnPressed() ), this, SLOT( LineEditReturnPressed() ) );
183 connect( GroupPntDir->LineEdit2, SIGNAL( returnPressed() ), this, SLOT( LineEditReturnPressed() ) );
184 connect( Group3Pnts->LineEdit1, SIGNAL( returnPressed() ), this, SLOT( LineEditReturnPressed() ) );
185 connect( Group3Pnts->LineEdit2, SIGNAL( returnPressed() ), this, SLOT( LineEditReturnPressed() ) );
186 connect( Group3Pnts->LineEdit3, SIGNAL( returnPressed() ), this, SLOT( LineEditReturnPressed() ) );
187 connect( GroupFace->LineEdit1, SIGNAL( returnPressed() ), this, SLOT( LineEditReturnPressed() ) );
188 connect( GroupFace->RadioButton1,SIGNAL( clicked() ), this, SLOT( SelectionTypeClicked() ) );
189 connect( GroupFace->RadioButton2,SIGNAL( clicked() ), this, SLOT( SelectionTypeClicked() ) );
191 connect( GroupPntDir->SpinBox_DX, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
192 connect( Group3Pnts->SpinBox_DX, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
193 connect( GroupFace->SpinBox_DX, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
195 connect( myGeomGUI, SIGNAL( SignalDefaultStepValueChanged( double ) ), this, SLOT( SetDoubleSpinBoxStep( double ) ) );
197 connect( myGeomGUI->getApp()->selectionMgr(), SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) );
199 initName( tr( "GEOM_PLANE" ) );
201 ConstructorsClicked( 0 );
204 //=================================================================================
205 // function : SetDoubleSpinBoxStep()
206 // purpose : Double spin box management
207 //=================================================================================
208 void BasicGUI_PlaneDlg::SetDoubleSpinBoxStep( double step )
210 GroupPntDir->SpinBox_DX->setSingleStep(step);
211 Group3Pnts->SpinBox_DX->setSingleStep(step);
212 GroupFace->SpinBox_DX->setSingleStep(step);
215 //=================================================================================
216 // function : SelectionTypeClicked()
217 // purpose : Selection type radio buttons managment
218 //=================================================================================
219 void BasicGUI_PlaneDlg::SelectionTypeClicked()
221 myFace = GEOM::GEOM_Object::_nil();
222 if ( GroupFace->RadioButton1->isChecked()) {
223 globalSelection(); // close local contexts, if any
224 localSelection( GEOM::GEOM_Object::_nil(), TopAbs_FACE );
225 } else if ( GroupFace->RadioButton2->isChecked()) {
226 TColStd_MapOfInteger aMap;
227 aMap.Add( GEOM_PLANE );
228 aMap.Add( GEOM_MARKER );
229 globalSelection( aMap );
235 //=================================================================================
236 // function : ConstructorsClicked()
237 // purpose : Radio button management
238 //=================================================================================
239 void BasicGUI_PlaneDlg::ConstructorsClicked( int constructorId )
241 disconnect( myGeomGUI->getApp()->selectionMgr(), 0, this, 0 );
242 myPoint = myDir = myPoint1 = myPoint2 = myPoint3 = myFace = GEOM::GEOM_Object::_nil();
244 switch ( constructorId ) {
245 case 0: /* plane from a point and a direction (vector, edge...) */
251 myEditCurrentArgument = GroupPntDir->LineEdit1;
252 GroupPntDir->LineEdit1->setText( "" );
253 GroupPntDir->LineEdit2->setText( "" );
254 GroupPntDir->PushButton1->setDown( true );
255 GroupPntDir->PushButton2->setDown( false );
256 GroupPntDir->LineEdit1->setEnabled( true );
257 GroupPntDir->LineEdit2->setEnabled( false );
259 /* for the first argument */
260 globalSelection(); // close local contexts, if any
261 localSelection( GEOM::GEOM_Object::_nil(), TopAbs_VERTEX );
264 case 1: /* plane from 3 points */
270 myEditCurrentArgument = Group3Pnts->LineEdit1;
271 Group3Pnts->LineEdit1->setText( "" );
272 Group3Pnts->LineEdit2->setText( "" );
273 Group3Pnts->LineEdit3->setText( "" );
274 Group3Pnts->PushButton1->setDown( true );
275 Group3Pnts->PushButton2->setDown( false );
276 Group3Pnts->PushButton3->setDown( false );
277 Group3Pnts->LineEdit1->setEnabled( true );
278 Group3Pnts->LineEdit2->setEnabled( false );
279 Group3Pnts->LineEdit3->setEnabled( false );
281 /* for the first argument */
282 globalSelection(); // close local contexts, if any
283 localSelection( GEOM::GEOM_Object::_nil(), TopAbs_VERTEX );
286 case 2: /* plane from a planar face or LSC selection */
292 myEditCurrentArgument = GroupFace->LineEdit1;
293 GroupFace->LineEdit1->setText( "" );
294 GroupFace->PushButton1->setDown( true );
296 if ( GroupFace->RadioButton1->isChecked()) {
297 globalSelection(); // close local contexts, if any
298 localSelection( GEOM::GEOM_Object::_nil(), TopAbs_FACE );
299 } else if ( GroupFace->RadioButton2->isChecked()) {
300 TColStd_MapOfInteger aMap;
301 aMap.Add( GEOM_PLANE );
302 aMap.Add( GEOM_MARKER );
303 globalSelection( aMap );
309 qApp->processEvents();
311 resize( minimumSize() );
313 myEditCurrentArgument->setFocus();
314 connect( myGeomGUI->getApp()->selectionMgr(), SIGNAL( currentSelectionChanged() ),
315 this, SLOT( SelectionIntoArgument() ) );
319 //=================================================================================
320 // function : ClickOnOk()
322 //=================================================================================
323 void BasicGUI_PlaneDlg::ClickOnOk()
325 if ( ClickOnApply() )
330 //=================================================================================
331 // function : ClickOnApply()
333 //=================================================================================
334 bool BasicGUI_PlaneDlg::ClickOnApply()
340 ConstructorsClicked( getConstructorId() );
344 //=================================================================================
345 // function : SelectionIntoArgument()
346 // purpose : Called when selection has changed
347 //=================================================================================
348 void BasicGUI_PlaneDlg::SelectionIntoArgument()
350 myEditCurrentArgument->setText("");
352 LightApp_SelectionMgr* aSelMgr = myGeomGUI->getApp()->selectionMgr();
353 SALOME_ListIO aSelList;
354 aSelMgr->selectedObjects(aSelList);
356 if (aSelList.Extent() != 1) {
357 if ( myEditCurrentArgument == GroupPntDir->LineEdit1 ) myPoint = GEOM::GEOM_Object::_nil();
358 else if ( myEditCurrentArgument == GroupPntDir->LineEdit2 ) myDir = GEOM::GEOM_Object::_nil();
359 else if ( myEditCurrentArgument == Group3Pnts->LineEdit1 ) myPoint1 = GEOM::GEOM_Object::_nil();
360 else if ( myEditCurrentArgument == Group3Pnts->LineEdit2 ) myPoint2 = GEOM::GEOM_Object::_nil();
361 else if ( myEditCurrentArgument == Group3Pnts->LineEdit3 ) myPoint3 = GEOM::GEOM_Object::_nil();
362 else if ( myEditCurrentArgument == GroupFace->LineEdit1 ) myFace = GEOM::GEOM_Object::_nil();
367 Standard_Boolean aRes = Standard_False;
368 GEOM::GEOM_Object_var aSelectedObject = GEOMBase::ConvertIOinGEOMObject(aSelList.First(), aRes);
369 if ( !CORBA::is_nil( aSelectedObject ) && aRes ) {
370 QString aName = GEOMBase::GetName( aSelectedObject );
371 TopAbs_ShapeEnum aNeedType = TopAbs_VERTEX;
372 if ( myEditCurrentArgument == GroupPntDir->LineEdit2 )
373 aNeedType = TopAbs_EDGE;
374 else if ( myEditCurrentArgument == GroupFace->LineEdit1 )
375 aNeedType = TopAbs_FACE;
378 if ( GEOMBase::GetShape( aSelectedObject, aShape, TopAbs_SHAPE ) && !aShape.IsNull() ) {
379 TColStd_IndexedMapOfInteger aMap;
380 aSelMgr->GetIndexes(aSelList.First(), aMap);
381 if ( aMap.Extent() == 1 ) { // Local Selection
382 int anIndex = aMap( 1 );
383 if ( aNeedType == TopAbs_EDGE )
384 aName += QString( ":edge_%1" ).arg( anIndex );
385 else if (aNeedType == TopAbs_FACE)
386 aName += QString( ":face_%1" ).arg( anIndex );
388 aName += QString( ":vertex_%1" ).arg( anIndex );
390 //Find SubShape Object in Father
391 GEOM::GEOM_Object_var aFindedObject = GEOMBase_Helper::findObjectInFather( aSelectedObject, aName );
393 if ( aFindedObject == GEOM::GEOM_Object::_nil() ) { // Object not found in study
394 GEOM::GEOM_IShapesOperations_var aShapesOp = getGeomEngine()->GetIShapesOperations( getStudyId() );
395 aSelectedObject = aShapesOp->GetSubShape( aSelectedObject, anIndex );
398 aSelectedObject = aFindedObject; // get Object from study
401 else { // Global Selection
402 if ( aShape.ShapeType() != aNeedType ) {
403 aSelectedObject = GEOM::GEOM_Object::_nil();
409 myEditCurrentArgument->setText( aName );
411 /* if (!aSelectedObject->_is_nil()) { // clear selection if something selected
413 if ( myEditCurrentArgument == GroupFace->LineEdit1 ) {
414 TColStd_MapOfInteger aMap;
415 aMap.Add( GEOM_PLANE );
416 aMap.Add( GEOM_MARKER );
417 globalSelection( aMap );
420 localSelection( GEOM::GEOM_Object::_nil(), aNeedType );
423 if ( myEditCurrentArgument == GroupPntDir->LineEdit1 ) {
424 myPoint = aSelectedObject;
425 if ( !myPoint->_is_nil() && myDir->_is_nil() )
426 GroupPntDir->PushButton2->click();
428 else if ( myEditCurrentArgument == GroupPntDir->LineEdit2 ) {
429 myDir = aSelectedObject;
430 if ( !myDir->_is_nil() && myPoint->_is_nil() )
431 GroupPntDir->PushButton1->click();
433 else if ( myEditCurrentArgument == Group3Pnts->LineEdit1 ) {
434 myPoint1 = aSelectedObject;
435 if ( !myPoint1->_is_nil() && myPoint2->_is_nil() )
436 Group3Pnts->PushButton2->click();
438 else if ( myEditCurrentArgument == Group3Pnts->LineEdit2 ) {
439 myPoint2 = aSelectedObject;
440 if ( !myPoint2->_is_nil() && myPoint3->_is_nil() )
441 Group3Pnts->PushButton3->click();
443 else if ( myEditCurrentArgument == Group3Pnts->LineEdit3 ) {
444 myPoint3 = aSelectedObject;
445 if ( !myPoint3->_is_nil() && myPoint1->_is_nil() )
446 Group3Pnts->PushButton1->click();
448 else if ( myEditCurrentArgument == GroupFace->LineEdit1 )
449 myFace = aSelectedObject;
456 //=================================================================================
457 // function : SetEditCurrentArgument()
459 //=================================================================================
460 void BasicGUI_PlaneDlg::SetEditCurrentArgument()
462 QPushButton* send = (QPushButton*)sender();
463 globalSelection( GEOM_POINT );
465 if ( send == GroupPntDir->PushButton1 ) {
466 myEditCurrentArgument = GroupPntDir->LineEdit1;
467 GroupPntDir->PushButton2->setDown( false );
468 GroupPntDir->LineEdit1->setEnabled( true );
469 GroupPntDir->LineEdit2->setEnabled( false );
471 else if ( send == GroupPntDir->PushButton2 ) {
472 myEditCurrentArgument = GroupPntDir->LineEdit2;
473 GroupPntDir->PushButton1->setDown( false );
474 GroupPntDir->LineEdit1->setEnabled( false );
475 GroupPntDir->LineEdit2->setEnabled( true );
477 else if ( send == Group3Pnts->PushButton1 ) {
478 myEditCurrentArgument = Group3Pnts->LineEdit1;
479 Group3Pnts->PushButton2->setDown( false );
480 Group3Pnts->PushButton3->setDown( false );
481 Group3Pnts->LineEdit1->setEnabled( true );
482 Group3Pnts->LineEdit2->setEnabled( false );
483 Group3Pnts->LineEdit3->setEnabled( false );
485 else if ( send == Group3Pnts->PushButton2 ) {
486 myEditCurrentArgument = Group3Pnts->LineEdit2;
487 Group3Pnts->PushButton1->setDown( false );
488 Group3Pnts->PushButton3->setDown( false );
489 Group3Pnts->LineEdit1->setEnabled( false );
490 Group3Pnts->LineEdit2->setEnabled( true );
491 Group3Pnts->LineEdit3->setEnabled( false );
493 else if ( send == Group3Pnts->PushButton3 ) {
494 myEditCurrentArgument = Group3Pnts->LineEdit3;
495 Group3Pnts->PushButton1->setDown( false );
496 Group3Pnts->PushButton2->setDown( false );
497 Group3Pnts->LineEdit1->setEnabled( false );
498 Group3Pnts->LineEdit2->setEnabled( false );
499 Group3Pnts->LineEdit3->setEnabled( true );
501 else if ( send == GroupFace->PushButton1 ) {
502 myEditCurrentArgument = GroupFace->LineEdit1;
503 GroupFace->PushButton1->setDown( true );
506 myEditCurrentArgument->setFocus();
508 if ( myEditCurrentArgument == GroupPntDir->LineEdit2 ) {
509 localSelection( GEOM::GEOM_Object::_nil(), TopAbs_EDGE );
511 else if ( myEditCurrentArgument == GroupFace->LineEdit1 ) {
512 TColStd_MapOfInteger aMap;
513 aMap.Add( GEOM_PLANE );
514 aMap.Add( GEOM_MARKER );
515 globalSelection( aMap );
518 localSelection( GEOM::GEOM_Object::_nil(), TopAbs_VERTEX );
521 // SelectionIntoArgument();
522 myEditCurrentArgument->setFocus();
528 //=================================================================================
529 // function : LineEditReturnPressed()
531 //=================================================================================
532 void BasicGUI_PlaneDlg::LineEditReturnPressed()
534 QLineEdit* send = (QLineEdit*)sender();
535 if ( send == GroupPntDir->LineEdit1 ||
536 send == GroupPntDir->LineEdit2 ||
537 send == Group3Pnts->LineEdit1 ||
538 send == Group3Pnts->LineEdit2 ||
539 send == Group3Pnts->LineEdit3 ||
540 send == GroupFace->LineEdit1 ) {
541 myEditCurrentArgument = send;
542 GEOMBase_Skeleton::LineEditReturnPressed();
547 //=================================================================================
548 // function : ActivateThisDialog()
550 //=================================================================================
551 void BasicGUI_PlaneDlg::ActivateThisDialog()
553 GEOMBase_Skeleton::ActivateThisDialog();
554 connect( myGeomGUI->getApp()->selectionMgr(), SIGNAL( currentSelectionChanged() ),
555 this, SLOT( SelectionIntoArgument() ) );
557 ConstructorsClicked( getConstructorId() );
560 //=================================================================================
561 // function : DeactivateActiveDialog()
562 // purpose : public slot to deactivate if active
563 //=================================================================================
564 void BasicGUI_PlaneDlg::DeactivateActiveDialog()
566 GEOMBase_Skeleton::DeactivateActiveDialog();
569 //=================================================================================
570 // function : enterEvent()
572 //=================================================================================
573 void BasicGUI_PlaneDlg::enterEvent( QEvent* )
575 if ( !mainFrame()->GroupConstructors->isEnabled() )
576 ActivateThisDialog();
580 //=================================================================================
581 // function : ValueChangedInSpinBox()
583 //=================================================================================
584 void BasicGUI_PlaneDlg::ValueChangedInSpinBox( double newValue )
589 //=================================================================================
590 // function : getSize()
592 //=================================================================================
593 double BasicGUI_PlaneDlg::getSize() const
595 switch ( getConstructorId() ) {
596 case 0 : return GroupPntDir->SpinBox_DX->value();
597 case 1 : return Group3Pnts->SpinBox_DX->value();
598 case 2 : return GroupFace->SpinBox_DX->value();
603 //=================================================================================
604 // function : createOperation
606 //=================================================================================
607 GEOM::GEOM_IOperations_ptr BasicGUI_PlaneDlg::createOperation()
609 return myGeomGUI->GetGeomGen()->GetIBasicOperations( getStudyId() );
612 //=================================================================================
613 // function : isEqual
614 // purpose : it may also be needed to check for min distance between gp_Pnt-s...
615 //=================================================================================
616 static bool isEqual( const GEOM::GEOM_Object_var& thePnt1, const GEOM::GEOM_Object_var& thePnt2 )
618 return thePnt1->_is_equivalent( thePnt2 );
621 //=================================================================================
622 // function : isValid
624 //=================================================================================
625 bool BasicGUI_PlaneDlg::isValid( QString& msg )
627 const int id = getConstructorId();
628 if ( getSize() <= 0 ) {
629 msg = QString( "Please, enter size greater than 0." );
633 return !CORBA::is_nil( myPoint ) && !CORBA::is_nil( myDir );
635 return !CORBA::is_nil( myPoint1 ) && !CORBA::is_nil( myPoint2 ) && !CORBA::is_nil( myPoint3 ) &&
636 !isEqual( myPoint1, myPoint2 ) && !isEqual( myPoint1, myPoint3 ) && !isEqual( myPoint2, myPoint3 );
638 return !CORBA::is_nil( myFace );
642 //=================================================================================
643 // function : execute
645 //=================================================================================
646 bool BasicGUI_PlaneDlg::execute( ObjectList& objects )
650 GEOM::GEOM_Object_var anObj;
652 switch ( getConstructorId() ) {
654 anObj = GEOM::GEOM_IBasicOperations::_narrow( getOperation() )->MakePlanePntVec( myPoint, myDir, getSize() );
658 anObj = GEOM::GEOM_IBasicOperations::_narrow( getOperation() )->MakePlaneThreePnt( myPoint1, myPoint2, myPoint3, getSize() );
662 anObj = GEOM::GEOM_IBasicOperations::_narrow( getOperation() )->MakePlaneFace( myFace, getSize() );
667 if ( !anObj->_is_nil() )
668 objects.push_back( anObj._retn() );
672 //=================================================================================
673 // function : addSubshapeToStudy
674 // purpose : virtual method to add new SubObjects if local selection
675 //=================================================================================
676 void BasicGUI_PlaneDlg::addSubshapesToStudy()
678 QMap<QString, GEOM::GEOM_Object_var> objMap;
680 switch ( getConstructorId() ) {
682 objMap[GroupPntDir->LineEdit1->text()] = myPoint;
683 objMap[GroupPntDir->LineEdit2->text()] = myDir;
686 objMap[Group3Pnts->LineEdit1->text()] = myPoint1;
687 objMap[Group3Pnts->LineEdit2->text()] = myPoint2;
688 objMap[Group3Pnts->LineEdit3->text()] = myPoint3;
691 objMap[GroupFace->LineEdit1->text()] = myFace;
694 addSubshapesToFather( objMap );