Salome HOME
dd392f68462ca4a051d210799f5c9c9e0c265090
[modules/smesh.git] / src / SMESHGUI / SMESHGUI_aParameter.h
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.h
25 //  Module : SMESH
26 //  $Header$
27
28 #ifndef SMESHGUI_aParameter_H
29 #define SMESHGUI_aParameter_H
30
31 #include <boost/shared_ptr.hpp>
32 #include <qstring.h>
33
34 class QWidget;
35 class SMESHGUI_aParameter;
36
37 typedef boost::shared_ptr<SMESHGUI_aParameter> SMESHGUI_aParameterPtr;
38
39 //=================================================================================
40 // class    : SMESHGUI_aParameter
41 // purpose  :
42 //=================================================================================
43 class SMESHGUI_aParameter
44
45 public:
46   SMESHGUI_aParameter(const QString& label):_label(label) {}
47   virtual ~SMESHGUI_aParameter();
48
49   enum Type { INT, DOUBLE };
50   virtual Type GetType() const = 0;
51   virtual bool GetNewInt( int & Value ) const = 0;
52   virtual bool GetNewDouble( double & Value ) const = 0;
53   virtual void InitializeWidget( QWidget* ) const = 0;
54   virtual void TakeValue( QWidget* ) = 0;
55
56   QString & Label() { return _label; }
57
58  private:
59   QString _label;
60 };
61
62 //=================================================================================
63 // class    : SMESHGUI_intParameter
64 // purpose  :
65 //=================================================================================
66 class SMESHGUI_intParameter: public SMESHGUI_aParameter
67
68 public:
69   SMESHGUI_intParameter(const int      initValue = 0,
70                         const QString& label     = QString::null,
71                         const int      bottom    = 0,
72                         const int      top       = 1000);
73   int & InitValue() { return _initValue; }
74   int & Top()       { return _top; }
75   int & Bottom()    { return _bottom; }
76   virtual Type GetType() const;
77   virtual bool GetNewInt( int & Value ) const;
78   virtual bool GetNewDouble( double & Value ) const;
79   virtual void InitializeWidget( QWidget* ) const;
80   virtual void TakeValue( QWidget* );
81
82  private:
83   int _top, _bottom;
84   int _initValue, _newValue;
85 };
86
87 //=================================================================================
88 // class    : SMESHGUI_doubleParameter
89 // purpose  :
90 //=================================================================================
91 class SMESHGUI_doubleParameter: public SMESHGUI_aParameter
92
93 public:
94   SMESHGUI_doubleParameter(const double   initValue = 0.0,
95                            const QString& label     = QString::null,
96                            const double   bottom    = -1E6,
97                            const double   top       = +1E6,
98                            const double   step      = 1.0,
99                            const int      decimals  = 3);
100   double & InitValue() { return _initValue; }
101   double & Top()       { return _top; }
102   double & Bottom()    { return _bottom; }
103   double & Step()      { return _step; }
104   int    & Decimals()  { return _decimals; }
105   virtual Type GetType() const;
106   virtual bool GetNewInt( int & Value ) const;
107   virtual bool GetNewDouble( double & Value ) const;
108   virtual void InitializeWidget( QWidget* ) const;
109   virtual void TakeValue( QWidget* );
110
111  private:
112   double _top, _bottom, _step;
113   double _initValue, _newValue;
114   int _decimals;
115 };
116
117 #endif // SMESHGUI_aParameter.h