Salome HOME
Update copyright information
[modules/geom.git] / src / BasicGUI / BasicGUI_PlaneDlg.cxx
index 73c8b6a6356ccfd12ada4b5352bdb7b5115e918c..6387a655866c078b1f682a2a8396e98470dd83d1 100644 (file)
@@ -1,28 +1,28 @@
-// GEOM GEOMGUI : GUI for Geometry component
+//  Copyright (C) 2007-2008  CEA/DEN, EDF R&D, OPEN CASCADE
 //
-// Copyright (C) 2003  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
-// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//  Copyright (C) 2003-2007  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 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.
+//  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
+//  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
+//  See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
 //
+// GEOM GEOMGUI : GUI for Geometry component
 // File   : BasicGUI_PlaneDlg.cxx
 // Author : Lucien PIGNOLONI, Open CASCADE S.A.S.
 //
-
 #include "BasicGUI_PlaneDlg.h"
 
 #include <DlgRef.h>
 #include <LightApp_SelectionMgr.h>
 
 #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>
 
 #include <GEOMImpl_Types.hxx>
 
@@ -72,6 +78,9 @@ BasicGUI_PlaneDlg::BasicGUI_PlaneDlg( GeometryGUI* theGeometryGUI, QWidget* pare
   GroupPntDir->PushButton2->setIcon( image3 );
   GroupPntDir->LineEdit1->setReadOnly( true );
   GroupPntDir->LineEdit2->setReadOnly( true );
+  GroupPntDir->PushButton1->setDown( true );
+  GroupPntDir->LineEdit1->setEnabled( true );
+  GroupPntDir->LineEdit2->setEnabled( false );
 
   Group3Pnts = new DlgRef_3Sel1Spin( centralWidget() );
   Group3Pnts->GroupBox1->setTitle( tr( "GEOM_3_POINTS" ) );
@@ -82,16 +91,25 @@ BasicGUI_PlaneDlg::BasicGUI_PlaneDlg( GeometryGUI* theGeometryGUI, QWidget* pare
   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 );
-
-  GroupFace = new DlgRef_1Sel1Spin( centralWidget() );
+  Group3Pnts->LineEdit1->setEnabled( true );
+  Group3Pnts->LineEdit2->setEnabled( false );
+  Group3Pnts->LineEdit3->setEnabled( false );
+
+  GroupFace = new DlgRef_3Radio1Sel1Spin( centralWidget() );
+  GroupFace->RadioButton1->setText(tr("GEOM_FACE"));
+  GroupFace->RadioButton2->setText(tr("GEOM_LCS"));
+  GroupFace->RadioButton3->setAttribute( Qt::WA_DeleteOnClose );
+  GroupFace->RadioButton3->close();
   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 );
 
@@ -102,7 +120,7 @@ BasicGUI_PlaneDlg::BasicGUI_PlaneDlg( GeometryGUI* theGeometryGUI, QWidget* pare
   layout->addWidget( GroupFace );
   /***************************************************************/
 
-  setHelpFileName( "plane.htm" );
+  setHelpFileName( "create_plane_page.html" );
 
   Init();
 }
@@ -125,6 +143,7 @@ void BasicGUI_PlaneDlg::Init()
 {
   /* init variables */
   myEditCurrentArgument = GroupPntDir->LineEdit1;
+  GroupFace->RadioButton1->setChecked(true);
 
   myPoint = myDir = myPoint1 = myPoint2 = myPoint3 = myFace = GEOM::GEOM_Object::_nil();
 
@@ -137,11 +156,11 @@ void BasicGUI_PlaneDlg::Init()
   double aTrimSize = 2000.0;
 
   /* min, max, step and decimals for spin boxes */
-  initSpinBox( GroupPntDir->SpinBox_DX, 0.001, COORD_MAX, aStep, 3 );
+  initSpinBox( GroupPntDir->SpinBox_DX, 0.000001, COORD_MAX, aStep, 6 ); // VSR: TODO: DBL_DIGITS_DISPLAY
   GroupPntDir->SpinBox_DX->setValue( aTrimSize );
-  initSpinBox( Group3Pnts->SpinBox_DX, 0.001, COORD_MAX, aStep, 3 );
+  initSpinBox( Group3Pnts->SpinBox_DX, 0.000001, COORD_MAX, aStep, 6 ); // VSR: TODO: DBL_DIGITS_DISPLAY
   Group3Pnts->SpinBox_DX->setValue( aTrimSize );
-  initSpinBox( GroupFace->SpinBox_DX, 0.001, COORD_MAX, aStep, 3 );
+  initSpinBox( GroupFace->SpinBox_DX, 0.000001, COORD_MAX, aStep, 6 ); // VSR: TODO: DBL_DIGITS_DISPLAY
   GroupFace->SpinBox_DX->setValue( aTrimSize );
 
   /* signals and slots connections */
@@ -166,24 +185,52 @@ void BasicGUI_PlaneDlg::Init()
   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( GroupFace->RadioButton1,SIGNAL( clicked() ), this, SLOT( SelectionTypeClicked() ) );
+  connect( GroupFace->RadioButton2,SIGNAL( clicked() ), this, SLOT( SelectionTypeClicked() ) );
 
   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 ) ) );
 
-  // VSR: TODO ->>
-  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( myGeomGUI, SIGNAL( SignalDefaultStepValueChanged( double ) ), this, SLOT( SetDoubleSpinBoxStep( double ) ) );
 
-  connect( ( (SalomeApp_Application*)( SUIT_Session::session()->activeApplication() ) )->selectionMgr(), SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) );
+  connect( myGeomGUI->getApp()->selectionMgr(), SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) );
 
   initName( tr( "GEOM_PLANE" ) );
 
   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 : SelectionTypeClicked()
