1 // Copyright (C) 2014-2017 CEA/DEN, EDF R&D
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License, or (at your option) any later version.
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 // Lesser General Public License for more details.
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 // See http://www.salome-platform.org/ or
18 // email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com>
21 #ifndef ModuleBase_ParamIntSpinBox_H
22 #define ModuleBase_ParamIntSpinBox_H
24 #include "ModuleBase.h"
26 #include <ModuleBase_IntSpinBox.h>
32 * An extension of a double spin box which let to use parameters and expressions for value definition
34 class MODULEBASE_EXPORT ModuleBase_ParamIntSpinBox : public ModuleBase_IntSpinBox
38 enum State { Invalid = 0, NoVariable, Incompatible, Acceptable };
44 Constructs a spin box with 0.0 as minimum value and 99.99 as maximum value,
45 a step value of 1.0 and a precision of 2 decimal places.
46 The value is initially set to 0.00.
48 \param theParent a parent object
50 explicit ModuleBase_ParamIntSpinBox(QWidget* theParent = 0);
51 virtual ~ModuleBase_ParamIntSpinBox();
53 virtual void stepBy(int);
55 /// Convert Int value from text string
56 virtual int valueFromText(const QString&) const;
58 /// Convert text string from int value
59 virtual QString textFromValue(int) const;
61 /// Validate the value
62 virtual QValidator::State validate(QString&, int&) const;
64 /// Set current int value
65 virtual void setValue(int);
67 /// Set current text value
68 virtual void setText(const QString&);
70 /// Set a flag about accepted variable
71 void setAcceptVariables(const bool);
73 /// Returns accepted variables flag
74 bool isAcceptVariables() const;
76 /// Returns True if the input value contains variable
77 bool hasVariable() const;
80 /// Returns True if the given text contains variable
81 /// \param theText a text string
82 bool hasVariable(const QString& theText) const;
84 /// Returns state of the control
85 State isValid(const QString&, double&) const;
87 /// Returns True if the given value is within min and max of the control
88 bool checkRange(const double) const;
90 /// Finds a variable by its name. Returns true in success
91 /// \param theName a name of variable
92 /// \param outValue an output value of the variable
93 bool findVariable(const QString& theName, double& outValue) const;
96 virtual void showEvent(QShowEvent*);
99 /// A slot called on text change
100 void onTextChanged(const QString&);
103 void connectSignalsAndSlots();
108 bool myAcceptVariables;