1 // Copyright (C) 2014-2021 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 Model_Expression_H_
21 #define Model_Expression_H_
24 #include "ModelAPI_Expression.h"
26 #include <TDataStd_Comment.hxx>
27 #include <TDataStd_ExtStringList.hxx>
28 #include <TDataStd_Integer.hxx>
29 #include <TDataStd_Name.hxx>
30 #include <TDataStd_Real.hxx>
32 #include <TDF_Label.hxx>
34 /**\class Model_Expression
36 * \brief Implementation of ModelAPI_Expression.
38 class Model_Expression : public virtual ModelAPI_Expression
41 /// Sets the text of this Expression
42 MODEL_EXPORT virtual void setText(const std::wstring& theText);
44 /// Returns the text of this Expression
45 MODEL_EXPORT virtual std::wstring text() const;
47 /// Allows to set expression (text) error (by the parameters listener)
48 MODEL_EXPORT virtual void setError(const std::string& theError);
50 /// Returns an expression error
51 MODEL_EXPORT virtual std::string error();
53 /// Defines the used parameters (by the parameters listener)
54 MODEL_EXPORT virtual void setUsedParameters(const std::set<std::wstring>& theUsedParameters);
56 /// Returns the used parameters
57 MODEL_EXPORT virtual std::set<std::wstring> usedParameters() const;
60 /// Initializes attributes
61 Model_Expression(TDF_Label& theLabel);
63 Handle_TDataStd_Name myText; ///< Text representation of the attribute (may differ for parameters)
64 Handle_TDataStd_Comment myError; ///< Error of expression of the text attribute
65 Handle_TDataStd_ExtStringList myUsedParameters; ///< Parameters used in expression
66 TDF_Label myLab; ///< if attribute is not initialized, store label here
70 /**\class Model_ExpressionDouble
72 * \brief Implementation of ModelAPI_ExpressionDouble.
74 class Model_ExpressionDouble :
75 public Model_Expression, // implementation inheritance
76 public ModelAPI_ExpressionDouble
79 /// Sets the text of this Expression
80 MODEL_EXPORT virtual void setText(const std::wstring& theText) {
81 Model_Expression::setText(theText);
84 /// Returns the text of this Expression
85 MODEL_EXPORT virtual std::wstring text() const {
86 return Model_Expression::text();
89 /// Allows to set expression (text) error (by the parameters listener)
90 MODEL_EXPORT virtual void setError(const std::string& theError) {
91 Model_Expression::setError(theError);
94 /// Returns an expression error
95 MODEL_EXPORT virtual std::string error() {
96 return Model_Expression::error();
99 /// Defines the used parameters (by the parameters listener)
100 MODEL_EXPORT virtual void setUsedParameters(const std::set<std::wstring>& theUsedParameters) {
101 Model_Expression::setUsedParameters(theUsedParameters);
104 /// Returns the used parameters
105 MODEL_EXPORT virtual std::set<std::wstring> usedParameters() const {
106 return Model_Expression::usedParameters();
109 /// Defines the double value
110 MODEL_EXPORT virtual void setValue(const double theValue);
112 /// Returns the double value
113 MODEL_EXPORT virtual double value();
115 /// Allows to set expression (text) as invalid (by the parameters listener)
116 MODEL_EXPORT virtual void setInvalid(const bool theFlag);
118 /// Returns true if text is invalid
119 MODEL_EXPORT virtual bool isInvalid();
122 /// Initializes attributes
123 Model_ExpressionDouble(TDF_Label& theLabel);
124 /// Reinitializes the internal state of the attribute (may be needed on undo/redo, abort, etc)
125 virtual void reinit();
127 friend class Model_AttributeDouble;
128 friend class Model_Data;
131 Handle_TDataStd_Real myReal; ///< double is Real attribute
135 /**\class Model_ExpressionInteger
137 * \brief Implementation of ModelAPI_ExpressionInteger.
139 class Model_ExpressionInteger :
140 public Model_Expression, // implementation inheritance
141 public ModelAPI_ExpressionInteger
144 /// Sets the text of this Expression
145 MODEL_EXPORT virtual void setText(const std::wstring& theText) {
146 Model_Expression::setText(theText);
149 /// Returns the text of this Expression
150 MODEL_EXPORT virtual std::wstring text() const {
151 return Model_Expression::text();
154 /// Allows to set expression (text) error (by the parameters listener)
155 MODEL_EXPORT virtual void setError(const std::string& theError) {
156 Model_Expression::setError(theError);
159 /// Returns an expression error
160 MODEL_EXPORT virtual std::string error() {
161 return Model_Expression::error();
164 /// Defines the used parameters (by the parameters listener)
165 MODEL_EXPORT virtual void setUsedParameters(const std::set<std::wstring>& theUsedParameters) {
166 Model_Expression::setUsedParameters(theUsedParameters);
169 /// Returns the used parameters
170 MODEL_EXPORT virtual std::set<std::wstring> usedParameters() const {
171 return Model_Expression::usedParameters();
174 /// Defines the integer value
175 MODEL_EXPORT virtual void setValue(const int theValue);
177 /// Returns the integer value
178 MODEL_EXPORT virtual int value();
180 /// Allows to set expression (text) as invalid (by the parameters listener)
181 MODEL_EXPORT virtual void setInvalid(const bool theFlag);
183 /// Returns true if text is invalid
184 MODEL_EXPORT virtual bool isInvalid();
187 /// Initializes attributes
188 Model_ExpressionInteger(TDF_Label& theLabel);
189 /// Reinitializes the internal state of the attribute (may be needed on undo/redo, abort, etc)
190 virtual void reinit();
192 friend class Model_AttributeInteger;
195 Handle_TDataStd_Integer myInteger;
198 #endif // Model_Expression_H_