Salome HOME
Dump Puthon extension
[modules/geom.git] / src / BasicGUI / BasicGUI_PlaneDlg.cxx
index 22975fe585d9c86d16fa40ac300d61c9d0796eda..d34e63c9ef00dd7a8225836d9364256a5190f9d7 100644 (file)
-//  GEOM GEOMGUI : GUI for Geometry component
+// GEOM GEOMGUI : GUI for Geometry component
 //
-//  Copyright (C) 2003  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
-//  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS 
-// 
-//  This library is free software; you can redistribute it and/or 
-//  modify it under the terms of the GNU Lesser General Public 
-//  License as published by the Free Software Foundation; either 
-//  version 2.1 of the License. 
-// 
-//  This library is distributed in the hope that it will be useful, 
-//  but WITHOUT ANY WARRANTY; without even the implied warranty of 
-//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU 
-//  Lesser General Public License for more details. 
-// 
-//  You should have received a copy of the GNU Lesser General Public 
-//  License along with this library; if not, write to the Free Software 
-//  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA 
-// 
-// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+// Copyright (C) 2003  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+// Lesser General Public License for more details.
 //
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
 //
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+// File   : BasicGUI_PlaneDlg.cxx
+// Author : Lucien PIGNOLONI, Open CASCADE S.A.S.
 //
-//  File   : BasicGUI_PlaneDlg.cxx
-//  Author : Lucien PIGNOLONI
-//  Module : GEOM
-//  $Header$
 
 #include "BasicGUI_PlaneDlg.h"
 
-#include "SUIT_Desktop.h"
-#include "SUIT_Session.h"
-#include "SalomeApp_Application.h"
-#include "LightApp_SelectionMgr.h"
+#include <DlgRef.h>
+
+#include <GeometryGUI.h>
+#include <GEOMBase.h>
 
-#include <qlabel.h>
+#include <SUIT_ResourceMgr.h>
+#include <SUIT_Session.h>
+#include <SalomeApp_Application.h>
+#include <LightApp_SelectionMgr.h>
 
-#include "GEOMImpl_Types.hxx"
+#include <TColStd_MapOfInteger.hxx>
+#include <TopoDS_Shape.hxx>
+#include <TopoDS_Edge.hxx>
+#include <TopoDS.hxx>
+#include <TopExp.hxx>
+#include <TColStd_IndexedMapOfInteger.hxx>
+#include <TopTools_IndexedMapOfShape.hxx>
 
-using namespace std;
+#include <GEOMImpl_Types.hxx>
 
 //=================================================================================
 // class    : BasicGUI_PlaneDlg()
-// purpose  : Constructs a BasicGUI_PlaneDlg which is a child of 'parent', with the 
+// purpose  : Constructs a BasicGUI_PlaneDlg which is a child of 'parent', with the
 //            name 'name' and widget flags set to 'f'.
 //            The dialog will by default be modeless, unless you set 'modal' to
 //            TRUE to construct a modal dialog.
 //=================================================================================
