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" ) + " (Origin by default)" );
74 GroupPntVecR->TextLabel2->setText( tr( "GEOM_VECTOR" ) + " (Z axis by 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 Standard_Boolean aRes = Standard_False;
338 GEOM::GEOM_Object_var aSelectedObject = GEOMBase::ConvertIOinGEOMObject(anIO, aRes);
339 if ( !CORBA::is_nil( aSelectedObject ) && aRes ) {
340 QString aName = GEOMBase::GetName( aSelectedObject );
342 TopAbs_ShapeEnum aNeedType = TopAbs_VERTEX;
343 if ( myEditCurrentArgument == GroupPntVecR->LineEdit2 )
344 aNeedType = TopAbs_EDGE;
346 // If selected Vertex or Edge on the some Shape Get selection Subshape
348 if ( GEOMBase::GetShape( aSelectedObject, aShape, TopAbs_SHAPE ) && !aShape.IsNull() ) {
349 TColStd_IndexedMapOfInteger aMap;
350 aSelMgr->GetIndexes(anIO, aMap);
351 if ( aMap.Extent() == 1 ) { // Local Selection
352 int anIndex = aMap(1);
353 if ( aNeedType == TopAbs_EDGE )
354 aName += QString( ":edge_%1" ).arg( anIndex );
356 aName += QString( ":vertex_%1" ).arg( anIndex );
358 //Find SubShape Object in Father
359 GEOM::GEOM_Object_var aFindedObject = GEOMBase_Helper::findObjectInFather( aSelectedObject, aName );
361 if ( aFindedObject == GEOM::GEOM_Object::_nil() ) { // Object not found in study
362 GEOM::GEOM_IShapesOperations_var aShapesOp = getGeomEngine()->GetIShapesOperations( getStudyId() );
363 aSelectedObject = aShapesOp->GetSubShape( aSelectedObject, anIndex );
366 aSelectedObject = aFindedObject; // get Object from study
369 else { // Global Selection
370 if ( aShape.ShapeType() != aNeedType ) {
371 aSelectedObject = GEOM::GEOM_Object::_nil();
377 myEditCurrentArgument->setText( aName );
379 if (!aSelectedObject->_is_nil()) { // clear selection if something selected
381 localSelection( GEOM::GEOM_Object::_nil(), aNeedType );
384 if ( myEditCurrentArgument == GroupPntVecR->LineEdit1 ) {
385 myPoint = aSelectedObject;
386 if ( !myPoint->_is_nil() && myDir->_is_nil() )
387 GroupPntVecR->PushButton2->click();
389 else if ( myEditCurrentArgument == GroupPntVecR->LineEdit2 ) {
390 myDir = aSelectedObject;
391 if ( !myDir->_is_nil() && myPoint->_is_nil() )
392 GroupPntVecR->PushButton1->click();
394 else if ( myEditCurrentArgument == Group3Pnts->LineEdit1 ) {
395 myPoint1 = aSelectedObject;
396 if ( !myPoint1->_is_nil() && myPoint2->_is_nil() )
397 Group3Pnts->PushButton2->click();
399 else if ( myEditCurrentArgument == Group3Pnts->LineEdit2 ) {
400 myPoint2 = aSelectedObject;
401 if ( !myPoint2->_is_nil() && myPoint3->_is_nil() )
402 Group3Pnts->PushButton3->click();
404 else if ( myEditCurrentArgument == Group3Pnts->LineEdit3 ) {
405 myPoint3 = aSelectedObject;
406 if ( !myPoint3->_is_nil() && myPoint1->_is_nil() )
407 Group3Pnts->PushButton1->click();
409 else if ( myEditCurrentArgument == GroupCenter2Pnts->LineEdit1 ) {
410 myPoint4 = aSelectedObject;
411 if ( !myPoint4->_is_nil() && myPoint5->_is_nil() )
412 GroupCenter2Pnts->PushButton2->click();
414 else if ( myEditCurrentArgument == GroupCenter2Pnts->LineEdit2 ) {
415 myPoint5 = aSelectedObject;
416 if ( !myPoint5->_is_nil() && myPoint6->_is_nil() )
417 GroupCenter2Pnts->PushButton3->click();
419 else if ( myEditCurrentArgument == GroupCenter2Pnts->LineEdit3 ) {
420 myPoint6 = aSelectedObject;
421 if ( !myPoint6->_is_nil() && myPoint4->_is_nil() )
422 GroupCenter2Pnts->PushButton1->click();
430 //=================================================================================
431 // function : SetEditCurrentArgument()
433 //=================================================================================
434 void BasicGUI_CircleDlg::SetEditCurrentArgument()
436 QPushButton* send = (QPushButton*)sender();
438 if ( send == GroupPntVecR->PushButton1 ) {
439 myEditCurrentArgument = GroupPntVecR->LineEdit1;
440 GroupPntVecR->PushButton2->setDown(false);
441 GroupPntVecR->LineEdit1->setEnabled( true );
442 GroupPntVecR->LineEdit2->setEnabled( false );
444 else if ( send == GroupPntVecR->PushButton2 ) {
445 myEditCurrentArgument = GroupPntVecR->LineEdit2;
446 GroupPntVecR->PushButton1->setDown(false);
447 GroupPntVecR->LineEdit1->setEnabled( false );
448 GroupPntVecR->LineEdit2->setEnabled( true );
450 else if ( send == Group3Pnts->PushButton1 ) {
451 myEditCurrentArgument = Group3Pnts->LineEdit1;
452 Group3Pnts->PushButton2->setDown( false );
453 Group3Pnts->PushButton3->setDown( false );
454 Group3Pnts->LineEdit1->setEnabled( true );
455 Group3Pnts->LineEdit2->setEnabled( false );
456 Group3Pnts->LineEdit3->setEnabled( false );
458 else if ( send == Group3Pnts->PushButton2 ) {
459 myEditCurrentArgument = Group3Pnts->LineEdit2;
460 Group3Pnts->PushButton1->setDown( false );
461 Group3Pnts->PushButton3->setDown( false );
462 Group3Pnts->LineEdit1->setEnabled( false );
463 Group3Pnts->LineEdit2->setEnabled( true );
464 Group3Pnts->LineEdit3->setEnabled( false );
466 else if ( send == Group3Pnts->PushButton3 ) {
467 myEditCurrentArgument = Group3Pnts->LineEdit3;
468 Group3Pnts->PushButton1->setDown( false );
469 Group3Pnts->PushButton2->setDown( false );
470 Group3Pnts->LineEdit1->setEnabled( false );
471 Group3Pnts->LineEdit2->setEnabled( false );
472 Group3Pnts->LineEdit3->setEnabled( true );
474 else if ( send == GroupCenter2Pnts->PushButton1 ) {
475 myEditCurrentArgument = GroupCenter2Pnts->LineEdit1;
476 GroupCenter2Pnts->PushButton2->setDown( false );
477 GroupCenter2Pnts->PushButton3->setDown( false );
478 GroupCenter2Pnts->LineEdit1->setEnabled( true );
479 GroupCenter2Pnts->LineEdit2->setEnabled( false );
480 GroupCenter2Pnts->LineEdit3->setEnabled( false );
482 else if ( send == GroupCenter2Pnts->PushButton2 ) {
483 myEditCurrentArgument = GroupCenter2Pnts->LineEdit2;
484 GroupCenter2Pnts->PushButton1->setDown( false );
485 GroupCenter2Pnts->PushButton3->setDown( false );
486 GroupCenter2Pnts->LineEdit1->setEnabled( false );
487 GroupCenter2Pnts->LineEdit2->setEnabled( true );
488 GroupCenter2Pnts->LineEdit3->setEnabled( false );
491 else if ( send == GroupCenter2Pnts->PushButton3 ) {
492 myEditCurrentArgument = GroupCenter2Pnts->LineEdit3;
493 GroupCenter2Pnts->PushButton1->setDown( false );
494 GroupCenter2Pnts->PushButton2->setDown( false );
495 GroupCenter2Pnts->LineEdit1->setEnabled( false );
496 GroupCenter2Pnts->LineEdit2->setEnabled( false );
497 GroupCenter2Pnts->LineEdit3->setEnabled( true );
501 myEditCurrentArgument->setFocus();
503 if ( myEditCurrentArgument == GroupPntVecR->LineEdit2 ) {
504 globalSelection(); // close local contexts, if any
505 localSelection( GEOM::GEOM_Object::_nil(), TopAbs_EDGE );
508 globalSelection(); // close local contexts, if any
509 localSelection( GEOM::GEOM_Object::_nil(), TopAbs_VERTEX );
512 myEditCurrentArgument->setFocus();
513 // SelectionIntoArgument();
518 //=================================================================================
519 // function : LineEditReturnPressed()
521 //=================================================================================
522 void BasicGUI_CircleDlg::LineEditReturnPressed()
524 QLineEdit* send = (QLineEdit*)sender();
525 if ( send == GroupPntVecR->LineEdit1 ||
526 send == GroupPntVecR->LineEdit2 ||
527 send == Group3Pnts->LineEdit1 ||
528 send == Group3Pnts->LineEdit2 ||
529 send == Group3Pnts->LineEdit3 ||
530 send == GroupCenter2Pnts->LineEdit1 ||
531 send == GroupCenter2Pnts->LineEdit2 ||
532 send == GroupCenter2Pnts->LineEdit3 ) {
533 myEditCurrentArgument = send;
534 GEOMBase_Skeleton::LineEditReturnPressed();
539 //=================================================================================
540 // function : ActivateThisDialog()
542 //=================================================================================
543 void BasicGUI_CircleDlg::ActivateThisDialog()
545 GEOMBase_Skeleton::ActivateThisDialog();
547 connect( myGeomGUI->getApp()->selectionMgr(), SIGNAL( currentSelectionChanged() ),
548 this, SLOT( SelectionIntoArgument() ) );
550 ConstructorsClicked( getConstructorId() );
554 //=================================================================================
555 // function : enterEvent()
557 //=================================================================================
558 void BasicGUI_CircleDlg::enterEvent( QEvent* )
560 if ( !mainFrame()->GroupConstructors->isEnabled() )
561 ActivateThisDialog();
564 //=================================================================================
565 // function : DeactivateActiveDialog()
566 // purpose : public slot to deactivate if active
567 //=================================================================================
568 void BasicGUI_CircleDlg::DeactivateActiveDialog()
570 // myGeomGUI->SetState( -1 );
571 GEOMBase_Skeleton::DeactivateActiveDialog();
574 //=================================================================================
575 // function : ValueChangedInSpinBox()
577 //=================================================================================
578 void BasicGUI_CircleDlg::ValueChangedInSpinBox()
583 //=================================================================================
584 // function : getRadius()
586 //=================================================================================
587 double BasicGUI_CircleDlg::getRadius() const
590 switch ( getConstructorId() ) {
592 r = GroupPntVecR->SpinBox_DX->value(); break;
597 //=================================================================================
598 // function : createOperation
600 //=================================================================================
601 GEOM::GEOM_IOperations_ptr BasicGUI_CircleDlg::createOperation()
603 return myGeomGUI->GetGeomGen()->GetICurvesOperations( getStudyId() );
606 //=================================================================================
607 // function : isEqual
608 // purpose : it may also be needed to check for min distance between gp_Pnt-s...
609 //=================================================================================
610 static bool isEqual( const GEOM::GEOM_Object_var& thePnt1, const GEOM::GEOM_Object_var& thePnt2 )
612 return thePnt1->_is_equivalent( thePnt2 );
615 //=================================================================================
616 // function : isValid
618 //=================================================================================
619 bool BasicGUI_CircleDlg::isValid( QString& msg )
621 const int id = getConstructorId();
623 //return !myPoint->_is_nil() && !myDir->_is_nil() && getRadius() > 0;
624 //nil point means origin of global CS
625 //nil vector means Z axis
626 bool ok = GroupPntVecR->SpinBox_DX->isValid(msg, !IsPreview());
627 return getRadius() > 0 && ok;
630 return !myPoint1->_is_nil() && !myPoint2->_is_nil() && !myPoint3->_is_nil() &&
631 !isEqual( myPoint1, myPoint2 ) && !isEqual( myPoint1, myPoint3 ) && !isEqual( myPoint2, myPoint3 );
633 return !myPoint4->_is_nil() && !myPoint5->_is_nil() && !myPoint6->_is_nil() &&
634 !isEqual( myPoint4, myPoint5 ) && !isEqual( myPoint5, myPoint6 ) && !isEqual( myPoint4, myPoint6 );
638 //=================================================================================
639 // function : execute
641 //=================================================================================
642 bool BasicGUI_CircleDlg::execute( ObjectList& objects )
646 GEOM::GEOM_Object_var anObj;
648 GEOM::GEOM_ICurvesOperations_var anOper = GEOM::GEOM_ICurvesOperations::_narrow( getOperation() );
650 switch ( getConstructorId() ) {
653 QStringList aParameters;
654 aParameters << GroupPntVecR->SpinBox_DX->text();
655 anObj = anOper->MakeCirclePntVecR( myPoint, myDir, getRadius() );
656 if ( !anObj->_is_nil() && !IsPreview() )
657 anObj->SetParameters(aParameters.join(":").toLatin1().constData());
662 anObj = anOper->MakeCircleThreePnt( myPoint1, myPoint2, myPoint3 );
666 anObj = anOper->MakeCircleCenter2Pnt( myPoint4, myPoint5, myPoint6 );
671 if ( !anObj->_is_nil() )
672 objects.push_back( anObj._retn() );
674 MESSAGE( "Execute Object is NULL!" );
680 //=================================================================================
681 // function : addSubshapeToStudy
682 // purpose : virtual method to add new SubObjects if local selection
683 //=================================================================================
684 void BasicGUI_CircleDlg::addSubshapesToStudy()
686 QMap<QString, GEOM::GEOM_Object_var> objMap;
688 switch ( getConstructorId() ) {
690 if (!CORBA::is_nil(myPoint))
691 objMap[GroupPntVecR->LineEdit1->text()] = myPoint;
692 if (!CORBA::is_nil(myDir))
693 objMap[GroupPntVecR->LineEdit2->text()] = myDir;
696 objMap[Group3Pnts->LineEdit1->text()] = myPoint1;
697 objMap[Group3Pnts->LineEdit2->text()] = myPoint2;
698 objMap[Group3Pnts->LineEdit3->text()] = myPoint3;
701 objMap[GroupCenter2Pnts->LineEdit1->text()] = myPoint4;
702 objMap[GroupCenter2Pnts->LineEdit2->text()] = myPoint5;
703 objMap[GroupCenter2Pnts->LineEdit3->text()] = myPoint6;
706 addSubshapesToFather( objMap );