]> SALOME platform Git repositories - modules/shaper.git/blob - src/GeomValidators/GeomValidators_Positive.cpp
Salome HOME
Speed up the redraw of sketch with constraints moved by the point of the line
[modules/shaper.git] / src / GeomValidators / GeomValidators_Positive.cpp
1 // File:        GeomValidators_ValidatorPositive.cpp
2 // Created:     16 Sep 2014
3 // Author:      Mikhail PONIKAROV
4
5 #include "GeomValidators_Positive.h"
6 #include <ModelAPI_AttributeDouble.h>
7 #include <ModelAPI_Session.h>
8 #include <ModelAPI_Validator.h>
9
10 /// Global instance for validators factory
11 GeomValidators_Positive MY_POSITIVE_INSTANCE;
12
13 GeomValidators_Positive::GeomValidators_Positive()
14 {
15   // this validator is registered in the factory on this library loading
16   SessionPtr aMgr = ModelAPI_Session::get();
17   ModelAPI_ValidatorsFactory* aFactory = aMgr->validators();
18   aFactory->registerValidator("GeomValidators_Positive", this);
19 }
20
21 bool GeomValidators_Positive::isValid(
22     const AttributePtr& theAttribute, const std::list<std::string>& theArguments) const
23 {
24   std::shared_ptr<ModelAPI_AttributeDouble> aDouble = 
25     std::dynamic_pointer_cast<ModelAPI_AttributeDouble>(theAttribute);
26   return aDouble->isInitialized() && aDouble->value() > 1.e-5;
27 }