1 // Copyright (C) 2007-2010 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
23 // GEOM GEOMGUI : GUI for Geometry component
24 // File : BasicGUI_PlaneDlg.cxx
25 // Author : Lucien PIGNOLONI, Open CASCADE S.A.S.
27 #include "BasicGUI_PlaneDlg.h"
31 #include <GeometryGUI.h>
34 #include <SUIT_ResourceMgr.h>
35 #include <SUIT_Session.h>
36 #include <SalomeApp_Application.h>
37 #include <LightApp_SelectionMgr.h>
39 #include <TColStd_MapOfInteger.hxx>
40 #include <TopoDS_Shape.hxx>
41 #include <TopoDS_Edge.hxx>
44 #include <TColStd_IndexedMapOfInteger.hxx>
45 #include <TopTools_IndexedMapOfShape.hxx>
47 #include <GEOMImpl_Types.hxx>
49 //=================================================================================
50 // class : BasicGUI_PlaneDlg()
51 // purpose : Constructs a BasicGUI_PlaneDlg which is a child of 'parent', with the
52 // name 'name' and widget flags set to 'f'.
53 // The dialog will by default be modeless, unless you set 'modal' to
54 // TRUE to construct a modal dialog.
55 //=================================================================================
56 BasicGUI_PlaneDlg::BasicGUI_PlaneDlg( GeometryGUI* theGeometryGUI, QWidget* parent,
57 bool modal, Qt::WindowFlags fl )
58 : GEOMBase_Skeleton( theGeometryGUI, parent, modal, fl )
60 QPixmap image0( SUIT_Session::session()->resourceMgr()->loadPixmap( "GEOM", tr( "ICON_DLG_PLANE_PV" ) ) );
61 QPixmap image1( SUIT_Session::session()->resourceMgr()->loadPixmap( "GEOM", tr( "ICON_DLG_PLANE_3PNTS" ) ) );
62 QPixmap image2( SUIT_Session::session()->resourceMgr()->loadPixmap( "GEOM", tr( "ICON_DLG_PLANE_FACE" ) ) );
63 QPixmap image3( SUIT_Session::session()->resourceMgr()->loadPixmap( "GEOM", tr( "ICON_SELECT" ) ) );
64 QPixmap image4( SUIT_Session::session()->resourceMgr()->loadPixmap( "GEOM", tr( "ICON_DLG_WPLANE_VECTOR" ) ) );
65 QPixmap image5( SUIT_Session::session()->resourceMgr()->loadPixmap( "GEOM", tr( "ICON_DLG_WPLANE_ORIGIN" ) ) );
67 setWindowTitle( tr( "GEOM_PLANE_TITLE" ) );
69 /***************************************************************/
70 mainFrame()->GroupConstructors->setTitle( tr( "GEOM_PLANE" ) );
71 mainFrame()->RadioButton1->setIcon( image0 );
72 mainFrame()->RadioButton2->setIcon( image1 );
73 mainFrame()->RadioButton3->setIcon( image2 );
74 mainFrame()->RadioButton4->show();
75 mainFrame()->RadioButton4->setIcon( image4 );
76 mainFrame()->RadioButton5->show();
77 mainFrame()->RadioButton5->setIcon( image5 );
79 GroupPntDir = new DlgRef_2Sel1Spin( centralWidget() );
80 GroupPntDir->GroupBox1->setTitle( tr( "GEOM_PLANE_PV" ) );
81 GroupPntDir->TextLabel1->setText( tr( "GEOM_POINT" ) );
82 GroupPntDir->TextLabel2->setText( tr( "GEOM_VECTOR" ) );
83 GroupPntDir->TextLabel3->setText( tr( "GEOM_PLANE_SIZE" ) );
84 GroupPntDir->PushButton1->setIcon( image3 );
85 GroupPntDir->PushButton2->setIcon( image3 );
86 GroupPntDir->LineEdit1->setReadOnly( true );
87 GroupPntDir->LineEdit2->setReadOnly( true );
88 GroupPntDir->PushButton1->setDown( true );
89 GroupPntDir->LineEdit1->setEnabled( true );
90 GroupPntDir->LineEdit2->setEnabled( false );
92 Group3Pnts = new DlgRef_3Sel1Spin( centralWidget() );
93 Group3Pnts->GroupBox1->setTitle( tr( "GEOM_3_POINTS" ) );
94 Group3Pnts->TextLabel1->setText( tr( "GEOM_POINT1" ) );
95 Group3Pnts->TextLabel2->setText( tr( "GEOM_POINT2" ) );
96 Group3Pnts->TextLabel3->setText( tr( "GEOM_POINT3" ) );
97 Group3Pnts->TextLabel4->setText( tr( "GEOM_PLANE_SIZE" ) );
98 Group3Pnts->PushButton1->setIcon( image3 );
99 Group3Pnts->PushButton2->setIcon( image3 );
100 Group3Pnts->PushButton3->setIcon( image3 );
101 Group3Pnts->PushButton1->setDown( true );
103 Group3Pnts->LineEdit1->setReadOnly( true );
104 Group3Pnts->LineEdit2->setReadOnly( true );
105 Group3Pnts->LineEdit3->setReadOnly( true );
106 Group3Pnts->LineEdit1->setEnabled( true );
107 Group3Pnts->LineEdit2->setEnabled( false );
108 Group3Pnts->LineEdit3->setEnabled( false );
110 GroupFace = new DlgRef_1Sel1Spin( centralWidget() );
111 GroupFace->GroupBox1->setTitle( tr( "GEOM_FACE" ) );
112 GroupFace->TextLabel1->setText( tr( "GEOM_SELECTION" ) );
113 GroupFace->TextLabel2->setText( tr( "GEOM_PLANE_SIZE" ) );
114 GroupFace->PushButton1->setIcon( image3 );
115 GroupFace->PushButton1->setDown( true );
117 GroupFace->LineEdit1->setReadOnly( true );
119 Group2Vec = new DlgRef_2Sel1Spin( centralWidget() );
121 Group2Vec->GroupBox1->setTitle( tr( "GEOM_WPLANE_VECTOR" ) );
122 Group2Vec->TextLabel1->setText( tr( "GEOM_WPLANE_VX" ) );
123 Group2Vec->TextLabel2->setText( tr( "GEOM_WPLANE_VZ" ) );
124 Group2Vec->PushButton1->setIcon( image3 );
125 Group2Vec->PushButton2->setIcon( image3 );
126 Group2Vec->LineEdit1->setReadOnly( true );
127 Group2Vec->LineEdit2->setReadOnly( true );
128 Group2Vec->PushButton1->setDown( true );
129 Group2Vec->LineEdit1->setEnabled( true );
130 Group2Vec->LineEdit2->setEnabled( false );
131 Group2Vec->TextLabel3->setText( tr( "GEOM_PLANE_SIZE" ) );
133 GroupLCS = new DlgRef_3Radio1Sel1Spin( centralWidget() );
134 GroupLCS->GroupBox1->setTitle( tr( "GEOM_LCS" ) );
135 GroupLCS->TextLabel1->setText( tr( "GEOM_SELECTION" ) );
136 GroupLCS->TextLabel2->setText( tr( "GEOM_PLANE_SIZE" ) );
137 GroupLCS->RadioButton1->setText( tr( "GEOM_WPLANE_OXY" ) );
138 GroupLCS->RadioButton2->setText( tr( "GEOM_WPLANE_OYZ" ) );
139 GroupLCS->RadioButton3->setText( tr( "GEOM_WPLANE_OZX" ) );
140 GroupLCS->PushButton1->setIcon( image3 );
141 GroupLCS->PushButton1->setDown( true );
143 QVBoxLayout* layout = new QVBoxLayout( centralWidget() );
144 layout->setMargin( 0 ); layout->setSpacing( 6 );
145 layout->addWidget( GroupPntDir );
146 layout->addWidget( Group3Pnts );
147 layout->addWidget( GroupFace );
148 layout->addWidget( Group2Vec );
149 layout->addWidget( GroupLCS );
150 /***************************************************************/
152 setHelpFileName( "create_plane_page.html" );
158 //=================================================================================
159 // function : ~BasicGUI_PlaneDlg()
160 // purpose : Destroys the object and frees any allocated resources
161 //=================================================================================
162 BasicGUI_PlaneDlg::~BasicGUI_PlaneDlg()
167 //=================================================================================
170 //=================================================================================
171 void BasicGUI_PlaneDlg::Init()
174 myEditCurrentArgument = GroupPntDir->LineEdit1;
176 myPoint = myDir = myPoint1 = myPoint2 = myPoint3 = myFace = GEOM::GEOM_Object::_nil();
178 // myGeomGUI->SetState( 0 );
181 /* Get setting of step value from file configuration */
182 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
183 double aStep = resMgr->doubleValue( "Geometry", "SettingsGeomStep", 100 );
185 double aTrimSize = 2000.0;
187 /* min, max, step and decimals for spin boxes */
188 initSpinBox( GroupPntDir->SpinBox_DX, 0.000001, COORD_MAX, aStep, "length_precision" );
189 GroupPntDir->SpinBox_DX->setValue( aTrimSize );
190 initSpinBox( Group3Pnts->SpinBox_DX, 0.000001, COORD_MAX, aStep, "length_precision" );
191 Group3Pnts->SpinBox_DX->setValue( aTrimSize );
192 initSpinBox( GroupFace->SpinBox_DX, 0.000001, COORD_MAX, aStep, "length_precision" );
193 GroupFace->SpinBox_DX->setValue( aTrimSize );
194 initSpinBox( Group2Vec->SpinBox_DX, 0.000001, COORD_MAX, aStep, "length_precision" );
195 Group2Vec->SpinBox_DX->setValue( aTrimSize );
196 initSpinBox( GroupLCS->SpinBox_DX, 0.000001, COORD_MAX, aStep, "length_precision" );
197 GroupLCS->SpinBox_DX->setValue( aTrimSize );
199 /* signals and slots connections */
200 connect( myGeomGUI, SIGNAL( SignalDeactivateActiveDialog() ), this, SLOT( DeactivateActiveDialog() ) );
201 connect( myGeomGUI, SIGNAL( SignalCloseAllDialogs() ), this, SLOT( ClickOnCancel() ) );
203 connect( buttonOk(), SIGNAL( clicked() ), this, SLOT( ClickOnOk() ) );
204 connect( buttonApply(), SIGNAL( clicked() ), this, SLOT( ClickOnApply() ) );
206 connect( this, SIGNAL( constructorsClicked( int ) ), this, SLOT( ConstructorsClicked( int ) ) );
208 connect( GroupPntDir->PushButton1, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) );
209 connect( GroupPntDir->PushButton2, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) );
210 connect( Group3Pnts->PushButton1, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) );
211 connect( Group3Pnts->PushButton2, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) );
212 connect( Group3Pnts->PushButton3, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) );
213 connect( GroupFace->PushButton1, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) );
214 connect( Group2Vec->PushButton1, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) );
215 connect( Group2Vec->PushButton2, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) );
217 connect( GroupLCS->RadioButton1, SIGNAL( clicked() ), this, SLOT( GroupClicked() ) );
218 connect( GroupLCS->RadioButton2, SIGNAL( clicked() ), this, SLOT( GroupClicked() ) );
219 connect( GroupLCS->RadioButton3, SIGNAL( clicked() ), this, SLOT( GroupClicked() ) );
221 connect( GroupPntDir->LineEdit1, SIGNAL( returnPressed() ), this, SLOT( LineEditReturnPressed() ) );
222 connect( GroupPntDir->LineEdit2, SIGNAL( returnPressed() ), this, SLOT( LineEditReturnPressed() ) );
223 connect( Group3Pnts->LineEdit1, SIGNAL( returnPressed() ), this, SLOT( LineEditReturnPressed() ) );
224 connect( Group3Pnts->LineEdit2, SIGNAL( returnPressed() ), this, SLOT( LineEditReturnPressed() ) );
225 connect( Group3Pnts->LineEdit3, SIGNAL( returnPressed() ), this, SLOT( LineEditReturnPressed() ) );
226 connect( GroupFace->LineEdit1, SIGNAL( returnPressed() ), this, SLOT( LineEditReturnPressed() ) );
227 connect( Group2Vec->LineEdit1, SIGNAL( returnPressed() ), this, SLOT( LineEditReturnPressed() ) );
228 connect( Group2Vec->LineEdit2, SIGNAL( returnPressed() ), this, SLOT( LineEditReturnPressed() ) );
230 connect( GroupPntDir->SpinBox_DX, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
231 connect( Group3Pnts->SpinBox_DX, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
232 connect( GroupFace->SpinBox_DX, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
233 connect( Group2Vec->SpinBox_DX, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
234 connect( GroupLCS->SpinBox_DX, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
236 connect( myGeomGUI, SIGNAL( SignalDefaultStepValueChanged( double ) ), this, SLOT( SetDoubleSpinBoxStep( double ) ) );
238 connect( myGeomGUI->getApp()->selectionMgr(), SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) );
240 initName( tr( "GEOM_PLANE" ) );
242 ConstructorsClicked( 0 );
245 //=================================================================================
246 // function : SetDoubleSpinBoxStep()
247 // purpose : Double spin box management
248 //=================================================================================
249 void BasicGUI_PlaneDlg::SetDoubleSpinBoxStep( double step )
251 GroupPntDir->SpinBox_DX->setSingleStep(step);
252 Group3Pnts->SpinBox_DX->setSingleStep(step);
253 GroupFace->SpinBox_DX->setSingleStep(step);
254 Group2Vec->SpinBox_DX->setSingleStep(step);
255 GroupLCS->SpinBox_DX->setSingleStep(step);
258 //=================================================================================
259 // function : ConstructorsClicked()
260 // purpose : Radio button management
261 //=================================================================================
262 void BasicGUI_PlaneDlg::ConstructorsClicked( int constructorId )
264 disconnect( myGeomGUI->getApp()->selectionMgr(), 0, this, 0 );
265 myPoint = myDir = myPoint1 = myPoint2 = myPoint3 = myFace = GEOM::GEOM_Object::_nil();
267 switch ( constructorId ) {
268 case 0: /* plane from a point and a direction (vector, edge...) */
276 myEditCurrentArgument = GroupPntDir->LineEdit1;
277 GroupPntDir->LineEdit1->setText( "" );
278 GroupPntDir->LineEdit2->setText( "" );
279 GroupPntDir->PushButton1->setDown( true );
280 GroupPntDir->PushButton2->setDown( false );
281 GroupPntDir->LineEdit1->setEnabled( true );
282 GroupPntDir->LineEdit2->setEnabled( false );
284 /* for the first argument */
285 globalSelection(); // close local contexts, if any
286 localSelection( GEOM::GEOM_Object::_nil(), TopAbs_VERTEX );
289 case 1: /* plane from 3 points */
297 myEditCurrentArgument = Group3Pnts->LineEdit1;
298 Group3Pnts->LineEdit1->setText( "" );
299 Group3Pnts->LineEdit2->setText( "" );
300 Group3Pnts->LineEdit3->setText( "" );
301 Group3Pnts->PushButton1->setDown( true );
302 Group3Pnts->PushButton2->setDown( false );
303 Group3Pnts->PushButton3->setDown( false );
304 Group3Pnts->LineEdit1->setEnabled( true );
305 Group3Pnts->LineEdit2->setEnabled( false );
306 Group3Pnts->LineEdit3->setEnabled( false );
308 /* for the first argument */
309 globalSelection(); // close local contexts, if any
310 localSelection( GEOM::GEOM_Object::_nil(), TopAbs_VERTEX );
313 case 2: /* plane from a planar face */
321 myEditCurrentArgument = GroupFace->LineEdit1;
322 GroupFace->LineEdit1->setText( "" );
323 GroupFace->PushButton1->setDown( true );
325 globalSelection(); // close local contexts, if any
326 localSelection( GEOM::GEOM_Object::_nil(), TopAbs_FACE );
329 case 3: /* plane from a 2 Vectors */
337 myEditCurrentArgument = Group2Vec->LineEdit1;
338 Group2Vec->LineEdit1->setText( "" );
339 Group2Vec->PushButton1->setDown( true );
341 globalSelection(); // close local contexts, if any
342 localSelection( GEOM::GEOM_Object::_nil(), TopAbs_EDGE );
345 case 4: /* plane from a LCS */
353 myEditCurrentArgument = GroupLCS->LineEdit1;
354 GroupLCS->LineEdit1->setText( "" );
355 GroupLCS->PushButton1->setDown( true );
356 GroupLCS->RadioButton1->setChecked( true );
359 globalSelection(GEOM_MARKER);
364 qApp->processEvents();
366 resize( minimumSizeHint() );
367 SelectionIntoArgument();
369 myEditCurrentArgument->setFocus();
370 connect( myGeomGUI->getApp()->selectionMgr(), SIGNAL( currentSelectionChanged() ),
371 this, SLOT( SelectionIntoArgument() ) );
376 //=================================================================================
377 // function : ClickOnOk()
379 //=================================================================================
380 void BasicGUI_PlaneDlg::ClickOnOk()
382 if ( ClickOnApply() )
387 //=================================================================================
388 // function : ClickOnApply()
390 //=================================================================================
391 bool BasicGUI_PlaneDlg::ClickOnApply()
397 ConstructorsClicked( getConstructorId() );
401 //=================================================================================
402 // function : GroupClicked()
403 // purpose : OX OY OZ Radio button management
404 //=================================================================================
405 void BasicGUI_PlaneDlg::GroupClicked()
407 QRadioButton* send = (QRadioButton*)sender();
409 if ( send == GroupLCS->RadioButton1 )
411 else if ( send == GroupLCS->RadioButton2 )
413 else if ( send == GroupLCS->RadioButton3 )
418 //=================================================================================
419 // function : SelectionIntoArgument()
420 // purpose : Called when selection has changed
421 //=================================================================================
422 void BasicGUI_PlaneDlg::SelectionIntoArgument()
424 myEditCurrentArgument->setText("");
426 LightApp_SelectionMgr* aSelMgr = myGeomGUI->getApp()->selectionMgr();
427 SALOME_ListIO aSelList;
428 aSelMgr->selectedObjects(aSelList);
430 if (aSelList.Extent() != 1) {
431 if ( myEditCurrentArgument == GroupPntDir->LineEdit1 ) myPoint = GEOM::GEOM_Object::_nil();
432 else if ( myEditCurrentArgument == GroupPntDir->LineEdit2 ) myDir = GEOM::GEOM_Object::_nil();
433 else if ( myEditCurrentArgument == Group3Pnts->LineEdit1 ) myPoint1 = GEOM::GEOM_Object::_nil();
434 else if ( myEditCurrentArgument == Group3Pnts->LineEdit2 ) myPoint2 = GEOM::GEOM_Object::_nil();
435 else if ( myEditCurrentArgument == Group3Pnts->LineEdit3 ) myPoint3 = GEOM::GEOM_Object::_nil();
436 else if ( myEditCurrentArgument == GroupFace->LineEdit1 ) myFace = GEOM::GEOM_Object::_nil();
437 else if ( myEditCurrentArgument == Group2Vec->LineEdit1 ) myVec1 = GEOM::GEOM_Object::_nil();
438 else if ( myEditCurrentArgument == Group2Vec->LineEdit2 ) myVec2 = GEOM::GEOM_Object::_nil();
439 else if ( myEditCurrentArgument == GroupLCS->LineEdit1 ) myLCS = GEOM::GEOM_Object::_nil();
445 Standard_Boolean aRes = Standard_False;
446 GEOM::GEOM_Object_var aSelectedObject = GEOMBase::ConvertIOinGEOMObject(aSelList.First(), aRes);
447 if ( !CORBA::is_nil( aSelectedObject ) && aRes ) {
448 QString aName = GEOMBase::GetName( aSelectedObject );
449 TopAbs_ShapeEnum aNeedType = TopAbs_VERTEX;
450 if ( myEditCurrentArgument == GroupPntDir->LineEdit2 || myEditCurrentArgument == Group2Vec->LineEdit1 || myEditCurrentArgument == Group2Vec->LineEdit2)
451 aNeedType = TopAbs_EDGE;
452 else if ( myEditCurrentArgument == GroupFace->LineEdit1 )
453 aNeedType = TopAbs_FACE;
454 else if ( myEditCurrentArgument == GroupLCS->LineEdit1 )
455 aNeedType = TopAbs_FACE;
458 if ( GEOMBase::GetShape( aSelectedObject, aShape, TopAbs_SHAPE ) && !aShape.IsNull() ) {
459 TColStd_IndexedMapOfInteger aMap;
460 aSelMgr->GetIndexes(aSelList.First(), aMap);
461 if ( aMap.Extent() == 1 ) { // Local Selection
462 int anIndex = aMap( 1 );
463 if ( aNeedType == TopAbs_EDGE )
464 aName += QString( ":edge_%1" ).arg( anIndex );
465 else if (aNeedType == TopAbs_FACE)
466 aName += QString( ":face_%1" ).arg( anIndex );
468 aName += QString( ":vertex_%1" ).arg( anIndex );
470 //Find SubShape Object in Father
471 GEOM::GEOM_Object_var aFindedObject = GEOMBase_Helper::findObjectInFather( aSelectedObject, aName );
473 if ( aFindedObject->_is_nil() ) { // Object not found in study
474 GEOM::GEOM_IShapesOperations_var aShapesOp = getGeomEngine()->GetIShapesOperations( getStudyId() );
475 aSelectedObject = aShapesOp->GetSubShape( aSelectedObject, anIndex );
478 aSelectedObject = aFindedObject; // get Object from study
481 else { // Global Selection
482 if ( aShape.ShapeType() != aNeedType ) {
483 aSelectedObject = GEOM::GEOM_Object::_nil();
489 myEditCurrentArgument->setText( aName );
491 /* if (!aSelectedObject->_is_nil()) { // clear selection if something selected
493 if ( myEditCurrentArgument == GroupFace->LineEdit1 ) {
494 TColStd_MapOfInteger aMap;
495 aMap.Add( GEOM_PLANE );
496 aMap.Add( GEOM_MARKER );
497 globalSelection( aMap );
500 localSelection( GEOM::GEOM_Object::_nil(), aNeedType );
503 if ( myEditCurrentArgument == GroupPntDir->LineEdit1 ) {
504 myPoint = aSelectedObject;
505 if ( !myPoint->_is_nil() && myDir->_is_nil() )
506 GroupPntDir->PushButton2->click();
508 else if ( myEditCurrentArgument == GroupPntDir->LineEdit2 ) {
509 myDir = aSelectedObject;
510 if ( !myDir->_is_nil() && myPoint->_is_nil() )
511 GroupPntDir->PushButton1->click();
513 else if ( myEditCurrentArgument == Group3Pnts->LineEdit1 ) {
514 myPoint1 = aSelectedObject;
515 if ( !myPoint1->_is_nil() && myPoint2->_is_nil() )
516 Group3Pnts->PushButton2->click();
518 else if ( myEditCurrentArgument == Group3Pnts->LineEdit2 ) {
519 myPoint2 = aSelectedObject;
520 if ( !myPoint2->_is_nil() && myPoint3->_is_nil() )
521 Group3Pnts->PushButton3->click();
523 else if ( myEditCurrentArgument == Group3Pnts->LineEdit3 ) {
524 myPoint3 = aSelectedObject;
525 if ( !myPoint3->_is_nil() && myPoint1->_is_nil() )
526 Group3Pnts->PushButton1->click();
528 else if ( myEditCurrentArgument == GroupFace->LineEdit1 )
529 myFace = aSelectedObject;
530 else if ( myEditCurrentArgument == Group2Vec->LineEdit1 ) {
531 myVec1 = aSelectedObject;
532 if ( !myVec1->_is_nil() && myVec2->_is_nil() )
533 Group2Vec->PushButton2->click();
534 } else if ( myEditCurrentArgument == Group2Vec->LineEdit2 ) {
535 myVec2 = aSelectedObject;
536 if ( !myVec2->_is_nil() && myVec1->_is_nil() )
537 Group2Vec->PushButton1->click();
538 } else if ( myEditCurrentArgument == GroupLCS->LineEdit1 )
539 myLCS = aSelectedObject;
547 //=================================================================================
548 // function : SetEditCurrentArgument()
550 //=================================================================================
551 void BasicGUI_PlaneDlg::SetEditCurrentArgument()
553 QPushButton* send = (QPushButton*)sender();
554 globalSelection( GEOM_POINT );
556 if ( send == GroupPntDir->PushButton1 ) {
557 myEditCurrentArgument = GroupPntDir->LineEdit1;
558 GroupPntDir->PushButton2->setDown( false );
559 GroupPntDir->LineEdit1->setEnabled( true );
560 GroupPntDir->LineEdit2->setEnabled( false );
562 else if ( send == GroupPntDir->PushButton2 ) {
563 myEditCurrentArgument = GroupPntDir->LineEdit2;
564 GroupPntDir->PushButton1->setDown( false );
565 GroupPntDir->LineEdit1->setEnabled( false );
566 GroupPntDir->LineEdit2->setEnabled( true );
568 else if ( send == Group3Pnts->PushButton1 ) {
569 myEditCurrentArgument = Group3Pnts->LineEdit1;
570 Group3Pnts->PushButton2->setDown( false );
571 Group3Pnts->PushButton3->setDown( false );
572 Group3Pnts->LineEdit1->setEnabled( true );
573 Group3Pnts->LineEdit2->setEnabled( false );
574 Group3Pnts->LineEdit3->setEnabled( false );
576 else if ( send == Group3Pnts->PushButton2 ) {
577 myEditCurrentArgument = Group3Pnts->LineEdit2;
578 Group3Pnts->PushButton1->setDown( false );
579 Group3Pnts->PushButton3->setDown( false );
580 Group3Pnts->LineEdit1->setEnabled( false );
581 Group3Pnts->LineEdit2->setEnabled( true );
582 Group3Pnts->LineEdit3->setEnabled( false );
584 else if ( send == Group3Pnts->PushButton3 ) {
585 myEditCurrentArgument = Group3Pnts->LineEdit3;
586 Group3Pnts->PushButton1->setDown( false );
587 Group3Pnts->PushButton2->setDown( false );
588 Group3Pnts->LineEdit1->setEnabled( false );
589 Group3Pnts->LineEdit2->setEnabled( false );
590 Group3Pnts->LineEdit3->setEnabled( true );
592 else if ( send == GroupFace->PushButton1 ) {
593 myEditCurrentArgument = GroupFace->LineEdit1;
594 GroupFace->PushButton1->setDown( true );
595 } else if ( send == Group2Vec->PushButton1 ) {
596 myEditCurrentArgument = Group2Vec->LineEdit1;
597 Group2Vec->PushButton2->setDown( false );
598 Group2Vec->LineEdit1->setEnabled( true );
599 Group2Vec->LineEdit2->setEnabled( false );
600 } else if ( send == Group2Vec->PushButton2 ) {
601 myEditCurrentArgument = Group2Vec->LineEdit2;
602 Group2Vec->PushButton1->setDown( false );
603 Group2Vec->LineEdit1->setEnabled( false );
604 Group2Vec->LineEdit2->setEnabled( true );
605 } else if ( send == GroupLCS->PushButton1 ) {
606 myEditCurrentArgument = GroupLCS->LineEdit1;
607 GroupLCS->LineEdit1->setEnabled( true );
610 myEditCurrentArgument->setFocus();
612 if ( myEditCurrentArgument == GroupPntDir->LineEdit2 ||
613 myEditCurrentArgument == Group2Vec->LineEdit1 ||
614 myEditCurrentArgument == Group2Vec->LineEdit2 ) {
615 localSelection( GEOM::GEOM_Object::_nil(), TopAbs_EDGE );
616 } else if ( myEditCurrentArgument == GroupFace->LineEdit1 ) {
617 TColStd_MapOfInteger aMap;
618 aMap.Add( GEOM_PLANE );
619 aMap.Add( GEOM_MARKER );
620 globalSelection( aMap );
621 } else if ( myEditCurrentArgument == GroupLCS->LineEdit1 ) {
622 globalSelection( GEOM_MARKER );
625 localSelection( GEOM::GEOM_Object::_nil(), TopAbs_VERTEX );
628 // SelectionIntoArgument();
629 myEditCurrentArgument->setFocus();
635 //=================================================================================
636 // function : LineEditReturnPressed()
638 //=================================================================================
639 void BasicGUI_PlaneDlg::LineEditReturnPressed()
641 QLineEdit* send = (QLineEdit*)sender();
642 if ( send == GroupPntDir->LineEdit1 ||
643 send == GroupPntDir->LineEdit2 ||
644 send == Group3Pnts->LineEdit1 ||
645 send == Group3Pnts->LineEdit2 ||
646 send == Group3Pnts->LineEdit3 ||
647 send == GroupFace->LineEdit1 ||
648 send == Group2Vec->LineEdit1 ||
649 send == Group2Vec->LineEdit2 ||
650 send == GroupLCS->LineEdit1 ) {
651 myEditCurrentArgument = send;
652 GEOMBase_Skeleton::LineEditReturnPressed();
657 //=================================================================================
658 // function : ActivateThisDialog()
660 //=================================================================================
661 void BasicGUI_PlaneDlg::ActivateThisDialog()
663 GEOMBase_Skeleton::ActivateThisDialog();
664 connect( myGeomGUI->getApp()->selectionMgr(), SIGNAL( currentSelectionChanged() ),
665 this, SLOT( SelectionIntoArgument() ) );
667 ConstructorsClicked( getConstructorId() );
668 SelectionIntoArgument();
671 //=================================================================================
672 // function : DeactivateActiveDialog()
673 // purpose : public slot to deactivate if active
674 //=================================================================================
675 void BasicGUI_PlaneDlg::DeactivateActiveDialog()
677 GEOMBase_Skeleton::DeactivateActiveDialog();
680 //=================================================================================
681 // function : enterEvent()
683 //=================================================================================
684 void BasicGUI_PlaneDlg::enterEvent( QEvent* )
686 if ( !mainFrame()->GroupConstructors->isEnabled() )
687 ActivateThisDialog();
691 //=================================================================================
692 // function : ValueChangedInSpinBox()
694 //=================================================================================
695 void BasicGUI_PlaneDlg::ValueChangedInSpinBox( double newValue )
700 //=================================================================================
701 // function : getSize()
703 //=================================================================================
704 double BasicGUI_PlaneDlg::getSize() const
706 switch ( getConstructorId() ) {
707 case 0 : return GroupPntDir->SpinBox_DX->value();
708 case 1 : return Group3Pnts->SpinBox_DX->value();
709 case 2 : return GroupFace->SpinBox_DX->value();
710 case 3 : return Group2Vec->SpinBox_DX->value();
711 case 4 : return GroupLCS->SpinBox_DX->value();
716 //=================================================================================
717 // function : getSize()
719 //=================================================================================
720 QString BasicGUI_PlaneDlg::getSizeAsString() const
722 switch ( getConstructorId() ) {
723 case 0 : return GroupPntDir->SpinBox_DX->text();
724 case 1 : return Group3Pnts->SpinBox_DX->text();
725 case 2 : return GroupFace->SpinBox_DX->text();
726 case 3 : return Group2Vec->SpinBox_DX->text();
731 //=================================================================================
732 // function : createOperation
734 //=================================================================================
735 GEOM::GEOM_IOperations_ptr BasicGUI_PlaneDlg::createOperation()
737 return myGeomGUI->GetGeomGen()->GetIBasicOperations( getStudyId() );
740 //=================================================================================
741 // function : isEqual
742 // purpose : it may also be needed to check for min distance between gp_Pnt-s...
743 //=================================================================================
744 static bool isEqual( const GEOM::GEOM_Object_var& thePnt1, const GEOM::GEOM_Object_var& thePnt2 )
746 return thePnt1->_is_equivalent( thePnt2 );
749 //=================================================================================
750 // function : isValid
752 //=================================================================================
753 bool BasicGUI_PlaneDlg::isValid( QString& msg )
755 const int id = getConstructorId();
756 if ( getSize() <= 0 ) {
757 msg = QString( "Please, enter size greater than 0." );
762 bool ok = GroupPntDir->SpinBox_DX->isValid( msg, !IsPreview() );
763 return !CORBA::is_nil( myPoint ) && !CORBA::is_nil( myDir ) && ok;
765 else if ( id == 1 ) {
766 bool ok = Group3Pnts->SpinBox_DX->isValid( msg, !IsPreview() );
767 return !CORBA::is_nil( myPoint1 ) && !CORBA::is_nil( myPoint2 ) && !CORBA::is_nil( myPoint3 ) &&
768 !isEqual( myPoint1, myPoint2 ) && !isEqual( myPoint1, myPoint3 ) && !isEqual( myPoint2, myPoint3 ) && ok;
770 else if ( id == 2 ) {
771 bool ok = GroupFace->SpinBox_DX->isValid( msg, !IsPreview() );
772 return !CORBA::is_nil( myFace ) && ok;
773 } else if ( id == 3 ) {
774 bool ok = Group2Vec->SpinBox_DX->isValid( msg, !IsPreview() );
775 return !CORBA::is_nil( myVec1 ) && !CORBA::is_nil( myVec2 ) && !isEqual( myVec1, myVec2 ) && ok;
776 } else if ( id == 4 ) {
777 bool ok = GroupLCS->SpinBox_DX->isValid( msg, !IsPreview() );
783 //=================================================================================
784 // function : execute
786 //=================================================================================
787 bool BasicGUI_PlaneDlg::execute( ObjectList& objects )
791 GEOM::GEOM_Object_var anObj;
793 GEOM::GEOM_IBasicOperations_var anOper = GEOM::GEOM_IBasicOperations::_narrow( getOperation() );
795 switch ( getConstructorId() ) {
797 anObj = anOper->MakePlanePntVec( myPoint, myDir, getSize() );
801 anObj = anOper->MakePlaneThreePnt( myPoint1, myPoint2, myPoint3, getSize() );
805 anObj = anOper->MakePlaneFace( myFace, getSize() );
809 anObj = anOper->MakePlane2Vec( myVec1, myVec2, getSize() );
813 anObj = anOper->MakePlaneLCS( myLCS, getSize(), myOriginType );
818 if ( !anObj->_is_nil() ) {
820 anObj->SetParameters(getSizeAsString().toLatin1().constData());
821 objects.push_back( anObj._retn() );
825 //=================================================================================
826 // function : addSubshapeToStudy
827 // purpose : virtual method to add new SubObjects if local selection
828 //=================================================================================
829 void BasicGUI_PlaneDlg::addSubshapesToStudy()
831 QMap<QString, GEOM::GEOM_Object_var> objMap;
833 switch ( getConstructorId() ) {
835 objMap[GroupPntDir->LineEdit1->text()] = myPoint;
836 objMap[GroupPntDir->LineEdit2->text()] = myDir;
839 objMap[Group3Pnts->LineEdit1->text()] = myPoint1;
840 objMap[Group3Pnts->LineEdit2->text()] = myPoint2;
841 objMap[Group3Pnts->LineEdit3->text()] = myPoint3;
844 objMap[GroupFace->LineEdit1->text()] = myFace;
847 objMap[Group2Vec->LineEdit1->text()] = myVec1;
848 objMap[Group2Vec->LineEdit2->text()] = myVec2;
851 addSubshapesToFather( objMap );