Salome HOME
Mantis issues 0020939(GetSharedShapes) and 0020842(AllSorted meaning).
[modules/geom.git] / src / EntityGUI / EntityGUI_SketcherDlg.cxx
index 472a52eb4e11b728c4b8c6b90fdd5567b279dd77..4d7574e5d7923038d4bd7f170d2aa404ab00a39c 100644 (file)
@@ -1,4 +1,4 @@
-//  Copyright (C) 2007-2008  CEA/DEN, EDF R&D, OPEN CASCADE
+//  Copyright (C) 2007-2010  CEA/DEN, EDF R&D, OPEN CASCADE
 //
 //  Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
 //  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
 //
 //  See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
 //
+
 // GEOM GEOMGUI : GUI for Geometry component
 // File   : EntityGUI_SketcherDlg.cxx
 // Author : Damien COQUERET, Open CASCADE S.A.S.
 //
 #include "EntityGUI_SketcherDlg.h"
 #include "EntityGUI_Widgets.h"
-#include <QtxDoubleSpinBox.h>
+#include <SalomeApp_DoubleSpinBox.h>
 
 #include <GEOMBase.h>
 #include <GeometryGUI.h>
@@ -56,6 +57,8 @@
 
 #include <gp_Pln.hxx>
 
+#include <Basics_Utils.hxx>
+
 //=================================================================================
 // class    : EntityGUI_SketcherDlg()
 // purpose  : Constructs a EntityGUI_SketcherDlg which is a child of 'parent', with the
@@ -104,12 +107,17 @@ EntityGUI_SketcherDlg::EntityGUI_SketcherDlg( GeometryGUI* GUI, QWidget* parent,
   /***************************************************************/
 
   GroupBox1 = new QGroupBox(tr("GEOM_CS"), this);
-  QGridLayout* OwnLayout = new QGridLayout(GroupBox1);
-  OwnLayout->setSpacing(6);
-  OwnLayout->setMargin(11);
+  QHBoxLayout* planeLayout = new QHBoxLayout(GroupBox1);
+  planeLayout->setSpacing(6);
+  planeLayout->setMargin(11);
 
   ComboBox1 = new QComboBox(GroupBox1);
-  OwnLayout->addWidget(ComboBox1);
+  ComboBox1->setSizePolicy( QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed) );
+  planeLayout->addWidget(ComboBox1);
+
+  planeButton = new QPushButton (GroupBox1);
+  planeButton->setText( tr( "GEOM_SKETCHER_RESTORE" ) );
+  planeLayout->addWidget(planeButton);
 
   topLayout->addWidget(GroupBox1);
   topLayout->addWidget( MainWidget );
