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 GEOM::GEOM_Object_var aSelectedObject = GEOMBase::ConvertIOinGEOMObject( aSelList.First() );
446 if ( !CORBA::is_nil( aSelectedObject ) ) {
447 QString aName = GEOMBase::GetName( aSelectedObject );
448 TopAbs_ShapeEnum aNeedType = TopAbs_VERTEX;
449 if ( myEditCurrentArgument == GroupPntDir->LineEdit2 || myEditCurrentArgument == Group2Vec->LineEdit1 || myEditCurrentArgument == Group2Vec->LineEdit2)
450 aNeedType = TopAbs_EDGE;
451 else if ( myEditCurrentArgument == GroupFace->LineEdit1 )
452 aNeedType = TopAbs_FACE;
453 else if ( myEditCurrentArgument == GroupLCS->LineEdit1 )
454 aNeedType = TopAbs_FACE;
457 if ( GEOMBase::GetShape( aSelectedObject, aShape, TopAbs_SHAPE ) && !aShape.IsNull() ) {
458 TColStd_IndexedMapOfInteger aMap;
459 aSelMgr->GetIndexes(aSelList.First(), aMap);
460 if ( aMap.Extent() == 1 ) { // Local Selection
461 int anIndex = aMap( 1 );
462 if ( aNeedType == TopAbs_EDGE )
463 aName += QString( ":edge_%1" ).arg( anIndex );
464 else if (aNeedType == TopAbs_FACE)
465 aName += QString( ":face_%1" ).arg( anIndex );
467 aName += QString( ":vertex_%1" ).arg( anIndex );
469 //Find SubShape Object in Father
470 GEOM::GEOM_Object_var aFindedObject = GEOMBase_Helper::findObjectInFather( aSelectedObject, aName );
472 if ( aFindedObject->_is_nil() ) { // Object not found in study
473 GEOM::GEOM_IShapesOperations_var aShapesOp = getGeomEngine()->GetIShapesOperations( getStudyId() );
474 aSelectedObject = aShapesOp->GetSubShape( aSelectedObject, anIndex );
477 aSelectedObject = aFindedObject; // get Object from study
480 else { // Global Selection
481 if ( aShape.ShapeType() != aNeedType ) {
482 aSelectedObject = GEOM::GEOM_Object::_nil();
488 myEditCurrentArgument->setText( aName );
490 /* if (!aSelectedObject->_is_nil()) { // clear selection if something selected
492 if ( myEditCurrentArgument == GroupFace->LineEdit1 ) {
493 TColStd_MapOfInteger aMap;
494 aMap.Add( GEOM_PLANE );
495 aMap.Add( GEOM_MARKER );
496 globalSelection( aMap );
499 localSelection( GEOM::GEOM_Object::_nil(), aNeedType );
502 if ( myEditCurrentArgument == GroupPntDir->LineEdit1 ) {
503 myPoint = aSelectedObject;
504 if ( !myPoint->_is_nil() && myDir->_is_nil() )
505 GroupPntDir->PushButton2->click();
507 else if ( myEditCurrentArgument == GroupPntDir->LineEdit2 ) {
508 myDir = aSelectedObject;
509 if ( !myDir->_is_nil() && myPoint->_is_nil() )
510 GroupPntDir->PushButton1->click();
512 else if ( myEditCurrentArgument == Group3Pnts->LineEdit1 ) {
513 myPoint1 = aSelectedObject;
514 if ( !myPoint1->_is_nil() && myPoint2->_is_nil() )
515 Group3Pnts->PushButton2->click();
517 else if ( myEditCurrentArgument == Group3Pnts->LineEdit2 ) {
518 myPoint2 = aSelectedObject;
519 if ( !myPoint2->_is_nil() && myPoint3->_is_nil() )
520 Group3Pnts->PushButton3->click();
522 else if ( myEditCurrentArgument == Group3Pnts->LineEdit3 ) {
523 myPoint3 = aSelectedObject;
524 if ( !myPoint3->_is_nil() && myPoint1->_is_nil() )
525 Group3Pnts->PushButton1->click();
527 else if ( myEditCurrentArgument == GroupFace->LineEdit1 )
528 myFace = aSelectedObject;
529 else if ( myEditCurrentArgument == Group2Vec->LineEdit1 ) {
530 myVec1 = aSelectedObject;
531 if ( !myVec1->_is_nil() && myVec2->_is_nil() )
532 Group2Vec->PushButton2->click();
533 } else if ( myEditCurrentArgument == Group2Vec->LineEdit2 ) {
534 myVec2 = aSelectedObject;
535 if ( !myVec2->_is_nil() && myVec1->_is_nil() )
536 Group2Vec->PushButton1->click();
537 } else if ( myEditCurrentArgument == GroupLCS->LineEdit1 )
538 myLCS = aSelectedObject;
546 //=================================================================================
547 // function : SetEditCurrentArgument()
549 //=================================================================================
550 void BasicGUI_PlaneDlg::SetEditCurrentArgument()
552 QPushButton* send = (QPushButton*)sender();
553 globalSelection( GEOM_POINT );
555 if ( send == GroupPntDir->PushButton1 ) {
556 myEditCurrentArgument = GroupPntDir->LineEdit1;
557 GroupPntDir->PushButton2->setDown( false );
558 GroupPntDir->LineEdit1->setEnabled( true );
559 GroupPntDir->LineEdit2->setEnabled( false );
561 else if ( send == GroupPntDir->PushButton2 ) {
562 myEditCurrentArgument = GroupPntDir->LineEdit2;
563 GroupPntDir->PushButton1->setDown( false );
564 GroupPntDir->LineEdit1->setEnabled( false );
565 GroupPntDir->LineEdit2->setEnabled( true );
567 else if ( send == Group3Pnts->PushButton1 ) {
568 myEditCurrentArgument = Group3Pnts->LineEdit1;
569 Group3Pnts->PushButton2->setDown( false );
570 Group3Pnts->PushButton3->setDown( false );
571 Group3Pnts->LineEdit1->setEnabled( true );
572 Group3Pnts->LineEdit2->setEnabled( false );
573 Group3Pnts->LineEdit3->setEnabled( false );
575 else if ( send == Group3Pnts->PushButton2 ) {
576 myEditCurrentArgument = Group3Pnts->LineEdit2;
577 Group3Pnts->PushButton1->setDown( false );
578 Group3Pnts->PushButton3->setDown( false );
579 Group3Pnts->LineEdit1->setEnabled( false );
580 Group3Pnts->LineEdit2->setEnabled( true );
581 Group3Pnts->LineEdit3->setEnabled( false );
583 else if ( send == Group3Pnts->PushButton3 ) {
584 myEditCurrentArgument = Group3Pnts->LineEdit3;
585 Group3Pnts->PushButton1->setDown( false );
586 Group3Pnts->PushButton2->setDown( false );
587 Group3Pnts->LineEdit1->setEnabled( false );
588 Group3Pnts->LineEdit2->setEnabled( false );
589 Group3Pnts->LineEdit3->setEnabled( true );
591 else if ( send == GroupFace->PushButton1 ) {
592 myEditCurrentArgument = GroupFace->LineEdit1;
593 GroupFace->PushButton1->setDown( true );
594 } else if ( send == Group2Vec->PushButton1 ) {
595 myEditCurrentArgument = Group2Vec->LineEdit1;
596 Group2Vec->PushButton2->setDown( false );
597 Group2Vec->LineEdit1->setEnabled( true );
598 Group2Vec->LineEdit2->setEnabled( false );
599 } else if ( send == Group2Vec->PushButton2 ) {
600 myEditCurrentArgument = Group2Vec->LineEdit2;
601 Group2Vec->PushButton1->setDown( false );
602 Group2Vec->LineEdit1->setEnabled( false );
603 Group2Vec->LineEdit2->setEnabled( true );
604 } else if ( send == GroupLCS->PushButton1 ) {
605 myEditCurrentArgument = GroupLCS->LineEdit1;
606 GroupLCS->LineEdit1->setEnabled( true );
609 myEditCurrentArgument->setFocus();
611 if ( myEditCurrentArgument == GroupPntDir->LineEdit2 ||
612 myEditCurrentArgument == Group2Vec->LineEdit1 ||
613 myEditCurrentArgument == Group2Vec->LineEdit2 ) {
614 localSelection( GEOM::GEOM_Object::_nil(), TopAbs_EDGE );
615 } else if ( myEditCurrentArgument == GroupFace->LineEdit1 ) {
616 TColStd_MapOfInteger aMap;
617 aMap.Add( GEOM_PLANE );
618 aMap.Add( GEOM_MARKER );
619 globalSelection( aMap );
620 } else if ( myEditCurrentArgument == GroupLCS->LineEdit1 ) {
621 globalSelection( GEOM_MARKER );
624 localSelection( GEOM::GEOM_Object::_nil(), TopAbs_VERTEX );
627 // SelectionIntoArgument();
628 myEditCurrentArgument->setFocus();
634 //=================================================================================
635 // function : LineEditReturnPressed()
637 //=================================================================================
638 void BasicGUI_PlaneDlg::LineEditReturnPressed()
640 QLineEdit* send = (QLineEdit*)sender();
641 if ( send == GroupPntDir->LineEdit1 ||
642 send == GroupPntDir->LineEdit2 ||
643 send == Group3Pnts->LineEdit1 ||
644 send == Group3Pnts->LineEdit2 ||
645 send == Group3Pnts->LineEdit3 ||
646 send == GroupFace->LineEdit1 ||
647 send == Group2Vec->LineEdit1 ||
648 send == Group2Vec->LineEdit2 ||
649 send == GroupLCS->LineEdit1 ) {
650 myEditCurrentArgument = send;
651 GEOMBase_Skeleton::LineEditReturnPressed();
656 //=================================================================================
657 // function : ActivateThisDialog()
659 //=================================================================================
660 void BasicGUI_PlaneDlg::ActivateThisDialog()
662 GEOMBase_Skeleton::ActivateThisDialog();
663 connect( myGeomGUI->getApp()->selectionMgr(), SIGNAL( currentSelectionChanged() ),
664 this, SLOT( SelectionIntoArgument() ) );
666 ConstructorsClicked( getConstructorId() );
667 SelectionIntoArgument();
670 //=================================================================================
671 // function : DeactivateActiveDialog()
672 // purpose : public slot to deactivate if active
673 //=================================================================================
674 void BasicGUI_PlaneDlg::DeactivateActiveDialog()
676 GEOMBase_Skeleton::DeactivateActiveDialog();
679 //=================================================================================
680 // function : enterEvent()
682 //=================================================================================
683 void BasicGUI_PlaneDlg::enterEvent( QEvent* )
685 if ( !mainFrame()->GroupConstructors->isEnabled() )
686 ActivateThisDialog();
690 //=================================================================================
691 // function : ValueChangedInSpinBox()
693 //=================================================================================
694 void BasicGUI_PlaneDlg::ValueChangedInSpinBox( double newValue )
699 //=================================================================================
700 // function : getSize()
702 //=================================================================================
703 double BasicGUI_PlaneDlg::getSize() const
705 switch ( getConstructorId() ) {
706 case 0 : return GroupPntDir->SpinBox_DX->value();
707 case 1 : return Group3Pnts->SpinBox_DX->value();
708 case 2 : return GroupFace->SpinBox_DX->value();
709 case 3 : return Group2Vec->SpinBox_DX->value();
710 case 4 : return GroupLCS->SpinBox_DX->value();
715 //=================================================================================
716 // function : getSize()
718 //=================================================================================
719 QString BasicGUI_PlaneDlg::getSizeAsString() const
721 switch ( getConstructorId() ) {
722 case 0 : return GroupPntDir->SpinBox_DX->text();
723 case 1 : return Group3Pnts->SpinBox_DX->text();
724 case 2 : return GroupFace->SpinBox_DX->text();
725 case 3 : return Group2Vec->SpinBox_DX->text();
730 //=================================================================================
731 // function : createOperation
733 //=================================================================================
734 GEOM::GEOM_IOperations_ptr BasicGUI_PlaneDlg::createOperation()
736 return myGeomGUI->GetGeomGen()->GetIBasicOperations( getStudyId() );
739 //=================================================================================
740 // function : isEqual
741 // purpose : it may also be needed to check for min distance between gp_Pnt-s...
742 //=================================================================================
743 static bool isEqual( const GEOM::GEOM_Object_var& thePnt1, const GEOM::GEOM_Object_var& thePnt2 )
745 return thePnt1->_is_equivalent( thePnt2 );
748 //=================================================================================
749 // function : isValid
751 //=================================================================================
752 bool BasicGUI_PlaneDlg::isValid( QString& msg )
754 const int id = getConstructorId();
755 if ( getSize() <= 0 ) {
756 msg = QString( "Please, enter size greater than 0." );
761 bool ok = GroupPntDir->SpinBox_DX->isValid( msg, !IsPreview() );
762 return !CORBA::is_nil( myPoint ) && !CORBA::is_nil( myDir ) && ok;
764 else if ( id == 1 ) {
765 bool ok = Group3Pnts->SpinBox_DX->isValid( msg, !IsPreview() );
766 return !CORBA::is_nil( myPoint1 ) && !CORBA::is_nil( myPoint2 ) && !CORBA::is_nil( myPoint3 ) &&
767 !isEqual( myPoint1, myPoint2 ) && !isEqual( myPoint1, myPoint3 ) && !isEqual( myPoint2, myPoint3 ) && ok;
769 else if ( id == 2 ) {
770 bool ok = GroupFace->SpinBox_DX->isValid( msg, !IsPreview() );
771 return !CORBA::is_nil( myFace ) && ok;
772 } else if ( id == 3 ) {
773 bool ok = Group2Vec->SpinBox_DX->isValid( msg, !IsPreview() );
774 return !CORBA::is_nil( myVec1 ) && !CORBA::is_nil( myVec2 ) && !isEqual( myVec1, myVec2 ) && ok;
775 } else if ( id == 4 ) {
776 bool ok = GroupLCS->SpinBox_DX->isValid( msg, !IsPreview() );
782 //=================================================================================
783 // function : execute
785 //=================================================================================
786 bool BasicGUI_PlaneDlg::execute( ObjectList& objects )
790 GEOM::GEOM_Object_var anObj;
792 GEOM::GEOM_IBasicOperations_var anOper = GEOM::GEOM_IBasicOperations::_narrow( getOperation() );
794 switch ( getConstructorId() ) {
796 anObj = anOper->MakePlanePntVec( myPoint, myDir, getSize() );
800 anObj = anOper->MakePlaneThreePnt( myPoint1, myPoint2, myPoint3, getSize() );
804 anObj = anOper->MakePlaneFace( myFace, getSize() );
808 anObj = anOper->MakePlane2Vec( myVec1, myVec2, getSize() );
812 anObj = anOper->MakePlaneLCS( myLCS, getSize(), myOriginType );
817 if ( !anObj->_is_nil() ) {
819 anObj->SetParameters(getSizeAsString().toLatin1().constData());
820 objects.push_back( anObj._retn() );
824 //=================================================================================
825 // function : addSubshapeToStudy
826 // purpose : virtual method to add new SubObjects if local selection
827 //=================================================================================
828 void BasicGUI_PlaneDlg::addSubshapesToStudy()
830 QMap<QString, GEOM::GEOM_Object_var> objMap;
832 switch ( getConstructorId() ) {
834 objMap[GroupPntDir->LineEdit1->text()] = myPoint;
835 objMap[GroupPntDir->LineEdit2->text()] = myDir;
838 objMap[Group3Pnts->LineEdit1->text()] = myPoint1;
839 objMap[Group3Pnts->LineEdit2->text()] = myPoint2;
840 objMap[Group3Pnts->LineEdit3->text()] = myPoint3;
843 objMap[GroupFace->LineEdit1->text()] = myFace;
846 objMap[Group2Vec->LineEdit1->text()] = myVec1;
847 objMap[Group2Vec->LineEdit2->text()] = myVec2;
850 addSubshapesToFather( objMap );