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->LineEdit1->setReadOnly( true );
141 GroupLCS->PushButton1->setIcon( image3 );
142 GroupLCS->PushButton1->setDown( true );
144 QVBoxLayout* layout = new QVBoxLayout( centralWidget() );
145 layout->setMargin( 0 ); layout->setSpacing( 6 );
146 layout->addWidget( GroupPntDir );
147 layout->addWidget( Group3Pnts );
148 layout->addWidget( GroupFace );
149 layout->addWidget( Group2Vec );
150 layout->addWidget( GroupLCS );
151 /***************************************************************/
153 setHelpFileName( "create_plane_page.html" );
159 //=================================================================================
160 // function : ~BasicGUI_PlaneDlg()
161 // purpose : Destroys the object and frees any allocated resources
162 //=================================================================================
163 BasicGUI_PlaneDlg::~BasicGUI_PlaneDlg()
168 //=================================================================================
171 //=================================================================================
172 void BasicGUI_PlaneDlg::Init()
175 myEditCurrentArgument = GroupPntDir->LineEdit1;
187 // myGeomGUI->SetState( 0 );
190 /* Get setting of step value from file configuration */
191 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
192 double aStep = resMgr->doubleValue( "Geometry", "SettingsGeomStep", 100 );
194 double aTrimSize = 2000.0;
196 /* min, max, step and decimals for spin boxes */
197 initSpinBox( GroupPntDir->SpinBox_DX, 0.000001, COORD_MAX, aStep, "length_precision" );
198 GroupPntDir->SpinBox_DX->setValue( aTrimSize );
199 initSpinBox( Group3Pnts->SpinBox_DX, 0.000001, COORD_MAX, aStep, "length_precision" );
200 Group3Pnts->SpinBox_DX->setValue( aTrimSize );
201 initSpinBox( GroupFace->SpinBox_DX, 0.000001, COORD_MAX, aStep, "length_precision" );
202 GroupFace->SpinBox_DX->setValue( aTrimSize );
203 initSpinBox( Group2Vec->SpinBox_DX, 0.000001, COORD_MAX, aStep, "length_precision" );
204 Group2Vec->SpinBox_DX->setValue( aTrimSize );
205 initSpinBox( GroupLCS->SpinBox_DX, 0.000001, COORD_MAX, aStep, "length_precision" );
206 GroupLCS->SpinBox_DX->setValue( aTrimSize );
208 /* signals and slots connections */
209 connect( myGeomGUI, SIGNAL( SignalDeactivateActiveDialog() ), this, SLOT( DeactivateActiveDialog() ) );
210 connect( myGeomGUI, SIGNAL( SignalCloseAllDialogs() ), this, SLOT( ClickOnCancel() ) );
212 connect( buttonOk(), SIGNAL( clicked() ), this, SLOT( ClickOnOk() ) );
213 connect( buttonApply(), SIGNAL( clicked() ), this, SLOT( ClickOnApply() ) );
215 connect( this, SIGNAL( constructorsClicked( int ) ), this, SLOT( ConstructorsClicked( int ) ) );
217 connect( GroupPntDir->PushButton1, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) );
218 connect( GroupPntDir->PushButton2, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) );
219 connect( Group3Pnts->PushButton1, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) );
220 connect( Group3Pnts->PushButton2, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) );
221 connect( Group3Pnts->PushButton3, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) );
222 connect( GroupFace->PushButton1, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) );
223 connect( Group2Vec->PushButton1, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) );
224 connect( Group2Vec->PushButton2, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) );
226 connect( GroupLCS->RadioButton1, SIGNAL( clicked() ), this, SLOT( GroupClicked() ) );
227 connect( GroupLCS->RadioButton2, SIGNAL( clicked() ), this, SLOT( GroupClicked() ) );
228 connect( GroupLCS->RadioButton3, SIGNAL( clicked() ), this, SLOT( GroupClicked() ) );
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 );
275 switch ( constructorId ) {
276 case 0: /* plane from a point and a direction (vector, edge...) */
284 myEditCurrentArgument = GroupPntDir->LineEdit1;
285 GroupPntDir->LineEdit1->setText( "" );
286 GroupPntDir->LineEdit2->setText( "" );
287 GroupPntDir->PushButton1->setDown( true );
288 GroupPntDir->PushButton2->setDown( false );
289 GroupPntDir->LineEdit1->setEnabled( true );
290 GroupPntDir->LineEdit2->setEnabled( false );
292 /* for the first argument */
293 globalSelection(); // close local contexts, if any
294 localSelection( GEOM::GEOM_Object::_nil(), TopAbs_VERTEX );
297 case 1: /* plane from 3 points */
305 myEditCurrentArgument = Group3Pnts->LineEdit1;
306 Group3Pnts->LineEdit1->setText( "" );
307 Group3Pnts->LineEdit2->setText( "" );
308 Group3Pnts->LineEdit3->setText( "" );
309 Group3Pnts->PushButton1->setDown( true );
310 Group3Pnts->PushButton2->setDown( false );
311 Group3Pnts->PushButton3->setDown( false );
312 Group3Pnts->LineEdit1->setEnabled( true );
313 Group3Pnts->LineEdit2->setEnabled( false );
314 Group3Pnts->LineEdit3->setEnabled( false );
316 /* for the first argument */
317 globalSelection(); // close local contexts, if any
318 localSelection( GEOM::GEOM_Object::_nil(), TopAbs_VERTEX );
321 case 2: /* plane from a planar face */
329 myEditCurrentArgument = GroupFace->LineEdit1;
330 GroupFace->LineEdit1->setText( "" );
331 GroupFace->PushButton1->setDown( true );
333 globalSelection(); // close local contexts, if any
334 localSelection( GEOM::GEOM_Object::_nil(), TopAbs_FACE );
337 case 3: /* plane from a 2 Vectors */
345 myEditCurrentArgument = Group2Vec->LineEdit1;
346 Group2Vec->LineEdit1->setText( "" );
347 Group2Vec->PushButton1->setDown( true );
349 globalSelection(); // close local contexts, if any
350 localSelection( GEOM::GEOM_Object::_nil(), TopAbs_EDGE );
353 case 4: /* plane from a LCS */
361 myEditCurrentArgument = GroupLCS->LineEdit1;
362 GroupLCS->LineEdit1->setText( "" );
363 GroupLCS->PushButton1->setDown( true );
364 GroupLCS->RadioButton1->setChecked( true );
367 globalSelection(GEOM_MARKER);
372 qApp->processEvents();
374 resize( minimumSizeHint() );
375 SelectionIntoArgument();
377 myEditCurrentArgument->setFocus();
378 connect( myGeomGUI->getApp()->selectionMgr(), SIGNAL( currentSelectionChanged() ),
379 this, SLOT( SelectionIntoArgument() ) );
384 //=================================================================================
385 // function : ClickOnOk()
387 //=================================================================================
388 void BasicGUI_PlaneDlg::ClickOnOk()
390 if ( ClickOnApply() )
395 //=================================================================================
396 // function : ClickOnApply()
398 //=================================================================================
399 bool BasicGUI_PlaneDlg::ClickOnApply()
405 ConstructorsClicked( getConstructorId() );
409 //=================================================================================
410 // function : GroupClicked()
411 // purpose : OX OY OZ Radio button management
412 //=================================================================================
413 void BasicGUI_PlaneDlg::GroupClicked()
415 QRadioButton* send = (QRadioButton*)sender();
417 if ( send == GroupLCS->RadioButton1 )
419 else if ( send == GroupLCS->RadioButton2 )
421 else if ( send == GroupLCS->RadioButton3 )
426 //=================================================================================
427 // function : SelectionIntoArgument()
428 // purpose : Called when selection has changed
429 //=================================================================================
430 void BasicGUI_PlaneDlg::SelectionIntoArgument()
432 myEditCurrentArgument->setText("");
434 LightApp_SelectionMgr* aSelMgr = myGeomGUI->getApp()->selectionMgr();
435 SALOME_ListIO aSelList;
436 aSelMgr->selectedObjects(aSelList);
438 if (aSelList.Extent() != 1) {
439 if ( myEditCurrentArgument == GroupPntDir->LineEdit1 ) myPoint.nullify();
440 else if ( myEditCurrentArgument == GroupPntDir->LineEdit2 ) myDir.nullify();
441 else if ( myEditCurrentArgument == Group3Pnts->LineEdit1 ) myPoint1.nullify();
442 else if ( myEditCurrentArgument == Group3Pnts->LineEdit2 ) myPoint2.nullify();
443 else if ( myEditCurrentArgument == Group3Pnts->LineEdit3 ) myPoint3.nullify();
444 else if ( myEditCurrentArgument == GroupFace->LineEdit1 ) myFace.nullify();
445 else if ( myEditCurrentArgument == Group2Vec->LineEdit1 ) myVec1.nullify();
446 else if ( myEditCurrentArgument == Group2Vec->LineEdit2 ) myVec2.nullify();
447 else if ( myEditCurrentArgument == GroupLCS->LineEdit1 ) myLCS.nullify();
452 TopAbs_ShapeEnum aNeedType;
453 if ( myEditCurrentArgument == GroupPntDir->LineEdit2 || myEditCurrentArgument == Group2Vec->LineEdit1 || myEditCurrentArgument == Group2Vec->LineEdit2)
454 aNeedType = TopAbs_EDGE;
455 else if ( myEditCurrentArgument == GroupFace->LineEdit1 )
456 aNeedType = TopAbs_FACE;
457 else if ( myEditCurrentArgument == GroupLCS->LineEdit1 )
458 aNeedType = TopAbs_FACE;
460 aNeedType = TopAbs_VERTEX;
461 GEOM::GeomObjPtr aSelectedObject = getSelected( aNeedType );
463 if ( aSelectedObject && GEOMBase::GetShape( aSelectedObject.get(), aShape ) && !aShape.IsNull() ) {
464 QString aName = GEOMBase::GetName( aSelectedObject.get() );
465 myEditCurrentArgument->setText( aName );
466 if ( myEditCurrentArgument == GroupPntDir->LineEdit1 ) {
467 myPoint = aSelectedObject;
468 if ( myPoint && !myDir )
469 GroupPntDir->PushButton2->click();
471 else if ( myEditCurrentArgument == GroupPntDir->LineEdit2 ) {
472 myDir = aSelectedObject;
473 if ( myDir && !myPoint )
474 GroupPntDir->PushButton1->click();
476 else if ( myEditCurrentArgument == Group3Pnts->LineEdit1 ) {
477 myPoint1 = aSelectedObject;
478 if ( myPoint1 && !myPoint2 )
479 Group3Pnts->PushButton2->click();
481 else if ( myEditCurrentArgument == Group3Pnts->LineEdit2 ) {
482 myPoint2 = aSelectedObject;
483 if ( myPoint2 && !myPoint3 )
484 Group3Pnts->PushButton3->click();
486 else if ( myEditCurrentArgument == Group3Pnts->LineEdit3 ) {
487 myPoint3 = aSelectedObject;
488 if ( myPoint3 && !myPoint1 )
489 Group3Pnts->PushButton1->click();
491 else if ( myEditCurrentArgument == GroupFace->LineEdit1 )
492 myFace = aSelectedObject;
493 else if ( myEditCurrentArgument == Group2Vec->LineEdit1 ) {
494 myVec1 = aSelectedObject;
495 if ( myVec1 && !myVec2 )
496 Group2Vec->PushButton2->click();
497 } else if ( myEditCurrentArgument == Group2Vec->LineEdit2 ) {
498 myVec2 = aSelectedObject;
499 if ( myVec2 && !myVec1 )
500 Group2Vec->PushButton1->click();
501 } else if ( myEditCurrentArgument == GroupLCS->LineEdit1 )
502 myLCS = aSelectedObject;
509 //=================================================================================
510 // function : SetEditCurrentArgument()
512 //=================================================================================
513 void BasicGUI_PlaneDlg::SetEditCurrentArgument()
515 QPushButton* send = (QPushButton*)sender();
516 globalSelection( GEOM_POINT );
518 if ( send == GroupPntDir->PushButton1 ) {
519 myEditCurrentArgument = GroupPntDir->LineEdit1;
520 GroupPntDir->PushButton2->setDown( false );
521 GroupPntDir->LineEdit1->setEnabled( true );
522 GroupPntDir->LineEdit2->setEnabled( false );
524 else if ( send == GroupPntDir->PushButton2 ) {
525 myEditCurrentArgument = GroupPntDir->LineEdit2;
526 GroupPntDir->PushButton1->setDown( false );
527 GroupPntDir->LineEdit1->setEnabled( false );
528 GroupPntDir->LineEdit2->setEnabled( true );
530 else if ( send == Group3Pnts->PushButton1 ) {
531 myEditCurrentArgument = Group3Pnts->LineEdit1;
532 Group3Pnts->PushButton2->setDown( false );
533 Group3Pnts->PushButton3->setDown( false );
534 Group3Pnts->LineEdit1->setEnabled( true );
535 Group3Pnts->LineEdit2->setEnabled( false );
536 Group3Pnts->LineEdit3->setEnabled( false );
538 else if ( send == Group3Pnts->PushButton2 ) {
539 myEditCurrentArgument = Group3Pnts->LineEdit2;
540 Group3Pnts->PushButton1->setDown( false );
541 Group3Pnts->PushButton3->setDown( false );
542 Group3Pnts->LineEdit1->setEnabled( false );
543 Group3Pnts->LineEdit2->setEnabled( true );
544 Group3Pnts->LineEdit3->setEnabled( false );
546 else if ( send == Group3Pnts->PushButton3 ) {
547 myEditCurrentArgument = Group3Pnts->LineEdit3;
548 Group3Pnts->PushButton1->setDown( false );
549 Group3Pnts->PushButton2->setDown( false );
550 Group3Pnts->LineEdit1->setEnabled( false );
551 Group3Pnts->LineEdit2->setEnabled( false );
552 Group3Pnts->LineEdit3->setEnabled( true );
554 else if ( send == GroupFace->PushButton1 ) {
555 myEditCurrentArgument = GroupFace->LineEdit1;
556 GroupFace->PushButton1->setDown( true );
557 } else if ( send == Group2Vec->PushButton1 ) {
558 myEditCurrentArgument = Group2Vec->LineEdit1;
559 Group2Vec->PushButton2->setDown( false );
560 Group2Vec->LineEdit1->setEnabled( true );
561 Group2Vec->LineEdit2->setEnabled( false );
562 } else if ( send == Group2Vec->PushButton2 ) {
563 myEditCurrentArgument = Group2Vec->LineEdit2;
564 Group2Vec->PushButton1->setDown( false );
565 Group2Vec->LineEdit1->setEnabled( false );
566 Group2Vec->LineEdit2->setEnabled( true );
567 } else if ( send == GroupLCS->PushButton1 ) {
568 myEditCurrentArgument = GroupLCS->LineEdit1;
569 GroupLCS->LineEdit1->setEnabled( true );
572 myEditCurrentArgument->setFocus();
574 if ( myEditCurrentArgument == GroupPntDir->LineEdit2 ||
575 myEditCurrentArgument == Group2Vec->LineEdit1 ||
576 myEditCurrentArgument == Group2Vec->LineEdit2 ) {
577 localSelection( GEOM::GEOM_Object::_nil(), TopAbs_EDGE );
578 } else if ( myEditCurrentArgument == GroupFace->LineEdit1 ) {
579 TColStd_MapOfInteger aMap;
580 aMap.Add( GEOM_PLANE );
581 aMap.Add( GEOM_MARKER );
582 globalSelection( aMap );
583 } else if ( myEditCurrentArgument == GroupLCS->LineEdit1 ) {
584 globalSelection( GEOM_MARKER );
587 localSelection( GEOM::GEOM_Object::_nil(), TopAbs_VERTEX );
590 // SelectionIntoArgument();
591 myEditCurrentArgument->setFocus();
597 //=================================================================================
598 // function : ActivateThisDialog()
600 //=================================================================================
601 void BasicGUI_PlaneDlg::ActivateThisDialog()
603 GEOMBase_Skeleton::ActivateThisDialog();
604 connect( myGeomGUI->getApp()->selectionMgr(), SIGNAL( currentSelectionChanged() ),
605 this, SLOT( SelectionIntoArgument() ) );
607 ConstructorsClicked( getConstructorId() );
608 SelectionIntoArgument();
611 //=================================================================================
612 // function : DeactivateActiveDialog()
613 // purpose : public slot to deactivate if active
614 //=================================================================================
615 void BasicGUI_PlaneDlg::DeactivateActiveDialog()
617 GEOMBase_Skeleton::DeactivateActiveDialog();
620 //=================================================================================
621 // function : enterEvent()
623 //=================================================================================
624 void BasicGUI_PlaneDlg::enterEvent( QEvent* )
626 if ( !mainFrame()->GroupConstructors->isEnabled() )
627 ActivateThisDialog();
631 //=================================================================================
632 // function : ValueChangedInSpinBox()
634 //=================================================================================
635 void BasicGUI_PlaneDlg::ValueChangedInSpinBox( double newValue )
640 //=================================================================================
641 // function : getSize()
643 //=================================================================================
644 double BasicGUI_PlaneDlg::getSize() const
646 switch ( getConstructorId() ) {
647 case 0 : return GroupPntDir->SpinBox_DX->value();
648 case 1 : return Group3Pnts->SpinBox_DX->value();
649 case 2 : return GroupFace->SpinBox_DX->value();
650 case 3 : return Group2Vec->SpinBox_DX->value();
651 case 4 : return GroupLCS->SpinBox_DX->value();
656 //=================================================================================
657 // function : getSize()
659 //=================================================================================
660 QString BasicGUI_PlaneDlg::getSizeAsString() const
662 switch ( getConstructorId() ) {
663 case 0 : return GroupPntDir->SpinBox_DX->text();
664 case 1 : return Group3Pnts->SpinBox_DX->text();
665 case 2 : return GroupFace->SpinBox_DX->text();
666 case 3 : return Group2Vec->SpinBox_DX->text();
671 //=================================================================================
672 // function : createOperation
674 //=================================================================================
675 GEOM::GEOM_IOperations_ptr BasicGUI_PlaneDlg::createOperation()
677 return myGeomGUI->GetGeomGen()->GetIBasicOperations( getStudyId() );
680 //=================================================================================
681 // function : isValid
683 //=================================================================================
684 bool BasicGUI_PlaneDlg::isValid( QString& msg )
687 if ( getSize() <= 0 ) {
688 msg = QString( "Please, enter size greater than 0." );
691 switch ( getConstructorId() ) {
693 ok = GroupPntDir->SpinBox_DX->isValid( msg, !IsPreview() ) && myPoint && myDir;
696 ok = Group3Pnts->SpinBox_DX->isValid( msg, !IsPreview() ) &&
697 myPoint1 && myPoint2 && myPoint3 &&
698 myPoint1 != myPoint2 && myPoint1 != myPoint3 && myPoint2 != myPoint3;
701 ok = GroupFace->SpinBox_DX->isValid( msg, !IsPreview() ) && myFace;
704 ok = Group2Vec->SpinBox_DX->isValid( msg, !IsPreview() ) &&
705 myVec1 && myVec2 && myVec1 != myVec2;
708 ok = GroupLCS->SpinBox_DX->isValid( msg, !IsPreview() );
717 //=================================================================================
718 // function : execute
720 //=================================================================================
721 bool BasicGUI_PlaneDlg::execute( ObjectList& objects )
725 GEOM::GEOM_Object_var anObj;
727 GEOM::GEOM_IBasicOperations_var anOper = GEOM::GEOM_IBasicOperations::_narrow( getOperation() );
729 switch ( getConstructorId() ) {
731 anObj = anOper->MakePlanePntVec( myPoint.get(), myDir.get(), getSize() );
735 anObj = anOper->MakePlaneThreePnt( myPoint1.get(), myPoint2.get(), myPoint3.get(), getSize() );
739 anObj = anOper->MakePlaneFace( myFace.get(), getSize() );
743 anObj = anOper->MakePlane2Vec( myVec1.get(), myVec2.get(), getSize() );
747 anObj = anOper->MakePlaneLCS( myLCS.get(), getSize(), myOriginType );
752 if ( !anObj->_is_nil() ) {
754 anObj->SetParameters(getSizeAsString().toLatin1().constData());
755 objects.push_back( anObj._retn() );
759 //=================================================================================
760 // function : addSubshapeToStudy
761 // purpose : virtual method to add new SubObjects if local selection
762 //=================================================================================
763 void BasicGUI_PlaneDlg::addSubshapesToStudy()
765 switch ( getConstructorId() ) {
767 GEOMBase::PublishSubObject( myPoint.get() );
768 GEOMBase::PublishSubObject( myDir.get() );
771 GEOMBase::PublishSubObject( myPoint1.get() );
772 GEOMBase::PublishSubObject( myPoint2.get() );
773 GEOMBase::PublishSubObject( myPoint3.get() );
776 GEOMBase::PublishSubObject( myFace.get() );
779 GEOMBase::PublishSubObject( myVec1.get() );
780 GEOMBase::PublishSubObject( myVec2.get() );
783 GEOMBase::PublishSubObject( myLCS.get() );