1 // Copyright (C) 2007-2014 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, or (at your option) any later version.
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() ) );
380 displayPreview(true);
384 //=================================================================================
385 // function : ClickOnOk()
387 //=================================================================================
388 void BasicGUI_PlaneDlg::ClickOnOk()
390 setIsApplyAndClose( true );
391 if ( ClickOnApply() )
396 //=================================================================================
397 // function : ClickOnApply()
399 //=================================================================================
400 bool BasicGUI_PlaneDlg::ClickOnApply()
406 ConstructorsClicked( getConstructorId() );
410 //=================================================================================
411 // function : GroupClicked()
412 // purpose : OX OY OZ Radio button management
413 //=================================================================================
414 void BasicGUI_PlaneDlg::GroupClicked()
416 QRadioButton* send = (QRadioButton*)sender();
418 if ( send == GroupLCS->RadioButton1 )
420 else if ( send == GroupLCS->RadioButton2 )
422 else if ( send == GroupLCS->RadioButton3 )
424 displayPreview(true);
427 //=================================================================================
428 // function : SelectionIntoArgument()
429 // purpose : Called when selection has changed
430 //=================================================================================
431 void BasicGUI_PlaneDlg::SelectionIntoArgument()
433 myEditCurrentArgument->setText("");
435 LightApp_SelectionMgr* aSelMgr = myGeomGUI->getApp()->selectionMgr();
436 SALOME_ListIO aSelList;
437 aSelMgr->selectedObjects(aSelList);
439 if (aSelList.Extent() != 1) {
440 if ( myEditCurrentArgument == GroupPntDir->LineEdit1 ) myPoint.nullify();
441 else if ( myEditCurrentArgument == GroupPntDir->LineEdit2 ) myDir.nullify();
442 else if ( myEditCurrentArgument == Group3Pnts->LineEdit1 ) myPoint1.nullify();
443 else if ( myEditCurrentArgument == Group3Pnts->LineEdit2 ) myPoint2.nullify();
444 else if ( myEditCurrentArgument == Group3Pnts->LineEdit3 ) myPoint3.nullify();
445 else if ( myEditCurrentArgument == GroupFace->LineEdit1 ) myFace.nullify();
446 else if ( myEditCurrentArgument == Group2Vec->LineEdit1 ) myVec1.nullify();
447 else if ( myEditCurrentArgument == Group2Vec->LineEdit2 ) myVec2.nullify();
448 else if ( myEditCurrentArgument == GroupLCS->LineEdit1 ) myLCS.nullify();
449 displayPreview(true);
453 TopAbs_ShapeEnum aNeedType;
454 if ( myEditCurrentArgument == GroupPntDir->LineEdit2 || myEditCurrentArgument == Group2Vec->LineEdit1 || myEditCurrentArgument == Group2Vec->LineEdit2)
455 aNeedType = TopAbs_EDGE;
456 else if ( myEditCurrentArgument == GroupFace->LineEdit1 )
457 aNeedType = TopAbs_FACE;
458 else if ( myEditCurrentArgument == GroupLCS->LineEdit1 )
459 aNeedType = TopAbs_FACE;
461 aNeedType = TopAbs_VERTEX;
462 GEOM::GeomObjPtr aSelectedObject = getSelected( aNeedType );
464 if ( aSelectedObject && GEOMBase::GetShape( aSelectedObject.get(), aShape ) && !aShape.IsNull() ) {
465 QString aName = GEOMBase::GetName( aSelectedObject.get() );
466 myEditCurrentArgument->setText( aName );
467 if ( myEditCurrentArgument == GroupPntDir->LineEdit1 ) {
468 myPoint = aSelectedObject;
469 if ( myPoint && !myDir )
470 GroupPntDir->PushButton2->click();
472 else if ( myEditCurrentArgument == GroupPntDir->LineEdit2 ) {
473 myDir = aSelectedObject;
474 if ( myDir && !myPoint )
475 GroupPntDir->PushButton1->click();
477 else if ( myEditCurrentArgument == Group3Pnts->LineEdit1 ) {
478 myPoint1 = aSelectedObject;
479 if ( myPoint1 && !myPoint2 )
480 Group3Pnts->PushButton2->click();
482 else if ( myEditCurrentArgument == Group3Pnts->LineEdit2 ) {
483 myPoint2 = aSelectedObject;
484 if ( myPoint2 && !myPoint3 )
485 Group3Pnts->PushButton3->click();
487 else if ( myEditCurrentArgument == Group3Pnts->LineEdit3 ) {
488 myPoint3 = aSelectedObject;
489 if ( myPoint3 && !myPoint1 )
490 Group3Pnts->PushButton1->click();
492 else if ( myEditCurrentArgument == GroupFace->LineEdit1 )
493 myFace = aSelectedObject;
494 else if ( myEditCurrentArgument == Group2Vec->LineEdit1 ) {
495 myVec1 = aSelectedObject;
496 if ( myVec1 && !myVec2 )
497 Group2Vec->PushButton2->click();
498 } else if ( myEditCurrentArgument == Group2Vec->LineEdit2 ) {
499 myVec2 = aSelectedObject;
500 if ( myVec2 && !myVec1 )
501 Group2Vec->PushButton1->click();
502 } else if ( myEditCurrentArgument == GroupLCS->LineEdit1 )
503 myLCS = aSelectedObject;
506 displayPreview(true);
510 //=================================================================================
511 // function : SetEditCurrentArgument()
513 //=================================================================================
514 void BasicGUI_PlaneDlg::SetEditCurrentArgument()
516 QPushButton* send = (QPushButton*)sender();
517 globalSelection( GEOM_POINT );
519 if ( send == GroupPntDir->PushButton1 ) {
520 myEditCurrentArgument = GroupPntDir->LineEdit1;
521 GroupPntDir->PushButton2->setDown( false );
522 GroupPntDir->LineEdit1->setEnabled( true );
523 GroupPntDir->LineEdit2->setEnabled( false );
525 else if ( send == GroupPntDir->PushButton2 ) {
526 myEditCurrentArgument = GroupPntDir->LineEdit2;
527 GroupPntDir->PushButton1->setDown( false );
528 GroupPntDir->LineEdit1->setEnabled( false );
529 GroupPntDir->LineEdit2->setEnabled( true );
531 else if ( send == Group3Pnts->PushButton1 ) {
532 myEditCurrentArgument = Group3Pnts->LineEdit1;
533 Group3Pnts->PushButton2->setDown( false );
534 Group3Pnts->PushButton3->setDown( false );
535 Group3Pnts->LineEdit1->setEnabled( true );
536 Group3Pnts->LineEdit2->setEnabled( false );
537 Group3Pnts->LineEdit3->setEnabled( false );
539 else if ( send == Group3Pnts->PushButton2 ) {
540 myEditCurrentArgument = Group3Pnts->LineEdit2;
541 Group3Pnts->PushButton1->setDown( false );
542 Group3Pnts->PushButton3->setDown( false );
543 Group3Pnts->LineEdit1->setEnabled( false );
544 Group3Pnts->LineEdit2->setEnabled( true );
545 Group3Pnts->LineEdit3->setEnabled( false );
547 else if ( send == Group3Pnts->PushButton3 ) {
548 myEditCurrentArgument = Group3Pnts->LineEdit3;
549 Group3Pnts->PushButton1->setDown( false );
550 Group3Pnts->PushButton2->setDown( false );
551 Group3Pnts->LineEdit1->setEnabled( false );
552 Group3Pnts->LineEdit2->setEnabled( false );
553 Group3Pnts->LineEdit3->setEnabled( true );
555 else if ( send == GroupFace->PushButton1 ) {
556 myEditCurrentArgument = GroupFace->LineEdit1;
557 GroupFace->PushButton1->setDown( true );
558 } else if ( send == Group2Vec->PushButton1 ) {
559 myEditCurrentArgument = Group2Vec->LineEdit1;
560 Group2Vec->PushButton2->setDown( false );
561 Group2Vec->LineEdit1->setEnabled( true );
562 Group2Vec->LineEdit2->setEnabled( false );
563 } else if ( send == Group2Vec->PushButton2 ) {
564 myEditCurrentArgument = Group2Vec->LineEdit2;
565 Group2Vec->PushButton1->setDown( false );
566 Group2Vec->LineEdit1->setEnabled( false );
567 Group2Vec->LineEdit2->setEnabled( true );
568 } else if ( send == GroupLCS->PushButton1 ) {
569 myEditCurrentArgument = GroupLCS->LineEdit1;
570 GroupLCS->LineEdit1->setEnabled( true );
573 myEditCurrentArgument->setFocus();
575 if ( myEditCurrentArgument == GroupPntDir->LineEdit2 ||
576 myEditCurrentArgument == Group2Vec->LineEdit1 ||
577 myEditCurrentArgument == Group2Vec->LineEdit2 ) {
578 localSelection( GEOM::GEOM_Object::_nil(), TopAbs_EDGE );
579 } else if ( myEditCurrentArgument == GroupFace->LineEdit1 ) {
580 TColStd_MapOfInteger aMap;
581 aMap.Add( GEOM_PLANE );
582 aMap.Add( GEOM_MARKER );
583 globalSelection( aMap );
584 } else if ( myEditCurrentArgument == GroupLCS->LineEdit1 ) {
585 globalSelection( GEOM_MARKER );
588 localSelection( GEOM::GEOM_Object::_nil(), TopAbs_VERTEX );
591 // SelectionIntoArgument();
592 myEditCurrentArgument->setFocus();
594 displayPreview(true);
598 //=================================================================================
599 // function : ActivateThisDialog()
601 //=================================================================================
602 void BasicGUI_PlaneDlg::ActivateThisDialog()
604 GEOMBase_Skeleton::ActivateThisDialog();
605 connect( myGeomGUI->getApp()->selectionMgr(), SIGNAL( currentSelectionChanged() ),
606 this, SLOT( SelectionIntoArgument() ) );
608 ConstructorsClicked( getConstructorId() );
609 SelectionIntoArgument();
612 //=================================================================================
613 // function : DeactivateActiveDialog()
614 // purpose : public slot to deactivate if active
615 //=================================================================================
616 void BasicGUI_PlaneDlg::DeactivateActiveDialog()
618 GEOMBase_Skeleton::DeactivateActiveDialog();
621 //=================================================================================
622 // function : enterEvent()
624 //=================================================================================
625 void BasicGUI_PlaneDlg::enterEvent( QEvent* )
627 if ( !mainFrame()->GroupConstructors->isEnabled() )
628 ActivateThisDialog();
632 //=================================================================================
633 // function : ValueChangedInSpinBox()
635 //=================================================================================
636 void BasicGUI_PlaneDlg::ValueChangedInSpinBox( double newValue )
638 displayPreview(true);
641 //=================================================================================
642 // function : getSize()
644 //=================================================================================
645 double BasicGUI_PlaneDlg::getSize() const
647 switch ( getConstructorId() ) {
648 case 0 : return GroupPntDir->SpinBox_DX->value();
649 case 1 : return Group3Pnts->SpinBox_DX->value();
650 case 2 : return GroupFace->SpinBox_DX->value();
651 case 3 : return Group2Vec->SpinBox_DX->value();
652 case 4 : return GroupLCS->SpinBox_DX->value();
657 //=================================================================================
658 // function : getSize()
660 //=================================================================================
661 QString BasicGUI_PlaneDlg::getSizeAsString() const
663 switch ( getConstructorId() ) {
664 case 0 : return GroupPntDir->SpinBox_DX->text();
665 case 1 : return Group3Pnts->SpinBox_DX->text();
666 case 2 : return GroupFace->SpinBox_DX->text();
667 case 3 : return Group2Vec->SpinBox_DX->text();
672 //=================================================================================
673 // function : createOperation
675 //=================================================================================
676 GEOM::GEOM_IOperations_ptr BasicGUI_PlaneDlg::createOperation()
678 return myGeomGUI->GetGeomGen()->GetIBasicOperations( getStudyId() );
681 //=================================================================================
682 // function : isValid
684 //=================================================================================
685 bool BasicGUI_PlaneDlg::isValid( QString& msg )
688 if ( getSize() <= 0 ) {
689 msg = QString( "Please, enter size greater than 0." );
692 switch ( getConstructorId() ) {
694 ok = GroupPntDir->SpinBox_DX->isValid( msg, !IsPreview() ) && myPoint && myDir;
697 ok = Group3Pnts->SpinBox_DX->isValid( msg, !IsPreview() ) &&
698 myPoint1 && myPoint2 && myPoint3 &&
699 myPoint1 != myPoint2 && myPoint1 != myPoint3 && myPoint2 != myPoint3;
702 ok = GroupFace->SpinBox_DX->isValid( msg, !IsPreview() ) && myFace;
705 ok = Group2Vec->SpinBox_DX->isValid( msg, !IsPreview() ) &&
706 myVec1 && myVec2 && myVec1 != myVec2;
709 ok = GroupLCS->SpinBox_DX->isValid( msg, !IsPreview() );
718 //=================================================================================
719 // function : execute
721 //=================================================================================
722 bool BasicGUI_PlaneDlg::execute( ObjectList& objects )
726 GEOM::GEOM_Object_var anObj;
728 GEOM::GEOM_IBasicOperations_var anOper = GEOM::GEOM_IBasicOperations::_narrow( getOperation() );
730 switch ( getConstructorId() ) {
732 anObj = anOper->MakePlanePntVec( myPoint.get(), myDir.get(), getSize() );
736 anObj = anOper->MakePlaneThreePnt( myPoint1.get(), myPoint2.get(), myPoint3.get(), getSize() );
740 anObj = anOper->MakePlaneFace( myFace.get(), getSize() );
744 anObj = anOper->MakePlane2Vec( myVec1.get(), myVec2.get(), getSize() );
748 anObj = anOper->MakePlaneLCS( myLCS.get(), getSize(), myOriginType );
753 if ( !anObj->_is_nil() ) {
755 anObj->SetParameters(getSizeAsString().toLatin1().constData());
756 objects.push_back( anObj._retn() );
760 //=================================================================================
761 // function : addSubshapeToStudy
762 // purpose : virtual method to add new SubObjects if local selection
763 //=================================================================================
764 void BasicGUI_PlaneDlg::addSubshapesToStudy()
766 switch ( getConstructorId() ) {
768 GEOMBase::PublishSubObject( myPoint.get() );
769 GEOMBase::PublishSubObject( myDir.get() );
772 GEOMBase::PublishSubObject( myPoint1.get() );
773 GEOMBase::PublishSubObject( myPoint2.get() );
774 GEOMBase::PublishSubObject( myPoint3.get() );
777 GEOMBase::PublishSubObject( myFace.get() );
780 GEOMBase::PublishSubObject( myVec1.get() );
781 GEOMBase::PublishSubObject( myVec2.get() );
784 GEOMBase::PublishSubObject( myLCS.get() );