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" ) ) );
63 QPixmap image4( SUIT_Session::session()->resourceMgr()->loadPixmap( "GEOM", tr( "ICON_DLG_WPLANE_VECTOR" ) ) );
64 QPixmap image5( SUIT_Session::session()->resourceMgr()->loadPixmap( "GEOM", tr( "ICON_DLG_WPLANE_ORIGIN" ) ) );
66 setWindowTitle( tr( "GEOM_PLANE_TITLE" ) );
68 /***************************************************************/
69 mainFrame()->GroupConstructors->setTitle( tr( "GEOM_PLANE" ) );
70 mainFrame()->RadioButton1->setIcon( image0 );
71 mainFrame()->RadioButton2->setIcon( image1 );
72 mainFrame()->RadioButton3->setIcon( image2 );
73 mainFrame()->RadioButton4->show();
74 mainFrame()->RadioButton4->setIcon( image4 );
75 mainFrame()->RadioButton5->show();
76 mainFrame()->RadioButton5->setIcon( image5 );
78 GroupPntDir = new DlgRef_2Sel1Spin( centralWidget() );
79 GroupPntDir->GroupBox1->setTitle( tr( "GEOM_PLANE_PV" ) );
80 GroupPntDir->TextLabel1->setText( tr( "GEOM_POINT" ) );
81 GroupPntDir->TextLabel2->setText( tr( "GEOM_VECTOR" ) );
82 GroupPntDir->TextLabel3->setText( tr( "GEOM_PLANE_SIZE" ) );
83 GroupPntDir->PushButton1->setIcon( image3 );
84 GroupPntDir->PushButton2->setIcon( image3 );
85 GroupPntDir->LineEdit1->setReadOnly( true );
86 GroupPntDir->LineEdit2->setReadOnly( true );
87 GroupPntDir->PushButton1->setDown( true );
88 GroupPntDir->LineEdit1->setEnabled( true );
89 GroupPntDir->LineEdit2->setEnabled( false );
91 Group3Pnts = new DlgRef_3Sel1Spin( centralWidget() );
92 Group3Pnts->GroupBox1->setTitle( tr( "GEOM_3_POINTS" ) );
93 Group3Pnts->TextLabel1->setText( tr( "GEOM_POINT1" ) );
94 Group3Pnts->TextLabel2->setText( tr( "GEOM_POINT2" ) );
95 Group3Pnts->TextLabel3->setText( tr( "GEOM_POINT3" ) );
96 Group3Pnts->TextLabel4->setText( tr( "GEOM_PLANE_SIZE" ) );
97 Group3Pnts->PushButton1->setIcon( image3 );
98 Group3Pnts->PushButton2->setIcon( image3 );
99 Group3Pnts->PushButton3->setIcon( image3 );
100 Group3Pnts->PushButton1->setDown( true );
102 Group3Pnts->LineEdit1->setReadOnly( true );
103 Group3Pnts->LineEdit2->setReadOnly( true );
104 Group3Pnts->LineEdit3->setReadOnly( true );
105 Group3Pnts->LineEdit1->setEnabled( true );
106 Group3Pnts->LineEdit2->setEnabled( false );
107 Group3Pnts->LineEdit3->setEnabled( false );
109 GroupFace = new DlgRef_1Sel1Spin( centralWidget() );
110 GroupFace->GroupBox1->setTitle( tr( "GEOM_FACE" ) );
111 GroupFace->TextLabel1->setText( tr( "GEOM_SELECTION" ) );
112 GroupFace->TextLabel2->setText( tr( "GEOM_PLANE_SIZE" ) );
113 GroupFace->PushButton1->setIcon( image3 );
114 GroupFace->PushButton1->setDown( true );
116 GroupFace->LineEdit1->setReadOnly( true );
118 Group2Vec = new DlgRef_2Sel1Spin( centralWidget() );
120 Group2Vec->GroupBox1->setTitle( tr( "GEOM_WPLANE_VECTOR" ) );
121 Group2Vec->TextLabel1->setText( tr( "GEOM_WPLANE_VX" ) );
122 Group2Vec->TextLabel2->setText( tr( "GEOM_WPLANE_VZ" ) );
123 Group2Vec->PushButton1->setIcon( image3 );
124 Group2Vec->PushButton2->setIcon( image3 );
125 Group2Vec->LineEdit1->setReadOnly( true );
126 Group2Vec->LineEdit2->setReadOnly( true );
127 Group2Vec->PushButton1->setDown( true );
128 Group2Vec->LineEdit1->setEnabled( true );
129 Group2Vec->LineEdit2->setEnabled( false );
130 Group2Vec->TextLabel3->setText( tr( "GEOM_PLANE_SIZE" ) );
132 GroupLCS = new DlgRef_3Radio1Sel1Spin( centralWidget() );
133 GroupLCS->GroupBox1->setTitle( tr( "GEOM_LCS" ) );
134 GroupLCS->TextLabel1->setText( tr( "GEOM_SELECTION" ) );
135 GroupLCS->TextLabel2->setText( tr( "GEOM_PLANE_SIZE" ) );
136 GroupLCS->RadioButton1->setText( tr( "GEOM_WPLANE_OXY" ) );
137 GroupLCS->RadioButton2->setText( tr( "GEOM_WPLANE_OYZ" ) );
138 GroupLCS->RadioButton3->setText( tr( "GEOM_WPLANE_OZX" ) );
139 GroupLCS->PushButton1->setIcon( image3 );
140 GroupLCS->PushButton1->setDown( true );
142 QVBoxLayout* layout = new QVBoxLayout( centralWidget() );
143 layout->setMargin( 0 ); layout->setSpacing( 6 );
144 layout->addWidget( GroupPntDir );
145 layout->addWidget( Group3Pnts );
146 layout->addWidget( GroupFace );
147 layout->addWidget( Group2Vec );
148 layout->addWidget( GroupLCS );
149 /***************************************************************/
151 setHelpFileName( "create_plane_page.html" );
157 //=================================================================================
158 // function : ~BasicGUI_PlaneDlg()
159 // purpose : Destroys the object and frees any allocated resources
160 //=================================================================================
161 BasicGUI_PlaneDlg::~BasicGUI_PlaneDlg()
166 //=================================================================================
169 //=================================================================================
170 void BasicGUI_PlaneDlg::Init()
173 myEditCurrentArgument = GroupPntDir->LineEdit1;
175 myPoint = myDir = myPoint1 = myPoint2 = myPoint3 = myFace = GEOM::GEOM_Object::_nil();
177 // myGeomGUI->SetState( 0 );
180 /* Get setting of step value from file configuration */
181 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
182 double aStep = resMgr->doubleValue( "Geometry", "SettingsGeomStep", 100 );
184 double aTrimSize = 2000.0;
186 /* min, max, step and decimals for spin boxes */
187 initSpinBox( GroupPntDir->SpinBox_DX, 0.000001, COORD_MAX, aStep, 6 ); // VSR: TODO: DBL_DIGITS_DISPLAY
188 GroupPntDir->SpinBox_DX->setValue( aTrimSize );
189 initSpinBox( Group3Pnts->SpinBox_DX, 0.000001, COORD_MAX, aStep, 6 ); // VSR: TODO: DBL_DIGITS_DISPLAY
190 Group3Pnts->SpinBox_DX->setValue( aTrimSize );
191 initSpinBox( GroupFace->SpinBox_DX, 0.000001, COORD_MAX, aStep, 6 ); // VSR: TODO: DBL_DIGITS_DISPLAY
192 GroupFace->SpinBox_DX->setValue( aTrimSize );
193 initSpinBox( Group2Vec->SpinBox_DX, 0.000001, COORD_MAX, aStep, 6 ); // VSR: TODO: DBL_DIGITS_DISPLAY
194 Group2Vec->SpinBox_DX->setValue( aTrimSize );
195 initSpinBox( GroupLCS->SpinBox_DX, 0.000001, COORD_MAX, aStep, 6 ); // VSR: TODO: DBL_DIGITS_DISPLAY
196 GroupLCS->SpinBox_DX->setValue( aTrimSize );
198 /* signals and slots connections */
199 connect( myGeomGUI, SIGNAL( SignalDeactivateActiveDialog() ), this, SLOT( DeactivateActiveDialog() ) );
200 connect( myGeomGUI, SIGNAL( SignalCloseAllDialogs() ), this, SLOT( ClickOnCancel() ) );
202 connect( buttonOk(), SIGNAL( clicked() ), this, SLOT( ClickOnOk() ) );
203 connect( buttonApply(), SIGNAL( clicked() ), this, SLOT( ClickOnApply() ) );
205 connect( this, SIGNAL( constructorsClicked( int ) ), this, SLOT( ConstructorsClicked( int ) ) );
207 connect( GroupPntDir->PushButton1, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) );
208 connect( GroupPntDir->PushButton2, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) );
209 connect( Group3Pnts->PushButton1, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) );
210 connect( Group3Pnts->PushButton2, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) );
211 connect( Group3Pnts->PushButton3, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) );
212 connect( GroupFace->PushButton1, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) );
213 connect( Group2Vec->PushButton1, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) );
214 connect( Group2Vec->PushButton2, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) );
216 connect( GroupLCS->RadioButton1, SIGNAL( clicked() ), this, SLOT( GroupClicked() ) );
217 connect( GroupLCS->RadioButton2, SIGNAL( clicked() ), this, SLOT( GroupClicked() ) );
218 connect( GroupLCS->RadioButton3, SIGNAL( clicked() ), this, SLOT( GroupClicked() ) );
220 connect( GroupPntDir->LineEdit1, SIGNAL( returnPressed() ), this, SLOT( LineEditReturnPressed() ) );
221 connect( GroupPntDir->LineEdit2, SIGNAL( returnPressed() ), this, SLOT( LineEditReturnPressed() ) );
222 connect( Group3Pnts->LineEdit1, SIGNAL( returnPressed() ), this, SLOT( LineEditReturnPressed() ) );
223 connect( Group3Pnts->LineEdit2, SIGNAL( returnPressed() ), this, SLOT( LineEditReturnPressed() ) );
224 connect( Group3Pnts->LineEdit3, SIGNAL( returnPressed() ), this, SLOT( LineEditReturnPressed() ) );
225 connect( GroupFace->LineEdit1, SIGNAL( returnPressed() ), this, SLOT( LineEditReturnPressed() ) );
226 connect( Group2Vec->LineEdit1, SIGNAL( returnPressed() ), this, SLOT( LineEditReturnPressed() ) );
227 connect( Group2Vec->LineEdit2, SIGNAL( returnPressed() ), this, SLOT( LineEditReturnPressed() ) );
229 connect( GroupPntDir->SpinBox_DX, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
230 connect( Group3Pnts->SpinBox_DX, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
231 connect( GroupFace->SpinBox_DX, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
232 connect( Group2Vec->SpinBox_DX, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
233 connect( GroupLCS->SpinBox_DX, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
235 connect( myGeomGUI, SIGNAL( SignalDefaultStepValueChanged( double ) ), this, SLOT( SetDoubleSpinBoxStep( double ) ) );
237 connect( myGeomGUI->getApp()->selectionMgr(), SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) );
239 initName( tr( "GEOM_PLANE" ) );
241 ConstructorsClicked( 0 );
244 //=================================================================================
245 // function : SetDoubleSpinBoxStep()
246 // purpose : Double spin box management
247 //=================================================================================
248 void BasicGUI_PlaneDlg::SetDoubleSpinBoxStep( double step )
250 GroupPntDir->SpinBox_DX->setSingleStep(step);
251 Group3Pnts->SpinBox_DX->setSingleStep(step);
252 GroupFace->SpinBox_DX->setSingleStep(step);
253 Group2Vec->SpinBox_DX->setSingleStep(step);
254 GroupLCS->SpinBox_DX->setSingleStep(step);
257 //=================================================================================
258 // function : ConstructorsClicked()
259 // purpose : Radio button management
260 //=================================================================================
261 void BasicGUI_PlaneDlg::ConstructorsClicked( int constructorId )
263 disconnect( myGeomGUI->getApp()->selectionMgr(), 0, this, 0 );
264 myPoint = myDir = myPoint1 = myPoint2 = myPoint3 = myFace = GEOM::GEOM_Object::_nil();
266 switch ( constructorId ) {
267 case 0: /* plane from a point and a direction (vector, edge...) */
275 myEditCurrentArgument = GroupPntDir->LineEdit1;
276 GroupPntDir->LineEdit1->setText( "" );
277 GroupPntDir->LineEdit2->setText( "" );
278 GroupPntDir->PushButton1->setDown( true );
279 GroupPntDir->PushButton2->setDown( false );
280 GroupPntDir->LineEdit1->setEnabled( true );
281 GroupPntDir->LineEdit2->setEnabled( false );
283 /* for the first argument */
284 globalSelection(); // close local contexts, if any
285 localSelection( GEOM::GEOM_Object::_nil(), TopAbs_VERTEX );
288 case 1: /* plane from 3 points */
296 myEditCurrentArgument = Group3Pnts->LineEdit1;
297 Group3Pnts->LineEdit1->setText( "" );
298 Group3Pnts->LineEdit2->setText( "" );
299 Group3Pnts->LineEdit3->setText( "" );
300 Group3Pnts->PushButton1->setDown( true );
301 Group3Pnts->PushButton2->setDown( false );
302 Group3Pnts->PushButton3->setDown( false );
303 Group3Pnts->LineEdit1->setEnabled( true );
304 Group3Pnts->LineEdit2->setEnabled( false );
305 Group3Pnts->LineEdit3->setEnabled( false );
307 /* for the first argument */
308 globalSelection(); // close local contexts, if any
309 localSelection( GEOM::GEOM_Object::_nil(), TopAbs_VERTEX );
312 case 2: /* plane from a planar face */
320 myEditCurrentArgument = GroupFace->LineEdit1;
321 GroupFace->LineEdit1->setText( "" );
322 GroupFace->PushButton1->setDown( true );
324 globalSelection(); // close local contexts, if any
325 localSelection( GEOM::GEOM_Object::_nil(), TopAbs_FACE );
328 case 3: /* plane from a 2 Vectors */
336 myEditCurrentArgument = Group2Vec->LineEdit1;
337 Group2Vec->LineEdit1->setText( "" );
338 Group2Vec->PushButton1->setDown( true );
340 globalSelection(); // close local contexts, if any
341 localSelection( GEOM::GEOM_Object::_nil(), TopAbs_EDGE );
344 case 4: /* plane from a LCS */
352 myEditCurrentArgument = GroupLCS->LineEdit1;
353 GroupLCS->LineEdit1->setText( "" );
354 GroupLCS->PushButton1->setDown( true );
355 GroupLCS->RadioButton1->setChecked( true );
358 globalSelection(GEOM_MARKER);
363 qApp->processEvents();
365 resize( minimumSizeHint() );
367 myEditCurrentArgument->setFocus();
368 connect( myGeomGUI->getApp()->selectionMgr(), SIGNAL( currentSelectionChanged() ),
369 this, SLOT( SelectionIntoArgument() ) );
374 //=================================================================================
375 // function : ClickOnOk()
377 //=================================================================================
378 void BasicGUI_PlaneDlg::ClickOnOk()
380 if ( ClickOnApply() )
385 //=================================================================================
386 // function : ClickOnApply()
388 //=================================================================================
389 bool BasicGUI_PlaneDlg::ClickOnApply()
395 ConstructorsClicked( getConstructorId() );
399 //=================================================================================
400 // function : GroupClicked()
401 // purpose : OX OY OZ Radio button management
402 //=================================================================================
403 void BasicGUI_PlaneDlg::GroupClicked()
405 QRadioButton* send = (QRadioButton*)sender();
407 if ( send == GroupLCS->RadioButton1 )
409 else if ( send == GroupLCS->RadioButton2 )
411 else if ( send == GroupLCS->RadioButton3 )
416 //=================================================================================
417 // function : SelectionIntoArgument()
418 // purpose : Called when selection has changed
419 //=================================================================================
420 void BasicGUI_PlaneDlg::SelectionIntoArgument()
422 myEditCurrentArgument->setText("");
424 LightApp_SelectionMgr* aSelMgr = myGeomGUI->getApp()->selectionMgr();
425 SALOME_ListIO aSelList;
426 aSelMgr->selectedObjects(aSelList);
428 if (aSelList.Extent() != 1) {
429 if ( myEditCurrentArgument == GroupPntDir->LineEdit1 ) myPoint = GEOM::GEOM_Object::_nil();
430 else if ( myEditCurrentArgument == GroupPntDir->LineEdit2 ) myDir = GEOM::GEOM_Object::_nil();
431 else if ( myEditCurrentArgument == Group3Pnts->LineEdit1 ) myPoint1 = GEOM::GEOM_Object::_nil();
432 else if ( myEditCurrentArgument == Group3Pnts->LineEdit2 ) myPoint2 = GEOM::GEOM_Object::_nil();
433 else if ( myEditCurrentArgument == Group3Pnts->LineEdit3 ) myPoint3 = GEOM::GEOM_Object::_nil();
434 else if ( myEditCurrentArgument == GroupFace->LineEdit1 ) myFace = GEOM::GEOM_Object::_nil();
435 else if ( myEditCurrentArgument == Group2Vec->LineEdit1 ) myVec1 = GEOM::GEOM_Object::_nil();
436 else if ( myEditCurrentArgument == Group2Vec->LineEdit2 ) myVec2 = GEOM::GEOM_Object::_nil();
437 else if ( myEditCurrentArgument == GroupLCS->LineEdit1 ) myLCS = GEOM::GEOM_Object::_nil();
443 Standard_Boolean aRes = Standard_False;
444 GEOM::GEOM_Object_var aSelectedObject = GEOMBase::ConvertIOinGEOMObject(aSelList.First(), aRes);
445 if ( !CORBA::is_nil( aSelectedObject ) && aRes ) {
446 QString aName = GEOMBase::GetName( aSelectedObject );
447 TopAbs_ShapeEnum aNeedType = TopAbs_VERTEX;
448 if ( myEditCurrentArgument == GroupPntDir->LineEdit2 || myEditCurrentArgument == Group2Vec->LineEdit1 || myEditCurrentArgument == Group2Vec->LineEdit2)
449 aNeedType = TopAbs_EDGE;
450 else if ( myEditCurrentArgument == GroupFace->LineEdit1 )
451 aNeedType = TopAbs_FACE;
452 else if ( myEditCurrentArgument == GroupLCS->LineEdit1 )
453 aNeedType = TopAbs_FACE;
456 if ( GEOMBase::GetShape( aSelectedObject, aShape, TopAbs_SHAPE ) && !aShape.IsNull() ) {
457 TColStd_IndexedMapOfInteger aMap;
458 aSelMgr->GetIndexes(aSelList.First(), aMap);
459 if ( aMap.Extent() == 1 ) { // Local Selection
460 int anIndex = aMap( 1 );
461 if ( aNeedType == TopAbs_EDGE )
462 aName += QString( ":edge_%1" ).arg( anIndex );
463 else if (aNeedType == TopAbs_FACE)
464 aName += QString( ":face_%1" ).arg( anIndex );
466 aName += QString( ":vertex_%1" ).arg( anIndex );
468 //Find SubShape Object in Father
469 GEOM::GEOM_Object_var aFindedObject = GEOMBase_Helper::findObjectInFather( aSelectedObject, aName );
471 if ( aFindedObject == GEOM::GEOM_Object::_nil() ) { // Object not found in study
472 GEOM::GEOM_IShapesOperations_var aShapesOp = getGeomEngine()->GetIShapesOperations( getStudyId() );
473 aSelectedObject = aShapesOp->GetSubShape( aSelectedObject, anIndex );
476 aSelectedObject = aFindedObject; // get Object from study
479 else { // Global Selection
480 if ( aShape.ShapeType() != aNeedType ) {
481 aSelectedObject = GEOM::GEOM_Object::_nil();
487 myEditCurrentArgument->setText( aName );
489 /* if (!aSelectedObject->_is_nil()) { // clear selection if something selected
491 if ( myEditCurrentArgument == GroupFace->LineEdit1 ) {
492 TColStd_MapOfInteger aMap;
493 aMap.Add( GEOM_PLANE );
494 aMap.Add( GEOM_MARKER );
495 globalSelection( aMap );
498 localSelection( GEOM::GEOM_Object::_nil(), aNeedType );
501 if ( myEditCurrentArgument == GroupPntDir->LineEdit1 ) {
502 myPoint = aSelectedObject;
503 if ( !myPoint->_is_nil() && myDir->_is_nil() )
504 GroupPntDir->PushButton2->click();
506 else if ( myEditCurrentArgument == GroupPntDir->LineEdit2 ) {
507 myDir = aSelectedObject;
508 if ( !myDir->_is_nil() && myPoint->_is_nil() )
509 GroupPntDir->PushButton1->click();
511 else if ( myEditCurrentArgument == Group3Pnts->LineEdit1 ) {
512 myPoint1 = aSelectedObject;
513 if ( !myPoint1->_is_nil() && myPoint2->_is_nil() )
514 Group3Pnts->PushButton2->click();
516 else if ( myEditCurrentArgument == Group3Pnts->LineEdit2 ) {
517 myPoint2 = aSelectedObject;
518 if ( !myPoint2->_is_nil() && myPoint3->_is_nil() )
519 Group3Pnts->PushButton3->click();
521 else if ( myEditCurrentArgument == Group3Pnts->LineEdit3 ) {
522 myPoint3 = aSelectedObject;
523 if ( !myPoint3->_is_nil() && myPoint1->_is_nil() )
524 Group3Pnts->PushButton1->click();
526 else if ( myEditCurrentArgument == GroupFace->LineEdit1 )
527 myFace = aSelectedObject;
528 else if ( myEditCurrentArgument == Group2Vec->LineEdit1 ) {
529 myVec1 = aSelectedObject;
530 if ( !myVec1->_is_nil() && myVec2->_is_nil() )
531 Group2Vec->PushButton2->click();
532 } else if ( myEditCurrentArgument == Group2Vec->LineEdit2 ) {
533 myVec2 = aSelectedObject;
534 if ( !myVec2->_is_nil() && myVec1->_is_nil() )
535 Group2Vec->PushButton1->click();
536 } else if ( myEditCurrentArgument == GroupLCS->LineEdit1 )
537 myLCS = aSelectedObject;
545 //=================================================================================
546 // function : SetEditCurrentArgument()
548 //=================================================================================
549 void BasicGUI_PlaneDlg::SetEditCurrentArgument()
551 QPushButton* send = (QPushButton*)sender();
552 globalSelection( GEOM_POINT );
554 if ( send == GroupPntDir->PushButton1 ) {
555 myEditCurrentArgument = GroupPntDir->LineEdit1;
556 GroupPntDir->PushButton2->setDown( false );
557 GroupPntDir->LineEdit1->setEnabled( true );
558 GroupPntDir->LineEdit2->setEnabled( false );
560 else if ( send == GroupPntDir->PushButton2 ) {
561 myEditCurrentArgument = GroupPntDir->LineEdit2;
562 GroupPntDir->PushButton1->setDown( false );
563 GroupPntDir->LineEdit1->setEnabled( false );
564 GroupPntDir->LineEdit2->setEnabled( true );
566 else if ( send == Group3Pnts->PushButton1 ) {
567 myEditCurrentArgument = Group3Pnts->LineEdit1;
568 Group3Pnts->PushButton2->setDown( false );
569 Group3Pnts->PushButton3->setDown( false );
570 Group3Pnts->LineEdit1->setEnabled( true );
571 Group3Pnts->LineEdit2->setEnabled( false );
572 Group3Pnts->LineEdit3->setEnabled( false );
574 else if ( send == Group3Pnts->PushButton2 ) {
575 myEditCurrentArgument = Group3Pnts->LineEdit2;
576 Group3Pnts->PushButton1->setDown( false );
577 Group3Pnts->PushButton3->setDown( false );
578 Group3Pnts->LineEdit1->setEnabled( false );
579 Group3Pnts->LineEdit2->setEnabled( true );
580 Group3Pnts->LineEdit3->setEnabled( false );
582 else if ( send == Group3Pnts->PushButton3 ) {
583 myEditCurrentArgument = Group3Pnts->LineEdit3;
584 Group3Pnts->PushButton1->setDown( false );
585 Group3Pnts->PushButton2->setDown( false );
586 Group3Pnts->LineEdit1->setEnabled( false );
587 Group3Pnts->LineEdit2->setEnabled( false );
588 Group3Pnts->LineEdit3->setEnabled( true );
590 else if ( send == GroupFace->PushButton1 ) {
591 myEditCurrentArgument = GroupFace->LineEdit1;
592 GroupFace->PushButton1->setDown( true );
593 } else if ( send == Group2Vec->PushButton1 ) {
594 myEditCurrentArgument = Group2Vec->LineEdit1;
595 Group2Vec->PushButton2->setDown( false );
596 Group2Vec->LineEdit1->setEnabled( true );
597 Group2Vec->LineEdit2->setEnabled( false );
598 } else if ( send == Group2Vec->PushButton2 ) {
599 myEditCurrentArgument = Group2Vec->LineEdit2;
600 Group2Vec->PushButton1->setDown( false );
601 Group2Vec->LineEdit1->setEnabled( false );
602 Group2Vec->LineEdit2->setEnabled( true );
603 } else if ( send == GroupLCS->PushButton1 ) {
604 myEditCurrentArgument = GroupLCS->LineEdit1;
605 GroupLCS->LineEdit1->setEnabled( true );
608 myEditCurrentArgument->setFocus();
610 if ( myEditCurrentArgument == GroupPntDir->LineEdit2 ||
611 myEditCurrentArgument == Group2Vec->LineEdit1 ||
612 myEditCurrentArgument == Group2Vec->LineEdit2 ) {
613 localSelection( GEOM::GEOM_Object::_nil(), TopAbs_EDGE );
614 } else if ( myEditCurrentArgument == GroupFace->LineEdit1 ) {
615 TColStd_MapOfInteger aMap;
616 aMap.Add( GEOM_PLANE );
617 aMap.Add( GEOM_MARKER );
618 globalSelection( aMap );
619 } else if ( myEditCurrentArgument == GroupLCS->LineEdit1 ) {
620 globalSelection( GEOM_MARKER );
623 localSelection( GEOM::GEOM_Object::_nil(), TopAbs_VERTEX );
626 // SelectionIntoArgument();
627 myEditCurrentArgument->setFocus();
633 //=================================================================================
634 // function : LineEditReturnPressed()
636 //=================================================================================
637 void BasicGUI_PlaneDlg::LineEditReturnPressed()
639 QLineEdit* send = (QLineEdit*)sender();
640 if ( send == GroupPntDir->LineEdit1 ||
641 send == GroupPntDir->LineEdit2 ||
642 send == Group3Pnts->LineEdit1 ||
643 send == Group3Pnts->LineEdit2 ||
644 send == Group3Pnts->LineEdit3 ||
645 send == GroupFace->LineEdit1 ||
646 send == Group2Vec->LineEdit1 ||
647 send == Group2Vec->LineEdit2 ||
648 send == GroupLCS->LineEdit1 ) {
649 myEditCurrentArgument = send;
650 GEOMBase_Skeleton::LineEditReturnPressed();
655 //=================================================================================
656 // function : ActivateThisDialog()
658 //=================================================================================
659 void BasicGUI_PlaneDlg::ActivateThisDialog()
661 GEOMBase_Skeleton::ActivateThisDialog();
662 connect( myGeomGUI->getApp()->selectionMgr(), SIGNAL( currentSelectionChanged() ),
663 this, SLOT( SelectionIntoArgument() ) );
665 ConstructorsClicked( getConstructorId() );
666 SelectionIntoArgument();
669 //=================================================================================
670 // function : DeactivateActiveDialog()
671 // purpose : public slot to deactivate if active
672 //=================================================================================
673 void BasicGUI_PlaneDlg::DeactivateActiveDialog()
675 GEOMBase_Skeleton::DeactivateActiveDialog();
678 //=================================================================================
679 // function : enterEvent()
681 //=================================================================================
682 void BasicGUI_PlaneDlg::enterEvent( QEvent* )
684 if ( !mainFrame()->GroupConstructors->isEnabled() )
685 ActivateThisDialog();
689 //=================================================================================
690 // function : ValueChangedInSpinBox()
692 //=================================================================================
693 void BasicGUI_PlaneDlg::ValueChangedInSpinBox( double newValue )
698 //=================================================================================
699 // function : getSize()
701 //=================================================================================
702 double BasicGUI_PlaneDlg::getSize() const
704 switch ( getConstructorId() ) {
705 case 0 : return GroupPntDir->SpinBox_DX->value();
706 case 1 : return Group3Pnts->SpinBox_DX->value();
707 case 2 : return GroupFace->SpinBox_DX->value();
708 case 3 : return Group2Vec->SpinBox_DX->value();
709 case 4 : return GroupLCS->SpinBox_DX->value();
714 //=================================================================================
715 // function : getSize()
717 //=================================================================================
718 QString BasicGUI_PlaneDlg::getSizeAsString() const
720 switch ( getConstructorId() ) {
721 case 0 : return GroupPntDir->SpinBox_DX->text();
722 case 1 : return Group3Pnts->SpinBox_DX->text();
723 case 2 : return GroupFace->SpinBox_DX->text();
724 case 3 : return Group2Vec->SpinBox_DX->text();
729 //=================================================================================
730 // function : createOperation
732 //=================================================================================
733 GEOM::GEOM_IOperations_ptr BasicGUI_PlaneDlg::createOperation()
735 return myGeomGUI->GetGeomGen()->GetIBasicOperations( getStudyId() );
738 //=================================================================================
739 // function : isEqual
740 // purpose : it may also be needed to check for min distance between gp_Pnt-s...
741 //=================================================================================
742 static bool isEqual( const GEOM::GEOM_Object_var& thePnt1, const GEOM::GEOM_Object_var& thePnt2 )
744 return thePnt1->_is_equivalent( thePnt2 );
747 //=================================================================================
748 // function : isValid
750 //=================================================================================
751 bool BasicGUI_PlaneDlg::isValid( QString& msg )
753 const int id = getConstructorId();
754 if ( getSize() <= 0 ) {
755 msg = QString( "Please, enter size greater than 0." );
760 bool ok = GroupPntDir->SpinBox_DX->isValid( msg, !IsPreview() );
761 return !CORBA::is_nil( myPoint ) && !CORBA::is_nil( myDir ) && ok;
763 else if ( id == 1 ) {
764 bool ok = Group3Pnts->SpinBox_DX->isValid( msg, !IsPreview() );
765 return !CORBA::is_nil( myPoint1 ) && !CORBA::is_nil( myPoint2 ) && !CORBA::is_nil( myPoint3 ) &&
766 !isEqual( myPoint1, myPoint2 ) && !isEqual( myPoint1, myPoint3 ) && !isEqual( myPoint2, myPoint3 ) && ok;
768 else if ( id == 2 ) {
769 bool ok = GroupFace->SpinBox_DX->isValid( msg, !IsPreview() );
770 return !CORBA::is_nil( myFace ) && ok;
771 } else if ( id == 3 ) {
772 bool ok = Group2Vec->SpinBox_DX->isValid( msg, !IsPreview() );
773 return !CORBA::is_nil( myVec1 ) && !CORBA::is_nil( myVec2 ) && !isEqual( myVec1, myVec2 ) && ok;
774 } else if ( id == 4 ) {
775 bool ok = GroupLCS->SpinBox_DX->isValid( msg, !IsPreview() );
781 //=================================================================================
782 // function : execute
784 //=================================================================================
785 bool BasicGUI_PlaneDlg::execute( ObjectList& objects )
789 GEOM::GEOM_Object_var anObj;
791 GEOM::GEOM_IBasicOperations_var anOper = GEOM::GEOM_IBasicOperations::_narrow( getOperation() );
793 switch ( getConstructorId() ) {
795 anObj = anOper->MakePlanePntVec( myPoint, myDir, getSize() );
799 anObj = anOper->MakePlaneThreePnt( myPoint1, myPoint2, myPoint3, getSize() );
803 anObj = anOper->MakePlaneFace( myFace, getSize() );
807 anObj = anOper->MakePlane2Vec( myVec1, myVec2, getSize() );
811 anObj = anOper->MakePlaneLCS( myLCS, getSize(), myOriginType );
816 if ( !anObj->_is_nil() ) {
818 anObj->SetParameters(getSizeAsString().toLatin1().constData());
819 objects.push_back( anObj._retn() );
823 //=================================================================================
824 // function : addSubshapeToStudy
825 // purpose : virtual method to add new SubObjects if local selection
826 //=================================================================================
827 void BasicGUI_PlaneDlg::addSubshapesToStudy()
829 QMap<QString, GEOM::GEOM_Object_var> objMap;
831 switch ( getConstructorId() ) {
833 objMap[GroupPntDir->LineEdit1->text()] = myPoint;
834 objMap[GroupPntDir->LineEdit2->text()] = myDir;
837 objMap[Group3Pnts->LineEdit1->text()] = myPoint1;
838 objMap[Group3Pnts->LineEdit2->text()] = myPoint2;
839 objMap[Group3Pnts->LineEdit3->text()] = myPoint3;
842 objMap[GroupFace->LineEdit1->text()] = myFace;
845 objMap[Group2Vec->LineEdit1->text()] = myVec1;
846 objMap[Group2Vec->LineEdit2->text()] = myVec2;
849 addSubshapesToFather( objMap );