Salome HOME
Issue #910 - Impossible to set start point , end points for line manually
[modules/shaper.git] / src / ModuleBase / ModuleBase_ParamSpinBox.h
1
2 #ifndef ModuleBase_ParamSpinBox_H
3 #define ModuleBase_ParamSpinBox_H
4
5 #include "ModuleBase.h"
6
7 #include <ModuleBase_DoubleSpinBox.h>
8
9 #include <QValidator>
10
11 class MODULEBASE_EXPORT ModuleBase_ParamSpinBox : public ModuleBase_DoubleSpinBox
12 {
13   Q_OBJECT
14
15   enum State { Invalid = 0, NoVariable, Incompatible, Acceptable };
16
17 public:
18   explicit ModuleBase_ParamSpinBox( QWidget* theParent = 0, int thePrecision = 12 );
19   virtual ~ModuleBase_ParamSpinBox();
20
21   virtual void stepBy(int);
22
23   virtual double valueFromText(const QString&) const;
24   virtual QString textFromValue (double value) const;
25
26   virtual QValidator::State validate(QString&, int&) const;
27
28   virtual void setValue(double);
29
30   virtual void setText(const QString&);
31
32   void setAcceptVariables(const bool);
33   bool isAcceptVariables() const;
34   bool hasVariable() const;
35
36 //signals:
37   //void textChanged(const QString&);
38
39  protected:
40   bool hasVariable(const QString& theText) const;
41   State isValid(const QString&, double&) const;
42
43   bool checkRange(const double) const;
44
45   bool findVariable(const QString&, double&) const;
46
47  protected:
48   //virtual void keyPressEvent(QKeyEvent*);
49   virtual void showEvent(QShowEvent*);
50
51  protected slots:
52   void onTextChanged(const QString&);
53
54  private:
55   void connectSignalsAndSlots();
56
57  private:
58   QString myTextValue;
59
60   bool myAcceptVariables;
61 };
62
63 #endif