1 // Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
22 // SMESH SMESHGUI : GUI for SMESH component
23 // File : SMESHGUI_SpinBox.cxx
24 // Author : Lucien PIGNOLONI, Open CASCADE S.A.S.
27 #include "SMESHGUI_SpinBox.h"
29 #include <SUIT_Session.h>
30 #include <SUIT_ResourceMgr.h>
36 //=================================================================================
37 // class : SMESHGUI_SpinBox()
38 // purpose : constructor of specific widget accepting floats in double precision.
39 //=================================================================================
40 SMESHGUI_SpinBox::SMESHGUI_SpinBox( QWidget* parent )
41 : SalomeApp_DoubleSpinBox( parent )
45 //=================================================================================
46 // function : ~SMESHGUI_SpinBox()
47 // purpose : destructor
48 //=================================================================================
49 SMESHGUI_SpinBox::~SMESHGUI_SpinBox()
53 //=================================================================================
54 // function : SetStep() [SLOT]
56 //=================================================================================
57 void SMESHGUI_SpinBox::SetStep( double newStep )
59 setSingleStep( newStep );
62 //=================================================================================
63 // function : SetValue()
65 //=================================================================================
66 void SMESHGUI_SpinBox::SetValue( double v )
69 editor()->setCursorPosition( 0 );
72 //=================================================================================
73 // function : GetValue()
74 // purpose : returns a double
75 //=================================================================================
76 double SMESHGUI_SpinBox::GetValue() const
81 //=================================================================================
82 // function : GetString()
83 // purpose : returns a QString
84 //=================================================================================
85 QString SMESHGUI_SpinBox::GetString() const
90 //=================================================================================
91 // function : editor()
92 // purpose : returns editor
93 //=================================================================================
94 QLineEdit* SMESHGUI_SpinBox::editor() const
96 return SalomeApp_DoubleSpinBox::lineEdit();
99 //=================================================================================
100 // function : RangeStepAndValidator()
102 //=================================================================================
103 void SMESHGUI_SpinBox::RangeStepAndValidator( double min,
106 const char* quantity )
108 // Obtain precision from preferences
109 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
110 int precision = resMgr->integerValue( "SMESH", quantity, -3 );
112 setPrecision(precision); // PAL8769. Minus is for using 'g' double->string conversion specifier,
113 // see QtxDoubleSpinBox::mapValueToText( double v )
114 // san: this can be achieved using preferences
115 setDecimals(qAbs(precision));
117 setSingleStep( step );
118 setDefaultValue( min );
120 // Add a hint for the user saying how to tune precision
121 QString userPropName = QObject::tr( QString( "SMESH_PREF_%1" ).arg( quantity ).toLatin1().constData() );
122 setProperty( "validity_tune_hint",
123 QVariant( QObject::tr( "SMESH_PRECISION_HINT" ).arg( userPropName ) ) );