Salome HOME
Issue #559: Control doesn't have variable if its text is empty
[modules/shaper.git] / src / GeomValidators / GeomValidators_Positive.cpp
index 58964c04f985a1ce4f9afc8bedd3c83f8ebc6926..9d3fbf983cbb233da6fbd89d8ee71c3aae325a99 100644 (file)
@@ -6,6 +6,7 @@
 
 #include "GeomValidators_Positive.h"
 #include <ModelAPI_AttributeDouble.h>
+#include <ModelAPI_AttributeInteger.h>
 #include <ModelAPI_Session.h>
 #include <ModelAPI_Validator.h>
 
@@ -23,7 +24,11 @@ GeomValidators_Positive::GeomValidators_Positive()
 bool GeomValidators_Positive::isValid(
     const AttributePtr& theAttribute, const std::list<std::string>& theArguments) const
 {
-  std::shared_ptr<ModelAPI_AttributeDouble> aDouble = 
+  AttributeDoublePtr aDouble = 
     std::dynamic_pointer_cast<ModelAPI_AttributeDouble>(theAttribute);
-  return aDouble->isInitialized() && aDouble->value() > 1.e-5;
+  if (aDouble.get())
+    return aDouble->isInitialized() && aDouble->value() > 1.e-5;
+  AttributeIntegerPtr aInteger = 
+    std::dynamic_pointer_cast<ModelAPI_AttributeInteger>(theAttribute);
+  return aInteger->isInitialized() && aInteger->value() > 0;
 }