Back to index

salome-geom  6.5.0
BasicGUI_PlaneDlg.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_PlaneDlg.cxx
00025 // Author : Lucien PIGNOLONI, Open CASCADE S.A.S.
00026 //
00027 #include "BasicGUI_PlaneDlg.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_MapOfInteger.hxx>
00040 #include <TopoDS_Shape.hxx>
00041 #include <TopoDS_Edge.hxx>
00042 #include <TopoDS.hxx>
00043 #include <TopExp.hxx>
00044 #include <TColStd_IndexedMapOfInteger.hxx>
00045 #include <TopTools_IndexedMapOfShape.hxx>
00046 
00047 #include <GEOMImpl_Types.hxx>
00048 
00049 //=================================================================================
00050 // class    : BasicGUI_PlaneDlg()
00051 // purpose  : Constructs a BasicGUI_PlaneDlg which is a child of 'parent', with the
00052 //            name 'name' and widget flags set to 'f'.
00053 //            The dialog will by default be modeless, unless you set 'modal' to
00054 //            TRUE to construct a modal dialog.
00055 //=================================================================================
00056 BasicGUI_PlaneDlg::BasicGUI_PlaneDlg( GeometryGUI* theGeometryGUI, QWidget* parent,
00057                                       bool modal, Qt::WindowFlags fl )
00058   : GEOMBase_Skeleton( theGeometryGUI, parent, modal, fl )
00059 {
00060   QPixmap image0( SUIT_Session::session()->resourceMgr()->loadPixmap( "GEOM", tr( "ICON_DLG_PLANE_PV" ) ) );
00061   QPixmap image1( SUIT_Session::session()->resourceMgr()->loadPixmap( "GEOM", tr( "ICON_DLG_PLANE_3PNTS" ) ) );
00062   QPixmap image2( SUIT_Session::session()->resourceMgr()->loadPixmap( "GEOM", tr( "ICON_DLG_PLANE_FACE" ) ) );
00063   QPixmap image3( SUIT_Session::session()->resourceMgr()->loadPixmap( "GEOM", tr( "ICON_SELECT" ) ) );
00064   QPixmap image4( SUIT_Session::session()->resourceMgr()->loadPixmap( "GEOM", tr( "ICON_DLG_WPLANE_VECTOR" ) ) );
00065   QPixmap image5( SUIT_Session::session()->resourceMgr()->loadPixmap( "GEOM", tr( "ICON_DLG_WPLANE_ORIGIN" ) ) );
00066 
00067   setWindowTitle( tr( "GEOM_PLANE_TITLE" ) );
00068 
00069   /***************************************************************/
00070   mainFrame()->GroupConstructors->setTitle( tr( "GEOM_PLANE" ) );
00071   mainFrame()->RadioButton1->setIcon( image0 );
00072   mainFrame()->RadioButton2->setIcon( image1 );
00073   mainFrame()->RadioButton3->setIcon( image2 );
00074   mainFrame()->RadioButton4->show();
00075   mainFrame()->RadioButton4->setIcon( image4 );
00076   mainFrame()->RadioButton5->show();
00077   mainFrame()->RadioButton5->setIcon( image5 );
00078 
00079   GroupPntDir = new DlgRef_2Sel1Spin( centralWidget() );
00080   GroupPntDir->GroupBox1->setTitle( tr( "GEOM_PLANE_PV" ) );
00081   GroupPntDir->TextLabel1->setText( tr( "GEOM_POINT" ) );
00082   GroupPntDir->TextLabel2->setText( tr( "GEOM_VECTOR" ) );
00083   GroupPntDir->TextLabel3->setText( tr( "GEOM_PLANE_SIZE" ) );
00084   GroupPntDir->PushButton1->setIcon( image3 );
00085   GroupPntDir->PushButton2->setIcon( image3 );
00086   GroupPntDir->LineEdit1->setReadOnly( true );
00087   GroupPntDir->LineEdit2->setReadOnly( true );
00088   GroupPntDir->PushButton1->setDown( true );
00089   GroupPntDir->LineEdit1->setEnabled( true );
00090   GroupPntDir->LineEdit2->setEnabled( false );
00091 
00092   Group3Pnts = new DlgRef_3Sel1Spin( centralWidget() );
00093   Group3Pnts->GroupBox1->setTitle( tr( "GEOM_3_POINTS" ) );
00094   Group3Pnts->TextLabel1->setText( tr( "GEOM_POINT1" ) );
00095   Group3Pnts->TextLabel2->setText( tr( "GEOM_POINT2" ) );
00096   Group3Pnts->TextLabel3->setText( tr( "GEOM_POINT3" ) );
00097   Group3Pnts->TextLabel4->setText( tr( "GEOM_PLANE_SIZE" ) );
00098   Group3Pnts->PushButton1->setIcon( image3 );
00099   Group3Pnts->PushButton2->setIcon( image3 );
00100   Group3Pnts->PushButton3->setIcon( image3 );
00101   Group3Pnts->PushButton1->setDown( true );
00102 
00103   Group3Pnts->LineEdit1->setReadOnly( true );
00104   Group3Pnts->LineEdit2->setReadOnly( true );
00105   Group3Pnts->LineEdit3->setReadOnly( true );
00106   Group3Pnts->LineEdit1->setEnabled( true );
00107   Group3Pnts->LineEdit2->setEnabled( false );
00108   Group3Pnts->LineEdit3->setEnabled( false );
00109 
00110   GroupFace = new DlgRef_1Sel1Spin( centralWidget() );
00111   GroupFace->GroupBox1->setTitle( tr( "GEOM_FACE" ) );
00112   GroupFace->TextLabel1->setText( tr( "GEOM_SELECTION" ) );
00113   GroupFace->TextLabel2->setText( tr( "GEOM_PLANE_SIZE" ) );
00114   GroupFace->PushButton1->setIcon( image3 );
00115   GroupFace->PushButton1->setDown( true );
00116 
00117   GroupFace->LineEdit1->setReadOnly( true );
00118 
00119   Group2Vec = new DlgRef_2Sel1Spin( centralWidget() );
00120 
00121   Group2Vec->GroupBox1->setTitle( tr( "GEOM_WPLANE_VECTOR" ) );
00122   Group2Vec->TextLabel1->setText( tr( "GEOM_WPLANE_VX" ) );
00123   Group2Vec->TextLabel2->setText( tr( "GEOM_WPLANE_VZ" ) );
00124   Group2Vec->PushButton1->setIcon( image3 );
00125   Group2Vec->PushButton2->setIcon( image3 );
00126   Group2Vec->LineEdit1->setReadOnly( true );
00127   Group2Vec->LineEdit2->setReadOnly( true );
00128   Group2Vec->PushButton1->setDown( true );
00129   Group2Vec->LineEdit1->setEnabled( true );
00130   Group2Vec->LineEdit2->setEnabled( false );
00131   Group2Vec->TextLabel3->setText( tr( "GEOM_PLANE_SIZE" ) );
00132 
00133   GroupLCS = new DlgRef_3Radio1Sel1Spin( centralWidget() );
00134   GroupLCS->GroupBox1->setTitle( tr( "GEOM_LCS" ) );
00135   GroupLCS->TextLabel1->setText( tr( "GEOM_SELECTION" ) );
00136   GroupLCS->TextLabel2->setText( tr( "GEOM_PLANE_SIZE" ) );
00137   GroupLCS->RadioButton1->setText( tr( "GEOM_WPLANE_OXY" ) );
00138   GroupLCS->RadioButton2->setText( tr( "GEOM_WPLANE_OYZ" ) );
00139   GroupLCS->RadioButton3->setText( tr( "GEOM_WPLANE_OZX" ) );
00140   GroupLCS->LineEdit1->setReadOnly( true );
00141   GroupLCS->PushButton1->setIcon( image3 );
00142   GroupLCS->PushButton1->setDown( true );
00143 
00144   QVBoxLayout* layout = new QVBoxLayout( centralWidget() );
00145   layout->setMargin( 0 ); layout->setSpacing( 6 );
00146   layout->addWidget( GroupPntDir );
00147   layout->addWidget( Group3Pnts );
00148   layout->addWidget( GroupFace );
00149   layout->addWidget( Group2Vec );
00150   layout->addWidget( GroupLCS );
00151   /***************************************************************/
00152 
00153   setHelpFileName( "create_plane_page.html" );
00154 
00155   Init();
00156 }
00157 
00158 
00159 //=================================================================================
00160 // function : ~BasicGUI_PlaneDlg()
00161 // purpose  : Destroys the object and frees any allocated resources
00162 //=================================================================================
00163 BasicGUI_PlaneDlg::~BasicGUI_PlaneDlg()
00164 {
00165 }
00166 
00167 
00168 //=================================================================================
00169 // function : Init()
00170 // purpose  :
00171 //=================================================================================
00172 void BasicGUI_PlaneDlg::Init()
00173 {
00174   /* init variables */
00175   myEditCurrentArgument = GroupPntDir->LineEdit1;
00176 
00177   myPoint.nullify();
00178   myDir.nullify();
00179   myPoint1.nullify();
00180   myPoint2.nullify();
00181   myPoint3.nullify();
00182   myFace.nullify();
00183   myLCS.nullify();
00184   myVec1.nullify();
00185   myVec2.nullify();
00186  
00187   // myGeomGUI->SetState( 0 );
00188   myOriginType = 1;
00189 
00190   /* Get setting of step value from file configuration */
00191   SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
00192   double aStep = resMgr->doubleValue( "Geometry", "SettingsGeomStep", 100 );
00193 
00194   double aTrimSize = 2000.0;
00195 
00196   /* min, max, step and decimals for spin boxes */
00197   initSpinBox( GroupPntDir->SpinBox_DX, 0.000001, COORD_MAX, aStep, "length_precision" );
00198   GroupPntDir->SpinBox_DX->setValue( aTrimSize );
00199   initSpinBox( Group3Pnts->SpinBox_DX, 0.000001, COORD_MAX, aStep, "length_precision" );
00200   Group3Pnts->SpinBox_DX->setValue( aTrimSize );
00201   initSpinBox( GroupFace->SpinBox_DX, 0.000001, COORD_MAX, aStep, "length_precision" );
00202   GroupFace->SpinBox_DX->setValue( aTrimSize );
00203   initSpinBox( Group2Vec->SpinBox_DX, 0.000001, COORD_MAX, aStep, "length_precision" );
00204   Group2Vec->SpinBox_DX->setValue( aTrimSize );
00205   initSpinBox( GroupLCS->SpinBox_DX, 0.000001, COORD_MAX, aStep, "length_precision" );
00206   GroupLCS->SpinBox_DX->setValue( aTrimSize );
00207 
00208   /* signals and slots connections */
00209   connect( myGeomGUI, SIGNAL( SignalDeactivateActiveDialog() ), this, SLOT( DeactivateActiveDialog() ) );
00210   connect( myGeomGUI, SIGNAL( SignalCloseAllDialogs() ),        this, SLOT( ClickOnCancel() ) );
00211 
00212   connect( buttonOk(),     SIGNAL( clicked() ), this, SLOT( ClickOnOk() ) );
00213   connect( buttonApply(),  SIGNAL( clicked() ), this, SLOT( ClickOnApply() ) );
00214 
00215   connect( this,           SIGNAL( constructorsClicked( int ) ), this, SLOT( ConstructorsClicked( int ) ) );
00216 
00217   connect( GroupPntDir->PushButton1, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) );
00218   connect( GroupPntDir->PushButton2, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) );
00219   connect( Group3Pnts->PushButton1,  SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) );
00220   connect( Group3Pnts->PushButton2,  SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) );
00221   connect( Group3Pnts->PushButton3,  SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) );
00222   connect( GroupFace->PushButton1,   SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) );
00223   connect( Group2Vec->PushButton1,   SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) );
00224   connect( Group2Vec->PushButton2,   SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) );
00225 
00226   connect( GroupLCS->RadioButton1,   SIGNAL( clicked() ), this, SLOT( GroupClicked() ) );
00227   connect( GroupLCS->RadioButton2,   SIGNAL( clicked() ), this, SLOT( GroupClicked() ) );
00228   connect( GroupLCS->RadioButton3,   SIGNAL( clicked() ), this, SLOT( GroupClicked() ) );
00229 
00230   connect( GroupPntDir->SpinBox_DX, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
00231   connect( Group3Pnts->SpinBox_DX,  SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
00232   connect( GroupFace->SpinBox_DX,   SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
00233   connect( Group2Vec->SpinBox_DX,   SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
00234   connect( GroupLCS->SpinBox_DX,   SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
00235 
00236   connect( myGeomGUI, SIGNAL( SignalDefaultStepValueChanged( double ) ), this, SLOT( SetDoubleSpinBoxStep( double ) ) );
00237 
00238   connect( myGeomGUI->getApp()->selectionMgr(), SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) );
00239 
00240   initName( tr( "GEOM_PLANE" ) );
00241 
00242   ConstructorsClicked( 0 );
00243 }
00244 
00245 //=================================================================================
00246 // function : SetDoubleSpinBoxStep()
00247 // purpose  : Double spin box management
00248 //=================================================================================
00249 void BasicGUI_PlaneDlg::SetDoubleSpinBoxStep( double step )
00250 {
00251   GroupPntDir->SpinBox_DX->setSingleStep(step);
00252   Group3Pnts->SpinBox_DX->setSingleStep(step);
00253   GroupFace->SpinBox_DX->setSingleStep(step);
00254   Group2Vec->SpinBox_DX->setSingleStep(step);
00255   GroupLCS->SpinBox_DX->setSingleStep(step);
00256 }
00257 
00258 //=================================================================================
00259 // function : ConstructorsClicked()
00260 // purpose  : Radio button management
00261 //=================================================================================
00262 void BasicGUI_PlaneDlg::ConstructorsClicked( int constructorId )
00263 {
00264   disconnect( myGeomGUI->getApp()->selectionMgr(), 0, this, 0 );
00265   myPoint.nullify();
00266   myDir.nullify();
00267   myPoint1.nullify();
00268   myPoint2.nullify();
00269   myPoint3.nullify();
00270   myFace.nullify();
00271   myLCS.nullify();
00272   myVec1.nullify();
00273   myVec2.nullify();
00274 
00275   switch ( constructorId ) {
00276   case 0: /* plane from a point and a direction (vector, edge...) */
00277     {
00278       Group3Pnts->hide();
00279       GroupFace->hide();
00280       GroupPntDir->show();
00281       Group2Vec->hide();
00282       GroupLCS->hide();
00283       
00284       myEditCurrentArgument = GroupPntDir->LineEdit1;
00285       GroupPntDir->LineEdit1->setText( "" );
00286       GroupPntDir->LineEdit2->setText( "" );
00287       GroupPntDir->PushButton1->setDown( true );
00288       GroupPntDir->PushButton2->setDown( false );
00289       GroupPntDir->LineEdit1->setEnabled( true );
00290       GroupPntDir->LineEdit2->setEnabled( false );
00291       
00292       /* for the first argument */
00293       globalSelection(); // close local contexts, if any
00294       localSelection( GEOM::GEOM_Object::_nil(), TopAbs_VERTEX );
00295       break;
00296     }
00297   case 1: /* plane from 3 points */
00298     {
00299       GroupPntDir->hide();
00300       GroupFace->hide();
00301       Group3Pnts->show();
00302       Group2Vec->hide();
00303       GroupLCS->hide();
00304       
00305       myEditCurrentArgument = Group3Pnts->LineEdit1;
00306       Group3Pnts->LineEdit1->setText( "" );
00307       Group3Pnts->LineEdit2->setText( "" );
00308       Group3Pnts->LineEdit3->setText( "" );
00309       Group3Pnts->PushButton1->setDown( true );
00310       Group3Pnts->PushButton2->setDown( false );
00311       Group3Pnts->PushButton3->setDown( false );
00312       Group3Pnts->LineEdit1->setEnabled( true );
00313       Group3Pnts->LineEdit2->setEnabled( false );
00314       Group3Pnts->LineEdit3->setEnabled( false );
00315       
00316       /* for the first argument */
00317       globalSelection(); // close local contexts, if any
00318       localSelection( GEOM::GEOM_Object::_nil(), TopAbs_VERTEX );
00319       break;
00320     }
00321   case 2: /* plane from a planar face */
00322     {
00323       GroupPntDir->hide();
00324       Group3Pnts->hide();
00325       GroupFace->show();
00326       Group2Vec->hide();
00327       GroupLCS->hide();
00328       
00329       myEditCurrentArgument = GroupFace->LineEdit1;
00330       GroupFace->LineEdit1->setText( "" );
00331       GroupFace->PushButton1->setDown( true );
00332       
00333       globalSelection(); // close local contexts, if any
00334       localSelection( GEOM::GEOM_Object::_nil(), TopAbs_FACE );
00335       break;
00336     }
00337   case 3: /* plane from a 2 Vectors */
00338     {
00339       GroupPntDir->hide();
00340       Group3Pnts->hide();
00341       GroupFace->hide();
00342       Group2Vec->show();
00343       GroupLCS->hide();
00344       
00345       myEditCurrentArgument = Group2Vec->LineEdit1;
00346       Group2Vec->LineEdit1->setText( "" );
00347       Group2Vec->PushButton1->setDown( true );
00348       
00349       globalSelection(); // close local contexts, if any
00350       localSelection( GEOM::GEOM_Object::_nil(), TopAbs_EDGE );
00351       break;
00352     }
00353   case 4: /* plane from a LCS */
00354     {
00355       GroupPntDir->hide();
00356       Group3Pnts->hide();
00357       GroupFace->hide();
00358       Group2Vec->hide();
00359       GroupLCS->show();
00360       
00361       myEditCurrentArgument = GroupLCS->LineEdit1;
00362       GroupLCS->LineEdit1->setText( "" );
00363       GroupLCS->PushButton1->setDown( true );
00364       GroupLCS->RadioButton1->setChecked( true );
00365       myOriginType = 1;
00366       
00367       globalSelection(GEOM_MARKER);
00368       break;
00369     }
00370   }
00371   
00372   qApp->processEvents();
00373   updateGeometry();
00374   resize( minimumSizeHint() );
00375   SelectionIntoArgument();
00376 
00377   myEditCurrentArgument->setFocus();
00378   connect( myGeomGUI->getApp()->selectionMgr(), SIGNAL( currentSelectionChanged() ),
00379            this, SLOT( SelectionIntoArgument() ) );
00380   displayPreview(true);
00381 }
00382 
00383 
00384 //=================================================================================
00385 // function : ClickOnOk()
00386 // purpose  :
00387 //=================================================================================
00388 void BasicGUI_PlaneDlg::ClickOnOk()
00389 {
00390   setIsApplyAndClose( true );
00391   if ( ClickOnApply() )
00392     ClickOnCancel();
00393 }
00394 
00395 
00396 //=================================================================================
00397 // function : ClickOnApply()
00398 // purpose  :
00399 //=================================================================================
00400 bool BasicGUI_PlaneDlg::ClickOnApply()
00401 {
00402   if ( !onAccept() )
00403     return false;
00404 
00405   initName();
00406   ConstructorsClicked( getConstructorId() );
00407   return true;
00408 }
00409 
00410 //=================================================================================
00411 // function : GroupClicked()
00412 // purpose  : OX OY OZ Radio button management
00413 //=================================================================================
00414 void BasicGUI_PlaneDlg::GroupClicked()
00415 {
00416   QRadioButton* send = (QRadioButton*)sender();
00417 
00418   if ( send == GroupLCS->RadioButton1 )
00419     myOriginType = 1;
00420   else if ( send == GroupLCS->RadioButton2 )
00421     myOriginType = 2;
00422   else if ( send == GroupLCS->RadioButton3 )
00423     myOriginType = 3;
00424   displayPreview(true);
00425 }
00426 
00427 //=================================================================================
00428 // function : SelectionIntoArgument()
00429 // purpose  : Called when selection has changed
00430 //=================================================================================
00431 void BasicGUI_PlaneDlg::SelectionIntoArgument()
00432 {
00433   myEditCurrentArgument->setText("");
00434 
00435   LightApp_SelectionMgr* aSelMgr = myGeomGUI->getApp()->selectionMgr();
00436   SALOME_ListIO aSelList;
00437   aSelMgr->selectedObjects(aSelList);
00438 
00439   if (aSelList.Extent() != 1) {
00440     if      ( myEditCurrentArgument == GroupPntDir->LineEdit1 ) myPoint.nullify();
00441     else if ( myEditCurrentArgument == GroupPntDir->LineEdit2 ) myDir.nullify();
00442     else if ( myEditCurrentArgument == Group3Pnts->LineEdit1 )  myPoint1.nullify();
00443     else if ( myEditCurrentArgument == Group3Pnts->LineEdit2 )  myPoint2.nullify();
00444     else if ( myEditCurrentArgument == Group3Pnts->LineEdit3 )  myPoint3.nullify();
00445     else if ( myEditCurrentArgument == GroupFace->LineEdit1 )   myFace.nullify();
00446     else if ( myEditCurrentArgument == Group2Vec->LineEdit1 )   myVec1.nullify();
00447     else if ( myEditCurrentArgument == Group2Vec->LineEdit2 )   myVec2.nullify();
00448     else if ( myEditCurrentArgument == GroupLCS->LineEdit1 )    myLCS.nullify();
00449     displayPreview(true);
00450     return;
00451   }
00452 
00453   TopAbs_ShapeEnum aNeedType;
00454   if ( myEditCurrentArgument == GroupPntDir->LineEdit2 || myEditCurrentArgument == Group2Vec->LineEdit1 || myEditCurrentArgument == Group2Vec->LineEdit2)
00455     aNeedType = TopAbs_EDGE;
00456   else if ( myEditCurrentArgument == GroupFace->LineEdit1 )
00457     aNeedType = TopAbs_FACE;
00458   else if ( myEditCurrentArgument == GroupLCS->LineEdit1 )
00459     aNeedType = TopAbs_FACE;
00460   else
00461     aNeedType = TopAbs_VERTEX;
00462   GEOM::GeomObjPtr aSelectedObject = getSelected( aNeedType );
00463   TopoDS_Shape aShape;
00464   if ( aSelectedObject && GEOMBase::GetShape( aSelectedObject.get(), aShape ) && !aShape.IsNull() ) {
00465     QString aName = GEOMBase::GetName( aSelectedObject.get() );
00466     myEditCurrentArgument->setText( aName );
00467     if ( myEditCurrentArgument == GroupPntDir->LineEdit1 ) {
00468       myPoint = aSelectedObject;
00469       if ( myPoint && !myDir )
00470         GroupPntDir->PushButton2->click();
00471     }
00472     else if ( myEditCurrentArgument == GroupPntDir->LineEdit2 ) {
00473       myDir = aSelectedObject;
00474       if ( myDir && !myPoint )
00475         GroupPntDir->PushButton1->click();
00476     }
00477     else if ( myEditCurrentArgument == Group3Pnts->LineEdit1 ) {
00478       myPoint1 = aSelectedObject;
00479       if ( myPoint1 && !myPoint2 )
00480         Group3Pnts->PushButton2->click();
00481     }
00482     else if ( myEditCurrentArgument == Group3Pnts->LineEdit2 ) {
00483       myPoint2 = aSelectedObject;
00484       if ( myPoint2 && !myPoint3 )
00485         Group3Pnts->PushButton3->click();
00486     }
00487     else if ( myEditCurrentArgument == Group3Pnts->LineEdit3 ) {
00488       myPoint3 = aSelectedObject;
00489       if ( myPoint3 && !myPoint1 )
00490         Group3Pnts->PushButton1->click();
00491     }
00492     else if ( myEditCurrentArgument == GroupFace->LineEdit1 )
00493       myFace   = aSelectedObject;
00494     else if ( myEditCurrentArgument == Group2Vec->LineEdit1 ) {
00495       myVec1 = aSelectedObject;
00496       if ( myVec1 && !myVec2 )
00497         Group2Vec->PushButton2->click();
00498     } else if ( myEditCurrentArgument == Group2Vec->LineEdit2 ) {
00499       myVec2 = aSelectedObject;
00500       if ( myVec2 && !myVec1 )
00501         Group2Vec->PushButton1->click();
00502     } else if ( myEditCurrentArgument == GroupLCS->LineEdit1 )
00503       myLCS = aSelectedObject;
00504   }
00505 
00506   displayPreview(true);
00507 }
00508 
00509 
00510 //=================================================================================
00511 // function : SetEditCurrentArgument()
00512 // purpose  :
00513 //=================================================================================
00514 void BasicGUI_PlaneDlg::SetEditCurrentArgument()
00515 {
00516   QPushButton* send = (QPushButton*)sender();
00517   globalSelection( GEOM_POINT );
00518 
00519   if      ( send == GroupPntDir->PushButton1 ) {
00520     myEditCurrentArgument = GroupPntDir->LineEdit1;
00521     GroupPntDir->PushButton2->setDown( false );
00522     GroupPntDir->LineEdit1->setEnabled( true );
00523     GroupPntDir->LineEdit2->setEnabled( false );
00524   }
00525   else if ( send == GroupPntDir->PushButton2 ) {
00526     myEditCurrentArgument = GroupPntDir->LineEdit2;
00527     GroupPntDir->PushButton1->setDown( false );
00528     GroupPntDir->LineEdit1->setEnabled( false );
00529     GroupPntDir->LineEdit2->setEnabled( true );
00530   }
00531   else if ( send == Group3Pnts->PushButton1 ) {
00532     myEditCurrentArgument = Group3Pnts->LineEdit1;
00533     Group3Pnts->PushButton2->setDown( false );
00534     Group3Pnts->PushButton3->setDown( false );
00535     Group3Pnts->LineEdit1->setEnabled( true );
00536     Group3Pnts->LineEdit2->setEnabled( false );
00537     Group3Pnts->LineEdit3->setEnabled( false );
00538   }
00539   else if ( send == Group3Pnts->PushButton2 ) {
00540     myEditCurrentArgument = Group3Pnts->LineEdit2;
00541     Group3Pnts->PushButton1->setDown( false );
00542     Group3Pnts->PushButton3->setDown( false );
00543     Group3Pnts->LineEdit1->setEnabled( false );
00544     Group3Pnts->LineEdit2->setEnabled( true );
00545     Group3Pnts->LineEdit3->setEnabled( false );
00546   }
00547   else if ( send == Group3Pnts->PushButton3 ) {
00548     myEditCurrentArgument = Group3Pnts->LineEdit3;
00549     Group3Pnts->PushButton1->setDown( false );
00550     Group3Pnts->PushButton2->setDown( false );
00551     Group3Pnts->LineEdit1->setEnabled( false );
00552     Group3Pnts->LineEdit2->setEnabled( false );
00553     Group3Pnts->LineEdit3->setEnabled( true );
00554   }
00555   else if ( send == GroupFace->PushButton1 ) {
00556     myEditCurrentArgument = GroupFace->LineEdit1;
00557     GroupFace->PushButton1->setDown( true );
00558   } else if ( send == Group2Vec->PushButton1 ) {
00559     myEditCurrentArgument = Group2Vec->LineEdit1;
00560     Group2Vec->PushButton2->setDown( false );
00561     Group2Vec->LineEdit1->setEnabled( true );
00562     Group2Vec->LineEdit2->setEnabled( false );
00563   } else if ( send == Group2Vec->PushButton2 ) {
00564     myEditCurrentArgument = Group2Vec->LineEdit2;
00565     Group2Vec->PushButton1->setDown( false );
00566     Group2Vec->LineEdit1->setEnabled( false );
00567     Group2Vec->LineEdit2->setEnabled( true );
00568   } else if ( send == GroupLCS->PushButton1 ) {
00569     myEditCurrentArgument = GroupLCS->LineEdit1;
00570     GroupLCS->LineEdit1->setEnabled( true );
00571   }
00572 
00573   myEditCurrentArgument->setFocus();
00574 
00575   if ( myEditCurrentArgument == GroupPntDir->LineEdit2 || 
00576        myEditCurrentArgument == Group2Vec->LineEdit1   ||
00577        myEditCurrentArgument == Group2Vec->LineEdit2 ) {
00578     localSelection( GEOM::GEOM_Object::_nil(), TopAbs_EDGE );
00579   } else if ( myEditCurrentArgument == GroupFace->LineEdit1 ) {
00580     TColStd_MapOfInteger aMap;
00581     aMap.Add( GEOM_PLANE );
00582     aMap.Add( GEOM_MARKER );
00583     globalSelection( aMap );
00584   } else if ( myEditCurrentArgument == GroupLCS->LineEdit1 ) {
00585     globalSelection( GEOM_MARKER );
00586   }
00587   else { // 3 Pnts
00588     localSelection( GEOM::GEOM_Object::_nil(), TopAbs_VERTEX );
00589   }
00590 
00591   //  SelectionIntoArgument();
00592   myEditCurrentArgument->setFocus();
00593   send->setDown(true);
00594   displayPreview(true);
00595 }
00596 
00597 
00598 //=================================================================================
00599 // function : ActivateThisDialog()
00600 // purpose  :
00601 //=================================================================================
00602 void BasicGUI_PlaneDlg::ActivateThisDialog()
00603 {
00604   GEOMBase_Skeleton::ActivateThisDialog();
00605   connect( myGeomGUI->getApp()->selectionMgr(), SIGNAL( currentSelectionChanged() ),
00606            this, SLOT( SelectionIntoArgument() ) );
00607 
00608   ConstructorsClicked( getConstructorId() );
00609   SelectionIntoArgument();
00610 }
00611 
00612 //=================================================================================
00613 // function : DeactivateActiveDialog()
00614 // purpose  : public slot to deactivate if active
00615 //=================================================================================
00616 void BasicGUI_PlaneDlg::DeactivateActiveDialog()
00617 {
00618   GEOMBase_Skeleton::DeactivateActiveDialog();
00619 }
00620 
00621 //=================================================================================
00622 // function : enterEvent()
00623 // purpose  :
00624 //=================================================================================
00625 void BasicGUI_PlaneDlg::enterEvent( QEvent* )
00626 {
00627   if ( !mainFrame()->GroupConstructors->isEnabled() )
00628     ActivateThisDialog();
00629 }
00630 
00631 
00632 //=================================================================================
00633 // function : ValueChangedInSpinBox()
00634 // purpose  :
00635 //=================================================================================
00636 void BasicGUI_PlaneDlg::ValueChangedInSpinBox( double newValue )
00637 {
00638   displayPreview(true);
00639 }
00640 
00641 //=================================================================================
00642 // function : getSize()
00643 // purpose  :
00644 //=================================================================================
00645 double BasicGUI_PlaneDlg::getSize() const
00646 {
00647   switch ( getConstructorId() ) {
00648   case 0 : return GroupPntDir->SpinBox_DX->value();
00649   case 1 : return Group3Pnts->SpinBox_DX->value();
00650   case 2 : return GroupFace->SpinBox_DX->value();
00651   case 3 : return Group2Vec->SpinBox_DX->value();
00652   case 4 : return GroupLCS->SpinBox_DX->value();
00653   }
00654   return 0.;
00655 }
00656 
00657 //=================================================================================
00658 // function : getSize()
00659 // purpose  :
00660 //=================================================================================
00661 QString BasicGUI_PlaneDlg::getSizeAsString() const
00662 {
00663   switch ( getConstructorId() ) {
00664   case 0 : return GroupPntDir->SpinBox_DX->text();
00665   case 1 : return Group3Pnts->SpinBox_DX->text();
00666   case 2 : return GroupFace->SpinBox_DX->text();
00667   case 3 : return Group2Vec->SpinBox_DX->text();
00668   }
00669   return QString();
00670 }
00671 
00672 //=================================================================================
00673 // function : createOperation
00674 // purpose  :
00675 //=================================================================================
00676 GEOM::GEOM_IOperations_ptr BasicGUI_PlaneDlg::createOperation()
00677 {
00678   return myGeomGUI->GetGeomGen()->GetIBasicOperations( getStudyId() );
00679 }
00680 
00681 //=================================================================================
00682 // function : isValid
00683 // purpose  :
00684 //=================================================================================
00685 bool BasicGUI_PlaneDlg::isValid( QString& msg )
00686 {
00687   bool ok = false;
00688   if ( getSize() <= 0 ) {
00689     msg = QString( "Please, enter size greater than 0." );
00690   }
00691   else {
00692     switch ( getConstructorId() ) {
00693     case 0:
00694       ok = GroupPntDir->SpinBox_DX->isValid( msg, !IsPreview() ) && myPoint && myDir;
00695       break;
00696     case 1:
00697       ok = Group3Pnts->SpinBox_DX->isValid( msg, !IsPreview() ) &&
00698           myPoint1 && myPoint2 && myPoint3 &&
00699           myPoint1 != myPoint2 && myPoint1 != myPoint3 && myPoint2 != myPoint3;
00700       break;
00701     case 2:
00702       ok = GroupFace->SpinBox_DX->isValid( msg, !IsPreview() ) && myFace;
00703       break;
00704     case 3:
00705       ok = Group2Vec->SpinBox_DX->isValid( msg, !IsPreview() ) &&
00706           myVec1 && myVec2 && myVec1 != myVec2;
00707       break;
00708     case 4:
00709       ok = GroupLCS->SpinBox_DX->isValid( msg, !IsPreview() );
00710       break;
00711     default:
00712       break;
00713     }
00714   }
00715   return ok;
00716 }
00717 
00718 //=================================================================================
00719 // function : execute
00720 // purpose  :
00721 //=================================================================================
00722 bool BasicGUI_PlaneDlg::execute( ObjectList& objects )
00723 {
00724   bool res = false;
00725 
00726   GEOM::GEOM_Object_var anObj;
00727 
00728   GEOM::GEOM_IBasicOperations_var anOper = GEOM::GEOM_IBasicOperations::_narrow( getOperation() );
00729 
00730   switch ( getConstructorId() ) {
00731   case 0 :
00732     anObj = anOper->MakePlanePntVec( myPoint.get(), myDir.get(), getSize() );
00733     res = true;
00734     break;
00735   case 1 :
00736     anObj = anOper->MakePlaneThreePnt( myPoint1.get(), myPoint2.get(), myPoint3.get(), getSize() );
00737     res = true;
00738     break;
00739   case 2 :
00740     anObj = anOper->MakePlaneFace( myFace.get(), getSize() );
00741     res = true;
00742     break;
00743   case 3 :
00744     anObj = anOper->MakePlane2Vec( myVec1.get(), myVec2.get(), getSize() );
00745     res = true;
00746     break;
00747   case 4 :
00748     anObj = anOper->MakePlaneLCS( myLCS.get(), getSize(), myOriginType );
00749     res = true;
00750     break;
00751   }
00752   
00753   if ( !anObj->_is_nil() ) {
00754     if ( !IsPreview() )
00755       anObj->SetParameters(getSizeAsString().toLatin1().constData());
00756     objects.push_back( anObj._retn() );
00757   }
00758   return res;
00759 }
00760 //=================================================================================
00761 // function : addSubshapeToStudy
00762 // purpose  : virtual method to add new SubObjects if local selection
00763 //=================================================================================
00764 void BasicGUI_PlaneDlg::addSubshapesToStudy()
00765 {
00766   switch ( getConstructorId() ) {
00767   case 0:
00768     GEOMBase::PublishSubObject( myPoint.get() );
00769     GEOMBase::PublishSubObject( myDir.get() );
00770     break;
00771   case 1:
00772     GEOMBase::PublishSubObject( myPoint1.get() );
00773     GEOMBase::PublishSubObject( myPoint2.get() );
00774     GEOMBase::PublishSubObject( myPoint3.get() );
00775     break;
00776   case 2:
00777     GEOMBase::PublishSubObject( myFace.get() );
00778     break;
00779   case 3:
00780     GEOMBase::PublishSubObject( myVec1.get() );
00781     GEOMBase::PublishSubObject( myVec2.get() );
00782     break;
00783   case 4:
00784     GEOMBase::PublishSubObject( myLCS.get() );
00785     break;
00786  default:
00787    break;
00788   }
00789 }