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