-BasicGUI_PlaneDlg::BasicGUI_PlaneDlg(GeometryGUI* theGeometryGUI, QWidget* parent,
-                                     const char* name, bool modal, WFlags fl)
-  :GEOMBase_Skeleton(theGeometryGUI, parent, name, modal, WStyle_Customize |
-                     WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu)
+BasicGUI_PlaneDlg::BasicGUI_PlaneDlg( GeometryGUI* theGeometryGUI, QWidget* parent,
+                                     bool modal, Qt::WindowFlags fl )
+  : GEOMBase_Skeleton( theGeometryGUI, parent, modal, fl )
 {
-  QPixmap image0(SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM",tr("ICON_DLG_PLANE_PV")));
-  QPixmap image1(SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM",tr("ICON_DLG_PLANE_3PNTS")));
-  QPixmap image2(SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM",tr("ICON_DLG_PLANE_FACE")));
-  QPixmap image3(SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM",tr("ICON_SELECT")));
+  QPixmap image0( SUIT_Session::session()->resourceMgr()->loadPixmap( "GEOM", tr( "ICON_DLG_PLANE_PV" ) ) );
+  QPixmap image1( SUIT_Session::session()->resourceMgr()->loadPixmap( "GEOM", tr( "ICON_DLG_PLANE_3PNTS" ) ) );
+  QPixmap image2( SUIT_Session::session()->resourceMgr()->loadPixmap( "GEOM", tr( "ICON_DLG_PLANE_FACE" ) ) );
+  QPixmap image3( SUIT_Session::session()->resourceMgr()->loadPixmap( "GEOM", tr( "ICON_SELECT" ) ) );
 
-  setCaption(tr("GEOM_PLANE_TITLE"));
+  setWindowTitle( tr( "GEOM_PLANE_TITLE" ) );
 
   /***************************************************************/
-  GroupConstructors->setTitle(tr("GEOM_PLANE"));
-  RadioButton1->setPixmap(image0);
-  RadioButton2->setPixmap(image1);
-  RadioButton3->setPixmap(image2);
-
-  GroupPntDir = new DlgRef_2Sel1Spin(this, "GroupPointDirection");
-  GroupPntDir->GroupBox1->setTitle(tr("GEOM_PLANE_PV"));
-  GroupPntDir->TextLabel1->setText(tr("GEOM_POINT"));
-  GroupPntDir->TextLabel2->setText(tr("GEOM_VECTOR"));
-  GroupPntDir->TextLabel3->setText(tr("GEOM_PLANE_SIZE"));
-  GroupPntDir->PushButton1->setPixmap(image3);
-  GroupPntDir->PushButton2->setPixmap(image3);
+  mainFrame()->GroupConstructors->setTitle( tr( "GEOM_PLANE" ) );
+  mainFrame()->RadioButton1->setIcon( image0 );
+  mainFrame()->RadioButton2->setIcon( image1 );
+  mainFrame()->RadioButton3->setIcon( image2 );
+
+  GroupPntDir = new DlgRef_2Sel1Spin( centralWidget() );
+  GroupPntDir->GroupBox1->setTitle( tr( "GEOM_PLANE_PV" ) );
+  GroupPntDir->TextLabel1->setText( tr( "GEOM_POINT" ) );
+  GroupPntDir->TextLabel2->setText( tr( "GEOM_VECTOR" ) );
+  GroupPntDir->TextLabel3->setText( tr( "GEOM_PLANE_SIZE" ) );
+  GroupPntDir->PushButton1->setIcon( image3 );
+  GroupPntDir->PushButton2->setIcon( image3 );
   GroupPntDir->LineEdit1->setReadOnly( true );
   GroupPntDir->LineEdit2->setReadOnly( true );
-
-  Group3Pnts = new DlgRef_3Sel1Spin(this, "Group3Pnts");
-  Group3Pnts->GroupBox1->setTitle(tr("GEOM_3_POINTS"));
-  Group3Pnts->TextLabel1->setText(tr("GEOM_POINT1"));
-  Group3Pnts->TextLabel2->setText(tr("GEOM_POINT2"));
-  Group3Pnts->TextLabel3->setText(tr("GEOM_POINT3"));
-  Group3Pnts->TextLabel4->setText(tr("GEOM_PLANE_SIZE"));
-  Group3Pnts->PushButton1->setPixmap(image3);
-  Group3Pnts->PushButton2->setPixmap(image3);
-  Group3Pnts->PushButton3->setPixmap(image3);
+  GroupPntDir->PushButton1->setDown( true );
+  GroupPntDir->LineEdit1->setEnabled( true );
+  GroupPntDir->LineEdit2->setEnabled( false );
+
+  Group3Pnts = new DlgRef_3Sel1Spin( centralWidget() );
+  Group3Pnts->GroupBox1->setTitle( tr( "GEOM_3_POINTS" ) );
+  Group3Pnts->TextLabel1->setText( tr( "GEOM_POINT1" ) );
+  Group3Pnts->TextLabel2->setText( tr( "GEOM_POINT2" ) );
+  Group3Pnts->TextLabel3->setText( tr( "GEOM_POINT3" ) );
+  Group3Pnts->TextLabel4->setText( tr( "GEOM_PLANE_SIZE" ) );
+  Group3Pnts->PushButton1->setIcon( image3 );
+  Group3Pnts->PushButton2->setIcon( image3 );
+  Group3Pnts->PushButton3->setIcon( image3 );
+  Group3Pnts->PushButton1->setDown( true );
 
   Group3Pnts->LineEdit1->setReadOnly( true );
   Group3Pnts->LineEdit2->setReadOnly( true );
   Group3Pnts->LineEdit3->setReadOnly( true );
+  Group3Pnts->LineEdit1->setEnabled( true );
+  Group3Pnts->LineEdit2->setEnabled( false );
+  Group3Pnts->LineEdit3->setEnabled( false );
 
-  GroupFace = new DlgRef_1Sel1Spin(this, "GroupFace");
-  GroupFace->GroupBox1->setTitle(tr("GEOM_FACE"));
-  GroupFace->TextLabel1->setText(tr("GEOM_SELECTION"));
-  GroupFace->TextLabel2->setText(tr("GEOM_PLANE_SIZE"));
-  GroupFace->PushButton1->setPixmap(image3);
+  GroupFace = new DlgRef_1Sel1Spin( centralWidget() );
+  GroupFace->GroupBox1->setTitle( tr( "GEOM_FACE_OR_LCS" ) );
+  GroupFace->TextLabel1->setText( tr( "GEOM_SELECTION" ) );
+  GroupFace->TextLabel2->setText( tr( "GEOM_PLANE_SIZE" ) );
+  GroupFace->PushButton1->setIcon( image3 );
+  GroupFace->PushButton1->setDown( true );
 
   GroupFace->LineEdit1->setReadOnly( true );
-    
-  Layout1->addWidget(GroupPntDir, 2, 0);
-  Layout1->addWidget(Group3Pnts, 2, 0);
-  Layout1->addWidget(GroupFace, 2, 0);
+
+  QVBoxLayout* layout = new QVBoxLayout( centralWidget() );
+  layout->setMargin( 0 ); layout->setSpacing( 6 );
+  layout->addWidget( GroupPntDir );
+  layout->addWidget( Group3Pnts );
+  layout->addWidget( GroupFace );
   /***************************************************************/
 
-  setHelpFileName("plane.htm");
-  
+  setHelpFileName( "create_plane_page.html" );
+
   Init();
 }
 
@@ -112,7 +127,7 @@ BasicGUI_PlaneDlg::BasicGUI_PlaneDlg(GeometryGUI* theGeometryGUI, QWidget* paren
 // purpose  : Destroys the object and frees any allocated resources
 //=================================================================================
 BasicGUI_PlaneDlg::~BasicGUI_PlaneDlg()
-{  
+{
 }
 
 
@@ -131,120 +146,144 @@ void BasicGUI_PlaneDlg::Init()
 
   /* Get setting of step value from file configuration */
   SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
-  double aStep = resMgr->doubleValue( "Geometry", "SettingsGeomStep", 100);
-  
+  double aStep = resMgr->doubleValue( "Geometry", "SettingsGeomStep", 100 );
+
   double aTrimSize = 2000.0;
-  
+
   /* min, max, step and decimals for spin boxes */
-  GroupPntDir->SpinBox_DX->RangeStepAndValidator( 0.001, 10000000.0, aStep, 3 );
-  GroupPntDir->SpinBox_DX->SetValue( aTrimSize );
-  Group3Pnts->SpinBox_DX->RangeStepAndValidator(0.001, 10000000.0, aStep, 3);
-  Group3Pnts->SpinBox_DX->SetValue( aTrimSize );
-  GroupFace->SpinBox_DX->RangeStepAndValidator(0.001, 10000000.0, aStep, 3);
-  GroupFace->SpinBox_DX->SetValue( aTrimSize );
+  initSpinBox( GroupPntDir->SpinBox_DX, 0.001, COORD_MAX, aStep, 3 ); // VSR:TODO : DBL_DIGITS_DISPLAY
+  GroupPntDir->SpinBox_DX->setValue( aTrimSize );
+  initSpinBox( Group3Pnts->SpinBox_DX, 0.001, COORD_MAX, aStep, 3 ); // VSR:TODO : DBL_DIGITS_DISPLAY
+  Group3Pnts->SpinBox_DX->setValue( aTrimSize );
+  initSpinBox( GroupFace->SpinBox_DX, 0.001, COORD_MAX, aStep, 3 ); // VSR:TODO : DBL_DIGITS_DISPLAY
+  GroupFace->SpinBox_DX->setValue( aTrimSize );
 
   /* signals and slots connections */
-  connect(buttonCancel, SIGNAL(clicked()), this, SLOT(ClickOnCancel()));
-  connect(myGeomGUI, SIGNAL(SignalDeactivateActiveDialog()), this, SLOT(DeactivateActiveDialog()));
-  connect(myGeomGUI, SIGNAL(SignalCloseAllDialogs()), this, SLOT(ClickOnCancel()));
-
-  connect(buttonOk, SIGNAL(clicked()), this, SLOT(ClickOnOk()));
-  connect(buttonApply, SIGNAL(clicked()), this, SLOT(ClickOnApply()));
-  connect(GroupConstructors, SIGNAL(clicked(int)), this, SLOT(ConstructorsClicked(int)));
-
-  connect(GroupPntDir->PushButton1, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
-  connect(GroupPntDir->PushButton2, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
-  connect(Group3Pnts->PushButton1, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
-  connect(Group3Pnts->PushButton2, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
-  connect(Group3Pnts->PushButton3, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
-  connect(GroupFace->PushButton1, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
-
-  connect(GroupPntDir->LineEdit1, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed()));
-  connect(GroupPntDir->LineEdit2, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed()));
-  connect(Group3Pnts->LineEdit1, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed()));
-  connect(Group3Pnts->LineEdit2, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed()));
-  connect(Group3Pnts->LineEdit3, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed()));
-  connect(GroupFace->LineEdit1, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed()));
-
-  connect(GroupPntDir->SpinBox_DX, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double)));
-  connect(Group3Pnts->SpinBox_DX, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double)));
-  connect(GroupFace->SpinBox_DX, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double)));
-
-  connect(myGeomGUI, SIGNAL(SignalDefaultStepValueChanged(double)), GroupPntDir->SpinBox_DX, SLOT(SetStep(double)));
-  connect(myGeomGUI, SIGNAL(SignalDefaultStepValueChanged(double)), Group3Pnts->SpinBox_DX, SLOT(SetStep(double)));
-  connect(myGeomGUI, SIGNAL(SignalDefaultStepValueChanged(double)), GroupFace->SpinBox_DX, SLOT(SetStep(double)));
-
-  connect(((SalomeApp_Application*)(SUIT_Session::session()->activeApplication()))->selectionMgr(), SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument()));
+  connect( myGeomGUI, SIGNAL( SignalDeactivateActiveDialog() ), this, SLOT( DeactivateActiveDialog() ) );
+  connect( myGeomGUI, SIGNAL( SignalCloseAllDialogs() ),        this, SLOT( ClickOnCancel() ) );
+
+  connect( buttonOk(),     SIGNAL( clicked() ), this, SLOT( ClickOnOk() ) );
+  connect( buttonApply(),  SIGNAL( clicked() ), this, SLOT( ClickOnApply() ) );
+
+  connect( this,           SIGNAL( constructorsClicked( int ) ), this, SLOT( ConstructorsClicked( int ) ) );
+
+  connect( GroupPntDir->PushButton1, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) );
+  connect( GroupPntDir->PushButton2, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) );
+  connect( Group3Pnts->PushButton1,  SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) );
+  connect( Group3Pnts->PushButton2,  SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) );
+  connect( Group3Pnts->PushButton3,  SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) );
+  connect( GroupFace->PushButton1,   SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) );
+
+  connect( GroupPntDir->LineEdit1, SIGNAL( returnPressed() ), this, SLOT( LineEditReturnPressed() ) );
+  connect( GroupPntDir->LineEdit2, SIGNAL( returnPressed() ), this, SLOT( LineEditReturnPressed() ) );
+  connect( Group3Pnts->LineEdit1,  SIGNAL( returnPressed() ), this, SLOT( LineEditReturnPressed() ) );
+  connect( Group3Pnts->LineEdit2,  SIGNAL( returnPressed() ), this, SLOT( LineEditReturnPressed() ) );
+  connect( Group3Pnts->LineEdit3,  SIGNAL( returnPressed() ), this, SLOT( LineEditReturnPressed() ) );
+  connect( GroupFace->LineEdit1,   SIGNAL( returnPressed() ), this, SLOT( LineEditReturnPressed() ) );
+
+  connect( GroupPntDir->SpinBox_DX, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
+  connect( Group3Pnts->SpinBox_DX,  SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
+  connect( GroupFace->SpinBox_DX,   SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
+
+  connect( myGeomGUI, SIGNAL( SignalDefaultStepValueChanged( double ) ), this, SLOT( SetDoubleSpinBoxStep( double ) ) );
+
+  connect( myGeomGUI->getApp()->selectionMgr(), SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) );
 
   initName( tr( "GEOM_PLANE" ) );
 
-  Group3Pnts->hide();
-  GroupFace->hide();
   ConstructorsClicked( 0 );
 }
 
+//=================================================================================
+// function : SetDoubleSpinBoxStep()
+// purpose  : Double spin box management
+//=================================================================================
+void BasicGUI_PlaneDlg::SetDoubleSpinBoxStep( double step )
+{
+  GroupPntDir->SpinBox_DX->setSingleStep(step);
+  Group3Pnts->SpinBox_DX->setSingleStep(step);
+  GroupFace->SpinBox_DX->setSingleStep(step);
+}
+
 
 //=================================================================================
 // function : ConstructorsClicked()
 // purpose  : Radio button management
 //=================================================================================
-void BasicGUI_PlaneDlg::ConstructorsClicked(int constructorId)
+void BasicGUI_PlaneDlg::ConstructorsClicked( int constructorId )
 {
-  disconnect(((SalomeApp_Application*)(SUIT_Session::session()->activeApplication()))->selectionMgr(), 0, this, 0);
+  disconnect( myGeomGUI->getApp()->selectionMgr(), 0, this, 0 );
   myPoint = myDir = myPoint1 = myPoint2 = myPoint3 = myFace = GEOM::GEOM_Object::_nil();
 
-  switch ( constructorId )
-  {
-    case 0: /* plane from a point and a direction (vector, edge...) */
-      {        
-                               Group3Pnts->hide();
-                               GroupFace->hide();
-                               resize(0, 0);
-                               GroupPntDir->show();
-
-                               myEditCurrentArgument = GroupPntDir->LineEdit1;
-                               GroupPntDir->LineEdit1->setText(tr(""));
-                               GroupPntDir->LineEdit2->setText(tr(""));
-
-                               /* for the first argument */
-                               globalSelection( GEOM_POINT );
-                               break;
-      }
-    case 1: /* plane from 3 points */
-      {
-                               GroupPntDir->hide();
-                               GroupFace->hide();
-                               resize(0, 0);
-                               Group3Pnts->show();
-
-                               myEditCurrentArgument = Group3Pnts->LineEdit1;
-                               Group3Pnts->LineEdit1->setText("");
-                               Group3Pnts->LineEdit2->setText("");
-                               Group3Pnts->LineEdit3->setText("");
-
-                               /* for the first argument */
-                               globalSelection( GEOM_POINT );
-                               break;
-      } 
-    case 2: /* plane from a planar face selection */
-      {
-                               GroupPntDir->hide();
-                               Group3Pnts->hide();
-                               resize(0, 0);
-                               GroupFace->show();
-
-                               myEditCurrentArgument = GroupFace->LineEdit1;
-                               GroupFace->LineEdit1->setText(tr(""));
-
-                               /* for the first argument */
-                               globalSelection( GEOM_PLANE );
-                               break;
-      }
+  switch ( constructorId ) {
+  case 0: /* plane from a point and a direction (vector, edge...) */
+    {
+      Group3Pnts->hide();
+      GroupFace->hide();
+      GroupPntDir->show();
+      
+      myEditCurrentArgument = GroupPntDir->LineEdit1;
+      GroupPntDir->LineEdit1->setText( "" );
+      GroupPntDir->LineEdit2->setText( "" );
+      GroupPntDir->PushButton1->setDown( true );
+      GroupPntDir->PushButton2->setDown( false );
+      GroupPntDir->LineEdit1->setEnabled( true );
+      GroupPntDir->LineEdit2->setEnabled( false );
+      
+      /* for the first argument */
+      globalSelection(); // close local contexts, if any
+      localSelection( GEOM::GEOM_Object::_nil(), TopAbs_VERTEX );
+      break;
+    }
+  case 1: /* plane from 3 points */
+    {
+      GroupPntDir->hide();
+      GroupFace->hide();
+      Group3Pnts->show();
+      
+      myEditCurrentArgument = Group3Pnts->LineEdit1;
+      Group3Pnts->LineEdit1->setText( "" );
+      Group3Pnts->LineEdit2->setText( "" );
+      Group3Pnts->LineEdit3->setText( "" );
+      Group3Pnts->PushButton1->setDown( true );
+      Group3Pnts->PushButton2->setDown( false );
+      Group3Pnts->PushButton3->setDown( false );
+      Group3Pnts->LineEdit1->setEnabled( true );
+      Group3Pnts->LineEdit2->setEnabled( false );
+      Group3Pnts->LineEdit3->setEnabled( false );
+      
+      /* for the first argument */
+      globalSelection(); // close local contexts, if any
+      localSelection( GEOM::GEOM_Object::_nil(), TopAbs_VERTEX );
+      break;
     }
+  case 2: /* plane from a planar face selection */
+    {
+      GroupPntDir->hide();
+      Group3Pnts->hide();
+      GroupFace->show();
+      
+      myEditCurrentArgument = GroupFace->LineEdit1;
+      GroupFace->LineEdit1->setText( "" );
+      GroupFace->PushButton1->setDown( true );
+      
+      /* for the first argument */
+      //globalSelection( GEOM_PLANE );
+      TColStd_MapOfInteger aMap;
+      aMap.Add( GEOM_PLANE );
+      aMap.Add( GEOM_MARKER );
+      globalSelection( aMap );
+      break;
+    }
+  }
+  
+  qApp->processEvents();
+  updateGeometry();
+  resize( minimumSize() );
 
   myEditCurrentArgument->setFocus();
-  connect(((SalomeApp_Application*)(SUIT_Session::session()->activeApplication()))->selectionMgr(), 
-         SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument()));
+  connect( myGeomGUI->getApp()->selectionMgr(), SIGNAL( currentSelectionChanged() ),
+          this, SLOT( SelectionIntoArgument() ) );
 }
 
 
@@ -273,15 +312,6 @@ bool BasicGUI_PlaneDlg::ClickOnApply()
   return true;
 }
 
