Salome HOME
Update copyrights
[modules/shaper.git] / src / ParametersAPI / ParametersAPI_Parameter.h
1 // Copyright (C) 2014-2019  CEA/DEN, EDF R&D
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 SRC_PARAMETERSAPI_PARAMETERSAPI_PARAMETER_H_
21 #define SRC_PARAMETERSAPI_PARAMETERSAPI_PARAMETER_H_
22
23 //--------------------------------------------------------------------------------------
24 #include "ParametersAPI.h"
25
26 #include <ParametersPlugin_Parameter.h>
27
28 #include <ModelHighAPI_Interface.h>
29 #include <ModelHighAPI_Macro.h>
30 //--------------------------------------------------------------------------------------
31 class ModelHighAPI_Double;
32 //--------------------------------------------------------------------------------------
33 /**\class ParametersAPI_Parameter
34  * \ingroup CPPHighAPI
35  * \brief Interface for Parameter feature
36  */
37 class ParametersAPI_Parameter : public ModelHighAPI_Interface
38 {
39 public:
40   /// Constructor without values
41   PARAMETERSAPI_EXPORT
42   explicit ParametersAPI_Parameter(const std::shared_ptr<ModelAPI_Feature> & theFeature);
43   /// Constructor with values
44   PARAMETERSAPI_EXPORT
45   explicit ParametersAPI_Parameter(const  std::shared_ptr<ModelAPI_Feature> & theFeature,
46                                    const std::string & theName,
47                                    const std::string & theExpression,
48                                    const std::string & theComment = std::string());
49   /// Destructor
50   PARAMETERSAPI_EXPORT
51   virtual ~ParametersAPI_Parameter();
52
53   INTERFACE_3(ParametersPlugin_Parameter::ID(),
54               name, ParametersPlugin_Parameter::VARIABLE_ID(),
55               ModelAPI_AttributeString, /** Name */,
56               expression, ParametersPlugin_Parameter::EXPRESSION_ID(),
57               ModelAPI_AttributeString, /** Expression */,
58               comment, ParametersPlugin_Parameter::COMMENT_ID(),
59               ModelAPI_AttributeString, /** Comment */
60   )
61
62   /// Just sets the numeric value to the parameter (it resets the previous expression)
63   PARAMETERSAPI_EXPORT void setValue(const double theValue);
64   /// Returns the current value of the parameter: the expression result.
65   PARAMETERSAPI_EXPORT double value();
66
67   /// Dump wrapped feature
68   PARAMETERSAPI_EXPORT
69   virtual void dump(ModelHighAPI_Dumper& theDumper) const;
70
71 };
72
73 //! Pointer on Parameter object
74 typedef std::shared_ptr<ParametersAPI_Parameter> ParameterPtr;
75
76 /**\ingroup CPPHighAPI
77  * \brief Create Parameter feature
78  */
79 PARAMETERSAPI_EXPORT
80 ParameterPtr addParameter(const std::shared_ptr<ModelAPI_Document> & thePart,
81                           const std::string & theName,
82                           const std::string & theExpression,
83                           const std::string & theComment = std::string());
84
85 /**\ingroup CPPHighAPI
86  * \brief Remove Parameter feature and substitute it by the value in referred features
87  */
88 PARAMETERSAPI_EXPORT
89 void removeParameter(const std::shared_ptr<ModelAPI_Document> & thePart,
90                      const ParameterPtr & theParameter);
91
92 //--------------------------------------------------------------------------------------
93 //--------------------------------------------------------------------------------------
94 #endif /* SRC_PARAMETERSAPI_PARAMETERSAPI_PARAMETER_H_ */