Salome HOME
Update GUI documentation for bugs 16559
[modules/geom.git] / src / DlgRef / DlgRef_SpinBox.cxx
index 418be2d55eda1a9b38661b95ff7873c1295f10ca..35bec55ba5db9a59950f306a6db8cfc2cb04970e 100644 (file)
@@ -17,7 +17,7 @@
 //  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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org 
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
 //
 //
 //
@@ -26,7 +26,6 @@
 //  Module : GEOM
 //  $Header$
 
-using namespace std;
 #include "DlgRef_SpinBox.h"
 
 #include <qvalidator.h>
@@ -97,7 +96,34 @@ QString DlgRef_SpinBox::GetString()
 void DlgRef_SpinBox::RangeStepAndValidator(double min, double max,double step,
                                           unsigned short decimals)
 {
+  setPrecision(-decimals); // PAL12789. Minus is for using 'g' double->string conversion specifier,
+  //                          see QtxDblSpinBox::mapValueToText( double v )
   setRange(min, max);
   setLineStep(step);
   ((QDoubleValidator*)validator())->setRange(min, max, decimals);
 }
+
+QString DlgRef_SpinBox::PrintDoubleValue (double theValue, int thePrecision)
+{
+  QString aRes;
+  aRes.setNum(theValue, 'g', thePrecision);
+
+  // remove trailing zeroes
+  QString delim( "." );
+
+  int idx = aRes.findRev( delim );
+  if ( idx == -1 )
+    return aRes;
+
+  QString iPart = aRes.left( idx );
+  QString fPart = aRes.mid( idx + 1 );
+
+  while ( !fPart.isEmpty() && fPart.at( fPart.length() - 1 ) == '0' )
+    fPart.remove( fPart.length() - 1, 1 );
+
+  aRes = iPart;
+  if ( !fPart.isEmpty() )
+    aRes += delim + fPart;
+
+  return aRes;
+}