-//=======================================================================
-// function : ClickOnCancel()
-// purpose  :
-//=======================================================================
-void BasicGUI_PlaneDlg::ClickOnCancel()
-{
-  GEOMBase_Skeleton::ClickOnCancel();
-}
-
 //=================================================================================
 // function : SelectionIntoArgument()
 // purpose  : Called when selection has changed
@@ -289,9 +319,12 @@ void BasicGUI_PlaneDlg::ClickOnCancel()
 void BasicGUI_PlaneDlg::SelectionIntoArgument()
 {
   myEditCurrentArgument->setText("");
-  
-  if ( IObjectCount() != 1 )  
-  {
+
+  LightApp_SelectionMgr* aSelMgr = myGeomGUI->getApp()->selectionMgr();
+  SALOME_ListIO aSelList;
+  aSelMgr->selectedObjects(aSelList);
+
+  if (aSelList.Extent() != 1) {
     if      ( myEditCurrentArgument == GroupPntDir->LineEdit1 ) myPoint  = GEOM::GEOM_Object::_nil();
     else if ( myEditCurrentArgument == GroupPntDir->LineEdit2 ) myDir    = GEOM::GEOM_Object::_nil();
     else if ( myEditCurrentArgument == Group3Pnts->LineEdit1 )  myPoint1 = GEOM::GEOM_Object::_nil();
@@ -303,16 +336,86 @@ void BasicGUI_PlaneDlg::SelectionIntoArgument()
 
   // nbSel == 1
   Standard_Boolean aRes = Standard_False;
-  GEOM::GEOM_Object_var aSelectedObject = GEOMBase::ConvertIOinGEOMObject( firstIObject(), aRes );
-  if ( !CORBA::is_nil( aSelectedObject ) && aRes )
-  {  
-    myEditCurrentArgument->setText( GEOMBase::GetName( aSelectedObject ) );
-    if      ( myEditCurrentArgument == GroupPntDir->LineEdit1 ) myPoint  = aSelectedObject;
-    else if ( myEditCurrentArgument == GroupPntDir->LineEdit2 ) myDir    = aSelectedObject;
-    else if ( myEditCurrentArgument == Group3Pnts->LineEdit1 )  myPoint1 = aSelectedObject;
-    else if ( myEditCurrentArgument == Group3Pnts->LineEdit2 )  myPoint2 = aSelectedObject;
-    else if ( myEditCurrentArgument == Group3Pnts->LineEdit3 )  myPoint3 = aSelectedObject;
-    else if ( myEditCurrentArgument == GroupFace->LineEdit1 )   myFace   = aSelectedObject;
+  GEOM::GEOM_Object_var aSelectedObject = GEOMBase::ConvertIOinGEOMObject(aSelList.First(), aRes);
+  if ( !CORBA::is_nil( aSelectedObject ) && aRes ) {
+    QString aName = GEOMBase::GetName( aSelectedObject );
+    TopAbs_ShapeEnum aNeedType = TopAbs_VERTEX;
+    if ( myEditCurrentArgument == GroupPntDir->LineEdit2 )
+      aNeedType = TopAbs_EDGE;
+
+    TopoDS_Shape aShape;
+    if ( GEOMBase::GetShape( aSelectedObject, aShape, TopAbs_SHAPE ) && !aShape.IsNull() ) {
+      TColStd_IndexedMapOfInteger aMap;
+      aSelMgr->GetIndexes(aSelList.First(), aMap);
+      if ( aMap.Extent() == 1 ) { // Local Selection
+        int anIndex = aMap( 1 );
+        if ( aNeedType == TopAbs_EDGE )
+          aName += QString( ":edge_%1" ).arg( anIndex );
+        else if (aNeedType == TopAbs_FACE)
+          aName += QString( ":face_%1" ).arg( anIndex );
+        else
+          aName += QString( ":vertex_%1" ).arg( anIndex );
+
+       //Find SubShape Object in Father
+       GEOM::GEOM_Object_var aFindedObject = GEOMBase_Helper::findObjectInFather( aSelectedObject, aName );
+
+       if ( aFindedObject == GEOM::GEOM_Object::_nil() ) { // Object not found in study
+         GEOM::GEOM_IShapesOperations_var aShapesOp = getGeomEngine()->GetIShapesOperations( getStudyId() );
+         aSelectedObject = aShapesOp->GetSubShape( aSelectedObject, anIndex );
+       } 
+       else {
+         aSelectedObject = aFindedObject; // get Object from study
+       }
+      }
+      else { // Global Selection
+        if ( aShape.ShapeType() != aNeedType ) {
+          aSelectedObject = GEOM::GEOM_Object::_nil();
+          aName = "";
+        }
+      }
+    }
+
+    myEditCurrentArgument->setText( aName );
+
+    if (!aSelectedObject->_is_nil()) { // clear selection if something selected
+      globalSelection();
+      if ( myEditCurrentArgument == GroupFace->LineEdit1 ) {
+       TColStd_MapOfInteger aMap;
+       aMap.Add( GEOM_PLANE );
+       aMap.Add( GEOM_MARKER );
+       globalSelection( aMap );
+      }
+      else
+       localSelection( GEOM::GEOM_Object::_nil(), aNeedType );
+    }
+
+    if      ( myEditCurrentArgument == GroupPntDir->LineEdit1 ) {
+      myPoint  = aSelectedObject;
+      if ( !myPoint->_is_nil() && myDir->_is_nil() )
+       GroupPntDir->PushButton2->click();
+    }
+    else if ( myEditCurrentArgument == GroupPntDir->LineEdit2 ) {
+      myDir    = aSelectedObject;
+      if ( !myDir->_is_nil() && myPoint->_is_nil() )
+       GroupPntDir->PushButton1->click();
+    }
+    else if ( myEditCurrentArgument == Group3Pnts->LineEdit1 ) {
+      myPoint1 = aSelectedObject;
+      if ( !myPoint1->_is_nil() && myPoint2->_is_nil() )
+       Group3Pnts->PushButton2->click();
+    }
+    else if ( myEditCurrentArgument == Group3Pnts->LineEdit2 ) {
+      myPoint2 = aSelectedObject;
+      if ( !myPoint2->_is_nil() && myPoint3->_is_nil() )
+       Group3Pnts->PushButton3->click();
+    }
+    else if ( myEditCurrentArgument == Group3Pnts->LineEdit3 ) {
+      myPoint3 = aSelectedObject;
+      if ( !myPoint3->_is_nil() && myPoint1->_is_nil() )
+       Group3Pnts->PushButton1->click();
+    }
+    else if ( myEditCurrentArgument == GroupFace->LineEdit1 )
+      myFace   = aSelectedObject;
   }
 
   displayPreview();
@@ -325,25 +428,69 @@ void BasicGUI_PlaneDlg::SelectionIntoArgument()
 //=================================================================================
 void BasicGUI_PlaneDlg::SetEditCurrentArgument()
 {
-  QPushButton* send = (QPushButton*)sender();  
+  QPushButton* send = (QPushButton*)sender();
+  globalSelection( GEOM_POINT );
+
+  if      ( send == GroupPntDir->PushButton1 ) {
+    myEditCurrentArgument = GroupPntDir->LineEdit1;
+    GroupPntDir->PushButton2->setDown( false );
+    GroupPntDir->LineEdit1->setEnabled( true );
+    GroupPntDir->LineEdit2->setEnabled( false );
+  }
+  else if ( send == GroupPntDir->PushButton2 ) {
+    myEditCurrentArgument = GroupPntDir->LineEdit2;
+    GroupPntDir->PushButton1->setDown( false );
+    GroupPntDir->LineEdit1->setEnabled( false );
+    GroupPntDir->LineEdit2->setEnabled( true );
+  }
+  else if ( send == Group3Pnts->PushButton1 ) {
+    myEditCurrentArgument = Group3Pnts->LineEdit1;
+    Group3Pnts->PushButton2->setDown( false );
+    Group3Pnts->PushButton3->setDown( false );
+    Group3Pnts->LineEdit1->setEnabled( true );
+    Group3Pnts->LineEdit2->setEnabled( false );
+    Group3Pnts->LineEdit3->setEnabled( false );
+  }
+  else if ( send == Group3Pnts->PushButton2 ) {
+    myEditCurrentArgument = Group3Pnts->LineEdit2;
+    Group3Pnts->PushButton1->setDown( false );
+    Group3Pnts->PushButton3->setDown( false );
+    Group3Pnts->LineEdit1->setEnabled( false );
+    Group3Pnts->LineEdit2->setEnabled( true );
+    Group3Pnts->LineEdit3->setEnabled( false );
+  }
+  else if ( send == Group3Pnts->PushButton3 ) {
+    myEditCurrentArgument = Group3Pnts->LineEdit3;
+    Group3Pnts->PushButton1->setDown( false );
+    Group3Pnts->PushButton2->setDown( false );
+    Group3Pnts->LineEdit1->setEnabled( false );
+    Group3Pnts->LineEdit2->setEnabled( false );
+    Group3Pnts->LineEdit3->setEnabled( true );
+  }
+  else if ( send == GroupFace->PushButton1 ) {
+    myEditCurrentArgument = GroupFace->LineEdit1;
+    GroupFace->PushButton1->setDown( true );
+  }
 
-  if      ( send == GroupPntDir->PushButton1 ) myEditCurrentArgument = GroupPntDir->LineEdit1;
-  else if ( send == GroupPntDir->PushButton2 ) myEditCurrentArgument = GroupPntDir->LineEdit2;
-  else if ( send == Group3Pnts->PushButton1 )  myEditCurrentArgument = Group3Pnts->LineEdit1;
-  else if ( send == Group3Pnts->PushButton2 )  myEditCurrentArgument = Group3Pnts->LineEdit2;
-  else if ( send == Group3Pnts->PushButton3 )  myEditCurrentArgument = Group3Pnts->LineEdit3;
-  else if ( send == GroupFace->PushButton1 )   myEditCurrentArgument = GroupFace->LineEdit1;
+  myEditCurrentArgument->setFocus();
+
+  if ( myEditCurrentArgument == GroupPntDir->LineEdit2 ) {
+    localSelection( GEOM::GEOM_Object::_nil(), TopAbs_EDGE );
+  }
+  else if ( myEditCurrentArgument == GroupFace->LineEdit1 ) {
+    TColStd_MapOfInteger aMap;
+    aMap.Add( GEOM_PLANE );
+    aMap.Add( GEOM_MARKER );
+    globalSelection( aMap );
+  }
+  else { // 3 Pnts
+    localSelection( GEOM::GEOM_Object::_nil(), TopAbs_VERTEX );
+  }
 
+  //  SelectionIntoArgument();
   myEditCurrentArgument->setFocus();
-  
-  if ( myEditCurrentArgument == GroupPntDir->LineEdit2 )
-    globalSelection( GEOM_LINE );
-  else if ( myEditCurrentArgument == GroupFace->LineEdit1 )
-       globalSelection( GEOM_PLANE );
-  else
-       globalSelection( GEOM_POINT );
-   
-  SelectionIntoArgument();
+  send->setDown(true);
+  displayPreview();
 }
 
 
@@ -359,8 +506,7 @@ void BasicGUI_PlaneDlg::LineEditReturnPressed()
        send == Group3Pnts->LineEdit1 ||
        send == Group3Pnts->LineEdit2 ||
        send == Group3Pnts->LineEdit3 ||
-       send == GroupFace->LineEdit1 )
-  {
+       send == GroupFace->LineEdit1 ) {
     myEditCurrentArgument = send;
     GEOMBase_Skeleton::LineEditReturnPressed();
   }
@@ -374,10 +520,8 @@ void BasicGUI_PlaneDlg::LineEditReturnPressed()
 void BasicGUI_PlaneDlg::ActivateThisDialog()
 {
   GEOMBase_Skeleton::ActivateThisDialog();
-  connect(((SalomeApp_Application*)(SUIT_Session::session()->activeApplication()))->selectionMgr(), 
-         SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument()));
-
-  // myGeomGUI->SetState( 0 );
+  connect( myGeomGUI->getApp()->selectionMgr(), SIGNAL( currentSelectionChanged() ),
+          this, SLOT( SelectionIntoArgument() ) );
 
   ConstructorsClicked( getConstructorId() );
 }
@@ -388,7 +532,6 @@ void BasicGUI_PlaneDlg::ActivateThisDialog()
 //=================================================================================
 void BasicGUI_PlaneDlg::DeactivateActiveDialog()
 {
-  // myGeomGUI->SetState( -1 );
   GEOMBase_Skeleton::DeactivateActiveDialog();
 }
 
@@ -396,9 +539,9 @@ void BasicGUI_PlaneDlg::DeactivateActiveDialog()
 // function : enterEvent()
 // purpose  :
 //=================================================================================
-void BasicGUI_PlaneDlg::enterEvent(QEvent* e)
+void BasicGUI_PlaneDlg::enterEvent( QEvent* )
 {
-  if ( !GroupConstructors->isEnabled() )
+  if ( !mainFrame()->GroupConstructors->isEnabled() )
     ActivateThisDialog();
 }
 
@@ -407,7 +550,7 @@ void BasicGUI_PlaneDlg::enterEvent(QEvent* e)
 // function : ValueChangedInSpinBox()
 // purpose  :
 //=================================================================================
-void BasicGUI_PlaneDlg::ValueChangedInSpinBox(double newValue)
+void BasicGUI_PlaneDlg::ValueChangedInSpinBox( double newValue )
 {
   displayPreview();
 }
@@ -418,15 +561,28 @@ void BasicGUI_PlaneDlg::ValueChangedInSpinBox(double newValue)
 //=================================================================================
 double BasicGUI_PlaneDlg::getSize() const
 {
-  switch ( getConstructorId() )
-  {
-  case 0 : return GroupPntDir->SpinBox_DX->GetValue();
-  case 1 : return Group3Pnts->SpinBox_DX->GetValue();
-  case 2 : return GroupFace->SpinBox_DX->GetValue();
+  switch ( getConstructorId() ) {
+  case 0 : return GroupPntDir->SpinBox_DX->value();
+  case 1 : return Group3Pnts->SpinBox_DX->value();
+  case 2 : return GroupFace->SpinBox_DX->value();
   }
   return 0.;
 }
 
+//=================================================================================
+// function : getSize()
+// purpose  :
+//=================================================================================
+QString BasicGUI_PlaneDlg::getSizeAsString() const
+{
+  switch ( getConstructorId() ) {
+  case 0 : return GroupPntDir->SpinBox_DX->text();
+  case 1 : return Group3Pnts->SpinBox_DX->text();
+  case 2 : return GroupFace->SpinBox_DX->text();
+  }
+  return QString();
+}
+
 //=================================================================================
 // function : createOperation
 // purpose  :
@@ -451,20 +607,26 @@ static bool isEqual( const GEOM::GEOM_Object_var& thePnt1, const GEOM::GEOM_Obje
 //=================================================================================
 bool BasicGUI_PlaneDlg::isValid( QString& msg )
 {
-       const int id = getConstructorId();
-       if ( getSize() <= 0 )
-       {
-               msg = QString( "Please, enter size greater than 0." );
-               return false;
-       }
-       if ( id == 0 )
-               return !CORBA::is_nil( myPoint ) && !CORBA::is_nil( myDir );
-       else if ( id == 1 )
-               return !CORBA::is_nil( myPoint1  ) && !CORBA::is_nil( myPoint2 ) && !CORBA::is_nil( myPoint3 ) &&
-                      !isEqual( myPoint1, myPoint2 ) && !isEqual( myPoint1, myPoint3 ) && !isEqual( myPoint2, myPoint3 );
-       else if ( id == 2 )
-               return !CORBA::is_nil( myFace );
-       return false;
+  const int id = getConstructorId();
+  if ( getSize() <= 0 ) {
+    msg = QString( "Please, enter size greater than 0." );
+    return false;
+  }
+
+  if ( id == 0 ) { 
+    bool ok = GroupPntDir->SpinBox_DX->isValid( msg, !IsPreview() );
+    return !CORBA::is_nil( myPoint ) && !CORBA::is_nil( myDir ) && ok;
+  }
+  else if ( id == 1 ) {
+    bool ok = Group3Pnts->SpinBox_DX->isValid( msg, !IsPreview() );
+    return !CORBA::is_nil( myPoint1  ) && !CORBA::is_nil( myPoint2 ) && !CORBA::is_nil( myPoint3 ) &&
+      !isEqual( myPoint1, myPoint2 ) && !isEqual( myPoint1, myPoint3 ) && !isEqual( myPoint2, myPoint3 ) && ok;
+  }
+  else if ( id == 2 ) {
+    bool ok = GroupFace->SpinBox_DX->isValid( msg, !IsPreview() );
+    return !CORBA::is_nil( myFace ) && ok;
+  }
+  return false;
 }
 
 //=================================================================================
@@ -477,8 +639,7 @@ bool BasicGUI_PlaneDlg::execute( ObjectList& objects )
 
   GEOM::GEOM_Object_var anObj;
 
-  switch ( getConstructorId() )
-  {
+  switch ( getConstructorId() ) {
   case 0 :
     anObj = GEOM::GEOM_IBasicOperations::_narrow( getOperation() )->MakePlanePntVec( myPoint, myDir, getSize() );
     res = true;
@@ -492,19 +653,35 @@ bool BasicGUI_PlaneDlg::execute( ObjectList& objects )
     res = true;
     break;
   }
-
-  if ( !anObj->_is_nil() )
+  
+  if ( !anObj->_is_nil() ) {
+    if ( !IsPreview() )
+      anObj->SetParameters(getSizeAsString().toLatin1().constData());
     objects.push_back( anObj._retn() );
-
+  }
   return res;
 }
-
 //=================================================================================
-// function : closeEvent
-// purpose  :
+// function : addSubshapeToStudy
+// purpose  : virtual method to add new SubObjects if local selection
 //=================================================================================
-void BasicGUI_PlaneDlg::closeEvent( QCloseEvent* e )
+void BasicGUI_PlaneDlg::addSubshapesToStudy()
 {
-  GEOMBase_Skeleton::closeEvent( e );
-}
+  QMap<QString, GEOM::GEOM_Object_var> objMap;
 
+  switch ( getConstructorId() ) {
+  case 0:
+    objMap[GroupPntDir->LineEdit1->text()] = myPoint;
+    objMap[GroupPntDir->LineEdit2->text()] = myDir;
+    break;
+  case 1:
+    objMap[Group3Pnts->LineEdit1->text()] = myPoint1;
+    objMap[Group3Pnts->LineEdit2->text()] = myPoint2;
+    objMap[Group3Pnts->LineEdit3->text()] = myPoint3;
+    break;
+  case 2:
+    objMap[GroupFace->LineEdit1->text()] = myFace;
+    break;
+  }
+  addSubshapesToFather( objMap );
+}