SHAPER 9.16.0
Model_Expression.h
1// Copyright (C) 2014-2026 CEA, EDF
2//
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.
7//
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.
12//
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
16//
17// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18//
19
20#ifndef Model_Expression_H_
21#define Model_Expression_H_
22
23#include "Model.h"
24#include "ModelAPI_Expression.h"
25
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>
31
32#include <TDF_Label.hxx>
33
39{
40 public:
42 MODEL_EXPORT virtual void setText(const std::wstring& theText);
43
45 MODEL_EXPORT virtual std::wstring text() const;
46
48 MODEL_EXPORT virtual void setError(const std::string& theError);
49
51 MODEL_EXPORT virtual std::string error();
52
54 MODEL_EXPORT virtual void setUsedParameters(const std::set<std::wstring>& theUsedParameters);
55
57 MODEL_EXPORT virtual std::set<std::wstring> usedParameters() const;
58
59 protected:
61 Model_Expression(TDF_Label& theLabel);
62
63 Handle_TDataStd_Name myText;
64 Handle_TDataStd_Comment myError;
65 Handle_TDataStd_ExtStringList myUsedParameters;
66 TDF_Label myLab;
67};
68
69
75 public Model_Expression, // implementation inheritance
77{
78 public:
80 MODEL_EXPORT virtual void setText(const std::wstring& theText) {
82 };
83
85 MODEL_EXPORT virtual std::wstring text() const {
87 };
88
90 MODEL_EXPORT virtual void setError(const std::string& theError) {
92 };
93
95 MODEL_EXPORT virtual std::string error() {
97 };
98
100 MODEL_EXPORT virtual void setUsedParameters(const std::set<std::wstring>& theUsedParameters) {
101 Model_Expression::setUsedParameters(theUsedParameters);
102 };
103
105 MODEL_EXPORT virtual std::set<std::wstring> usedParameters() const {
107 };
108
110 MODEL_EXPORT virtual void setValue(const double theValue);
111
113 MODEL_EXPORT virtual double value();
114
116 MODEL_EXPORT virtual void setInvalid(const bool theFlag);
117
119 MODEL_EXPORT virtual bool isInvalid();
120
121 protected:
123 Model_ExpressionDouble(TDF_Label& theLabel);
125 virtual void reinit();
126
127 friend class Model_AttributeDouble;
128 friend class Model_Data;
129
130 private:
131 Handle_TDataStd_Real myReal;
132};
133
134
140 public Model_Expression, // implementation inheritance
142{
143 public:
145 MODEL_EXPORT virtual void setText(const std::wstring& theText) {
147 };
148
150 MODEL_EXPORT virtual std::wstring text() const {
151 return Model_Expression::text();
152 };
153
155 MODEL_EXPORT virtual void setError(const std::string& theError) {
157 };
158
160 MODEL_EXPORT virtual std::string error() {
162 };
163
165 MODEL_EXPORT virtual void setUsedParameters(const std::set<std::wstring>& theUsedParameters) {
166 Model_Expression::setUsedParameters(theUsedParameters);
167 };
168
170 MODEL_EXPORT virtual std::set<std::wstring> usedParameters() const {
172 };
173
175 MODEL_EXPORT virtual void setValue(const int theValue);
176
178 MODEL_EXPORT virtual int value();
179
181 MODEL_EXPORT virtual void setInvalid(const bool theFlag);
182
184 MODEL_EXPORT virtual bool isInvalid();
185
186 protected:
188 Model_ExpressionInteger(TDF_Label& theLabel);
190 virtual void reinit();
191
192 friend class Model_AttributeInteger;
193
194 private:
195 Handle_TDataStd_Integer myInteger;
196};
197
198#endif // Model_Expression_H_
Expression for calculated double values.
Definition: ModelAPI_Expression.h:101
Expression for calculated integer values.
Definition: ModelAPI_Expression.h:122
Expression for calculated values.
Definition: ModelAPI_Expression.h:34
Attribute that contains real value with double precision.
Definition: Model_AttributeDouble.h:36
Attribute that contains integer.
Definition: Model_AttributeInteger.h:36
General object of the application that allows to get/set attributes from the document and compute res...
Definition: Model_Data.h:62
Implementation of ModelAPI_ExpressionDouble.
Definition: Model_Expression.h:77
virtual void reinit()
Reinitializes the internal state of the attribute (may be needed on undo/redo, abort,...
Definition: Model_Expression.cpp:101
virtual std::wstring text() const
Returns the text of this Expression.
Definition: Model_Expression.h:85
virtual void setError(const std::string &theError)
Allows to set expression (text) error (by the parameters listener)
Definition: Model_Expression.h:90
virtual bool isInvalid()
Returns true if text is invalid.
Definition: Model_Expression.cpp:136
Model_ExpressionDouble(TDF_Label &theLabel)
Initializes attributes.
Definition: Model_Expression.cpp:94
virtual double value()
Returns the double value.
Definition: Model_Expression.cpp:120
virtual std::string error()
Returns an expression error.
Definition: Model_Expression.h:95
virtual void setText(const std::wstring &theText)
Sets the text of this Expression.
Definition: Model_Expression.h:80
virtual void setValue(const double theValue)
Defines the double value.
Definition: Model_Expression.cpp:110
virtual void setUsedParameters(const std::set< std::wstring > &theUsedParameters)
Defines the used parameters (by the parameters listener)
Definition: Model_Expression.h:100
virtual std::set< std::wstring > usedParameters() const
Returns the used parameters.
Definition: Model_Expression.h:105
virtual void setInvalid(const bool theFlag)
Allows to set expression (text) as invalid (by the parameters listener)
Definition: Model_Expression.cpp:127
Implementation of ModelAPI_ExpressionInteger.
Definition: Model_Expression.h:142
virtual void reinit()
Reinitializes the internal state of the attribute (may be needed on undo/redo, abort,...
Definition: Model_Expression.cpp:149
virtual bool isInvalid()
Returns true if text is invalid.
Definition: Model_Expression.cpp:184
virtual std::string error()
Returns an expression error.
Definition: Model_Expression.h:160
virtual void setValue(const int theValue)
Defines the integer value.
Definition: Model_Expression.cpp:158
virtual void setError(const std::string &theError)
Allows to set expression (text) error (by the parameters listener)
Definition: Model_Expression.h:155
virtual std::set< std::wstring > usedParameters() const
Returns the used parameters.
Definition: Model_Expression.h:170
Model_ExpressionInteger(TDF_Label &theLabel)
Initializes attributes.
Definition: Model_Expression.cpp:142
virtual std::wstring text() const
Returns the text of this Expression.
Definition: Model_Expression.h:150
virtual void setText(const std::wstring &theText)
Sets the text of this Expression.
Definition: Model_Expression.h:145
virtual void setUsedParameters(const std::set< std::wstring > &theUsedParameters)
Defines the used parameters (by the parameters listener)
Definition: Model_Expression.h:165
virtual int value()
Returns the integer value.
Definition: Model_Expression.cpp:168
virtual void setInvalid(const bool theFlag)
Allows to set expression (text) as invalid (by the parameters listener)
Definition: Model_Expression.cpp:175
Implementation of ModelAPI_Expression.
Definition: Model_Expression.h:39
Handle_TDataStd_Name myText
Text representation of the attribute (may differ for parameters)
Definition: Model_Expression.h:63
virtual void setError(const std::string &theError)
Allows to set expression (text) error (by the parameters listener)
Definition: Model_Expression.cpp:65
virtual std::wstring text() const
Returns the text of this Expression.
Definition: Model_Expression.cpp:60
Handle_TDataStd_ExtStringList myUsedParameters
Parameters used in expression.
Definition: Model_Expression.h:65
Model_Expression(TDF_Label &theLabel)
Initializes attributes.
Definition: Model_Expression.cpp:37
TDF_Label myLab
if attribute is not initialized, store label here
Definition: Model_Expression.h:66
Handle_TDataStd_Comment myError
Error of expression of the text attribute.
Definition: Model_Expression.h:64
virtual std::set< std::wstring > usedParameters() const
Returns the used parameters.
Definition: Model_Expression.cpp:84
virtual void setText(const std::wstring &theText)
Sets the text of this Expression.
Definition: Model_Expression.cpp:50
virtual void setUsedParameters(const std::set< std::wstring > &theUsedParameters)
Defines the used parameters (by the parameters listener)
Definition: Model_Expression.cpp:76
virtual std::string error()
Returns an expression error.
Definition: Model_Expression.cpp:71