1 // Name : ParametersAPI_Parameter.cpp
5 // 16/06/16 - Sergey POKHODENKO - Creation of the file
7 //--------------------------------------------------------------------------------------
8 #include "ParametersAPI_Parameter.h"
9 //--------------------------------------------------------------------------------------
10 #include <ModelHighAPI_Dumper.h>
11 #include <ModelHighAPI_Tools.h>
12 //--------------------------------------------------------------------------------------
13 ParametersAPI_Parameter::ParametersAPI_Parameter(
14 const std::shared_ptr<ModelAPI_Feature> & theFeature)
15 : ModelHighAPI_Interface(theFeature)
20 ParametersAPI_Parameter::ParametersAPI_Parameter(
21 const std::shared_ptr<ModelAPI_Feature> & theFeature,
22 const std::string & theName,
23 const std::string & theExpression,
24 const std::string & theComment)
25 : ModelHighAPI_Interface(theFeature)
28 fillAttribute(theName, name());
29 fillAttribute(theExpression, expression());
30 fillAttribute(theComment, comment());
36 ParametersAPI_Parameter::~ParametersAPI_Parameter()
40 void ParametersAPI_Parameter::dump(ModelHighAPI_Dumper& theDumper) const
42 FeaturePtr aBase = feature();
43 const std::string& aDocName = theDumper.name(aBase->document());
44 const std::string& aParamName = theDumper.name(aBase);
46 AttributeStringPtr anExpr = aBase->string(ParametersPlugin_Parameter::EXPRESSION_ID());
47 AttributeStringPtr aComment = aBase->string(ParametersPlugin_Parameter::COMMENT_ID());
49 theDumper << "model.addParameter(" << aDocName << ", \"" << aParamName << "\", " << anExpr;
50 if (aComment->isInitialized() && !aComment->value().empty())
51 theDumper << ", " << aComment;
52 theDumper << ")" << std::endl;
55 //--------------------------------------------------------------------------------------
56 ParameterPtr addParameter(const std::shared_ptr<ModelAPI_Document> & thePart,
57 const std::string & theName,
58 const std::string & theExpression,
59 const std::string & theComment)
61 // TODO(spo): check that thePart is not empty
62 std::shared_ptr<ModelAPI_Feature> aFeature = thePart->addFeature(ParametersAPI_Parameter::ID());
63 return ParameterPtr(new ParametersAPI_Parameter(aFeature, theName, theExpression, theComment));