From: jfa Date: Thu, 7 Jun 2007 09:10:04 +0000 (+0000) Subject: NPAL16123: EDF435: 3 significant digits in Point Creation dialog. X-Git-Tag: V3_2_7~17 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=eb3ecf9eba4fb865825a1fdc582aefa72934fc0e;p=modules%2Fgeom.git NPAL16123: EDF435: 3 significant digits in Point Creation dialog. --- diff --git a/src/BasicGUI/BasicGUI_PointDlg.cxx b/src/BasicGUI/BasicGUI_PointDlg.cxx index 16b642130..755a04b9b 100644 --- a/src/BasicGUI/BasicGUI_PointDlg.cxx +++ b/src/BasicGUI/BasicGUI_PointDlg.cxx @@ -157,22 +157,22 @@ void BasicGUI_PointDlg::Init() double step = resMgr->doubleValue( "Geometry", "SettingsGeomStep", 100); /* min, max, step and decimals for spin boxes */ - GroupXYZ->SpinBox_DX->RangeStepAndValidator(COORD_MIN, COORD_MAX, step, 3); - GroupXYZ->SpinBox_DY->RangeStepAndValidator(COORD_MIN, COORD_MAX, step, 3); - GroupXYZ->SpinBox_DZ->RangeStepAndValidator(COORD_MIN, COORD_MAX, step, 3); + GroupXYZ->SpinBox_DX->RangeStepAndValidator(COORD_MIN, COORD_MAX, step, DBL_DIGITS_DISPLAY); + GroupXYZ->SpinBox_DY->RangeStepAndValidator(COORD_MIN, COORD_MAX, step, DBL_DIGITS_DISPLAY); + GroupXYZ->SpinBox_DZ->RangeStepAndValidator(COORD_MIN, COORD_MAX, step, DBL_DIGITS_DISPLAY); GroupXYZ->SpinBox_DX->SetValue(0.0); GroupXYZ->SpinBox_DY->SetValue(0.0); GroupXYZ->SpinBox_DZ->SetValue(0.0); - GroupRefPoint->SpinBox_DX->RangeStepAndValidator(COORD_MIN, COORD_MAX, step, 3); - GroupRefPoint->SpinBox_DY->RangeStepAndValidator(COORD_MIN, COORD_MAX, step, 3); - GroupRefPoint->SpinBox_DZ->RangeStepAndValidator(COORD_MIN, COORD_MAX, step, 3); + GroupRefPoint->SpinBox_DX->RangeStepAndValidator(COORD_MIN, COORD_MAX, step, DBL_DIGITS_DISPLAY); + GroupRefPoint->SpinBox_DY->RangeStepAndValidator(COORD_MIN, COORD_MAX, step, DBL_DIGITS_DISPLAY); + GroupRefPoint->SpinBox_DZ->RangeStepAndValidator(COORD_MIN, COORD_MAX, step, DBL_DIGITS_DISPLAY); GroupRefPoint->SpinBox_DX->SetValue(0.0); GroupRefPoint->SpinBox_DY->SetValue(0.0); GroupRefPoint->SpinBox_DZ->SetValue(0.0); step = 0.1; - GroupOnCurve->SpinBox_DX->RangeStepAndValidator(0., 1., step, 3); + GroupOnCurve->SpinBox_DX->RangeStepAndValidator(0., 1., step, DBL_DIGITS_DISPLAY); GroupOnCurve->SpinBox_DX->SetValue( 0.5 ); /* signals and slots connections */ diff --git a/src/DlgRef/DlgRef_SpinBox.cxx b/src/DlgRef/DlgRef_SpinBox.cxx index 8a7ad7931..35bec55ba 100644 --- a/src/DlgRef/DlgRef_SpinBox.cxx +++ b/src/DlgRef/DlgRef_SpinBox.cxx @@ -102,3 +102,28 @@ void DlgRef_SpinBox::RangeStepAndValidator(double min, double max,double step, 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; +} diff --git a/src/DlgRef/DlgRef_SpinBox.h b/src/DlgRef/DlgRef_SpinBox.h index 9cc039d45..b45f5cee1 100644 --- a/src/DlgRef/DlgRef_SpinBox.h +++ b/src/DlgRef/DlgRef_SpinBox.h @@ -30,11 +30,7 @@ #define GEOMSPINBOX_H #include "QtxDblSpinBox.h" -//#if defined WNT -//#include -//#else -//#define SALOME_WNT_EXPORT -//#endif + #if defined WNT && defined WIN32 && defined SALOME_WNT_EXPORTS #define DLGREF_WNT_EXPORT __declspec( dllexport ) #else @@ -44,6 +40,7 @@ #define COORD_MIN -1e+15 #define COORD_MAX +1e+15 #define MAX_NUMBER 100000 +#define DBL_DIGITS_DISPLAY 16 //================================================================================= // class : DlgRef_SpinBox @@ -62,10 +59,11 @@ public : void SetValue(double v); double GetValue(); QString GetString(); + + static QString PrintDoubleValue (double theValue, int Precision = DBL_DIGITS_DISPLAY); public slots: void SetStep(double newStep); - }; #endif // GEOMSPINBOX_H diff --git a/src/MeasureGUI/MeasureGUI_PointDlg.cxx b/src/MeasureGUI/MeasureGUI_PointDlg.cxx index 1a14cc347..92bf23fd7 100644 --- a/src/MeasureGUI/MeasureGUI_PointDlg.cxx +++ b/src/MeasureGUI/MeasureGUI_PointDlg.cxx @@ -29,7 +29,10 @@ #include "MeasureGUI_PointDlg.h" #include "GEOMBase.h" +#include "DlgRef_SpinBox.h" + #include "utilities.h" + #include "SUIT_Session.h" #include "SalomeApp_Application.h" #include "LightApp_SelectionMgr.h" @@ -189,9 +192,9 @@ void MeasureGUI_PointDlg::SelectionIntoArgument() { gp_Pnt aPnt = BRep_Tool::Pnt( aPoint ); mySelEdit->setText( aName ); - myX->setText( QString( "%1" ).arg( aPnt.X() ) ); - myY->setText( QString( "%1" ).arg( aPnt.Y() ) ); - myZ->setText( QString( "%1" ).arg( aPnt.Z() ) ); + myX->setText(DlgRef_SpinBox::PrintDoubleValue(aPnt.X())); + myY->setText(DlgRef_SpinBox::PrintDoubleValue(aPnt.Y())); + myZ->setText(DlgRef_SpinBox::PrintDoubleValue(aPnt.Z())); } } catch( ... )