2004-12-01 15:48:31 +05:00
|
|
|
// SMESH SMESHGUI : GUI for SMESH component
|
|
|
|
//
|
|
|
|
// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
|
2005-06-07 19:22:20 +06:00
|
|
|
// 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 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
|
2004-12-01 15:48:31 +05:00
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
// File : SMESHGUI_aParameter.cxx
|
|
|
|
// Module : SMESH
|
|
|
|
// $Header$
|
|
|
|
|
|
|
|
#include "SMESHGUI_aParameter.h"
|
2005-06-07 19:22:20 +06:00
|
|
|
|
2004-12-01 15:48:31 +05:00
|
|
|
#include <qspinbox.h>
|
|
|
|
#include <qvalidator.h>
|
2005-01-28 13:57:30 +05:00
|
|
|
#include <qtextedit.h>
|
|
|
|
|
2005-06-07 19:22:20 +06:00
|
|
|
#include <QtxDblSpinBox.h>
|
2004-12-01 15:48:31 +05:00
|
|
|
|
|
|
|
SMESHGUI_aParameter::~SMESHGUI_aParameter() {}
|
|
|
|
|
|
|
|
//=================================================================================
|
|
|
|
// class : SMESHGUI_intParameter
|
|
|
|
// purpose :
|
|
|
|
//=================================================================================
|
2005-06-07 19:22:20 +06:00
|
|
|
SMESHGUI_intParameter::SMESHGUI_intParameter (const int theInitValue,
|
|
|
|
const QString& theLabel,
|
|
|
|
const int theBottom,
|
|
|
|
const int theTop)
|
2004-12-01 15:48:31 +05:00
|
|
|
:SMESHGUI_aParameter(theLabel),
|
2005-06-07 19:22:20 +06:00
|
|
|
_top(theTop), _bottom(theBottom), _initValue(theInitValue)
|
2004-12-01 15:48:31 +05:00
|
|
|
{
|
|
|
|
}
|
|
|
|
SMESHGUI_aParameter::Type SMESHGUI_intParameter::GetType() const
|
|
|
|
{
|
|
|
|
return SMESHGUI_aParameter::INT;
|
|
|
|
}
|
2005-06-07 19:22:20 +06:00
|
|
|
bool SMESHGUI_intParameter::GetNewInt (int & theValue) const
|
2004-12-01 15:48:31 +05:00
|
|
|
{
|
|
|
|
theValue = _newValue;
|
|
|
|
return _newValue != _initValue;
|
|
|
|
}
|
2005-06-07 19:22:20 +06:00
|
|
|
bool SMESHGUI_intParameter::GetNewDouble (double & Value) const
|
2004-12-01 15:48:31 +05:00
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
2005-06-07 19:22:20 +06:00
|
|
|
bool SMESHGUI_intParameter::GetNewText (QString & Value) const
|
2005-01-28 13:57:30 +05:00
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
2005-06-07 19:22:20 +06:00
|
|
|
void SMESHGUI_intParameter::InitializeWidget (QWidget* theQWidget) const
|
2004-12-01 15:48:31 +05:00
|
|
|
{
|
2005-06-07 19:22:20 +06:00
|
|
|
QSpinBox * aSpin = dynamic_cast< QSpinBox *>(theQWidget);
|
|
|
|
if (aSpin) {
|
|
|
|
aSpin->setMinValue(_bottom);
|
|
|
|
aSpin->setMaxValue(_top);
|
|
|
|
aSpin->setValue(_initValue);
|
2004-12-01 15:48:31 +05:00
|
|
|
}
|
|
|
|
}
|
2005-06-07 19:22:20 +06:00
|
|
|
void SMESHGUI_intParameter::TakeValue (QWidget* theQWidget)
|
2004-12-01 15:48:31 +05:00
|
|
|
{
|
2005-06-07 19:22:20 +06:00
|
|
|
QSpinBox * aSpin = dynamic_cast< QSpinBox *>(theQWidget);
|
|
|
|
if (aSpin)
|
2004-12-01 15:48:31 +05:00
|
|
|
_newValue = aSpin->value();
|
|
|
|
}
|
2005-06-07 19:22:20 +06:00
|
|
|
|
2004-12-01 15:48:31 +05:00
|
|
|
//=================================================================================
|
|
|
|
// class : SMESHGUI_doubleParameter
|
|
|
|
// purpose :
|
|
|
|
//=================================================================================
|
2005-06-07 19:22:20 +06:00
|
|
|
SMESHGUI_doubleParameter::SMESHGUI_doubleParameter (const double theInitValue,
|
|
|
|
const QString& theLabel,
|
|
|
|
const double theBottom,
|
|
|
|
const double theTop,
|
|
|
|
const double theStep,
|
|
|
|
const int theDecimals)
|
|
|
|
:SMESHGUI_aParameter(theLabel),
|
|
|
|
_top(theTop), _bottom(theBottom), _step(theStep),
|
|
|
|
_initValue(theInitValue), _decimals(theDecimals)
|
2004-12-01 15:48:31 +05:00
|
|
|
{
|
|
|
|
}
|
|
|
|
SMESHGUI_aParameter::Type SMESHGUI_doubleParameter::GetType() const
|
|
|
|
{
|
|
|
|
return SMESHGUI_aParameter::DOUBLE;
|
|
|
|
}
|
2005-06-07 19:22:20 +06:00
|
|
|
bool SMESHGUI_doubleParameter::GetNewInt (int & theValue) const
|
2004-12-01 15:48:31 +05:00
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
2005-06-07 19:22:20 +06:00
|
|
|
bool SMESHGUI_doubleParameter::GetNewDouble (double & Value) const
|
2004-12-01 15:48:31 +05:00
|
|
|
{
|
|
|
|
Value = _newValue;
|
|
|
|
return _newValue != _initValue;
|
|
|
|
}
|
2005-06-07 19:22:20 +06:00
|
|
|
bool SMESHGUI_doubleParameter::GetNewText (QString & Value) const
|
2005-01-28 13:57:30 +05:00
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
2005-06-07 19:22:20 +06:00
|
|
|
void SMESHGUI_doubleParameter::InitializeWidget (QWidget* theQWidget) const
|
|
|
|
{
|
|
|
|
QtxDblSpinBox* aSpin = dynamic_cast<QtxDblSpinBox*>(theQWidget);
|
|
|
|
if (aSpin) {
|
|
|
|
aSpin->setPrecision(_decimals);
|
|
|
|
#ifdef NEW_GUI
|
|
|
|
aSpin->setDblPrecision(_bottom);
|
|
|
|
#endif
|
|
|
|
aSpin->setRange(_bottom, _top);
|
|
|
|
aSpin->setValue(_initValue);
|
|
|
|
aSpin->setLineStep(_step);
|
2004-12-01 15:48:31 +05:00
|
|
|
}
|
|
|
|
}
|
2005-06-07 19:22:20 +06:00
|
|
|
void SMESHGUI_doubleParameter::TakeValue (QWidget* theQWidget)
|
2004-12-01 15:48:31 +05:00
|
|
|
{
|
2005-06-07 19:22:20 +06:00
|
|
|
QtxDblSpinBox* aSpin = dynamic_cast<QtxDblSpinBox*>(theQWidget);
|
|
|
|
if (aSpin)
|
2004-12-01 15:48:31 +05:00
|
|
|
_newValue = aSpin->value();
|
|
|
|
}
|
2005-01-28 13:57:30 +05:00
|
|
|
|
|
|
|
//=================================================================================
|
|
|
|
// class : SMESHGUI_strParameter
|
|
|
|
// purpose :
|
|
|
|
//=================================================================================
|
2005-06-07 19:22:20 +06:00
|
|
|
SMESHGUI_strParameter::SMESHGUI_strParameter (const QString& theInitValue,
|
|
|
|
const QString& theLabel)
|
2005-01-28 13:57:30 +05:00
|
|
|
:SMESHGUI_aParameter(theLabel),
|
2005-06-07 19:22:20 +06:00
|
|
|
_initValue(theInitValue)
|
2005-01-28 13:57:30 +05:00
|
|
|
{
|
|
|
|
}
|
|
|
|
SMESHGUI_aParameter::Type SMESHGUI_strParameter::GetType() const
|
|
|
|
{
|
|
|
|
return SMESHGUI_aParameter::TEXT;
|
|
|
|
}
|
2005-06-07 19:22:20 +06:00
|
|
|
bool SMESHGUI_strParameter::GetNewInt (int & theValue) const
|
2005-01-28 13:57:30 +05:00
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
2005-06-07 19:22:20 +06:00
|
|
|
bool SMESHGUI_strParameter::GetNewDouble (double & Value) const
|
2005-01-28 13:57:30 +05:00
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
2005-06-07 19:22:20 +06:00
|
|
|
bool SMESHGUI_strParameter::GetNewText (QString & theValue) const
|
2005-01-28 13:57:30 +05:00
|
|
|
{
|
|
|
|
theValue = _newValue;
|
|
|
|
return _newValue != _initValue;
|
|
|
|
}
|
2005-06-07 19:22:20 +06:00
|
|
|
void SMESHGUI_strParameter::InitializeWidget (QWidget* theQWidget) const
|
2005-01-28 13:57:30 +05:00
|
|
|
{
|
2005-06-07 19:22:20 +06:00
|
|
|
QTextEdit * anEdit = dynamic_cast< QTextEdit *>(theQWidget);
|
|
|
|
if (anEdit) {
|
|
|
|
anEdit->setText(_initValue);
|
2005-01-28 13:57:30 +05:00
|
|
|
}
|
|
|
|
}
|
2005-06-07 19:22:20 +06:00
|
|
|
void SMESHGUI_strParameter::TakeValue (QWidget* theQWidget)
|
2005-01-28 13:57:30 +05:00
|
|
|
{
|
2005-06-07 19:22:20 +06:00
|
|
|
QTextEdit * anEdit = dynamic_cast< QTextEdit *>(theQWidget);
|
|
|
|
if (anEdit)
|
2005-01-28 13:57:30 +05:00
|
|
|
_newValue = anEdit->text();
|
|
|
|
}
|