+// purpose  : Selection type radio buttons managment
+//=================================================================================
+void BasicGUI_PlaneDlg::SelectionTypeClicked()
+{
+  myFace   = GEOM::GEOM_Object::_nil();
+  if ( GroupFace->RadioButton1->isChecked()) {
+    globalSelection(); // close local contexts, if any
+    localSelection( GEOM::GEOM_Object::_nil(), TopAbs_FACE );
+  } else if ( GroupFace->RadioButton2->isChecked()) {
+    TColStd_MapOfInteger aMap;
+    aMap.Add( GEOM_PLANE );
+    aMap.Add( GEOM_MARKER );
+    globalSelection( aMap );
+  }
+  displayPreview();
+}
+
 
 //=================================================================================
 // function : ConstructorsClicked()
@@ -191,7 +238,7 @@ void BasicGUI_PlaneDlg::Init()
 //=================================================================================
 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 ) {
@@ -204,9 +251,14 @@ void BasicGUI_PlaneDlg::ConstructorsClicked( int constructorId )
       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( GEOM_POINT );
+      globalSelection(); // close local contexts, if any
+      localSelection( GEOM::GEOM_Object::_nil(), TopAbs_VERTEX );
       break;
     }
   case 1: /* plane from 3 points */
@@ -219,12 +271,19 @@ void BasicGUI_PlaneDlg::ConstructorsClicked( int constructorId )
       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( GEOM_POINT );
+      globalSelection(); // close local contexts, if any
+      localSelection( GEOM::GEOM_Object::_nil(), TopAbs_VERTEX );
       break;
     }
-  case 2: /* plane from a planar face selection */
+  case 2: /* plane from a planar face or LSC selection */
     {
       GroupPntDir->hide();
       Group3Pnts->hide();
@@ -232,13 +291,17 @@ void BasicGUI_PlaneDlg::ConstructorsClicked( int constructorId )
       
       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 );
+      if ( GroupFace->RadioButton1->isChecked()) {
+       globalSelection(); // close local contexts, if any
+       localSelection( GEOM::GEOM_Object::_nil(), TopAbs_FACE );
+      } else if ( GroupFace->RadioButton2->isChecked()) {
+       TColStd_MapOfInteger aMap;
+       aMap.Add( GEOM_PLANE );
+       aMap.Add( GEOM_MARKER );
+       globalSelection( aMap );
+      }
       break;
     }
   }
@@ -248,8 +311,8 @@ void BasicGUI_PlaneDlg::ConstructorsClicked( int constructorId )
   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() ) );
 }
 
 
@@ -286,7 +349,11 @@ 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();
@@ -298,15 +365,88 @@ void BasicGUI_PlaneDlg::SelectionIntoArgument()
 
   // nbSel == 1
   Standard_Boolean aRes = Standard_False;
-  GEOM::GEOM_Object_var aSelectedObject = GEOMBase::ConvertIOinGEOMObject( firstIObject(), aRes );
+  GEOM::GEOM_Object_var aSelectedObject = GEOMBase::ConvertIOinGEOMObject(aSelList.First(), 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;
+    QString aName = GEOMBase::GetName( aSelectedObject );
+    TopAbs_ShapeEnum aNeedType = TopAbs_VERTEX;
+    if ( myEditCurrentArgument == GroupPntDir->LineEdit2 )
+      aNeedType = TopAbs_EDGE;
+    else if ( myEditCurrentArgument == GroupFace->LineEdit1 )
+      aNeedType = TopAbs_FACE;
+
+    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();
@@ -320,29 +460,68 @@ void BasicGUI_PlaneDlg::SelectionIntoArgument()
 void BasicGUI_PlaneDlg::SetEditCurrentArgument()
 {
   QPushButton* send = (QPushButton*)sender();
+  globalSelection( GEOM_POINT );
 
-  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;
+  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 );
+  }
 
   myEditCurrentArgument->setFocus();
 
-  if ( myEditCurrentArgument == GroupPntDir->LineEdit2 )
-    globalSelection( GEOM_LINE );
+  if ( myEditCurrentArgument == GroupPntDir->LineEdit2 ) {
+    localSelection( GEOM::GEOM_Object::_nil(), TopAbs_EDGE );
+  }
   else if ( myEditCurrentArgument == GroupFace->LineEdit1 ) {
-    //globalSelection( GEOM_PLANE );
     TColStd_MapOfInteger aMap;
     aMap.Add( GEOM_PLANE );
     aMap.Add( GEOM_MARKER );
     globalSelection( aMap );
   }
-  else
-    globalSelection( GEOM_POINT );
+  else { // 3 Pnts
+    localSelection( GEOM::GEOM_Object::_nil(), TopAbs_VERTEX );
+  }
 
-  SelectionIntoArgument();
+  //  SelectionIntoArgument();
+  myEditCurrentArgument->setFocus();
+  send->setDown(true);
+  displayPreview();
 }
 
 
@@ -372,10 +551,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() );
 }
@@ -386,7 +563,6 @@ void BasicGUI_PlaneDlg::ActivateThisDialog()
 //=================================================================================
 void BasicGUI_PlaneDlg::DeactivateActiveDialog()
 {
-  // myGeomGUI->SetState( -1 );
   GEOMBase_Skeleton::DeactivateActiveDialog();
 }
 
@@ -493,13 +669,27 @@ bool BasicGUI_PlaneDlg::execute( ObjectList& objects )
   
   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 );
+}