Salome HOME
Update from local sources
[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, TEXT };
50   virtual Type GetType() const = 0;
51   virtual bool GetNewInt( int & Value ) const = 0;
52   virtual bool GetNewDouble( double & Value ) const = 0;
53   virtual bool GetNewText( QString & Value ) const = 0;
54   virtual void InitializeWidget( QWidget* ) const = 0;
55   virtual void TakeValue( QWidget* ) = 0;
56
57   QString & Label() { return _label; }
58
59  private:
60   QString _label;
61 };
62
63 //=================================================================================
64 // class    : SMESHGUI_intParameter
65 // purpose  :
66 //=================================================================================
67 class SMESHGUI_intParameter: public SMESHGUI_aParameter
68
69 public:
70   SMESHGUI_intParameter(const int      initValue = 0,
71                         const QString& label     = QString::null,
72                         const int      bottom    = 0,
73                         const int      top       = 1000);
74   int & InitValue() { return _initValue; }
75   int & Top()       { return _top; }
76   int & Bottom()    { return _bottom; }
77   virtual Type GetType() const;
78   virtual bool GetNewInt( int & Value ) const;
79   virtual bool GetNewDouble( double & Value ) const;
80   virtual bool GetNewText( QString & Value ) const;
81   virtual void InitializeWidget( QWidget* ) const;
82   virtual void TakeValue( QWidget* );
83
84  private:
85   int _top, _bottom;
86   int _initValue, _newValue;
87 };
88
89 //=================================================================================
90 // class    : SMESHGUI_doubleParameter
91 // purpose  :
92 //=================================================================================
93 class SMESHGUI_doubleParameter: public SMESHGUI_aParameter
94
95 public:
96   SMESHGUI_doubleParameter(const double   initValue = 0.0,
97                            const QString& label     = QString::null,
98                            const double   bottom    = -1E6,
99                            const double   top       = +1E6,
100                            const double   step      = 1.0,
101                            const int      decimals  = 3);
102   double & InitValue() { return _initValue; }
103   double & Top()       { return _top; }
104   double & Bottom()    { return _bottom; }
105   double & Step()      { return _step; }
106   int    & Decimals()  { return _decimals; }
107   virtual Type GetType() const;
108   virtual bool GetNewInt( int & Value ) const;
109   virtual bool GetNewDouble( double & Value ) const;
110   virtual bool GetNewText( QString & Value ) const;
111   virtual void InitializeWidget( QWidget* ) const;
112   virtual void TakeValue( QWidget* );
113
114  private:
115   double _top, _bottom, _step;
116   double _initValue, _newValue;
117   int _decimals;
118 };
119
120
121 //=================================================================================
122 // class    : SMESHGUI_strParameter
123 // purpose  :
124 //=================================================================================
125 class SMESHGUI_strParameter: public SMESHGUI_aParameter
126
127 public:
128   SMESHGUI_strParameter(const QString& initValue = "",
129                         const QString& label     = QString::null);
130   QString InitValue() { return _initValue; }
131   virtual Type GetType() const;
132   virtual bool GetNewInt( int & Value ) const;
133   virtual bool GetNewDouble( double & Value ) const;
134   virtual bool GetNewText( QString & Value ) const;
135   virtual void InitializeWidget( QWidget* ) const;
136   virtual void TakeValue( QWidget* );
137
138  private:
139   QString _initValue, _newValue;
140 };
141
142 #endif // SMESHGUI_aParameter.h