smesh/src/SMESHGUI/SMESHGUI_SpinBox.cxx

121 lines
4.3 KiB
C++
Raw Normal View History

2009-02-17 10:27:49 +05:00
// Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE
2003-07-10 19:18:22 +06:00
//
2009-02-17 10:27:49 +05:00
// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
2003-07-10 19:18:22 +06:00
//
2009-02-17 10:27:49 +05:00
// 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.
2003-07-10 19:18:22 +06:00
//
2009-02-17 10:27:49 +05:00
// 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
//
// 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.
// SMESH includes
2003-07-10 19:18:22 +06:00
//
2003-05-19 20:07:00 +06:00
#include "SMESHGUI_SpinBox.h"
2009-02-17 10:27:49 +05:00
// Qt includes
#include <QDoubleValidator>
#include <QLineEdit>
2004-12-01 15:48:31 +05:00
2003-05-19 20:07:00 +06:00
//=================================================================================
// class : SMESHGUI_SpinBox()
// purpose : constructor of specific widget accepting floats in double precision.
//=================================================================================
2009-02-17 10:27:49 +05:00
SMESHGUI_SpinBox::SMESHGUI_SpinBox( QWidget* parent )
: SalomeApp_DoubleSpinBox( parent )
2003-05-19 20:07:00 +06:00
{
}
//=================================================================================
2009-02-17 10:27:49 +05:00
// function : ~SMESHGUI_SpinBox()
// purpose : destructor
2003-05-19 20:07:00 +06:00
//=================================================================================
2009-02-17 10:27:49 +05:00
SMESHGUI_SpinBox::~SMESHGUI_SpinBox()
2003-05-19 20:07:00 +06:00
{
}
//=================================================================================
2009-02-17 10:27:49 +05:00
// function : SetStep() [SLOT]
// purpose :
2003-05-19 20:07:00 +06:00
//=================================================================================
2009-02-17 10:27:49 +05:00
void SMESHGUI_SpinBox::SetStep( double newStep )
2003-05-19 20:07:00 +06:00
{
2009-02-17 10:27:49 +05:00
setSingleStep( newStep );
2003-05-19 20:07:00 +06:00
}
//=================================================================================
// function : SetValue()
// purpose :
//=================================================================================
2009-02-17 10:27:49 +05:00
void SMESHGUI_SpinBox::SetValue( double v )
2003-05-19 20:07:00 +06:00
{
setValue(v);
editor()->setCursorPosition( 0 );
2003-05-19 20:07:00 +06:00
}
//=================================================================================
// function : GetValue()
// purpose : returns a double
//=================================================================================
2009-02-17 10:27:49 +05:00
double SMESHGUI_SpinBox::GetValue() const
2003-05-19 20:07:00 +06:00
{
return value();
}
//=================================================================================
// function : GetString()
// purpose : returns a QString
//=================================================================================
2009-02-17 10:27:49 +05:00
QString SMESHGUI_SpinBox::GetString() const
2003-05-19 20:07:00 +06:00
{
return cleanText();
}
2009-02-17 10:27:49 +05:00
//=================================================================================
// function : editor()
// purpose : returns editor
//=================================================================================
QLineEdit* SMESHGUI_SpinBox::editor() const
{
return SalomeApp_DoubleSpinBox::lineEdit();
}
//=================================================================================
// function : validator()
// purpose : returns validator
//=================================================================================
QDoubleValidator* SMESHGUI_SpinBox::validator() const
{
return (QDoubleValidator*)editor()->validator();
}
2003-05-19 20:07:00 +06:00
//=================================================================================
// function : RangeStepAndValidator()
// purpose :
//=================================================================================
2009-02-17 10:27:49 +05:00
void SMESHGUI_SpinBox::RangeStepAndValidator( double min,
double max,
double step,
unsigned short precision )
2003-05-19 20:07:00 +06:00
{
2009-02-17 10:27:49 +05:00
setPrecision(precision*(-1)); // PAL8769. Minus is for using 'g' double->string conversion specifier,
// see QtxDoubleSpinBox::mapValueToText( double v )
setDecimals(32);
setRange(min, max);
2009-02-17 10:27:49 +05:00
setSingleStep( step );
setDefaultValue( min );
2003-05-19 20:07:00 +06:00
}