+void ParametersPlugin_EvalListener::renameInDependents(std::shared_ptr<ModelAPI_ResultParameter> theResultParameter,
+ const std::string& theOldName,
+ const std::string& theNewName)
+{
+ std::set<std::shared_ptr<ModelAPI_Attribute> > anAttributes =
+ theResultParameter->data()->refsToMe();
+ std::set<std::shared_ptr<ModelAPI_Attribute> >::const_iterator anAttributeIt =
+ anAttributes.cbegin();
+ for (; anAttributeIt != anAttributes.cend(); ++anAttributeIt) {
+ const AttributePtr& anAttribute = *anAttributeIt;
+ if (anAttribute->attributeType() == ModelAPI_AttributeRefList::typeId()) {
+ std::shared_ptr<ParametersPlugin_Parameter> aParameter =
+ std::dynamic_pointer_cast<ParametersPlugin_Parameter>(
+ anAttribute->owner());
+ if (aParameter.get())
+ // Rename
+ renameInParameter(aParameter, theOldName, theNewName);
+ } else
+ // Rename
+ renameInAttribute(anAttribute, theOldName, theNewName);
+ }
+}
+
+bool isValidAttribute(const AttributePtr& theAttribute)
+{
+ std::string aValidator, anError;
+ return ModelAPI_Session::get()->validators()->validate(theAttribute, aValidator, anError);
+}
+
+void setParameterName(ResultParameterPtr theResultParameter, const std::string& theName)
+{
+ theResultParameter->data()->blockSendAttributeUpdated(true);
+ theResultParameter->data()->setName(theName);
+ theResultParameter->data()->blockSendAttributeUpdated(false);
+
+ std::shared_ptr<ParametersPlugin_Parameter> aParameter =
+ std::dynamic_pointer_cast<ParametersPlugin_Parameter>(
+ ModelAPI_Feature::feature(theResultParameter));
+
+ aParameter->data()->blockSendAttributeUpdated(true);
+ aParameter->data()->setName(theName);
+ aParameter->string(ParametersPlugin_Parameter::VARIABLE_ID())->setValue(theName);
+ aParameter->data()->blockSendAttributeUpdated(false);
+}
+