@@ -232,6 +240,7 @@ EntityGUI_SketcherDlg::EntityGUI_SketcherDlg( GeometryGUI* GUI, QWidget* parent,
   connect( Group4Spin->SpinBox_DS, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
 
   connect( ComboBox1, SIGNAL( activated( int ) ), this, SLOT( SelectionIntoArgument() ) );
+  connect( planeButton, SIGNAL( clicked() ), this, SLOT( ActivateLocalCS() ) );
 
   connect( myGeometryGUI, SIGNAL( SignalDefaultStepValueChanged( double ) ), this, SLOT( SetDoubleSpinBoxStep( double ) ) );
 
@@ -326,16 +335,17 @@ void EntityGUI_SketcherDlg::Init()
   double step = SUIT_Session::session()->resourceMgr()->doubleValue( "Geometry", "SettingsGeomStep", 100.0 );
 
   /* min, max, step and decimals for spin boxes */
-  initSpinBox( Group1Spin->SpinBox_DX, COORD_MIN, COORD_MAX, step, 3 ); // VSR: TODO: DBL_DIGITS_DISPLAY
-  initSpinBox( Group2Spin->SpinBox_DX, COORD_MIN, COORD_MAX, step, 3 ); // VSR: TODO: DBL_DIGITS_DISPLAY
-  initSpinBox( Group2Spin->SpinBox_DY, COORD_MIN, COORD_MAX, step, 3 ); // VSR: TODO: DBL_DIGITS_DISPLAY
-  initSpinBox( Group3Spin->SpinBox_DX, COORD_MIN, COORD_MAX, step, 3 ); // VSR: TODO: DBL_DIGITS_DISPLAY
-  initSpinBox( Group3Spin->SpinBox_DY, COORD_MIN, COORD_MAX, step, 3 ); // VSR: TODO: DBL_DIGITS_DISPLAY
-  initSpinBox( Group3Spin->SpinBox_DZ, COORD_MIN, COORD_MAX, step, 3 ); // VSR: TODO: DBL_DIGITS_DISPLAY
-  initSpinBox( Group4Spin->SpinBox_DX, COORD_MIN, COORD_MAX, 0.1, 3 ); // VSR: TODO: DBL_DIGITS_DISPLAY
-  initSpinBox( Group4Spin->SpinBox_DY, COORD_MIN, COORD_MAX, 0.1, 3 ); // VSR: TODO: DBL_DIGITS_DISPLAY
-  initSpinBox( Group4Spin->SpinBox_DZ, COORD_MIN, COORD_MAX, step, 3 ); // VSR: TODO: DBL_DIGITS_DISPLAY
-  initSpinBox( Group4Spin->SpinBox_DS, COORD_MIN, COORD_MAX, 5., 3 ); // VSR: TODO: DBL_DIGITS_DISPLAY
+  initSpinBox( Group1Spin->SpinBox_DX, COORD_MIN, COORD_MAX, step, "length_precision" );
+  initSpinBox( Group2Spin->SpinBox_DX, COORD_MIN, COORD_MAX, step, "length_precision" );
+  initSpinBox( Group2Spin->SpinBox_DY, COORD_MIN, COORD_MAX, step, "length_precision" );
+  initSpinBox( Group3Spin->SpinBox_DX, COORD_MIN, COORD_MAX, step, "length_precision" );
+  initSpinBox( Group3Spin->SpinBox_DY, COORD_MIN, COORD_MAX, step, "length_precision" );
+  initSpinBox( Group3Spin->SpinBox_DZ, COORD_MIN, COORD_MAX, step, "length_precision" );
+  initSpinBox( Group4Spin->SpinBox_DZ, COORD_MIN, COORD_MAX, step, "length_precision" );
+  // san: Note specific step values below!
+  initSpinBox( Group4Spin->SpinBox_DX, COORD_MIN, COORD_MAX, 0.1, "length_precision" );
+  initSpinBox( Group4Spin->SpinBox_DY, COORD_MIN, COORD_MAX, 0.1, "length_precision" );
+  initSpinBox( Group4Spin->SpinBox_DS, COORD_MIN, COORD_MAX, 5., "length_precision" );
 
   /* displays Dialog */
   MainWidget->GroupConstructors->setEnabled( false );
@@ -345,11 +355,12 @@ void EntityGUI_SketcherDlg::Init()
 
   MainWidget->RadioButton1->setChecked( true );
 
-  resize(100,100);
   TypeClicked( 0 );
 
   FindLocalCS();
+  resize(100,100);
 
+  ActivateLocalCS();
   GEOMBase_Helper::displayPreview( false, true, true, myLineWidth );
 }
 
@@ -367,8 +378,6 @@ void EntityGUI_SketcherDlg::InitClick()
   Group2Spin->hide();
   Group3Spin->hide();
   Group4Spin->hide();
-
-  resize(100,100);
 }
 
 
@@ -387,7 +396,7 @@ void EntityGUI_SketcherDlg::TypeClicked( int constructorId )
   }
   else if (  myConstructorId == 1 ) { // ARC
     GroupD2->setEnabled( false );
-    MainWidget->RB_Dest1->setEnabled( false );
+    MainWidget->RB_Dest1->setEnabled( true ); 
     MainWidget->RB_Dest2->setChecked( true );
     DestClicked( 0 );
   }
