1 // SMESH SMESHGUI : GUI for SMESH component
3 // Copyright (C) 2003 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
24 // File : SMESHGUI_aParameter.cxx
28 #include "SMESHGUI_aParameter.h"
31 #include <qvalidator.h>
32 #include <qtextedit.h>
34 #include <QtxDblSpinBox.h>
36 SMESHGUI_aParameter::~SMESHGUI_aParameter() {}
38 //=================================================================================
39 // class : SMESHGUI_intParameter
41 //=================================================================================
42 SMESHGUI_intParameter::SMESHGUI_intParameter (const int theInitValue,
43 const QString& theLabel,
46 :SMESHGUI_aParameter(theLabel),
47 _top(theTop), _bottom(theBottom), _initValue(theInitValue)
50 SMESHGUI_aParameter::Type SMESHGUI_intParameter::GetType() const
52 return SMESHGUI_aParameter::INT;
54 bool SMESHGUI_intParameter::GetNewInt (int & theValue) const
57 return _newValue != _initValue;
59 bool SMESHGUI_intParameter::GetNewDouble (double & Value) const
63 bool SMESHGUI_intParameter::GetNewText (QString & Value) const
67 void SMESHGUI_intParameter::InitializeWidget (QWidget* theQWidget) const
69 QSpinBox * aSpin = dynamic_cast< QSpinBox *>(theQWidget);
71 aSpin->setMinValue(_bottom);
72 aSpin->setMaxValue(_top);
73 aSpin->setValue(_initValue);
76 void SMESHGUI_intParameter::TakeValue (QWidget* theQWidget)
78 QSpinBox * aSpin = dynamic_cast< QSpinBox *>(theQWidget);
80 _newValue = aSpin->value();
83 //=================================================================================
84 // class : SMESHGUI_doubleParameter
86 //=================================================================================
87 SMESHGUI_doubleParameter::SMESHGUI_doubleParameter (const double theInitValue,
88 const QString& theLabel,
89 const double theBottom,
92 const int theDecimals)
93 :SMESHGUI_aParameter(theLabel),
94 _top(theTop), _bottom(theBottom), _step(theStep),
95 _initValue(theInitValue), _decimals(theDecimals)
98 SMESHGUI_aParameter::Type SMESHGUI_doubleParameter::GetType() const
100 return SMESHGUI_aParameter::DOUBLE;
102 bool SMESHGUI_doubleParameter::GetNewInt (int & theValue) const
106 bool SMESHGUI_doubleParameter::GetNewDouble (double & Value) const
109 return _newValue != _initValue;
111 bool SMESHGUI_doubleParameter::GetNewText (QString & Value) const
115 void SMESHGUI_doubleParameter::InitializeWidget (QWidget* theQWidget) const
117 QtxDblSpinBox* aSpin = dynamic_cast<QtxDblSpinBox*>(theQWidget);
119 aSpin->setPrecision(_decimals);
121 aSpin->setDblPrecision(_bottom);
123 aSpin->setRange(_bottom, _top);
124 aSpin->setValue(_initValue);
125 aSpin->setLineStep(_step);
128 void SMESHGUI_doubleParameter::TakeValue (QWidget* theQWidget)
130 QtxDblSpinBox* aSpin = dynamic_cast<QtxDblSpinBox*>(theQWidget);
132 _newValue = aSpin->value();
135 //=================================================================================
136 // class : SMESHGUI_strParameter
138 //=================================================================================
139 SMESHGUI_strParameter::SMESHGUI_strParameter (const QString& theInitValue,
140 const QString& theLabel)
141 :SMESHGUI_aParameter(theLabel),
142 _initValue(theInitValue)
145 SMESHGUI_aParameter::Type SMESHGUI_strParameter::GetType() const
147 return SMESHGUI_aParameter::TEXT;
149 bool SMESHGUI_strParameter::GetNewInt (int & theValue) const
153 bool SMESHGUI_strParameter::GetNewDouble (double & Value) const
157 bool SMESHGUI_strParameter::GetNewText (QString & theValue) const
159 theValue = _newValue;
160 return _newValue != _initValue;
162 void SMESHGUI_strParameter::InitializeWidget (QWidget* theQWidget) const
164 QTextEdit * anEdit = dynamic_cast< QTextEdit *>(theQWidget);
166 anEdit->setText(_initValue);
169 void SMESHGUI_strParameter::TakeValue (QWidget* theQWidget)
171 QTextEdit * anEdit = dynamic_cast< QTextEdit *>(theQWidget);
173 _newValue = anEdit->text();