X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FGeomValidators%2FGeomValidators_Positive.cpp;h=344cfe08d76369b799e9f6e59cef947ae670e341;hb=71a74e7993bcab222f1bf8deed1d141cab81bdf5;hp=9d3fbf983cbb233da6fbd89d8ee71c3aae325a99;hpb=3d063c74ca0ff72184f77d74df198c3bf0730aff;p=modules%2Fshaper.git diff --git a/src/GeomValidators/GeomValidators_Positive.cpp b/src/GeomValidators/GeomValidators_Positive.cpp index 9d3fbf983..344cfe08d 100644 --- a/src/GeomValidators/GeomValidators_Positive.cpp +++ b/src/GeomValidators/GeomValidators_Positive.cpp @@ -21,14 +21,35 @@ GeomValidators_Positive::GeomValidators_Positive() aFactory->registerValidator("GeomValidators_Positive", this); } -bool GeomValidators_Positive::isValid( - const AttributePtr& theAttribute, const std::list& theArguments) const +bool GeomValidators_Positive::isValid(const AttributePtr& theAttribute, + const std::list& theArguments, + std::string& theError) const { - AttributeDoublePtr aDouble = - std::dynamic_pointer_cast(theAttribute); - if (aDouble.get()) - return aDouble->isInitialized() && aDouble->value() > 1.e-5; - AttributeIntegerPtr aInteger = - std::dynamic_pointer_cast(theAttribute); - return aInteger->isInitialized() && aInteger->value() > 0; + if (theAttribute->attributeType() == ModelAPI_AttributeDouble::typeId()) { + AttributeDoublePtr aDouble = + std::dynamic_pointer_cast(theAttribute); + if (!aDouble->isInitialized()) { + theError = "Double is not initialized."; + return false; + } + if (aDouble->value() <= 1.e-5) { + theError = "Double is not positive."; + return false; + } + } + + if (theAttribute->attributeType() == ModelAPI_AttributeInteger::typeId()) { + AttributeIntegerPtr aInteger = + std::dynamic_pointer_cast(theAttribute); + if (!aInteger->isInitialized()) { + theError = "Integer is not initialized."; + return false; + } + if (aInteger->value() <= 0) { + theError = "Integer is not positive."; + return false; + } + } + + return true; }