X-Git-Url: http://git.salome-platform.org/gitweb/?p=modules%2Fsmesh.git;a=blobdiff_plain;f=src%2FSMESHGUI%2FSMESHGUI_SpinBox.cxx;h=c90cbda018cc98b80562ab3bfaff0c2dc18b5d88;hp=1b30cb08a33e0ede5f9b3e82e26a9a84c0bd187a;hb=251f8c052dd12dd29922210dc901b295fe999a0e;hpb=0635c9fc80f67d1e5dc0e94ec85f487286a92070 diff --git a/src/SMESHGUI/SMESHGUI_SpinBox.cxx b/src/SMESHGUI/SMESHGUI_SpinBox.cxx index 1b30cb08a..c90cbda01 100644 --- a/src/SMESHGUI/SMESHGUI_SpinBox.cxx +++ b/src/SMESHGUI/SMESHGUI_SpinBox.cxx @@ -1,24 +1,25 @@ -// Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE +// Copyright (C) 2007-2015 CEA/DEN, EDF R&D, OPEN CASCADE // -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS // -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. // -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. // -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// You should have received a copy of the GNU Lesser General Public +// 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.salome-platform.org/ or email : webmaster.salome@opencascade.com +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // + // SMESH SMESHGUI : GUI for SMESH component // File : SMESHGUI_SpinBox.cxx // Author : Lucien PIGNOLONI, Open CASCADE S.A.S. @@ -26,9 +27,12 @@ // #include "SMESHGUI_SpinBox.h" +#include +#include + // Qt includes -#include #include +#include //================================================================================= // class : SMESHGUI_SpinBox() @@ -62,7 +66,7 @@ void SMESHGUI_SpinBox::SetStep( double newStep ) //================================================================================= void SMESHGUI_SpinBox::SetValue( double v ) { - setValue(v); + setValue(valueFromText(textFromValue(v))); editor()->setCursorPosition( 0 ); } @@ -93,28 +97,29 @@ QLineEdit* SMESHGUI_SpinBox::editor() const return SalomeApp_DoubleSpinBox::lineEdit(); } -//================================================================================= -// function : validator() -// purpose : returns validator -//================================================================================= -QDoubleValidator* SMESHGUI_SpinBox::validator() const -{ - return (QDoubleValidator*)editor()->validator(); -} - //================================================================================= // function : RangeStepAndValidator() // purpose : //================================================================================= void SMESHGUI_SpinBox::RangeStepAndValidator( double min, - double max, - double step, - unsigned short precision ) + double max, + double step, + const char* quantity ) { - setPrecision(precision*(-1)); // PAL8769. Minus is for using 'g' double->string conversion specifier, - // see QtxDoubleSpinBox::mapValueToText( double v ) - setDecimals(32); + // Obtain precision from preferences + SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr(); + int precision = resMgr->integerValue( "SMESH", quantity, -3 ); + + setPrecision(precision); // PAL8769. Minus is for using 'g' double->string conversion specifier, + // see QtxDoubleSpinBox::mapValueToText( double v ) + // san: this can be achieved using preferences + setDecimals( 20 ); // qAbs(precision) setRange(min, max); setSingleStep( step ); setDefaultValue( min ); + + // Add a hint for the user saying how to tune precision + QString userPropName = QObject::tr( QString( "SMESH_PREF_%1" ).arg( quantity ).toLatin1().constData() ); + setProperty( "validity_tune_hint", + QVariant( QObject::tr( "SMESH_PRECISION_HINT" ).arg( userPropName ) ) ); }