NPAL16123: EDF435: 3 significant digits in Point Creation dialog.

This commit is contained in:
jfa 2007-06-07 09:10:04 +00:00
parent 97fc7b1c06
commit eb3ecf9eba
4 changed files with 42 additions and 16 deletions

View File

@ -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 */

View File

@ -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;
}

View File

@ -30,11 +30,7 @@
#define GEOMSPINBOX_H
#include "QtxDblSpinBox.h"
//#if defined WNT
//#include <SALOME_WNT.hxx>
//#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

View File

@ -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( ... )