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 "QAD_SpinBoxDbl.h"
36 #include <utilities.h>
38 SMESHGUI_aParameter::~SMESHGUI_aParameter() {}
40 //=================================================================================
41 // class : SMESHGUI_intParameter
43 //=================================================================================
44 SMESHGUI_intParameter::SMESHGUI_intParameter(const int theInitValue,
45 const QString& theLabel,
48 :SMESHGUI_aParameter(theLabel),
49 _top(theTop), _bottom(theBottom), _initValue( theInitValue )
52 SMESHGUI_aParameter::Type SMESHGUI_intParameter::GetType() const
54 return SMESHGUI_aParameter::INT;
56 bool SMESHGUI_intParameter::GetNewInt( int & theValue ) const
59 return _newValue != _initValue;
61 bool SMESHGUI_intParameter::GetNewDouble( double & Value ) const
65 bool SMESHGUI_intParameter::GetNewText( QString & Value ) const
69 void SMESHGUI_intParameter::InitializeWidget( QWidget* theQWidget) const
71 QSpinBox * aSpin = dynamic_cast< QSpinBox *>( theQWidget );
73 aSpin->setMinValue( _bottom );
74 aSpin->setMaxValue( _top );
75 aSpin->setValue( _initValue );
78 void SMESHGUI_intParameter::TakeValue( QWidget* theQWidget)
80 QSpinBox * aSpin = dynamic_cast< QSpinBox *>( theQWidget );
82 _newValue = aSpin->value();
84 //=================================================================================
85 // class : SMESHGUI_doubleParameter
87 //=================================================================================
88 SMESHGUI_doubleParameter::SMESHGUI_doubleParameter(const double theInitValue,
89 const QString& theLabel,
90 const double theBottom,
93 const int theDecimals)
94 :SMESHGUI_aParameter( theLabel ),
95 _top( theTop ), _bottom( theBottom ), _step( theStep ),
96 _initValue( theInitValue ), _decimals( theDecimals )
99 SMESHGUI_aParameter::Type SMESHGUI_doubleParameter::GetType() const
101 return SMESHGUI_aParameter::DOUBLE;
103 bool SMESHGUI_doubleParameter::GetNewInt( int & theValue ) const
107 bool SMESHGUI_doubleParameter::GetNewDouble( double & Value ) const
110 return _newValue != _initValue;
112 bool SMESHGUI_doubleParameter::GetNewText( QString & Value ) const
116 void SMESHGUI_doubleParameter::InitializeWidget( QWidget* theQWidget) const
118 QAD_SpinBoxDbl * aSpin = dynamic_cast< QAD_SpinBoxDbl *>( theQWidget );
120 aSpin->setRange( _bottom, _top );
121 ((QDoubleValidator*)(aSpin->validator()))->setRange( _bottom, _top, _decimals );
122 aSpin->setValue( _initValue );
123 aSpin->setLineStep( _step );
126 void SMESHGUI_doubleParameter::TakeValue( QWidget* theQWidget)
128 QAD_SpinBoxDbl * aSpin = dynamic_cast< QAD_SpinBoxDbl *>( theQWidget );
130 _newValue = aSpin->value();
133 //=================================================================================
134 // class : SMESHGUI_strParameter
136 //=================================================================================
137 SMESHGUI_strParameter::SMESHGUI_strParameter(const QString& theInitValue,
138 const QString& theLabel)
139 :SMESHGUI_aParameter(theLabel),
140 _initValue( theInitValue )
142 MESSAGE("SMESHGUI_strParameter::SMESHGUI_strParameter")
144 SMESHGUI_aParameter::Type SMESHGUI_strParameter::GetType() const
146 return SMESHGUI_aParameter::TEXT;
148 bool SMESHGUI_strParameter::GetNewInt( int & theValue ) const
152 bool SMESHGUI_strParameter::GetNewDouble( double & Value ) const
156 bool SMESHGUI_strParameter::GetNewText( QString & theValue ) const
158 theValue = _newValue;
159 return _newValue != _initValue;
161 void SMESHGUI_strParameter::InitializeWidget( QWidget* theQWidget) const
163 MESSAGE("SMESHGUI_strParameter::InitializeWidget")
164 QTextEdit * anEdit = dynamic_cast< QTextEdit *>( theQWidget );
166 anEdit->setText( _initValue );
169 void SMESHGUI_strParameter::TakeValue( QWidget* theQWidget)
171 MESSAGE("SMESHGUI_strParameter::TakeValue")
172 QTextEdit * anEdit = dynamic_cast< QTextEdit *>( theQWidget );
174 _newValue = anEdit->text();