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_CircleDlg.cxx
24 // Author : Lucien PIGNOLONI, Open CASCADE S.A.S.
26 #include "BasicGUI_CircleDlg.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_IndexedMapOfInteger.hxx>
39 #include <TopTools_IndexedMapOfShape.hxx>
40 #include <TopoDS_Shape.hxx>
41 #include <TopoDS_Edge.hxx>
45 //=================================================================================
46 // class : BasicGUI_CircleDlg()
47 // purpose : Constructs a BasicGUI_CircleDlg which is a child of 'parent', with the
48 // name 'name' and widget flags set to 'f'.
49 // The dialog will by default be modeless, unless you set 'modal' to
50 // TRUE to construct a modal dialog.
51 //=================================================================================
52 BasicGUI_CircleDlg::BasicGUI_CircleDlg( GeometryGUI* theGeometryGUI, QWidget* parent,
53 bool modal, Qt::WindowFlags fl )
54 : GEOMBase_Skeleton( theGeometryGUI, parent, modal, fl )
56 QPixmap image0( SUIT_Session::session()->resourceMgr()->loadPixmap( "GEOM", tr( "ICON_DLG_CIRCLE_PV" ) ) );
57 QPixmap image2( SUIT_Session::session()->resourceMgr()->loadPixmap( "GEOM", tr( "ICON_DLG_CIRCLE_PNTS" ) ) );
58 QPixmap image3( SUIT_Session::session()->resourceMgr()->loadPixmap( "GEOM", tr( "ICON_DLG_CIRCLE_C2P" ) ) );
59 QPixmap image1( SUIT_Session::session()->resourceMgr()->loadPixmap( "GEOM", tr( "ICON_SELECT" ) ) );
61 setWindowTitle( tr( "GEOM_CIRCLE_TITLE" ) );
63 /***************************************************************/
64 mainFrame()->GroupConstructors->setTitle( tr( "GEOM_CIRCLE" ) );
65 mainFrame()->RadioButton1->setIcon( image0 );
66 mainFrame()->RadioButton2->setIcon( image2 );
67 mainFrame()->RadioButton3->setIcon( image3 );
69 GroupPntVecR = new DlgRef_2Sel1Spin( centralWidget() );
70 GroupPntVecR->GroupBox1->setTitle( tr( "GEOM_ARGUMENTS" ) );
72 GroupPntVecR->TextLabel1->setText( tr( "GEOM_CENTER_POINT" ) + " (Origin by default)" );
73 GroupPntVecR->TextLabel2->setText( tr( "GEOM_VECTOR" ) + " (Z axis by default)" );
74 GroupPntVecR->TextLabel3->setText( tr( "GEOM_RADIUS" ) );
75 GroupPntVecR->PushButton1->setIcon( image1 );
76 GroupPntVecR->PushButton2->setIcon( image1 );
77 GroupPntVecR->PushButton1->setDown( true );
79 GroupPntVecR->LineEdit1->setReadOnly( true );
80 GroupPntVecR->LineEdit2->setReadOnly( true );
82 GroupPntVecR->LineEdit1->setEnabled( true );
83 GroupPntVecR->LineEdit2->setEnabled( false );
85 Group3Pnts = new DlgRef_3Sel( centralWidget() );
87 Group3Pnts->GroupBox1->setTitle( tr( "GEOM_3_POINTS" ) );
88 Group3Pnts->TextLabel1->setText( tr( "GEOM_POINT1" ) );
89 Group3Pnts->TextLabel2->setText( tr( "GEOM_POINT2" ) );
90 Group3Pnts->TextLabel3->setText( tr( "GEOM_POINT3" ) );
91 Group3Pnts->PushButton1->setIcon( image1 );
92 Group3Pnts->PushButton2->setIcon( image1 );
93 Group3Pnts->PushButton3->setIcon( image1 );
94 Group3Pnts->PushButton1->setDown( true );
96 Group3Pnts->LineEdit1->setReadOnly( true );
97 Group3Pnts->LineEdit2->setReadOnly( true );
98 Group3Pnts->LineEdit3->setReadOnly( true );
99 Group3Pnts->LineEdit1->setEnabled( true );
100 Group3Pnts->LineEdit2->setEnabled( false );
101 Group3Pnts->LineEdit3->setEnabled( false );
103 GroupCenter2Pnts = new DlgRef_3Sel( centralWidget() );
104 GroupCenter2Pnts->GroupBox1->setTitle( tr( "GEOM_CENTER_2POINTS" ) );
105 GroupCenter2Pnts->TextLabel1->setText( tr( "GEOM_CENTER_POINT" ) );
106 GroupCenter2Pnts->TextLabel2->setText( tr( "GEOM_POINT1" ) );
107 GroupCenter2Pnts->TextLabel3->setText( tr( "GEOM_POINT2" ) );
108 GroupCenter2Pnts->PushButton1->setIcon( image1 );
109 GroupCenter2Pnts->PushButton2->setIcon( image1 );
110 GroupCenter2Pnts->PushButton3->setIcon( image1 );
111 GroupCenter2Pnts->PushButton1->setDown( true );
113 GroupCenter2Pnts->LineEdit1->setReadOnly( true );
114 GroupCenter2Pnts->LineEdit2->setReadOnly( true );
115 GroupCenter2Pnts->LineEdit3->setReadOnly( true );
117 GroupCenter2Pnts->LineEdit1->setEnabled( true );
118 GroupCenter2Pnts->LineEdit2->setEnabled( false );
119 GroupCenter2Pnts->LineEdit3->setEnabled( false );
121 QVBoxLayout* layout = new QVBoxLayout( centralWidget() );
122 layout->setMargin( 0 ); layout->setSpacing( 6 );
123 layout->addWidget( GroupPntVecR );
124 layout->addWidget( Group3Pnts );
125 layout->addWidget( GroupCenter2Pnts );
126 /***************************************************************/
128 setHelpFileName( "create_circle_page.html" );
134 //=================================================================================
135 // function : ~BasicGUI_CircleDlg()
136 // purpose : Destroys the object and frees any allocated resources
137 //=================================================================================
138 BasicGUI_CircleDlg::~BasicGUI_CircleDlg()
143 //=================================================================================
146 //=================================================================================
147 void BasicGUI_CircleDlg::Init()
150 myEditCurrentArgument = GroupPntVecR->LineEdit1;
152 myPoint = myDir = myPoint1 = myPoint2 = myPoint3 = GEOM::GEOM_Object::_nil();
154 // myGeomGUI->SetState( 0 );
156 /* Get setting of step value from file configuration */
157 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
158 double aStep = resMgr->doubleValue( "Geometry", "SettingsGeomStep", 100 );
160 /* min, max, step and decimals for spin boxes & initial values */
161 initSpinBox( GroupPntVecR->SpinBox_DX, 0.000001, COORD_MAX, aStep, 6 ); // VSR: TODO: DBL_DIGITS_DISPLAY
162 GroupPntVecR->SpinBox_DX->setValue( 100 );
164 /* signals and slots connections */
165 connect( myGeomGUI, SIGNAL( SignalDeactivateActiveDialog() ), this, SLOT( DeactivateActiveDialog() ) );
166 connect( myGeomGUI, SIGNAL( SignalCloseAllDialogs() ), this, SLOT( ClickOnCancel() ) );
168 connect( buttonOk(), SIGNAL( clicked() ), this, SLOT( ClickOnOk() ) );
169 connect( buttonApply(), SIGNAL( clicked() ), this, SLOT( ClickOnApply() ) );
171 connect( this, SIGNAL( constructorsClicked( int ) ), this, SLOT( ConstructorsClicked( int ) ) );
173 connect( GroupPntVecR->PushButton1, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) );
174 connect( GroupPntVecR->PushButton2, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) );
175 connect( Group3Pnts->PushButton1, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) );
176 connect( Group3Pnts->PushButton2, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) );
177 connect( Group3Pnts->PushButton3, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) );
179 connect( GroupCenter2Pnts->PushButton1, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) );
180 connect( GroupCenter2Pnts->PushButton2, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) );
181 connect( GroupCenter2Pnts->PushButton3, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) );
183 connect( GroupPntVecR->LineEdit1, SIGNAL( returnPressed() ), this, SLOT( LineEditReturnPressed() ) );
184 connect( GroupPntVecR->LineEdit2, SIGNAL( returnPressed() ), this, SLOT( LineEditReturnPressed() ) );
186 connect( GroupPntVecR->SpinBox_DX, SIGNAL( valueChanged( double ) ), this, SLOT(ValueChangedInSpinBox() ) );
187 connect( myGeomGUI, SIGNAL( SignalDefaultStepValueChanged( double ) ), this, SLOT( SetDoubleSpinBoxStep( double ) ) );
189 connect( myGeomGUI->getApp()->selectionMgr(), SIGNAL( currentSelectionChanged() ),
190 this, SLOT( SelectionIntoArgument() ) );
192 initName( tr( "GEOM_CIRCLE" ) );
194 ConstructorsClicked( 0 );
197 //=================================================================================
198 // function : SetDoubleSpinBoxStep()
199 // purpose : Double spin box management
200 //=================================================================================
201 void BasicGUI_CircleDlg::SetDoubleSpinBoxStep( double step )
203 GroupPntVecR->SpinBox_DX->setSingleStep(step);
206 //=================================================================================
207 // function : ConstructorsClicked()
208 // purpose : Radio button management
209 //=================================================================================
210 void BasicGUI_CircleDlg::ConstructorsClicked( int constructorId )
212 disconnect( myGeomGUI->getApp()->selectionMgr(), 0, this, 0);
214 myPoint = myDir = myPoint1 = myPoint2 = myPoint3 = GEOM::GEOM_Object::_nil();
216 switch ( constructorId ) {
220 GroupCenter2Pnts->hide();
221 GroupPntVecR->show();
223 myEditCurrentArgument = GroupPntVecR->LineEdit1;
224 GroupPntVecR->LineEdit1->setText( "" );
225 GroupPntVecR->LineEdit2->setText( "" );
226 GroupPntVecR->PushButton1->setDown( true );
227 GroupPntVecR->PushButton2->setDown( false );
228 GroupPntVecR->LineEdit1->setEnabled( true );
229 GroupPntVecR->LineEdit2->setEnabled( false );
234 GroupPntVecR->hide();
235 GroupCenter2Pnts->hide();
238 myEditCurrentArgument = Group3Pnts->LineEdit1;
239 Group3Pnts->LineEdit1->setText( "" );
240 Group3Pnts->LineEdit2->setText( "" );
241 Group3Pnts->LineEdit3->setText( "" );
242 Group3Pnts->PushButton1->setDown( true );
243 Group3Pnts->PushButton2->setDown( false );
244 Group3Pnts->PushButton3->setDown( false );
245 Group3Pnts->LineEdit1->setEnabled( true );
246 Group3Pnts->LineEdit2->setEnabled( false );
247 Group3Pnts->LineEdit3->setEnabled( false );
252 GroupPntVecR->hide();
254 GroupCenter2Pnts->show();
256 myEditCurrentArgument = GroupCenter2Pnts->LineEdit1;
257 GroupCenter2Pnts->LineEdit1->setText( "" );
258 GroupCenter2Pnts->LineEdit2->setText( "" );
259 GroupCenter2Pnts->LineEdit3->setText( "" );
260 GroupCenter2Pnts->PushButton1->setDown( true );
261 GroupCenter2Pnts->PushButton2->setDown( false );
262 GroupCenter2Pnts->PushButton3->setDown( false );
263 GroupCenter2Pnts->LineEdit1->setEnabled( true );
264 GroupCenter2Pnts->LineEdit2->setEnabled( false );
265 GroupCenter2Pnts->LineEdit3->setEnabled( false );
270 qApp->processEvents();
272 resize( minimumSizeHint() );
274 myEditCurrentArgument->setFocus();
275 globalSelection(); // close local contexts, if any
276 localSelection( GEOM::GEOM_Object::_nil(), TopAbs_VERTEX );
278 connect( myGeomGUI->getApp()->selectionMgr(), SIGNAL(currentSelectionChanged() ),
279 this, SLOT( SelectionIntoArgument() ) );
284 //=================================================================================
285 // function : ClickOnOk()
287 //=================================================================================
288 void BasicGUI_CircleDlg::ClickOnOk()
290 if ( ClickOnApply() )
294 //=================================================================================
295 // function : ClickOnApply()
297 //=================================================================================
298 bool BasicGUI_CircleDlg::ClickOnApply()
304 ConstructorsClicked( getConstructorId() );
308 //=================================================================================
309 // function : SelectionIntoArgument()
310 // purpose : Called when selection as changed or other case
311 //=================================================================================
312 void BasicGUI_CircleDlg::SelectionIntoArgument()
314 myEditCurrentArgument->setText( "" );
316 LightApp_SelectionMgr* aSelMgr = myGeomGUI->getApp()->selectionMgr();
318 aSelMgr->selectedObjects( aList );
320 if ( aList.Extent() != 1 ) {
321 if ( myEditCurrentArgument == GroupPntVecR->LineEdit1 ) myPoint = GEOM::GEOM_Object::_nil();
322 else if ( myEditCurrentArgument == GroupPntVecR->LineEdit2 ) myDir = GEOM::GEOM_Object::_nil();
323 else if ( myEditCurrentArgument == Group3Pnts->LineEdit1 ) myPoint1 = GEOM::GEOM_Object::_nil();
324 else if ( myEditCurrentArgument == Group3Pnts->LineEdit2 ) myPoint2 = GEOM::GEOM_Object::_nil();
325 else if ( myEditCurrentArgument == Group3Pnts->LineEdit3 ) myPoint3 = GEOM::GEOM_Object::_nil();
326 else if ( myEditCurrentArgument == GroupCenter2Pnts->LineEdit1 ) myPoint4 = GEOM::GEOM_Object::_nil();
327 else if ( myEditCurrentArgument == GroupCenter2Pnts->LineEdit2 ) myPoint5 = GEOM::GEOM_Object::_nil();
328 else if ( myEditCurrentArgument == GroupCenter2Pnts->LineEdit3 ) myPoint6 = GEOM::GEOM_Object::_nil();
333 Handle(SALOME_InteractiveObject) anIO = aList.First();
335 Standard_Boolean aRes = Standard_False;
336 GEOM::GEOM_Object_var aSelectedObject = GEOMBase::ConvertIOinGEOMObject(anIO, aRes);
337 if ( !CORBA::is_nil( aSelectedObject ) && aRes ) {
338 QString aName = GEOMBase::GetName( aSelectedObject );
340 TopAbs_ShapeEnum aNeedType = TopAbs_VERTEX;
341 if ( myEditCurrentArgument == GroupPntVecR->LineEdit2 )
342 aNeedType = TopAbs_EDGE;
344 // If selected Vertex or Edge on the some Shape Get selection Subshape
346 if ( GEOMBase::GetShape( aSelectedObject, aShape, TopAbs_SHAPE ) && !aShape.IsNull() ) {
347 TColStd_IndexedMapOfInteger aMap;
348 aSelMgr->GetIndexes(anIO, aMap);
349 if ( aMap.Extent() == 1 ) { // Local Selection
350 int anIndex = aMap(1);
351 if ( aNeedType == TopAbs_EDGE )
352 aName += QString( ":edge_%1" ).arg( anIndex );
354 aName += QString( ":vertex_%1" ).arg( anIndex );
356 //Find SubShape Object in Father
357 GEOM::GEOM_Object_var aFindedObject = GEOMBase_Helper::findObjectInFather( aSelectedObject, aName );
359 if ( aFindedObject == GEOM::GEOM_Object::_nil() ) { // Object not found in study
360 GEOM::GEOM_IShapesOperations_var aShapesOp = getGeomEngine()->GetIShapesOperations( getStudyId() );
361 aSelectedObject = aShapesOp->GetSubShape( aSelectedObject, anIndex );
364 aSelectedObject = aFindedObject; // get Object from study
367 else { // Global Selection
368 if ( aShape.ShapeType() != aNeedType ) {
369 aSelectedObject = GEOM::GEOM_Object::_nil();
375 myEditCurrentArgument->setText( aName );
377 if (!aSelectedObject->_is_nil()) { // clear selection if something selected
379 localSelection( GEOM::GEOM_Object::_nil(), aNeedType );
382 if ( myEditCurrentArgument == GroupPntVecR->LineEdit1 ) {
383 myPoint = aSelectedObject;
384 if ( !myPoint->_is_nil() && myDir->_is_nil() )
385 GroupPntVecR->PushButton2->click();
387 else if ( myEditCurrentArgument == GroupPntVecR->LineEdit2 ) {
388 myDir = aSelectedObject;
389 if ( !myDir->_is_nil() && myPoint->_is_nil() )
390 GroupPntVecR->PushButton1->click();
392 else if ( myEditCurrentArgument == Group3Pnts->LineEdit1 ) {
393 myPoint1 = aSelectedObject;
394 if ( !myPoint1->_is_nil() && myPoint2->_is_nil() )
395 Group3Pnts->PushButton2->click();
397 else if ( myEditCurrentArgument == Group3Pnts->LineEdit2 ) {
398 myPoint2 = aSelectedObject;
399 if ( !myPoint2->_is_nil() && myPoint3->_is_nil() )
400 Group3Pnts->PushButton3->click();
402 else if ( myEditCurrentArgument == Group3Pnts->LineEdit3 ) {
403 myPoint3 = aSelectedObject;
404 if ( !myPoint3->_is_nil() && myPoint1->_is_nil() )
405 Group3Pnts->PushButton1->click();
407 else if ( myEditCurrentArgument == GroupCenter2Pnts->LineEdit1 ) {
408 myPoint4 = aSelectedObject;
409 if ( !myPoint4->_is_nil() && myPoint5->_is_nil() )
410 GroupCenter2Pnts->PushButton2->click();
412 else if ( myEditCurrentArgument == GroupCenter2Pnts->LineEdit2 ) {
413 myPoint5 = aSelectedObject;
414 if ( !myPoint5->_is_nil() && myPoint6->_is_nil() )
415 GroupCenter2Pnts->PushButton3->click();
417 else if ( myEditCurrentArgument == GroupCenter2Pnts->LineEdit3 ) {
418 myPoint6 = aSelectedObject;
419 if ( !myPoint6->_is_nil() && myPoint4->_is_nil() )
420 GroupCenter2Pnts->PushButton1->click();
428 //=================================================================================
429 // function : SetEditCurrentArgument()
431 //=================================================================================
432 void BasicGUI_CircleDlg::SetEditCurrentArgument()
434 QPushButton* send = (QPushButton*)sender();
436 if ( send == GroupPntVecR->PushButton1 ) {
437 myEditCurrentArgument = GroupPntVecR->LineEdit1;
438 GroupPntVecR->PushButton2->setDown(false);
439 GroupPntVecR->LineEdit1->setEnabled( true );
440 GroupPntVecR->LineEdit2->setEnabled( false );
442 else if ( send == GroupPntVecR->PushButton2 ) {
443 myEditCurrentArgument = GroupPntVecR->LineEdit2;
444 GroupPntVecR->PushButton1->setDown(false);
445 GroupPntVecR->LineEdit1->setEnabled( false );
446 GroupPntVecR->LineEdit2->setEnabled( true );
448 else if ( send == Group3Pnts->PushButton1 ) {
449 myEditCurrentArgument = Group3Pnts->LineEdit1;
450 Group3Pnts->PushButton2->setDown( false );
451 Group3Pnts->PushButton3->setDown( false );
452 Group3Pnts->LineEdit1->setEnabled( true );
453 Group3Pnts->LineEdit2->setEnabled( false );
454 Group3Pnts->LineEdit3->setEnabled( false );
456 else if ( send == Group3Pnts->PushButton2 ) {
457 myEditCurrentArgument = Group3Pnts->LineEdit2;
458 Group3Pnts->PushButton1->setDown( false );
459 Group3Pnts->PushButton3->setDown( false );
460 Group3Pnts->LineEdit1->setEnabled( false );
461 Group3Pnts->LineEdit2->setEnabled( true );
462 Group3Pnts->LineEdit3->setEnabled( false );
464 else if ( send == Group3Pnts->PushButton3 ) {
465 myEditCurrentArgument = Group3Pnts->LineEdit3;
466 Group3Pnts->PushButton1->setDown( false );
467 Group3Pnts->PushButton2->setDown( false );
468 Group3Pnts->LineEdit1->setEnabled( false );
469 Group3Pnts->LineEdit2->setEnabled( false );
470 Group3Pnts->LineEdit3->setEnabled( true );
472 else if ( send == GroupCenter2Pnts->PushButton1 ) {
473 myEditCurrentArgument = GroupCenter2Pnts->LineEdit1;
474 GroupCenter2Pnts->PushButton2->setDown( false );
475 GroupCenter2Pnts->PushButton3->setDown( false );
476 GroupCenter2Pnts->LineEdit1->setEnabled( true );
477 GroupCenter2Pnts->LineEdit2->setEnabled( false );
478 GroupCenter2Pnts->LineEdit3->setEnabled( false );
480 else if ( send == GroupCenter2Pnts->PushButton2 ) {
481 myEditCurrentArgument = GroupCenter2Pnts->LineEdit2;
482 GroupCenter2Pnts->PushButton1->setDown( false );
483 GroupCenter2Pnts->PushButton3->setDown( false );
484 GroupCenter2Pnts->LineEdit1->setEnabled( false );
485 GroupCenter2Pnts->LineEdit2->setEnabled( true );
486 GroupCenter2Pnts->LineEdit3->setEnabled( false );
489 else if ( send == GroupCenter2Pnts->PushButton3 ) {
490 myEditCurrentArgument = GroupCenter2Pnts->LineEdit3;
491 GroupCenter2Pnts->PushButton1->setDown( false );
492 GroupCenter2Pnts->PushButton2->setDown( false );
493 GroupCenter2Pnts->LineEdit1->setEnabled( false );
494 GroupCenter2Pnts->LineEdit2->setEnabled( false );
495 GroupCenter2Pnts->LineEdit3->setEnabled( true );
499 myEditCurrentArgument->setFocus();
501 if ( myEditCurrentArgument == GroupPntVecR->LineEdit2 ) {
502 globalSelection(); // close local contexts, if any
503 localSelection( GEOM::GEOM_Object::_nil(), TopAbs_EDGE );
506 globalSelection(); // close local contexts, if any
507 localSelection( GEOM::GEOM_Object::_nil(), TopAbs_VERTEX );
510 myEditCurrentArgument->setFocus();
511 // SelectionIntoArgument();
516 //=================================================================================
517 // function : LineEditReturnPressed()
519 //=================================================================================
520 void BasicGUI_CircleDlg::LineEditReturnPressed()
522 QLineEdit* send = (QLineEdit*)sender();
523 if ( send == GroupPntVecR->LineEdit1 ||
524 send == GroupPntVecR->LineEdit2 ||
525 send == Group3Pnts->LineEdit1 ||
526 send == Group3Pnts->LineEdit2 ||
527 send == Group3Pnts->LineEdit3 ||
528 send == GroupCenter2Pnts->LineEdit1 ||
529 send == GroupCenter2Pnts->LineEdit2 ||
530 send == GroupCenter2Pnts->LineEdit3 ) {
531 myEditCurrentArgument = send;
532 GEOMBase_Skeleton::LineEditReturnPressed();
537 //=================================================================================
538 // function : ActivateThisDialog()
540 //=================================================================================
541 void BasicGUI_CircleDlg::ActivateThisDialog()
543 GEOMBase_Skeleton::ActivateThisDialog();
545 connect( myGeomGUI->getApp()->selectionMgr(), SIGNAL( currentSelectionChanged() ),
546 this, SLOT( SelectionIntoArgument() ) );
548 ConstructorsClicked( getConstructorId() );
552 //=================================================================================
553 // function : enterEvent()
555 //=================================================================================
556 void BasicGUI_CircleDlg::enterEvent( QEvent* )
558 if ( !mainFrame()->GroupConstructors->isEnabled() )
559 ActivateThisDialog();
562 //=================================================================================
563 // function : DeactivateActiveDialog()
564 // purpose : public slot to deactivate if active
565 //=================================================================================
566 void BasicGUI_CircleDlg::DeactivateActiveDialog()
568 // myGeomGUI->SetState( -1 );
569 GEOMBase_Skeleton::DeactivateActiveDialog();
572 //=================================================================================
573 // function : ValueChangedInSpinBox()
575 //=================================================================================
576 void BasicGUI_CircleDlg::ValueChangedInSpinBox()
581 //=================================================================================
582 // function : getRadius()
584 //=================================================================================
585 double BasicGUI_CircleDlg::getRadius() const
588 switch ( getConstructorId() ) {
590 r = GroupPntVecR->SpinBox_DX->value(); break;
595 //=================================================================================
596 // function : createOperation
598 //=================================================================================
599 GEOM::GEOM_IOperations_ptr BasicGUI_CircleDlg::createOperation()
601 return myGeomGUI->GetGeomGen()->GetICurvesOperations( getStudyId() );
604 //=================================================================================
605 // function : isEqual
606 // purpose : it may also be needed to check for min distance between gp_Pnt-s...
607 //=================================================================================
608 static bool isEqual( const GEOM::GEOM_Object_var& thePnt1, const GEOM::GEOM_Object_var& thePnt2 )
610 return thePnt1->_is_equivalent( thePnt2 );
613 //=================================================================================
614 // function : isValid
616 //=================================================================================
617 bool BasicGUI_CircleDlg::isValid( QString& msg )
619 const int id = getConstructorId();
621 //return !myPoint->_is_nil() && !myDir->_is_nil() && getRadius() > 0;
622 //nil point means origin of global CS
623 //nil vector means Z axis
624 bool ok = GroupPntVecR->SpinBox_DX->isValid(msg, !IsPreview());
625 return getRadius() > 0 && ok;
628 return !myPoint1->_is_nil() && !myPoint2->_is_nil() && !myPoint3->_is_nil() &&
629 !isEqual( myPoint1, myPoint2 ) && !isEqual( myPoint1, myPoint3 ) && !isEqual( myPoint2, myPoint3 );
631 return !myPoint4->_is_nil() && !myPoint5->_is_nil() && !myPoint6->_is_nil() &&
632 !isEqual( myPoint4, myPoint5 ) && !isEqual( myPoint5, myPoint6 ) && !isEqual( myPoint4, myPoint6 );
636 //=================================================================================
637 // function : execute
639 //=================================================================================
640 bool BasicGUI_CircleDlg::execute( ObjectList& objects )
644 GEOM::GEOM_Object_var anObj;
646 switch ( getConstructorId() ) {
649 QStringList aParameters;
650 aParameters << GroupPntVecR->SpinBox_DX->text();
651 anObj = GEOM::GEOM_ICurvesOperations::_narrow( getOperation() )->MakeCirclePntVecR( myPoint, myDir, getRadius() );
652 if ( !anObj->_is_nil() && !IsPreview() )
653 anObj->SetParameters(GeometryGUI::JoinObjectParameters(aParameters));
658 anObj = GEOM::GEOM_ICurvesOperations::_narrow( getOperation() )->MakeCircleThreePnt( myPoint1, myPoint2, myPoint3 );
662 anObj = GEOM::GEOM_ICurvesOperations::_narrow( getOperation() )->MakeCircleCenter2Pnt( myPoint4, myPoint5, myPoint6 );
667 if ( !anObj->_is_nil() )
668 objects.push_back( anObj._retn() );
670 MESSAGE( "Execute Object is NULL!" );
676 //=================================================================================
677 // function : addSubshapeToStudy
678 // purpose : virtual method to add new SubObjects if local selection
679 //=================================================================================
680 void BasicGUI_CircleDlg::addSubshapesToStudy()
682 QMap<QString, GEOM::GEOM_Object_var> objMap;
684 switch ( getConstructorId() ) {
686 if (!CORBA::is_nil(myPoint))
687 objMap[GroupPntVecR->LineEdit1->text()] = myPoint;
688 if (!CORBA::is_nil(myDir))
689 objMap[GroupPntVecR->LineEdit2->text()] = myDir;
692 objMap[Group3Pnts->LineEdit1->text()] = myPoint1;
693 objMap[Group3Pnts->LineEdit2->text()] = myPoint2;
694 objMap[Group3Pnts->LineEdit3->text()] = myPoint3;
697 objMap[GroupCenter2Pnts->LineEdit1->text()] = myPoint4;
698 objMap[GroupCenter2Pnts->LineEdit2->text()] = myPoint5;
699 objMap[GroupCenter2Pnts->LineEdit3->text()] = myPoint6;
702 addSubshapesToFather( objMap );