Salome HOME
Integration of PAL/SALOME V2.1.0c from OCC
[modules/smesh.git] / src / SMESHGUI / SMESHGUI_aParameter.cxx
1 //  SMESH SMESHGUI : GUI for SMESH component
2 //
3 //  Copyright (C) 2003  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 //  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS 
5 // 
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. 
10 // 
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. 
15 // 
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 
19 // 
20 //  See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org 
21 //
22 //
23 //
24 //  File   : SMESHGUI_aParameter.cxx
25 //  Module : SMESH
26 //  $Header$
27
28 #include "SMESHGUI_aParameter.h"
29   
30 #include <qspinbox.h>
31 #include <qvalidator.h>
32 #include "QAD_SpinBoxDbl.h"
33
34 SMESHGUI_aParameter::~SMESHGUI_aParameter() {}
35
36 //=================================================================================
37 // class    : SMESHGUI_intParameter
38 // purpose  :
39 //=================================================================================
40 SMESHGUI_intParameter::SMESHGUI_intParameter(const int      theInitValue,
41                                              const QString& theLabel,
42                                              const int      theBottom,   
43                                              const int      theTop)
44      :SMESHGUI_aParameter(theLabel),
45        _top(theTop), _bottom(theBottom), _initValue( theInitValue )
46 {
47 }
48 SMESHGUI_aParameter::Type SMESHGUI_intParameter::GetType() const
49 {
50   return SMESHGUI_aParameter::INT;
51 }
52 bool SMESHGUI_intParameter::GetNewInt( int & theValue ) const
53 {
54   theValue = _newValue;
55   return _newValue != _initValue;
56 }
57 bool SMESHGUI_intParameter::GetNewDouble( double & Value ) const
58 {
59   return false;
60 }
61 void SMESHGUI_intParameter::InitializeWidget( QWidget* theQWidget) const
62 {
63   QSpinBox * aSpin = dynamic_cast< QSpinBox *>( theQWidget );
64   if ( aSpin ) {
65     aSpin->setMinValue( _bottom );
66     aSpin->setMaxValue( _top );
67     aSpin->setValue( _initValue );
68   }
69 }
70 void SMESHGUI_intParameter::TakeValue( QWidget* theQWidget)
71 {
72   QSpinBox * aSpin = dynamic_cast< QSpinBox *>( theQWidget );
73   if ( aSpin )
74     _newValue = aSpin->value();
75 }
76 //=================================================================================
77 // class    : SMESHGUI_doubleParameter
78 // purpose  :
79 //=================================================================================
80 SMESHGUI_doubleParameter::SMESHGUI_doubleParameter(const double   theInitValue,
81                                                    const QString& theLabel,
82                                                    const double   theBottom,   
83                                                    const double   theTop,
84                                                    const double   theStep,
85                                                    const int      theDecimals)
86      :SMESHGUI_aParameter( theLabel ),
87        _top( theTop ), _bottom( theBottom ), _step( theStep ),
88        _initValue( theInitValue ), _decimals( theDecimals )
89 {
90 }
91 SMESHGUI_aParameter::Type SMESHGUI_doubleParameter::GetType() const
92 {
93   return SMESHGUI_aParameter::DOUBLE;
94 }
95 bool SMESHGUI_doubleParameter::GetNewInt( int & theValue ) const
96 {
97   return false;
98 }
99 bool SMESHGUI_doubleParameter::GetNewDouble( double & Value ) const
100 {
101   Value = _newValue;
102   return _newValue != _initValue;
103 }
104 void SMESHGUI_doubleParameter::InitializeWidget( QWidget* theQWidget) const
105 {
106   QAD_SpinBoxDbl * aSpin = dynamic_cast< QAD_SpinBoxDbl *>( theQWidget );
107   if ( aSpin ) {
108     aSpin->setRange( _bottom, _top );
109     ((QDoubleValidator*)(aSpin->validator()))->setRange( _bottom, _top, _decimals );
110     aSpin->setValue( _initValue );
111     aSpin->setLineStep( _step );
112   }
113 }
114 void SMESHGUI_doubleParameter::TakeValue( QWidget* theQWidget)
115 {
116   QAD_SpinBoxDbl * aSpin = dynamic_cast< QAD_SpinBoxDbl *>( theQWidget );
117   if ( aSpin )
118     _newValue = aSpin->value();
119 }