@@ -431,11 +440,11 @@ void EntityGUI_SketcherDlg::PointClicked( int constructorId )
   // Get setting of step value from file configuration
   double step = SUIT_Session::session()->resourceMgr()->doubleValue( "Geometry", "SettingsGeomStep", 100.0 );
 
-  if ( myConstructorId == 0 ) {  // SEGMENT
+  if ( (myConstructorId == 0) || (myConstructorId == 1) ) {  // SEGMENT OR ARC
     if ( constructorId == 1 ) {  // XY
       mySketchType = PT_ABS;
-      initSpinBox( Group2Spin->SpinBox_DX, COORD_MIN, COORD_MAX, step, 3 ); // VSR: TODO: DBL_DIGITS_DISPLAY
-      initSpinBox( Group2Spin->SpinBox_DY, COORD_MIN, COORD_MAX, step, 3 ); // VSR: TODO: DBL_DIGITS_DISPLAY
+      initSpinBox( Group2Spin->SpinBox_DX, COORD_MIN, COORD_MAX, step, "length_precision" );
+      initSpinBox( Group2Spin->SpinBox_DY, COORD_MIN, COORD_MAX, step, "length_precision" );
       Group2Spin->TextLabel1->setText( tr( "GEOM_SKETCHER_X2" ) );
       Group2Spin->TextLabel2->setText( tr( "GEOM_SKETCHER_Y2" ) );
       myX = 0.0;
@@ -449,8 +458,8 @@ void EntityGUI_SketcherDlg::PointClicked( int constructorId )
     }
     else if ( constructorId == 0 ) {  // DXDY
       mySketchType = PT_RELATIVE;
-      initSpinBox( Group2Spin->SpinBox_DX, COORD_MIN, COORD_MAX, step, 3 ); // VSR: TODO: DBL_DIGITS_DISPLAY
-      initSpinBox( Group2Spin->SpinBox_DY, COORD_MIN, COORD_MAX, step, 3 ); // VSR: TODO: DBL_DIGITS_DISPLAY
+      initSpinBox( Group2Spin->SpinBox_DX, COORD_MIN, COORD_MAX, step, "length_precision" );
+      initSpinBox( Group2Spin->SpinBox_DY, COORD_MIN, COORD_MAX, step, "length_precision" );
       Group2Spin->TextLabel1->setText( tr( "GEOM_SKETCHER_DX2" ) );
       Group2Spin->TextLabel2->setText( tr( "GEOM_SKETCHER_DY2" ) );
       myDX = 0.0;
@@ -465,12 +474,13 @@ void EntityGUI_SketcherDlg::PointClicked( int constructorId )
     else if ( constructorId == 2 ) {  // Selection
       mySketchType = PT_SEL;
       myEditCurrentArgument = Group1Sel->LineEdit1;
-      connect( myGeometryGUI->getApp()->selectionMgr(),
-               SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) );
       Group1Sel->show();
       Group1Sel->buttonApply->setFocus();
       SelectionIntoArgument();
     }
+
+    connect( myGeometryGUI->getApp()->selectionMgr(),
+             SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) );
   }
 }
 
