X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FModuleBase%2FModuleBase_ParamSpinBox.h;h=591d0cfd970658fa981a8ffc0f6a47ad69d3c117;hb=752c9e02e6aa8ced24e9b53097cb42540d5e6a08;hp=5945dcbd84250337d40c7bbf99da9105ddfac857;hpb=150ef68b3ea2df3c2130a4f5ea8128ddb5c76048;p=modules%2Fshaper.git diff --git a/src/ModuleBase/ModuleBase_ParamSpinBox.h b/src/ModuleBase/ModuleBase_ParamSpinBox.h index 5945dcbd8..591d0cfd9 100644 --- a/src/ModuleBase/ModuleBase_ParamSpinBox.h +++ b/src/ModuleBase/ModuleBase_ParamSpinBox.h @@ -8,6 +8,10 @@ #include +/** +* \ingroup GUI +* An extension of a double spin box which let to use parameters and expressions for value definition +*/ class MODULEBASE_EXPORT ModuleBase_ParamSpinBox : public ModuleBase_DoubleSpinBox { Q_OBJECT @@ -15,56 +19,69 @@ class MODULEBASE_EXPORT ModuleBase_ParamSpinBox : public ModuleBase_DoubleSpinBo enum State { Invalid = 0, NoVariable, Incompatible, Acceptable }; public: - explicit ModuleBase_ParamSpinBox(QWidget* theParent = 0, int thePrecision = 6); + /*! + \brief Constructor. + + Constructs a spin box with 0.0 as minimum value and 99.99 as maximum value, + a step value of 1.0 and a precision of 2 decimal places. + The value is initially set to 0.00. + + \param theParent a parent object + \param thePrecision a precision of values display + */ + explicit ModuleBase_ParamSpinBox( QWidget* theParent = 0, int thePrecision = -12 ); virtual ~ModuleBase_ParamSpinBox(); virtual void stepBy(int); virtual double valueFromText(const QString&) const; - virtual QString textFromValue(double) const; + virtual QString textFromValue (double value) const; virtual QValidator::State validate(QString&, int&) const; - virtual void setDefaultValue(const double); - virtual void setValue(double); virtual void setText(const QString&); + /// Set a flag about accepted variable void setAcceptVariables(const bool); + + /// Returns accepted variables flag bool isAcceptVariables() const; - bool hasVariables() const; -signals: - void textChanged(const QString&); + /// Returns True if the input value contains variable + bool hasVariable() const; protected: + /// Returns True if the given text contains variable + /// \param theText a text string + bool hasVariable(const QString& theText) const; + + /// Returns state of the control State isValid(const QString&, double&) const; - double defaultValue() const; + /// Returns True if the given value is within min and max of the control bool checkRange(const double) const; - bool findVariable(const QString&, double&) const; + /// Finds a variable by its name. Returns true in success + /// \param theName a name of variable + /// \param outValue an output value of the variable + bool findVariable(const QString& theName, double& outValue) const; protected: - virtual void keyPressEvent(QKeyEvent*); virtual void showEvent(QShowEvent*); protected slots: - void onEditingFinished(); + /// A slot called on text change void onTextChanged(const QString&); private: void connectSignalsAndSlots(); private: - double myDefaultValue; - - QString myCorrectValue; QString myTextValue; bool myAcceptVariables; - bool myHasVariables; }; #endif