X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;ds=sidebyside;f=src%2FParametersPlugin%2FParametersPlugin_Validators.cpp;h=d0b00ca8e8bff0494247b5cd4af0956a2c650333;hb=5c95c92510111cb79b244390964240d966efb1c4;hp=90ded60313edf285607d299f0d0908c846d4bbd9;hpb=70a245439d9148ebde66aa98a00fcb7b01fb92bd;p=modules%2Fshaper.git diff --git a/src/ParametersPlugin/ParametersPlugin_Validators.cpp b/src/ParametersPlugin/ParametersPlugin_Validators.cpp index 90ded6031..d0b00ca8e 100644 --- a/src/ParametersPlugin/ParametersPlugin_Validators.cpp +++ b/src/ParametersPlugin/ParametersPlugin_Validators.cpp @@ -21,11 +21,19 @@ ParametersPlugin_VariableValidator::~ParametersPlugin_VariableValidator() } bool ParametersPlugin_VariableValidator::isValid(const AttributePtr& theAttribute, - const std::list& theArguments) const + const std::list& theArguments, + std::string& theError) const { AttributeStringPtr aStrAttr = std::dynamic_pointer_cast(theAttribute); - bool result = isVariable(aStrAttr->value()) && isUnique(theAttribute, aStrAttr->value()); - return result; + if (!isVariable(aStrAttr->value())) { + theError = "Incorrect variable name."; + return false; + } + if (!isUnique(theAttribute, aStrAttr->value())) { + theError = "Variable name is not unique."; + return false; + } + return true; } bool ParametersPlugin_VariableValidator::isVariable(const std::string& theString) const @@ -75,20 +83,26 @@ ParametersPlugin_ExpressionValidator::~ParametersPlugin_ExpressionValidator() } bool ParametersPlugin_ExpressionValidator::isValid(const AttributePtr& theAttribute, - const std::list& theArguments) const + const std::list& theArguments, + std::string& theError) const { FeaturePtr aFeature = std::dynamic_pointer_cast(theAttribute->owner()); ResultParameterPtr aParam = std::dynamic_pointer_cast(aFeature->firstResult()); AttributeStringPtr aStrAttr = - std::dynamic_pointer_cast(theAttribute); + std::dynamic_pointer_cast(theAttribute); bool isEmptyExpr = aStrAttr->value().empty(); - if(isEmptyExpr) + if(isEmptyExpr) { + theError = "Expression is empty."; return false; + } - if(!aParam.get()) + if(!aParam.get()) { + theError = "Result is empty."; return false; + } + theError = aFeature->error(); return aFeature->error().empty(); }