@@ -504,8 +514,7 @@ void EntityGUI_SketcherDlg::Dir2Clicked( int constructorId )
     myY = 0.0;
     myLength = 100.0;
     if ( myConstructorDirId == 2 ) {  // Angle
-      initSpinBox( Group2Spin->SpinBox_DX, COORD_MIN, COORD_MAX, 5., 3 ); // VSR: TODO: DBL_DIGITS_DISPLAY
-      initSpinBox( Group2Spin->SpinBox_DY, COORD_MIN, COORD_MAX, step, 3 ); // VSR: TODO: DBL_DIGITS_DISPLAY
+      initSpinBox( Group2Spin->SpinBox_DX, COORD_MIN, COORD_MAX, 5., "length_precision" );
       Group2Spin->TextLabel1->setText( tr( "GEOM_SKETCHER_ANGLE2" ) );
       Group2Spin->SpinBox_DX->setValue( myAngle );
       Group2Spin->buttonApply->setFocus();
@@ -513,16 +522,19 @@ void EntityGUI_SketcherDlg::Dir2Clicked( int constructorId )
 
       if ( constructorId == 2 ) {  // Length
         mySketchType = DIR_ANGLE_LENGTH;
+        initSpinBox( Group2Spin->SpinBox_DY, COORD_MIN, COORD_MAX, step, "length_precision" );
         Group2Spin->TextLabel2->setText( tr( "GEOM_SKETCHER_LENGTH2" ) );
         Group2Spin->SpinBox_DY->setValue( myLength );
       }
       else if ( constructorId == 0 ) {  // X
         mySketchType = DIR_ANGLE_X;
+        initSpinBox( Group2Spin->SpinBox_DY, COORD_MIN, COORD_MAX, step, "angle_precision" );
         Group2Spin->TextLabel2->setText( tr( "GEOM_SKETCHER_X3" ) );
         Group2Spin->SpinBox_DY->setValue( myX );
       }
       else if ( constructorId == 1 ) {  // Y
         mySketchType = DIR_ANGLE_Y;
+        initSpinBox( Group2Spin->SpinBox_DY, COORD_MIN, COORD_MAX, step, "angle_precision" );        
         Group2Spin->TextLabel2->setText( tr( "GEOM_SKETCHER_Y3" ) );
         Group2Spin->SpinBox_DY->setValue( myY );
       }
@@ -568,9 +580,9 @@ void EntityGUI_SketcherDlg::Dir2Clicked( int constructorId )
       }
     }
     else if ( myConstructorDirId == 3 ) {  // DXDY
-      initSpinBox( Group3Spin->SpinBox_DX, COORD_MIN, COORD_MAX, 0.1, 3 ); // VSR: TODO: DBL_DIGITS_DISPLAY
-      initSpinBox( Group3Spin->SpinBox_DY, COORD_MIN, COORD_MAX, 0.1, 3 ); // VSR: TODO: DBL_DIGITS_DISPLAY
-      initSpinBox( Group3Spin->SpinBox_DZ, COORD_MIN, COORD_MAX, step, 3 ); // VSR: TODO: DBL_DIGITS_DISPLAY
+      initSpinBox( Group3Spin->SpinBox_DX, COORD_MIN, COORD_MAX, 0.1, "length_precision" );
+      initSpinBox( Group3Spin->SpinBox_DY, COORD_MIN, COORD_MAX, 0.1, "length_precision" );
+      initSpinBox( Group3Spin->SpinBox_DZ, COORD_MIN, COORD_MAX, step, "length_precision" );
       Group3Spin->TextLabel1->setText( tr( "GEOM_SKETCHER_VX2" ) );
       Group3Spin->TextLabel2->setText( tr( "GEOM_SKETCHER_VY2" ) );
       myDX = 0.0;
@@ -601,9 +613,9 @@ void EntityGUI_SketcherDlg::Dir2Clicked( int constructorId )
     if ( myConstructorDirId == 2 ) {  // Angle
       if ( constructorId == 2 ) {  // Length
         mySketchType = DIR_ANGLE_LENGTH;
-        initSpinBox( Group3Spin->SpinBox_DX, COORD_MIN, COORD_MAX, 5., 3 ); // VSR: TODO: DBL_DIGITS_DISPLAY
-        initSpinBox( Group3Spin->SpinBox_DY, COORD_MIN, COORD_MAX, step, 3 ); // VSR: TODO: DBL_DIGITS_DISPLAY
-        initSpinBox( Group3Spin->SpinBox_DZ, COORD_MIN, COORD_MAX, 5., 3 ); // VSR: TODO: DBL_DIGITS_DISPLAY
+        initSpinBox( Group3Spin->SpinBox_DX, COORD_MIN, COORD_MAX, 5., "angle_precision" );
+        initSpinBox( Group3Spin->SpinBox_DY, COORD_MIN, COORD_MAX, step, "length_precision" );
+        initSpinBox( Group3Spin->SpinBox_DZ, COORD_MIN, COORD_MAX, 5., "angle_precision" );
         Group3Spin->TextLabel1->setText( tr( "GEOM_SKETCHER_ANGLE2" ) );
         Group3Spin->TextLabel2->setText( tr( "GEOM_SKETCHER_RADIUS2" ) );
         Group3Spin->TextLabel3->setText( tr( "GEOM_SKETCHER_ANGLE2" ));
@@ -619,8 +631,8 @@ void EntityGUI_SketcherDlg::Dir2Clicked( int constructorId )
     else if ( myConstructorDirId == 0 ) {  // Perpendicular
       if ( constructorId == 2 ) {  // Length
         mySketchType = DIR_PER_LENGTH;
-        initSpinBox( Group2Spin->SpinBox_DY, COORD_MIN, COORD_MAX, step, 3 ); // VSR: TODO: DBL_DIGITS_DISPLAY
-        initSpinBox( Group2Spin->SpinBox_DY, COORD_MIN, COORD_MAX, 5., 3 ); // VSR: TODO: DBL_DIGITS_DISPLAY
+        initSpinBox( Group2Spin->SpinBox_DY, COORD_MIN, COORD_MAX, step, "length_precision" );
+        initSpinBox( Group2Spin->SpinBox_DY, COORD_MIN, COORD_MAX, 5., "angle_precision" );
         Group2Spin->TextLabel1->setText( tr( "GEOM_SKETCHER_RADIUS2" ) );
         Group2Spin->TextLabel2->setText( tr( "GEOM_SKETCHER_ANGLE2" ) );
         myRadius = 100.0;
@@ -634,8 +646,8 @@ void EntityGUI_SketcherDlg::Dir2Clicked( int constructorId )
     else if ( myConstructorDirId == 1 ) {  // Tangent
       if ( constructorId == 2 ) {  // Length
         mySketchType = DIR_TAN_LENGTH;
-        initSpinBox( Group2Spin->SpinBox_DY, COORD_MIN, COORD_MAX, step, 3 ); // VSR: TODO: DBL_DIGITS_DISPLAY
-        initSpinBox( Group2Spin->SpinBox_DY, COORD_MIN, COORD_MAX, 5., 3 ); // VSR: TODO: DBL_DIGITS_DISPLAY
+        initSpinBox( Group2Spin->SpinBox_DY, COORD_MIN, COORD_MAX, step, "length_precision" );
+        initSpinBox( Group2Spin->SpinBox_DY, COORD_MIN, COORD_MAX, 5., "angle_precision" );
         Group2Spin->TextLabel1->setText( tr( "GEOM_SKETCHER_RADIUS2" ) );
         Group2Spin->TextLabel2->setText( tr( "GEOM_SKETCHER_ANGLE2" ) );
         myRadius = 100.0;
@@ -818,6 +830,9 @@ void EntityGUI_SketcherDlg::ClickOnUndo()
     MainWidget->RadioButton1->setChecked( true );
     TypeClicked( 0 );
 
+    connect( myGeometryGUI->getApp()->selectionMgr(),
+             SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) );
+
     MainWidget->GroupConstructors->setEnabled( false );
     MainWidget->GroupDest1->setEnabled( false );
     setEnabledUndo( false );
@@ -885,8 +900,16 @@ void EntityGUI_SketcherDlg::setEnabledRedo( bool value )
 void EntityGUI_SketcherDlg::SelectionIntoArgument()
 {
   myEditCurrentArgument->setText( "" );
+  double tmpX = myX;
+  double tmpY = myY;
   myX = myLastX1;
   myY = myLastY1;
+  //  printf ("\nmyX = %f         myY = %f", myX, myY);
+  //  printf ("\nmyLastX1 = %f    myLastY1 = %f", myLastX1, myLastY1);
+  //  printf ("\nmyLastX2 = %f    myLastY2 = %f", myLastX2, myLastY2);
+
+  if ( sender() == ComboBox1 )
+      ActivateLocalCS();
 
   LightApp_SelectionMgr* aSelMgr = myGeometryGUI->getApp()->selectionMgr();
   SALOME_ListIO aSelList;
@@ -911,6 +934,27 @@ void EntityGUI_SketcherDlg::SelectionIntoArgument()
           myX = aPnt.X();
           myY = aPnt.Y();
           Group1Sel->LineEdit1->setText( GEOMBase::GetName( aSelectedObject ) );
+          if( Group2Spin->isVisible() && mySketchType == PT_ABS ) {
+            disconnect( Group2Spin->SpinBox_DX, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
+            disconnect( Group2Spin->SpinBox_DY, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
+            Group2Spin->SpinBox_DX->setValue(myX);
+            Group2Spin->SpinBox_DY->setValue(myY);
+            connect( Group2Spin->SpinBox_DX, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
+            connect( Group2Spin->SpinBox_DY, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
+          } else if ( Group2Spin->isVisible() && mySketchType == PT_RELATIVE ) {
+            if ( myLastX1 && myLastY1 ) {
+              Group2Spin->SpinBox_DX->setValue(myX - myLastX1);
+              Group2Spin->SpinBox_DY->setValue(myY - myLastY1);
+            } else {
+              if ( mySketchState != FIRST_POINT ) {
+                Group2Spin->SpinBox_DX->setValue(myX - tmpX);
+                Group2Spin->SpinBox_DY->setValue(myY - tmpY);
+              } else {
+                Group2Spin->SpinBox_DX->setValue(myX);
+                Group2Spin->SpinBox_DY->setValue(myY);
+              }
+            }
+          }
         }
       }
     }
@@ -1170,6 +1214,18 @@ void EntityGUI_SketcherDlg::ValueChangedInSpinBox( double newValue )
     }
   }
   else if ( myConstructorId == 1 ) {  // ARC
+    if ( mySketchType == PT_ABS ) {  
+      myX = vx;
+      myY = vy;
+      myXStr = vxStr;
+      myYStr = vyStr;
+    }
+    else if ( mySketchType == PT_RELATIVE ) {
+      myDX = vx;
+      myDY = vy;
+      myDXStr = vxStr;
+      myDYStr = vyStr;
+    } 
     if ( mySketchType == DIR_ANGLE_LENGTH ) {
       myAngle = vx;
       myRadius = vy;
@@ -1294,6 +1350,14 @@ QString EntityGUI_SketcherDlg::GetNewCommand( QString& theParameters )
     }
   }
   else if ( myConstructorId == 1 ) {  // ARC
+    if ( mySketchType == PT_ABS || mySketchType == PT_SEL ) {
+      myNewCommand = myNewCommand + "AA " + QString::number( myX ) + " " + QString::number( myY );
+      theParameters = myXStr + ":" + myYStr;
+    }
+    if ( mySketchType == PT_RELATIVE) {
+      myNewCommand = myNewCommand + "A " + QString::number( myDX ) + " " + QString::number( myDY );
+      theParameters = myDXStr + ":" + myDYStr;
+    } 
     if ( mySketchType == DIR_ANGLE_LENGTH ) {
       myNewCommand = myNewCommand + "R " + QString::number( myAngle );
       myNewCommand = myNewCommand + ":" + "C " + QString::number( myRadius ) + " " + QString::number( myLength );
@@ -1376,6 +1440,9 @@ bool EntityGUI_SketcherDlg::execute( ObjectList& objects )
     //Test if the current point is the same as the last one
     TopoDS_Shape myShape1, myShape2;
 
+    // Set "C" numeric locale
+    Kernel_Utils::Localizer loc;
+
     //Last Shape
     QString Command1 = myCommand.join( "" );
     Sketcher_Profile aProfile1( Command1.toAscii() );
@@ -1602,13 +1669,31 @@ void  EntityGUI_SketcherDlg::keyPressEvent( QKeyEvent* e )
   }
 }
 
+//=================================================================================
+// function : initSpinBox()
+// purpose  :
+//=================================================================================
 void EntityGUI_SketcherDlg::initSpinBox( SalomeApp_DoubleSpinBox* spinBox,
                                          double min,  double max,
-                                         double step, int decimals )
+                                         double step, const char* quantity )
 {
-  spinBox->setDecimals( decimals );
+  // The same stuff as in GEOMBase_Skeleton::initSpinBox()!
+  // TODO: Think how to keep the single piece of code...
+
+  // Obtain precision from preferences
+  SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
+  int aPrecision = resMgr->integerValue( "Geometry", quantity, 6 );
+  
+  spinBox->setPrecision( aPrecision );
+  spinBox->setDecimals( qAbs( aPrecision ) ); // it's necessary to set decimals before the range setting,
+                                              // by default Qt rounds boundaries to 2 decimals at setRange
   spinBox->setRange( min, max );
   spinBox->setSingleStep( step );
+  
+  // Add a hint for the user saying how to tune precision
+  QString userPropName = QObject::tr( QString( "GEOM_PREF_%1" ).arg( quantity ).toLatin1().constData() );
+  spinBox->setProperty( "validity_tune_hint", 
+                        QVariant( QObject::tr( "GEOM_PRECISION_HINT" ).arg( userPropName ) ) );
 }
 
 //=================================================================================
@@ -1623,10 +1708,13 @@ void EntityGUI_SketcherDlg::SetDoubleSpinBoxStep( double step )
   Group3Spin->SpinBox_DX->setSingleStep(step);
   Group3Spin->SpinBox_DY->setSingleStep(step);
   Group3Spin->SpinBox_DZ->setSingleStep(step);
-  Group4Spin->SpinBox_DX->setSingleStep(step);
-  Group4Spin->SpinBox_DY->setSingleStep(step);
   Group4Spin->SpinBox_DZ->setSingleStep(step);
-  Group4Spin->SpinBox_DS->setSingleStep(step);
+
+  // san: Do NOT override the step when a speicifc step value is used
+  // in some input fields!
+  //Group4Spin->SpinBox_DX->setSingleStep(step);
+  //Group4Spin->SpinBox_DY->setSingleStep(step);
+  //Group4Spin->SpinBox_DS->setSingleStep(step);
 }
 
 //=================================================================================
@@ -1696,7 +1784,7 @@ void EntityGUI_SketcherDlg::FindLocalCS()
 
 //=================================================================================
 // function : GetActiveLocalCS()
-// purpose  : Find All Coordinates systems in study
+// purpose  : Get Working plane
 //=================================================================================
 gp_Ax3 EntityGUI_SketcherDlg::GetActiveLocalCS()
 {
@@ -1706,7 +1794,15 @@ gp_Ax3 EntityGUI_SketcherDlg::GetActiveLocalCS()
 
   gp_Ax3 aLCS = myLCSList.at(ind);
 
-  myGeometryGUI->SetWorkingPlane( aLCS );
-  myGeometryGUI->ActiveWorkingPlane();
   return aLCS;
 }
+
+//=================================================================================
+// function : ActivateLocalCS()
+// purpose  : Activate & Fit Working plane
+//=================================================================================
+void EntityGUI_SketcherDlg::ActivateLocalCS()
+{
+    myGeometryGUI->SetWorkingPlane( GetActiveLocalCS() );
+    myGeometryGUI->ActiveWorkingPlane();
+}