Back to index

salome-geom  6.5.0
BasicGUI_CircleDlg.cxx
Go to the documentation of this file.
00001 // Copyright (C) 2007-2012  CEA/DEN, EDF R&D, OPEN CASCADE
00002 //
00003 // Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
00004 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
00005 //
00006 // This library is free software; you can redistribute it and/or
00007 // modify it under the terms of the GNU Lesser General Public
00008 // License as published by the Free Software Foundation; either
00009 // version 2.1 of the License.
00010 //
00011 // This library is distributed in the hope that it will be useful,
00012 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00013 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014 // Lesser General Public License for more details.
00015 //
00016 // You should have received a copy of the GNU Lesser General Public
00017 // License along with this library; if not, write to the Free Software
00018 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
00019 //
00020 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
00021 //
00022 
00023 // GEOM GEOMGUI : GUI for Geometry component
00024 // File   : BasicGUI_CircleDlg.cxx
00025 // Author : Lucien PIGNOLONI, Open CASCADE S.A.S.
00026 //
00027 #include "BasicGUI_CircleDlg.h"
00028 
00029 #include <DlgRef.h>
00030 
00031 #include <GeometryGUI.h>
00032 #include <GEOMBase.h>
00033 
00034 #include <SUIT_ResourceMgr.h>
00035 #include <SUIT_Session.h>
00036 #include <SalomeApp_Application.h>
00037 #include <LightApp_SelectionMgr.h>
00038 
00039 #include <TColStd_IndexedMapOfInteger.hxx>
00040 #include <TopTools_IndexedMapOfShape.hxx>
00041 #include <TopoDS_Shape.hxx>
00042 #include <TopoDS_Edge.hxx>
00043 #include <TopoDS.hxx>
00044 #include <TopExp.hxx>
00045 
00046 //=================================================================================
00047 // class    : BasicGUI_CircleDlg()
00048 // purpose  : Constructs a BasicGUI_CircleDlg which is a child of 'parent', with the 
00049 //            name 'name' and widget flags set to 'f'.
00050 //            The dialog will by default be modeless, unless you set 'modal' to
00051 //            TRUE to construct a modal dialog.
00052 //=================================================================================
00053 BasicGUI_CircleDlg::BasicGUI_CircleDlg( GeometryGUI* theGeometryGUI, QWidget* parent,
00054                                         bool modal, Qt::WindowFlags fl )
00055   : GEOMBase_Skeleton( theGeometryGUI, parent, modal, fl )
00056 {
00057   QPixmap image0( SUIT_Session::session()->resourceMgr()->loadPixmap( "GEOM", tr( "ICON_DLG_CIRCLE_PV" ) ) );
00058   QPixmap image2( SUIT_Session::session()->resourceMgr()->loadPixmap( "GEOM", tr( "ICON_DLG_CIRCLE_PNTS" ) ) );
00059   QPixmap image3( SUIT_Session::session()->resourceMgr()->loadPixmap( "GEOM", tr( "ICON_DLG_CIRCLE_C2P" ) ) );
00060   QPixmap image1( SUIT_Session::session()->resourceMgr()->loadPixmap( "GEOM", tr( "ICON_SELECT" ) ) );
00061 
00062   setWindowTitle( tr( "GEOM_CIRCLE_TITLE" ) );
00063 
00064   /***************************************************************/
00065   mainFrame()->GroupConstructors->setTitle( tr( "GEOM_CIRCLE" ) );
00066   mainFrame()->RadioButton1->setIcon( image0 );
00067   mainFrame()->RadioButton2->setIcon( image2 );
00068   mainFrame()->RadioButton3->setIcon( image3 );
00069 
00070   GroupPntVecR = new DlgRef_2Sel1Spin( centralWidget() );
00071   GroupPntVecR->GroupBox1->setTitle( tr( "GEOM_ARGUMENTS" ) );
00072   
00073   GroupPntVecR->TextLabel1->setText( tr( "GEOM_CENTER_POINT" ) + " " + tr( "GEOM_CENTER_DEFAULT" )  );
00074   GroupPntVecR->TextLabel2->setText( tr( "GEOM_VECTOR" ) + " " + tr( "GEOM_AXIS_DEFAULT" ) );
00075   GroupPntVecR->TextLabel3->setText( tr( "GEOM_RADIUS" ) );
00076   GroupPntVecR->PushButton1->setIcon( image1 );
00077   GroupPntVecR->PushButton2->setIcon( image1 );
00078   GroupPntVecR->PushButton1->setDown( true );
00079 
00080   GroupPntVecR->LineEdit1->setReadOnly( true );
00081   GroupPntVecR->LineEdit2->setReadOnly( true );
00082 
00083   GroupPntVecR->LineEdit1->setEnabled( true );
00084   GroupPntVecR->LineEdit2->setEnabled( false );
00085 
00086   Group3Pnts = new DlgRef_3Sel( centralWidget() );
00087 
00088   Group3Pnts->GroupBox1->setTitle( tr( "GEOM_3_POINTS" ) );
00089   Group3Pnts->TextLabel1->setText( tr( "GEOM_POINT1" ) );
00090   Group3Pnts->TextLabel2->setText( tr( "GEOM_POINT2" ) );
00091   Group3Pnts->TextLabel3->setText( tr( "GEOM_POINT3" ) );
00092   Group3Pnts->PushButton1->setIcon( image1 );
00093   Group3Pnts->PushButton2->setIcon( image1 );
00094   Group3Pnts->PushButton3->setIcon( image1 );
00095   Group3Pnts->PushButton1->setDown( true );
00096 
00097   Group3Pnts->LineEdit1->setReadOnly( true );
00098   Group3Pnts->LineEdit2->setReadOnly( true );
00099   Group3Pnts->LineEdit3->setReadOnly( true );
00100   Group3Pnts->LineEdit1->setEnabled( true );
00101   Group3Pnts->LineEdit2->setEnabled( false );
00102   Group3Pnts->LineEdit3->setEnabled( false );
00103 
00104   GroupCenter2Pnts = new DlgRef_3Sel( centralWidget() );
00105   GroupCenter2Pnts->GroupBox1->setTitle( tr( "GEOM_CENTER_2POINTS" ) );
00106   GroupCenter2Pnts->TextLabel1->setText( tr( "GEOM_CENTER_POINT" ) );
00107   GroupCenter2Pnts->TextLabel2->setText( tr( "GEOM_POINT1" ) );
00108   GroupCenter2Pnts->TextLabel3->setText( tr( "GEOM_POINT2" ) );
00109   GroupCenter2Pnts->PushButton1->setIcon( image1 );
00110   GroupCenter2Pnts->PushButton2->setIcon( image1 );
00111   GroupCenter2Pnts->PushButton3->setIcon( image1 );
00112   GroupCenter2Pnts->PushButton1->setDown( true );
00113 
00114   GroupCenter2Pnts->LineEdit1->setReadOnly( true );
00115   GroupCenter2Pnts->LineEdit2->setReadOnly( true );
00116   GroupCenter2Pnts->LineEdit3->setReadOnly( true );
00117 
00118   GroupCenter2Pnts->LineEdit1->setEnabled( true );
00119   GroupCenter2Pnts->LineEdit2->setEnabled( false );
00120   GroupCenter2Pnts->LineEdit3->setEnabled( false );
00121 
00122   QVBoxLayout* layout = new QVBoxLayout( centralWidget() );
00123   layout->setMargin( 0 ); layout->setSpacing( 6 );
00124   layout->addWidget( GroupPntVecR );
00125   layout->addWidget( Group3Pnts );
00126   layout->addWidget( GroupCenter2Pnts );
00127   /***************************************************************/
00128 
00129   setHelpFileName( "create_circle_page.html" );
00130 
00131   Init();
00132 }
00133 
00134 
00135 //=================================================================================
00136 // function : ~BasicGUI_CircleDlg()
00137 // purpose  : Destroys the object and frees any allocated resources
00138 //=================================================================================
00139 BasicGUI_CircleDlg::~BasicGUI_CircleDlg()
00140 {
00141 }
00142 
00143 
00144 //=================================================================================
00145 // function : Init()
00146 // purpose  :
00147 //=================================================================================
00148 void BasicGUI_CircleDlg::Init()
00149 {
00150   /* init variables */
00151   myEditCurrentArgument = GroupPntVecR->LineEdit1;
00152 
00153   myPoint.nullify();
00154   myDir.nullify();
00155   myPoint1.nullify();
00156   myPoint2.nullify();
00157   myPoint3.nullify();
00158   myPoint4.nullify();
00159   myPoint5.nullify();
00160   myPoint6.nullify();
00161 
00162   /* Get setting of step value from file configuration */
00163   SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
00164   double aStep = resMgr->doubleValue( "Geometry", "SettingsGeomStep", 100 );
00165 
00166   /* min, max, step and decimals for spin boxes & initial values */
00167   initSpinBox( GroupPntVecR->SpinBox_DX, 0.000001, COORD_MAX, aStep, "length_precision" );
00168   GroupPntVecR->SpinBox_DX->setValue( 100 );
00169 
00170   /* signals and slots connections */
00171   connect( myGeomGUI, SIGNAL( SignalDeactivateActiveDialog() ), this, SLOT( DeactivateActiveDialog() ) );
00172   connect( myGeomGUI, SIGNAL( SignalCloseAllDialogs() ),        this, SLOT( ClickOnCancel() ) );
00173   
00174   connect( buttonOk(),     SIGNAL( clicked() ), this, SLOT( ClickOnOk() ) );
00175   connect( buttonApply(),  SIGNAL( clicked() ), this, SLOT( ClickOnApply() ) );
00176 
00177   connect( this,           SIGNAL( constructorsClicked( int ) ), this, SLOT( ConstructorsClicked( int ) ) );
00178 
00179   connect( GroupPntVecR->PushButton1, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) );
00180   connect( GroupPntVecR->PushButton2, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) );
00181   connect( Group3Pnts->PushButton1,   SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) );
00182   connect( Group3Pnts->PushButton2,   SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) );
00183   connect( Group3Pnts->PushButton3,   SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) );
00184 
00185   connect( GroupCenter2Pnts->PushButton1, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) );
00186   connect( GroupCenter2Pnts->PushButton2, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) );
00187   connect( GroupCenter2Pnts->PushButton3, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) );
00188 
00189   connect( GroupPntVecR->SpinBox_DX, SIGNAL( valueChanged( double ) ), this, SLOT(ValueChangedInSpinBox() ) );
00190   connect( myGeomGUI, SIGNAL( SignalDefaultStepValueChanged( double ) ), this, SLOT( SetDoubleSpinBoxStep( double ) ) );
00191 
00192   connect( myGeomGUI->getApp()->selectionMgr(), SIGNAL( currentSelectionChanged() ),
00193            this, SLOT( SelectionIntoArgument() ) );
00194 
00195   initName( tr( "GEOM_CIRCLE" ) );
00196 
00197   ConstructorsClicked( 0 );
00198 }
00199 
00200 //=================================================================================
00201 // function : SetDoubleSpinBoxStep()
00202 // purpose  : Double spin box management
00203 //=================================================================================
00204 void BasicGUI_CircleDlg::SetDoubleSpinBoxStep( double step )
00205 {
00206   GroupPntVecR->SpinBox_DX->setSingleStep(step);
00207 }
00208 
00209 //=================================================================================
00210 // function : ConstructorsClicked()
00211 // purpose  : Radio button management
00212 //=================================================================================
00213 void BasicGUI_CircleDlg::ConstructorsClicked( int constructorId )
00214 {
00215   disconnect( myGeomGUI->getApp()->selectionMgr(), 0, this, 0);
00216 
00217   myPoint.nullify();
00218   myDir.nullify();
00219   myPoint1.nullify();
00220   myPoint2.nullify();
00221   myPoint3.nullify();
00222   myPoint4.nullify();
00223   myPoint5.nullify();
00224   myPoint6.nullify();
00225 
00226   switch ( constructorId ) {
00227   case 0:
00228     {
00229       Group3Pnts->hide();
00230       GroupCenter2Pnts->hide();
00231       GroupPntVecR->show();
00232       
00233       myEditCurrentArgument = GroupPntVecR->LineEdit1;
00234       GroupPntVecR->LineEdit1->setText( "" );
00235       GroupPntVecR->LineEdit2->setText( "" );
00236       GroupPntVecR->PushButton1->setDown( true );
00237       GroupPntVecR->PushButton2->setDown( false );
00238       GroupPntVecR->LineEdit1->setEnabled( true );
00239       GroupPntVecR->LineEdit2->setEnabled( false );
00240       break;
00241     }
00242   case 1:
00243     {
00244       GroupPntVecR->hide();
00245       GroupCenter2Pnts->hide();
00246       Group3Pnts->show();
00247       
00248       myEditCurrentArgument = Group3Pnts->LineEdit1;
00249       Group3Pnts->LineEdit1->setText( "" );
00250       Group3Pnts->LineEdit2->setText( "" );
00251       Group3Pnts->LineEdit3->setText( "" );
00252       Group3Pnts->PushButton1->setDown( true );
00253       Group3Pnts->PushButton2->setDown( false );
00254       Group3Pnts->PushButton3->setDown( false );
00255       Group3Pnts->LineEdit1->setEnabled( true );
00256       Group3Pnts->LineEdit2->setEnabled( false );
00257       Group3Pnts->LineEdit3->setEnabled( false );
00258       break;
00259     }
00260   case 2:
00261     {
00262       GroupPntVecR->hide();
00263       Group3Pnts->hide();               
00264       GroupCenter2Pnts->show();
00265       
00266       myEditCurrentArgument = GroupCenter2Pnts->LineEdit1;
00267       GroupCenter2Pnts->LineEdit1->setText( "" );
00268       GroupCenter2Pnts->LineEdit2->setText( "" );
00269       GroupCenter2Pnts->LineEdit3->setText( "" );
00270       GroupCenter2Pnts->PushButton1->setDown( true );
00271       GroupCenter2Pnts->PushButton2->setDown( false );
00272       GroupCenter2Pnts->PushButton3->setDown( false );
00273       GroupCenter2Pnts->LineEdit1->setEnabled( true );
00274       GroupCenter2Pnts->LineEdit2->setEnabled( false );
00275       GroupCenter2Pnts->LineEdit3->setEnabled( false );
00276       break;
00277     }
00278   }
00279   
00280   qApp->processEvents();
00281   updateGeometry();
00282   resize( minimumSizeHint() );
00283   SelectionIntoArgument();
00284 
00285   myEditCurrentArgument->setFocus();
00286   globalSelection(); // close local contexts, if any
00287   localSelection( GEOM::GEOM_Object::_nil(), TopAbs_VERTEX );
00288 
00289   connect( myGeomGUI->getApp()->selectionMgr(), SIGNAL(currentSelectionChanged() ),
00290            this, SLOT( SelectionIntoArgument() ) );
00291 
00292   displayPreview(true);
00293 }
00294 
00295 //=================================================================================
00296 // function : ClickOnOk()
00297 // purpose  :
00298 //=================================================================================
00299 void BasicGUI_CircleDlg::ClickOnOk()
00300 {
00301   setIsApplyAndClose( true );
00302   if ( ClickOnApply() )
00303     ClickOnCancel();
00304 }
00305 
00306 //=================================================================================
00307 // function : ClickOnApply()
00308 // purpose  :
00309 //=================================================================================
00310 bool BasicGUI_CircleDlg::ClickOnApply()
00311 {
00312   if ( !onAccept() )
00313     return false;
00314 
00315   initName();
00316   ConstructorsClicked( getConstructorId() );
00317   return true;
00318 }
00319 
00320 //=================================================================================
00321 // function : SelectionIntoArgument()
00322 // purpose  : Called when selection as changed or other case
00323 //=================================================================================
00324 void BasicGUI_CircleDlg::SelectionIntoArgument()
00325 {
00326   myEditCurrentArgument->setText( "" );
00327   
00328   LightApp_SelectionMgr* aSelMgr = myGeomGUI->getApp()->selectionMgr();
00329   SALOME_ListIO aList;
00330   aSelMgr->selectedObjects( aList );
00331 
00332   if ( aList.Extent() != 1 ) {
00333     if      ( myEditCurrentArgument == GroupPntVecR->LineEdit1 )     myPoint.nullify();
00334     else if ( myEditCurrentArgument == GroupPntVecR->LineEdit2 )     myDir.nullify();
00335     else if ( myEditCurrentArgument == Group3Pnts->LineEdit1 )       myPoint1.nullify();
00336     else if ( myEditCurrentArgument == Group3Pnts->LineEdit2 )       myPoint2.nullify();
00337     else if ( myEditCurrentArgument == Group3Pnts->LineEdit3 )       myPoint3.nullify();
00338     else if ( myEditCurrentArgument == GroupCenter2Pnts->LineEdit1 ) myPoint4.nullify();
00339     else if ( myEditCurrentArgument == GroupCenter2Pnts->LineEdit2 ) myPoint5.nullify();
00340     else if ( myEditCurrentArgument == GroupCenter2Pnts->LineEdit3 ) myPoint6.nullify();
00341     return;
00342   }
00343 
00344   TopAbs_ShapeEnum aNeedType = ( myEditCurrentArgument == GroupPntVecR->LineEdit2 ) ?
00345     TopAbs_EDGE : TopAbs_VERTEX;
00346   GEOM::GeomObjPtr aSelectedObject = getSelected( aNeedType );
00347   TopoDS_Shape aShape;
00348   if ( aSelectedObject && GEOMBase::GetShape( aSelectedObject.get(), aShape ) && !aShape.IsNull() ) {
00349     QString aName = GEOMBase::GetName( aSelectedObject.get() );
00350     
00351     myEditCurrentArgument->setText( aName );
00352 
00353     if      ( myEditCurrentArgument == GroupPntVecR->LineEdit1 ) {
00354       myPoint  = aSelectedObject;
00355       if ( myPoint && !myDir )
00356         GroupPntVecR->PushButton2->click();
00357     }
00358     else if ( myEditCurrentArgument == GroupPntVecR->LineEdit2 ) {
00359       myDir    = aSelectedObject;
00360       if ( myDir && !myPoint )
00361         GroupPntVecR->PushButton1->click();
00362     }
00363     else if ( myEditCurrentArgument == Group3Pnts->LineEdit1 ) {
00364       myPoint1 = aSelectedObject;
00365       if ( myPoint1 && !myPoint2 )
00366         Group3Pnts->PushButton2->click();
00367     }
00368     else if ( myEditCurrentArgument == Group3Pnts->LineEdit2 ) {
00369       myPoint2 = aSelectedObject;
00370       if ( myPoint2 && !myPoint3 )
00371         Group3Pnts->PushButton3->click();
00372     }
00373     else if ( myEditCurrentArgument == Group3Pnts->LineEdit3 ) {
00374       myPoint3 = aSelectedObject;
00375       if ( myPoint3 && !myPoint1 )
00376         Group3Pnts->PushButton1->click();
00377     }
00378     else if ( myEditCurrentArgument == GroupCenter2Pnts->LineEdit1 ) {
00379       myPoint4 = aSelectedObject;
00380       if ( myPoint4 && !myPoint5 )
00381         GroupCenter2Pnts->PushButton2->click();
00382     }
00383     else if ( myEditCurrentArgument == GroupCenter2Pnts->LineEdit2 ) {
00384       myPoint5 = aSelectedObject;
00385       if ( myPoint5 && !myPoint6 )
00386         GroupCenter2Pnts->PushButton3->click();
00387     }
00388     else if ( myEditCurrentArgument == GroupCenter2Pnts->LineEdit3 ) {
00389       myPoint6 = aSelectedObject;
00390       if ( myPoint6 && !myPoint4 )
00391         GroupCenter2Pnts->PushButton1->click();
00392     }
00393   }
00394 
00395   displayPreview(true);
00396 }
00397 
00398 
00399 //=================================================================================
00400 // function : SetEditCurrentArgument()
00401 // purpose  :
00402 //=================================================================================
00403 void BasicGUI_CircleDlg::SetEditCurrentArgument()
00404 {
00405   QPushButton* send = (QPushButton*)sender();
00406 
00407   if ( send == GroupPntVecR->PushButton1 ) {
00408     myEditCurrentArgument = GroupPntVecR->LineEdit1;
00409     GroupPntVecR->PushButton2->setDown(false);
00410     GroupPntVecR->LineEdit1->setEnabled( true );
00411     GroupPntVecR->LineEdit2->setEnabled( false );
00412   }
00413   else if ( send == GroupPntVecR->PushButton2 ) {
00414     myEditCurrentArgument = GroupPntVecR->LineEdit2;
00415     GroupPntVecR->PushButton1->setDown(false);
00416     GroupPntVecR->LineEdit1->setEnabled( false );
00417     GroupPntVecR->LineEdit2->setEnabled( true );
00418   }
00419   else if ( send == Group3Pnts->PushButton1 ) {
00420     myEditCurrentArgument = Group3Pnts->LineEdit1;
00421     Group3Pnts->PushButton2->setDown( false );
00422     Group3Pnts->PushButton3->setDown( false );
00423     Group3Pnts->LineEdit1->setEnabled( true );
00424     Group3Pnts->LineEdit2->setEnabled( false );
00425     Group3Pnts->LineEdit3->setEnabled( false );
00426   }
00427   else if ( send == Group3Pnts->PushButton2 )  {
00428     myEditCurrentArgument = Group3Pnts->LineEdit2;
00429     Group3Pnts->PushButton1->setDown( false );
00430     Group3Pnts->PushButton3->setDown( false );
00431     Group3Pnts->LineEdit1->setEnabled( false );
00432     Group3Pnts->LineEdit2->setEnabled( true );
00433     Group3Pnts->LineEdit3->setEnabled( false );
00434   }
00435   else if ( send == Group3Pnts->PushButton3 ) {
00436     myEditCurrentArgument = Group3Pnts->LineEdit3;
00437     Group3Pnts->PushButton1->setDown( false );
00438     Group3Pnts->PushButton2->setDown( false );
00439     Group3Pnts->LineEdit1->setEnabled( false );
00440     Group3Pnts->LineEdit2->setEnabled( false );
00441     Group3Pnts->LineEdit3->setEnabled( true );
00442   }
00443   else if ( send == GroupCenter2Pnts->PushButton1 ) {
00444     myEditCurrentArgument = GroupCenter2Pnts->LineEdit1;
00445     GroupCenter2Pnts->PushButton2->setDown( false );
00446     GroupCenter2Pnts->PushButton3->setDown( false );
00447     GroupCenter2Pnts->LineEdit1->setEnabled( true );
00448     GroupCenter2Pnts->LineEdit2->setEnabled( false );
00449     GroupCenter2Pnts->LineEdit3->setEnabled( false );
00450   }
00451   else if ( send == GroupCenter2Pnts->PushButton2 ) {
00452     myEditCurrentArgument = GroupCenter2Pnts->LineEdit2;
00453     GroupCenter2Pnts->PushButton1->setDown( false );
00454     GroupCenter2Pnts->PushButton3->setDown( false );
00455     GroupCenter2Pnts->LineEdit1->setEnabled( false );
00456     GroupCenter2Pnts->LineEdit2->setEnabled( true );
00457     GroupCenter2Pnts->LineEdit3->setEnabled( false );
00458     
00459   }
00460   else if ( send == GroupCenter2Pnts->PushButton3 ) {
00461     myEditCurrentArgument = GroupCenter2Pnts->LineEdit3;
00462     GroupCenter2Pnts->PushButton1->setDown( false );
00463     GroupCenter2Pnts->PushButton2->setDown( false );
00464     GroupCenter2Pnts->LineEdit1->setEnabled( false );
00465     GroupCenter2Pnts->LineEdit2->setEnabled( false );
00466     GroupCenter2Pnts->LineEdit3->setEnabled( true );
00467   }
00468 
00469   
00470   myEditCurrentArgument->setFocus();
00471 
00472   TopAbs_ShapeEnum aNeedType = ( myEditCurrentArgument == GroupPntVecR->LineEdit2 ) ?
00473     TopAbs_EDGE : TopAbs_VERTEX;
00474   globalSelection(); // close local contexts, if any
00475   localSelection( GEOM::GEOM_Object::_nil(), aNeedType );
00476 
00477   myEditCurrentArgument->setFocus();
00478   //  SelectionIntoArgument();
00479   send->setDown(true);
00480   displayPreview(true);
00481 }
00482 
00483 
00484 //=================================================================================
00485 // function : ActivateThisDialog()
00486 // purpose  :
00487 //=================================================================================
00488 void BasicGUI_CircleDlg::ActivateThisDialog()
00489 {
00490   GEOMBase_Skeleton::ActivateThisDialog();
00491 
00492   connect( myGeomGUI->getApp()->selectionMgr(), SIGNAL( currentSelectionChanged() ),
00493            this, SLOT( SelectionIntoArgument() ) );
00494 
00495   ConstructorsClicked( getConstructorId() );
00496 }
00497 
00498 
00499 //=================================================================================
00500 // function : enterEvent()
00501 // purpose  :
00502 //=================================================================================
00503 void BasicGUI_CircleDlg::enterEvent( QEvent* )
00504 {
00505   if ( !mainFrame()->GroupConstructors->isEnabled() )
00506     ActivateThisDialog();
00507 }
00508 
00509 //=================================================================================
00510 // function : DeactivateActiveDialog()
00511 // purpose  : public slot to deactivate if active
00512 //=================================================================================
00513 void BasicGUI_CircleDlg::DeactivateActiveDialog()
00514 {
00515   GEOMBase_Skeleton::DeactivateActiveDialog();
00516 }
00517 
00518 //=================================================================================
00519 // function : ValueChangedInSpinBox()
00520 // purpose  :
00521 //=================================================================================
00522 void BasicGUI_CircleDlg::ValueChangedInSpinBox()
00523 {
00524   displayPreview(true);
00525 }
00526 
00527 //=================================================================================
00528 // function : getRadius()
00529 // purpose  :
00530 //=================================================================================
00531 double BasicGUI_CircleDlg::getRadius() const
00532 {
00533   double r = 0.;
00534   switch ( getConstructorId() ) {
00535   case 0:
00536     r = GroupPntVecR->SpinBox_DX->value(); break;
00537   }
00538   return r;
00539 }
00540 
00541 //=================================================================================
00542 // function : createOperation
00543 // purpose  :
00544 //=================================================================================
00545 GEOM::GEOM_IOperations_ptr BasicGUI_CircleDlg::createOperation()
00546 {
00547   return myGeomGUI->GetGeomGen()->GetICurvesOperations( getStudyId() );
00548 }
00549 
00550 //=================================================================================
00551 // function : isValid
00552 // purpose  :
00553 //=================================================================================
00554 bool BasicGUI_CircleDlg::isValid( QString& msg )
00555 {
00556   bool ok = false;
00557   switch( getConstructorId() ) {
00558   case 0:
00559     // nil point means origin of global CS
00560     // nil vector means Z axis
00561     ok = GroupPntVecR->SpinBox_DX->isValid(msg, !IsPreview()) && getRadius() > 0;
00562     break;
00563   case 1:
00564     ok = myPoint1 && myPoint2 && myPoint3 && myPoint1 != myPoint2 && 
00565          myPoint1 != myPoint3 && myPoint2 != myPoint3;
00566     break;
00567   case 2:
00568     ok = myPoint4 && myPoint5 && myPoint6 && myPoint4 != myPoint5 && 
00569          myPoint5 != myPoint6 && myPoint4 != myPoint6;
00570     break;
00571   default:
00572     break;
00573   }
00574   return ok;
00575 }
00576 
00577 //=================================================================================
00578 // function : execute
00579 // purpose  :
00580 //=================================================================================
00581 bool BasicGUI_CircleDlg::execute( ObjectList& objects )
00582 {
00583   bool res = false;
00584   
00585   GEOM::GEOM_Object_var anObj;
00586   
00587   GEOM::GEOM_ICurvesOperations_var anOper = GEOM::GEOM_ICurvesOperations::_narrow( getOperation() );
00588 
00589   switch ( getConstructorId() ) {
00590   case 0 :
00591     {
00592       QStringList aParameters;
00593       aParameters << GroupPntVecR->SpinBox_DX->text();
00594       anObj = anOper->MakeCirclePntVecR( myPoint.get(), myDir.get(), getRadius() );
00595       if ( !anObj->_is_nil() && !IsPreview() )
00596         anObj->SetParameters(aParameters.join(":").toLatin1().constData());
00597       res = true;
00598       break;
00599     }
00600   case 1 :
00601     anObj = anOper->MakeCircleThreePnt( myPoint1.get(), myPoint2.get(), myPoint3.get() );
00602     res = true;
00603     break;
00604   case 2:
00605     anObj = anOper->MakeCircleCenter2Pnt( myPoint4.get(), myPoint5.get(), myPoint6.get() );
00606     res = true;
00607     break;
00608   }
00609   
00610   if ( !anObj->_is_nil() )
00611     objects.push_back( anObj._retn() );
00612   else {
00613     MESSAGE( "Execute Object is NULL!" );
00614   }
00615   
00616   return res;
00617 }
00618 
00619 //=================================================================================
00620 // function : addSubshapeToStudy
00621 // purpose  : virtual method to add new SubObjects if local selection
00622 //=================================================================================
00623 void BasicGUI_CircleDlg::addSubshapesToStudy()
00624 {
00625   switch ( getConstructorId() ) {
00626   case 0:
00627     GEOMBase::PublishSubObject( myPoint.get() );
00628     GEOMBase::PublishSubObject( myDir.get() );
00629     break;
00630   case 1:
00631     GEOMBase::PublishSubObject( myPoint1.get() );
00632     GEOMBase::PublishSubObject( myPoint2.get() );
00633     GEOMBase::PublishSubObject( myPoint3.get() );
00634     break;
00635   case 2:
00636     GEOMBase::PublishSubObject( myPoint4.get() );
00637     GEOMBase::PublishSubObject( myPoint5.get() );
00638     GEOMBase::PublishSubObject( myPoint6.get() );
00639     break;
00640  default:
00641    break;
00642   }
00643 }