X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FGeomValidators%2FGeomValidators_Positive.cpp;h=6737f289aaba4e180b893edfb664971858f2c7ee;hb=3e6012473696e5fd94e3c8240e2e1eda8def1743;hp=344cfe08d76369b799e9f6e59cef947ae670e341;hpb=e074e769a363f00ed7e4fb1ddcb3d05081f84358;p=modules%2Fshaper.git diff --git a/src/GeomValidators/GeomValidators_Positive.cpp b/src/GeomValidators/GeomValidators_Positive.cpp index 344cfe08d..6737f289a 100644 --- a/src/GeomValidators/GeomValidators_Positive.cpp +++ b/src/GeomValidators/GeomValidators_Positive.cpp @@ -5,11 +5,16 @@ // Author: Mikhail PONIKAROV #include "GeomValidators_Positive.h" + +#include + #include #include #include #include +#include + /// Global instance for validators factory GeomValidators_Positive MY_POSITIVE_INSTANCE; @@ -21,10 +26,21 @@ GeomValidators_Positive::GeomValidators_Positive() aFactory->registerValidator("GeomValidators_Positive", this); } -bool GeomValidators_Positive::isValid(const AttributePtr& theAttribute, +bool GeomValidators_Positive::isValid(const AttributePtr& theAttribute, const std::list& theArguments, - std::string& theError) const + Events_InfoMessage& theError) const { + double aMinValue = 1.e-5; + if(theArguments.size() == 1) { + std::list::const_iterator anIt = theArguments.begin(); + char *aErr; + double aValue = strtod((*anIt).c_str(), &aErr); + if(*aErr == 0) { + // very probably ok + aMinValue = aValue; + } + } + if (theAttribute->attributeType() == ModelAPI_AttributeDouble::typeId()) { AttributeDoublePtr aDouble = std::dynamic_pointer_cast(theAttribute); @@ -32,7 +48,7 @@ bool GeomValidators_Positive::isValid(const AttributePtr& theAttribute, theError = "Double is not initialized."; return false; } - if (aDouble->value() <= 1.e-5) { + if (aDouble->value() <= aMinValue) { theError = "Double is not positive."; return false; } @@ -45,7 +61,7 @@ bool GeomValidators_Positive::isValid(const AttributePtr& theAttribute, theError = "Integer is not initialized."; return false; } - if (aInteger->value() <= 0) { + if (aInteger->value() <= floor(aMinValue)) { theError = "Integer is not positive."; return false; }