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_CircleDlg.cxx
25 // Author : Lucien PIGNOLONI, Open CASCADE S.A.S.
27 #include "BasicGUI_CircleDlg.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_IndexedMapOfInteger.hxx>
40 #include <TopTools_IndexedMapOfShape.hxx>
41 #include <TopoDS_Shape.hxx>
42 #include <TopoDS_Edge.hxx>
46 //=================================================================================
47 // class : BasicGUI_CircleDlg()
48 // purpose : Constructs a BasicGUI_CircleDlg which is a child of 'parent', with the
49 // name 'name' and widget flags set to 'f'.
50 // The dialog will by default be modeless, unless you set 'modal' to
51 // TRUE to construct a modal dialog.
52 //=================================================================================
53 BasicGUI_CircleDlg::BasicGUI_CircleDlg( GeometryGUI* theGeometryGUI, QWidget* parent,
54 bool modal, Qt::WindowFlags fl )
55 : GEOMBase_Skeleton( theGeometryGUI, parent, modal, fl )
57 QPixmap image0( SUIT_Session::session()->resourceMgr()->loadPixmap( "GEOM", tr( "ICON_DLG_CIRCLE_PV" ) ) );
58 QPixmap image2( SUIT_Session::session()->resourceMgr()->loadPixmap( "GEOM", tr( "ICON_DLG_CIRCLE_PNTS" ) ) );
59 QPixmap image3( SUIT_Session::session()->resourceMgr()->loadPixmap( "GEOM", tr( "ICON_DLG_CIRCLE_C2P" ) ) );
60 QPixmap image1( SUIT_Session::session()->resourceMgr()->loadPixmap( "GEOM", tr( "ICON_SELECT" ) ) );
62 setWindowTitle( tr( "GEOM_CIRCLE_TITLE" ) );
64 /***************************************************************/
65 mainFrame()->GroupConstructors->setTitle( tr( "GEOM_CIRCLE" ) );
66 mainFrame()->RadioButton1->setIcon( image0 );
67 mainFrame()->RadioButton2->setIcon( image2 );
68 mainFrame()->RadioButton3->setIcon( image3 );
70 GroupPntVecR = new DlgRef_2Sel1Spin( centralWidget() );
71 GroupPntVecR->GroupBox1->setTitle( tr( "GEOM_ARGUMENTS" ) );
73 GroupPntVecR->TextLabel1->setText( tr( "GEOM_CENTER_POINT" ) + " " + tr( "GEOM_CENTER_DEFAULT" ) );
74 GroupPntVecR->TextLabel2->setText( tr( "GEOM_VECTOR" ) + " " + tr( "GEOM_AXIS_DEFAULT" ) );
75 GroupPntVecR->TextLabel3->setText( tr( "GEOM_RADIUS" ) );
76 GroupPntVecR->PushButton1->setIcon( image1 );
77 GroupPntVecR->PushButton2->setIcon( image1 );
78 GroupPntVecR->PushButton1->setDown( true );
80 GroupPntVecR->LineEdit1->setReadOnly( true );
81 GroupPntVecR->LineEdit2->setReadOnly( true );
83 GroupPntVecR->LineEdit1->setEnabled( true );
84 GroupPntVecR->LineEdit2->setEnabled( false );
86 Group3Pnts = new DlgRef_3Sel( centralWidget() );
88 Group3Pnts->GroupBox1->setTitle( tr( "GEOM_3_POINTS" ) );
89 Group3Pnts->TextLabel1->setText( tr( "GEOM_POINT1" ) );
90 Group3Pnts->TextLabel2->setText( tr( "GEOM_POINT2" ) );
91 Group3Pnts->TextLabel3->setText( tr( "GEOM_POINT3" ) );
92 Group3Pnts->PushButton1->setIcon( image1 );
93 Group3Pnts->PushButton2->setIcon( image1 );
94 Group3Pnts->PushButton3->setIcon( image1 );
95 Group3Pnts->PushButton1->setDown( true );
97 Group3Pnts->LineEdit1->setReadOnly( true );
98 Group3Pnts->LineEdit2->setReadOnly( true );
99 Group3Pnts->LineEdit3->setReadOnly( true );
100 Group3Pnts->LineEdit1->setEnabled( true );
101 Group3Pnts->LineEdit2->setEnabled( false );
102 Group3Pnts->LineEdit3->setEnabled( false );
104 GroupCenter2Pnts = new DlgRef_3Sel( centralWidget() );
105 GroupCenter2Pnts->GroupBox1->setTitle( tr( "GEOM_CENTER_2POINTS" ) );
106 GroupCenter2Pnts->TextLabel1->setText( tr( "GEOM_CENTER_POINT" ) );
107 GroupCenter2Pnts->TextLabel2->setText( tr( "GEOM_POINT1" ) );
108 GroupCenter2Pnts->TextLabel3->setText( tr( "GEOM_POINT2" ) );
109 GroupCenter2Pnts->PushButton1->setIcon( image1 );
110 GroupCenter2Pnts->PushButton2->setIcon( image1 );
111 GroupCenter2Pnts->PushButton3->setIcon( image1 );
112 GroupCenter2Pnts->PushButton1->setDown( true );
114 GroupCenter2Pnts->LineEdit1->setReadOnly( true );
115 GroupCenter2Pnts->LineEdit2->setReadOnly( true );
116 GroupCenter2Pnts->LineEdit3->setReadOnly( true );
118 GroupCenter2Pnts->LineEdit1->setEnabled( true );
119 GroupCenter2Pnts->LineEdit2->setEnabled( false );
120 GroupCenter2Pnts->LineEdit3->setEnabled( false );
122 QVBoxLayout* layout = new QVBoxLayout( centralWidget() );
123 layout->setMargin( 0 ); layout->setSpacing( 6 );
124 layout->addWidget( GroupPntVecR );
125 layout->addWidget( Group3Pnts );
126 layout->addWidget( GroupCenter2Pnts );
127 /***************************************************************/
129 setHelpFileName( "create_circle_page.html" );
135 //=================================================================================
136 // function : ~BasicGUI_CircleDlg()
137 // purpose : Destroys the object and frees any allocated resources
138 //=================================================================================
139 BasicGUI_CircleDlg::~BasicGUI_CircleDlg()
144 //=================================================================================
147 //=================================================================================
148 void BasicGUI_CircleDlg::Init()
151 myEditCurrentArgument = GroupPntVecR->LineEdit1;
153 myPoint = myDir = myPoint1 = myPoint2 = myPoint3 = GEOM::GEOM_Object::_nil();
155 // myGeomGUI->SetState( 0 );
157 /* Get setting of step value from file configuration */
158 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
159 double aStep = resMgr->doubleValue( "Geometry", "SettingsGeomStep", 100 );
161 /* min, max, step and decimals for spin boxes & initial values */
162 initSpinBox( GroupPntVecR->SpinBox_DX, 0.000001, COORD_MAX, aStep, "length_precision" );
163 GroupPntVecR->SpinBox_DX->setValue( 100 );
165 /* signals and slots connections */
166 connect( myGeomGUI, SIGNAL( SignalDeactivateActiveDialog() ), this, SLOT( DeactivateActiveDialog() ) );
167 connect( myGeomGUI, SIGNAL( SignalCloseAllDialogs() ), this, SLOT( ClickOnCancel() ) );
169 connect( buttonOk(), SIGNAL( clicked() ), this, SLOT( ClickOnOk() ) );
170 connect( buttonApply(), SIGNAL( clicked() ), this, SLOT( ClickOnApply() ) );
172 connect( this, SIGNAL( constructorsClicked( int ) ), this, SLOT( ConstructorsClicked( int ) ) );
174 connect( GroupPntVecR->PushButton1, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) );
175 connect( GroupPntVecR->PushButton2, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) );
176 connect( Group3Pnts->PushButton1, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) );
177 connect( Group3Pnts->PushButton2, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) );
178 connect( Group3Pnts->PushButton3, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) );
180 connect( GroupCenter2Pnts->PushButton1, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) );
181 connect( GroupCenter2Pnts->PushButton2, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) );
182 connect( GroupCenter2Pnts->PushButton3, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) );
184 connect( GroupPntVecR->LineEdit1, SIGNAL( returnPressed() ), this, SLOT( LineEditReturnPressed() ) );
185 connect( GroupPntVecR->LineEdit2, SIGNAL( returnPressed() ), this, SLOT( LineEditReturnPressed() ) );
187 connect( GroupPntVecR->SpinBox_DX, SIGNAL( valueChanged( double ) ), this, SLOT(ValueChangedInSpinBox() ) );
188 connect( myGeomGUI, SIGNAL( SignalDefaultStepValueChanged( double ) ), this, SLOT( SetDoubleSpinBoxStep( double ) ) );
190 connect( myGeomGUI->getApp()->selectionMgr(), SIGNAL( currentSelectionChanged() ),
191 this, SLOT( SelectionIntoArgument() ) );
193 initName( tr( "GEOM_CIRCLE" ) );
195 ConstructorsClicked( 0 );
198 //=================================================================================
199 // function : SetDoubleSpinBoxStep()
200 // purpose : Double spin box management
201 //=================================================================================
202 void BasicGUI_CircleDlg::SetDoubleSpinBoxStep( double step )
204 GroupPntVecR->SpinBox_DX->setSingleStep(step);
207 //=================================================================================
208 // function : ConstructorsClicked()
209 // purpose : Radio button management
210 //=================================================================================
211 void BasicGUI_CircleDlg::ConstructorsClicked( int constructorId )
213 disconnect( myGeomGUI->getApp()->selectionMgr(), 0, this, 0);
215 myPoint = myDir = myPoint1 = myPoint2 = myPoint3 = GEOM::GEOM_Object::_nil();
217 switch ( constructorId ) {
221 GroupCenter2Pnts->hide();
222 GroupPntVecR->show();
224 myEditCurrentArgument = GroupPntVecR->LineEdit1;
225 GroupPntVecR->LineEdit1->setText( "" );
226 GroupPntVecR->LineEdit2->setText( "" );
227 GroupPntVecR->PushButton1->setDown( true );
228 GroupPntVecR->PushButton2->setDown( false );
229 GroupPntVecR->LineEdit1->setEnabled( true );
230 GroupPntVecR->LineEdit2->setEnabled( false );
235 GroupPntVecR->hide();
236 GroupCenter2Pnts->hide();
239 myEditCurrentArgument = Group3Pnts->LineEdit1;
240 Group3Pnts->LineEdit1->setText( "" );
241 Group3Pnts->LineEdit2->setText( "" );
242 Group3Pnts->LineEdit3->setText( "" );
243 Group3Pnts->PushButton1->setDown( true );
244 Group3Pnts->PushButton2->setDown( false );
245 Group3Pnts->PushButton3->setDown( false );
246 Group3Pnts->LineEdit1->setEnabled( true );
247 Group3Pnts->LineEdit2->setEnabled( false );
248 Group3Pnts->LineEdit3->setEnabled( false );
253 GroupPntVecR->hide();
255 GroupCenter2Pnts->show();
257 myEditCurrentArgument = GroupCenter2Pnts->LineEdit1;
258 GroupCenter2Pnts->LineEdit1->setText( "" );
259 GroupCenter2Pnts->LineEdit2->setText( "" );
260 GroupCenter2Pnts->LineEdit3->setText( "" );
261 GroupCenter2Pnts->PushButton1->setDown( true );
262 GroupCenter2Pnts->PushButton2->setDown( false );
263 GroupCenter2Pnts->PushButton3->setDown( false );
264 GroupCenter2Pnts->LineEdit1->setEnabled( true );
265 GroupCenter2Pnts->LineEdit2->setEnabled( false );
266 GroupCenter2Pnts->LineEdit3->setEnabled( false );
271 qApp->processEvents();
273 resize( minimumSizeHint() );
274 SelectionIntoArgument();
276 myEditCurrentArgument->setFocus();
277 globalSelection(); // close local contexts, if any
278 localSelection( GEOM::GEOM_Object::_nil(), TopAbs_VERTEX );
280 connect( myGeomGUI->getApp()->selectionMgr(), SIGNAL(currentSelectionChanged() ),
281 this, SLOT( SelectionIntoArgument() ) );
286 //=================================================================================
287 // function : ClickOnOk()
289 //=================================================================================
290 void BasicGUI_CircleDlg::ClickOnOk()
292 if ( ClickOnApply() )
296 //=================================================================================
297 // function : ClickOnApply()
299 //=================================================================================
300 bool BasicGUI_CircleDlg::ClickOnApply()
306 ConstructorsClicked( getConstructorId() );
310 //=================================================================================
311 // function : SelectionIntoArgument()
312 // purpose : Called when selection as changed or other case
313 //=================================================================================
314 void BasicGUI_CircleDlg::SelectionIntoArgument()
316 myEditCurrentArgument->setText( "" );
318 LightApp_SelectionMgr* aSelMgr = myGeomGUI->getApp()->selectionMgr();
320 aSelMgr->selectedObjects( aList );
322 if ( aList.Extent() != 1 ) {
323 if ( myEditCurrentArgument == GroupPntVecR->LineEdit1 ) myPoint = GEOM::GEOM_Object::_nil();
324 else if ( myEditCurrentArgument == GroupPntVecR->LineEdit2 ) myDir = GEOM::GEOM_Object::_nil();
325 else if ( myEditCurrentArgument == Group3Pnts->LineEdit1 ) myPoint1 = GEOM::GEOM_Object::_nil();
326 else if ( myEditCurrentArgument == Group3Pnts->LineEdit2 ) myPoint2 = GEOM::GEOM_Object::_nil();
327 else if ( myEditCurrentArgument == Group3Pnts->LineEdit3 ) myPoint3 = GEOM::GEOM_Object::_nil();
328 else if ( myEditCurrentArgument == GroupCenter2Pnts->LineEdit1 ) myPoint4 = GEOM::GEOM_Object::_nil();
329 else if ( myEditCurrentArgument == GroupCenter2Pnts->LineEdit2 ) myPoint5 = GEOM::GEOM_Object::_nil();
330 else if ( myEditCurrentArgument == GroupCenter2Pnts->LineEdit3 ) myPoint6 = GEOM::GEOM_Object::_nil();
335 Handle(SALOME_InteractiveObject) anIO = aList.First();
337 GEOM::GEOM_Object_var aSelectedObject = GEOMBase::ConvertIOinGEOMObject( anIO );
338 if ( !CORBA::is_nil( aSelectedObject ) ) {
339 QString aName = GEOMBase::GetName( aSelectedObject );
341 TopAbs_ShapeEnum aNeedType = TopAbs_VERTEX;
342 if ( myEditCurrentArgument == GroupPntVecR->LineEdit2 )
343 aNeedType = TopAbs_EDGE;
345 // If selected Vertex or Edge on the some Shape Get selection Subshape
347 if ( GEOMBase::GetShape( aSelectedObject, aShape, TopAbs_SHAPE ) && !aShape.IsNull() ) {
348 TColStd_IndexedMapOfInteger aMap;
349 aSelMgr->GetIndexes(anIO, aMap);
350 if ( aMap.Extent() == 1 ) { // Local Selection
351 int anIndex = aMap(1);
352 if ( aNeedType == TopAbs_EDGE )
353 aName += QString( ":edge_%1" ).arg( anIndex );
355 aName += QString( ":vertex_%1" ).arg( anIndex );
357 //Find SubShape Object in Father
358 GEOM::GEOM_Object_var aFindedObject = GEOMBase_Helper::findObjectInFather( aSelectedObject, aName );
360 if ( aFindedObject->_is_nil() ) { // Object not found in study
361 GEOM::GEOM_IShapesOperations_var aShapesOp = getGeomEngine()->GetIShapesOperations( getStudyId() );
362 aSelectedObject = aShapesOp->GetSubShape( aSelectedObject, anIndex );
365 aSelectedObject = aFindedObject; // get Object from study
368 else { // Global Selection
369 if ( aShape.ShapeType() != aNeedType ) {
370 aSelectedObject = GEOM::GEOM_Object::_nil();
376 myEditCurrentArgument->setText( aName );
378 if (!aSelectedObject->_is_nil()) { // clear selection if something selected
380 localSelection( GEOM::GEOM_Object::_nil(), aNeedType );
383 if ( myEditCurrentArgument == GroupPntVecR->LineEdit1 ) {
384 myPoint = aSelectedObject;
385 if ( !myPoint->_is_nil() && myDir->_is_nil() )
386 GroupPntVecR->PushButton2->click();
388 else if ( myEditCurrentArgument == GroupPntVecR->LineEdit2 ) {
389 myDir = aSelectedObject;
390 if ( !myDir->_is_nil() && myPoint->_is_nil() )
391 GroupPntVecR->PushButton1->click();
393 else if ( myEditCurrentArgument == Group3Pnts->LineEdit1 ) {
394 myPoint1 = aSelectedObject;
395 if ( !myPoint1->_is_nil() && myPoint2->_is_nil() )
396 Group3Pnts->PushButton2->click();
398 else if ( myEditCurrentArgument == Group3Pnts->LineEdit2 ) {
399 myPoint2 = aSelectedObject;
400 if ( !myPoint2->_is_nil() && myPoint3->_is_nil() )
401 Group3Pnts->PushButton3->click();
403 else if ( myEditCurrentArgument == Group3Pnts->LineEdit3 ) {
404 myPoint3 = aSelectedObject;
405 if ( !myPoint3->_is_nil() && myPoint1->_is_nil() )
406 Group3Pnts->PushButton1->click();
408 else if ( myEditCurrentArgument == GroupCenter2Pnts->LineEdit1 ) {
409 myPoint4 = aSelectedObject;
410 if ( !myPoint4->_is_nil() && myPoint5->_is_nil() )
411 GroupCenter2Pnts->PushButton2->click();
413 else if ( myEditCurrentArgument == GroupCenter2Pnts->LineEdit2 ) {
414 myPoint5 = aSelectedObject;
415 if ( !myPoint5->_is_nil() && myPoint6->_is_nil() )
416 GroupCenter2Pnts->PushButton3->click();
418 else if ( myEditCurrentArgument == GroupCenter2Pnts->LineEdit3 ) {
419 myPoint6 = aSelectedObject;
420 if ( !myPoint6->_is_nil() && myPoint4->_is_nil() )
421 GroupCenter2Pnts->PushButton1->click();
429 //=================================================================================
430 // function : SetEditCurrentArgument()
432 //=================================================================================
433 void BasicGUI_CircleDlg::SetEditCurrentArgument()
435 QPushButton* send = (QPushButton*)sender();
437 if ( send == GroupPntVecR->PushButton1 ) {
438 myEditCurrentArgument = GroupPntVecR->LineEdit1;
439 GroupPntVecR->PushButton2->setDown(false);
440 GroupPntVecR->LineEdit1->setEnabled( true );
441 GroupPntVecR->LineEdit2->setEnabled( false );
443 else if ( send == GroupPntVecR->PushButton2 ) {
444 myEditCurrentArgument = GroupPntVecR->LineEdit2;
445 GroupPntVecR->PushButton1->setDown(false);
446 GroupPntVecR->LineEdit1->setEnabled( false );
447 GroupPntVecR->LineEdit2->setEnabled( true );
449 else if ( send == Group3Pnts->PushButton1 ) {
450 myEditCurrentArgument = Group3Pnts->LineEdit1;
451 Group3Pnts->PushButton2->setDown( false );
452 Group3Pnts->PushButton3->setDown( false );
453 Group3Pnts->LineEdit1->setEnabled( true );
454 Group3Pnts->LineEdit2->setEnabled( false );
455 Group3Pnts->LineEdit3->setEnabled( false );
457 else if ( send == Group3Pnts->PushButton2 ) {
458 myEditCurrentArgument = Group3Pnts->LineEdit2;
459 Group3Pnts->PushButton1->setDown( false );
460 Group3Pnts->PushButton3->setDown( false );
461 Group3Pnts->LineEdit1->setEnabled( false );
462 Group3Pnts->LineEdit2->setEnabled( true );
463 Group3Pnts->LineEdit3->setEnabled( false );
465 else if ( send == Group3Pnts->PushButton3 ) {
466 myEditCurrentArgument = Group3Pnts->LineEdit3;
467 Group3Pnts->PushButton1->setDown( false );
468 Group3Pnts->PushButton2->setDown( false );
469 Group3Pnts->LineEdit1->setEnabled( false );
470 Group3Pnts->LineEdit2->setEnabled( false );
471 Group3Pnts->LineEdit3->setEnabled( true );
473 else if ( send == GroupCenter2Pnts->PushButton1 ) {
474 myEditCurrentArgument = GroupCenter2Pnts->LineEdit1;
475 GroupCenter2Pnts->PushButton2->setDown( false );
476 GroupCenter2Pnts->PushButton3->setDown( false );
477 GroupCenter2Pnts->LineEdit1->setEnabled( true );
478 GroupCenter2Pnts->LineEdit2->setEnabled( false );
479 GroupCenter2Pnts->LineEdit3->setEnabled( false );
481 else if ( send == GroupCenter2Pnts->PushButton2 ) {
482 myEditCurrentArgument = GroupCenter2Pnts->LineEdit2;
483 GroupCenter2Pnts->PushButton1->setDown( false );
484 GroupCenter2Pnts->PushButton3->setDown( false );
485 GroupCenter2Pnts->LineEdit1->setEnabled( false );
486 GroupCenter2Pnts->LineEdit2->setEnabled( true );
487 GroupCenter2Pnts->LineEdit3->setEnabled( false );
490 else if ( send == GroupCenter2Pnts->PushButton3 ) {
491 myEditCurrentArgument = GroupCenter2Pnts->LineEdit3;
492 GroupCenter2Pnts->PushButton1->setDown( false );
493 GroupCenter2Pnts->PushButton2->setDown( false );
494 GroupCenter2Pnts->LineEdit1->setEnabled( false );
495 GroupCenter2Pnts->LineEdit2->setEnabled( false );
496 GroupCenter2Pnts->LineEdit3->setEnabled( true );
500 myEditCurrentArgument->setFocus();
502 if ( myEditCurrentArgument == GroupPntVecR->LineEdit2 ) {
503 globalSelection(); // close local contexts, if any
504 localSelection( GEOM::GEOM_Object::_nil(), TopAbs_EDGE );
507 globalSelection(); // close local contexts, if any
508 localSelection( GEOM::GEOM_Object::_nil(), TopAbs_VERTEX );
511 myEditCurrentArgument->setFocus();
512 // SelectionIntoArgument();
517 //=================================================================================
518 // function : LineEditReturnPressed()
520 //=================================================================================
521 void BasicGUI_CircleDlg::LineEditReturnPressed()
523 QLineEdit* send = (QLineEdit*)sender();
524 if ( send == GroupPntVecR->LineEdit1 ||
525 send == GroupPntVecR->LineEdit2 ||
526 send == Group3Pnts->LineEdit1 ||
527 send == Group3Pnts->LineEdit2 ||
528 send == Group3Pnts->LineEdit3 ||
529 send == GroupCenter2Pnts->LineEdit1 ||
530 send == GroupCenter2Pnts->LineEdit2 ||
531 send == GroupCenter2Pnts->LineEdit3 ) {
532 myEditCurrentArgument = send;
533 GEOMBase_Skeleton::LineEditReturnPressed();
538 //=================================================================================
539 // function : ActivateThisDialog()
541 //=================================================================================
542 void BasicGUI_CircleDlg::ActivateThisDialog()
544 GEOMBase_Skeleton::ActivateThisDialog();
546 connect( myGeomGUI->getApp()->selectionMgr(), SIGNAL( currentSelectionChanged() ),
547 this, SLOT( SelectionIntoArgument() ) );
549 ConstructorsClicked( getConstructorId() );
553 //=================================================================================
554 // function : enterEvent()
556 //=================================================================================
557 void BasicGUI_CircleDlg::enterEvent( QEvent* )
559 if ( !mainFrame()->GroupConstructors->isEnabled() )
560 ActivateThisDialog();
563 //=================================================================================
564 // function : DeactivateActiveDialog()
565 // purpose : public slot to deactivate if active
566 //=================================================================================
567 void BasicGUI_CircleDlg::DeactivateActiveDialog()
569 // myGeomGUI->SetState( -1 );
570 GEOMBase_Skeleton::DeactivateActiveDialog();
573 //=================================================================================
574 // function : ValueChangedInSpinBox()
576 //=================================================================================
577 void BasicGUI_CircleDlg::ValueChangedInSpinBox()
582 //=================================================================================
583 // function : getRadius()
585 //=================================================================================
586 double BasicGUI_CircleDlg::getRadius() const
589 switch ( getConstructorId() ) {
591 r = GroupPntVecR->SpinBox_DX->value(); break;
596 //=================================================================================
597 // function : createOperation
599 //=================================================================================
600 GEOM::GEOM_IOperations_ptr BasicGUI_CircleDlg::createOperation()
602 return myGeomGUI->GetGeomGen()->GetICurvesOperations( getStudyId() );
605 //=================================================================================
606 // function : isEqual
607 // purpose : it may also be needed to check for min distance between gp_Pnt-s...
608 //=================================================================================
609 static bool isEqual( const GEOM::GEOM_Object_var& thePnt1, const GEOM::GEOM_Object_var& thePnt2 )
611 return thePnt1->_is_equivalent( thePnt2 );
614 //=================================================================================
615 // function : isValid
617 //=================================================================================
618 bool BasicGUI_CircleDlg::isValid( QString& msg )
620 const int id = getConstructorId();
622 //return !myPoint->_is_nil() && !myDir->_is_nil() && getRadius() > 0;
623 //nil point means origin of global CS
624 //nil vector means Z axis
625 bool ok = GroupPntVecR->SpinBox_DX->isValid(msg, !IsPreview());
626 return getRadius() > 0 && ok;
629 return !myPoint1->_is_nil() && !myPoint2->_is_nil() && !myPoint3->_is_nil() &&
630 !isEqual( myPoint1, myPoint2 ) && !isEqual( myPoint1, myPoint3 ) && !isEqual( myPoint2, myPoint3 );
632 return !myPoint4->_is_nil() && !myPoint5->_is_nil() && !myPoint6->_is_nil() &&
633 !isEqual( myPoint4, myPoint5 ) && !isEqual( myPoint5, myPoint6 ) && !isEqual( myPoint4, myPoint6 );
637 //=================================================================================
638 // function : execute
640 //=================================================================================
641 bool BasicGUI_CircleDlg::execute( ObjectList& objects )
645 GEOM::GEOM_Object_var anObj;
647 GEOM::GEOM_ICurvesOperations_var anOper = GEOM::GEOM_ICurvesOperations::_narrow( getOperation() );
649 switch ( getConstructorId() ) {
652 QStringList aParameters;
653 aParameters << GroupPntVecR->SpinBox_DX->text();
654 anObj = anOper->MakeCirclePntVecR( myPoint, myDir, getRadius() );
655 if ( !anObj->_is_nil() && !IsPreview() )
656 anObj->SetParameters(aParameters.join(":").toLatin1().constData());
661 anObj = anOper->MakeCircleThreePnt( myPoint1, myPoint2, myPoint3 );
665 anObj = anOper->MakeCircleCenter2Pnt( myPoint4, myPoint5, myPoint6 );
670 if ( !anObj->_is_nil() )
671 objects.push_back( anObj._retn() );
673 MESSAGE( "Execute Object is NULL!" );
679 //=================================================================================
680 // function : addSubshapeToStudy
681 // purpose : virtual method to add new SubObjects if local selection
682 //=================================================================================
683 void BasicGUI_CircleDlg::addSubshapesToStudy()
685 QMap<QString, GEOM::GEOM_Object_var> objMap;
687 switch ( getConstructorId() ) {
689 if (!CORBA::is_nil(myPoint))
690 objMap[GroupPntVecR->LineEdit1->text()] = myPoint;
691 if (!CORBA::is_nil(myDir))
692 objMap[GroupPntVecR->LineEdit2->text()] = myDir;
695 objMap[Group3Pnts->LineEdit1->text()] = myPoint1;
696 objMap[Group3Pnts->LineEdit2->text()] = myPoint2;
697 objMap[Group3Pnts->LineEdit3->text()] = myPoint3;
700 objMap[GroupCenter2Pnts->LineEdit1->text()] = myPoint4;
701 objMap[GroupCenter2Pnts->LineEdit2->text()] = myPoint5;
702 objMap[GroupCenter2Pnts->LineEdit3->text()] = myPoint6;
705 addSubshapesToFather( objMap );