1 // Copyright (C) 2014-2019 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 email : webmaster.salome@opencascade.com
20 #ifndef ModuleBase_ParamIntSpinBox_H
21 #define ModuleBase_ParamIntSpinBox_H
23 #include "ModuleBase.h"
25 #include <ModuleBase_IntSpinBox.h>
31 * An extension of a double spin box which let to use parameters and expressions for value definition
33 class MODULEBASE_EXPORT ModuleBase_ParamIntSpinBox : public ModuleBase_IntSpinBox
37 enum State { Invalid = 0, NoVariable, Incompatible, Acceptable };
43 Constructs a spin box with 0.0 as minimum value and 99.99 as maximum value,
44 a step value of 1.0 and a precision of 2 decimal places.
45 The value is initially set to 0.00.
47 \param theParent a parent object
49 explicit ModuleBase_ParamIntSpinBox(QWidget* theParent = 0);
50 virtual ~ModuleBase_ParamIntSpinBox();
52 virtual void stepBy(int);
54 /// Convert Int value from text string
55 virtual int valueFromText(const QString&) const;
57 /// Convert text string from int value
58 virtual QString textFromValue(int) const;
60 /// Validate the value
61 virtual QValidator::State validate(QString&, int&) const;
63 /// Set current int value
64 virtual void setValue(int);
66 /// Set current text value
67 virtual void setText(const QString&);
69 /// Set a flag about accepted variable
70 void setAcceptVariables(const bool);
72 /// Returns accepted variables flag
73 bool isAcceptVariables() const;
75 /// Returns True if the input value contains variable
76 bool hasVariable() const;
79 /// Returns True if the given text contains variable
80 /// \param theText a text string
81 bool hasVariable(const QString& theText) const;
83 /// Returns state of the control
84 State isValid(const QString&, double&) const;
86 /// Returns True if the given value is within min and max of the control
87 bool checkRange(const double) const;
89 /// Finds a variable by its name. Returns true in success
90 /// \param theName a name of variable
91 /// \param outValue an output value of the variable
92 bool findVariable(const QString& theName, double& outValue) const;
95 virtual void showEvent(QShowEvent*);
98 /// A slot called on text change
99 void onTextChanged(const QString&);
102 void connectSignalsAndSlots();
107 bool myAcceptVariables;