1 // Copyright (C) 2009-2013 CEA/DEN, EDF R&D
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License.
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 // Lesser General Public License for more details.
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 #include "MyDlgRef.hxx"
24 //////////////////////////////////////////
26 //////////////////////////////////////////
28 MyDlgRef_1Sel2Spin::MyDlgRef_1Sel2Spin( QWidget* parent, Qt::WindowFlags f )
29 : QWidget( parent, f )
34 MyDlgRef_1Sel2Spin::~MyDlgRef_1Sel2Spin()
38 //////////////////////////////////////////
40 //////////////////////////////////////////
42 MyDlgRef_1Sel3Spin::MyDlgRef_1Sel3Spin( QWidget* parent, Qt::WindowFlags f )
43 : QWidget( parent, f )
48 MyDlgRef_1Sel3Spin::~MyDlgRef_1Sel3Spin()
52 //////////////////////////////////////////
54 //////////////////////////////////////////
56 MyDlgRef_2Sel1Spin::MyDlgRef_2Sel1Spin( QWidget* parent, Qt::WindowFlags f )
57 : QWidget( parent, f )
62 MyDlgRef_2Sel1Spin::~MyDlgRef_2Sel1Spin()
66 //////////////////////////////////////////
68 //////////////////////////////////////////
70 MyDlgRef_2Sel::MyDlgRef_2Sel( QWidget* parent, Qt::WindowFlags f )
71 : QWidget( parent, f )
76 MyDlgRef_2Sel::~MyDlgRef_2Sel()
80 //////////////////////////////////////////
82 //////////////////////////////////////////
84 MyDlgRef_3Spin::MyDlgRef_3Spin( QWidget* parent, Qt::WindowFlags f )
85 : QWidget( parent, f )
90 MyDlgRef_3Spin::~MyDlgRef_3Spin()
94 //////////////////////////////////////////
96 //////////////////////////////////////////
98 MyDlgRef_Skeleton::MyDlgRef_Skeleton( QWidget* parent, Qt::WindowFlags f )
99 : QWidget( parent, f )
104 MyDlgRef_Skeleton::~MyDlgRef_Skeleton()
108 //////////////////////////////////////////
110 //////////////////////////////////////////
112 QString MyDlgRef::PrintDoubleValue( double theValue, int thePrecision )
114 const double prec = 1e-12;
116 if ( qAbs(theValue) < prec )
119 QString aRes = QLocale().toString( theValue, thePrecision >= 0 ? 'f' : 'g', qAbs( thePrecision ) );
123 while ( p < thePrecision ) {
124 QString aRes = QLocale().toString( theValue, thePrecision >= 0 ? 'f' : 'g', qAbs( p++ ) );
125 double v = aRes.toDouble();
126 double err = qAbs( theValue - v );
127 if ( err > 0 && err <= prec )
132 // remove trailing zeroes
134 QRegExp expre( QString( "(%1|%2)[+-]?[0-9]+$" ).arg( QLocale().exponential().toLower(),
135 QLocale().exponential().toUpper() ) );
137 int idx = aRes.indexOf( expre );
138 QString aResExp = "";
140 aResExp = aRes.mid( idx );
141 aRes = aRes.left( idx );
144 if ( aRes.contains( QLocale().decimalPoint() ) )
145 aRes.remove( QRegExp( QString( "(\\%1|0)0*$" ).arg( QLocale().decimalPoint() ) ) );
147 return aRes == "-0" ? QString( "0" ) : aRes + aResExp;