Salome HOME
Merge branch 'Dev_1.2.0' of newgeom:newgeom into Dev_1.2.0
[modules/shaper.git] / src / GeomValidators / GeomValidators_ShapeType.h
1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D
2
3 // File:        GeomValidators_ShapeType.h
4 // Created:     19 Mar 2015
5 // Author:      Natalia ERMOLAEVA
6
7 #ifndef GeomValidators_ShapeType_H
8 #define GeomValidators_ShapeType_H
9
10 #include "GeomValidators.h"
11 #include "ModelAPI_AttributeValidator.h"
12
13 #include <GeomAPI_Shape.h>
14
15 #include <string>
16
17 /**
18 * \ingroup Validators
19 * A validator for shape types, such as vertex, line, circe or arc.
20 * If there are some argument parameters, this validator returns true if the attribute satisfied
21 * at least one argument (OR combination of arguments).
22 */
23 class GeomValidators_ShapeType : public ModelAPI_AttributeValidator
24 {
25  public:
26   //  the edge type
27   enum TypeOfShape
28   {
29     AnyShape,
30     Vertex,
31     Edge,
32     Line,
33     Circle,
34     Solid,
35     Face
36   };
37
38  public:
39    GEOMVALIDATORS_EXPORT GeomValidators_ShapeType() {}
40   //! returns true if attribute is valid
41   //! \param theAttribute the checked attribute
42   //! \param theArguments arguments of the attribute
43   GEOMVALIDATORS_EXPORT virtual bool isValid(const AttributePtr& theAttribute,
44                                              const std::list<std::string>& theArguments) const;
45 protected:
46   /// Convert string to TypeOfShape value
47   /// \param theType a string value
48   static TypeOfShape shapeType(const std::string& theType);
49
50   bool isValidArgument(const AttributePtr& theAttribute,
51                        const std::string& theArgument) const;
52
53   /// Returns true if the attibute's object type satisfies the argument value
54   /// \param theAttribute a checked attribute
55   /// \param theArgument a parameter
56   bool isValidAttribute(const AttributePtr& theAttribute,
57                         const TypeOfShape theShapeType) const;
58
59   /// Returns true if the attibute's object type satisfies the argument value
60   /// \param theAttribute a checked object
61   /// \param theShapeType a shape type
62   bool isValidObject(const ObjectPtr& theObject,
63                      const TypeOfShape theShapeType) const;
64
65   /// Returns true if the attibute's object type satisfies the argument value
66   /// \param theShape a checked shape
67   /// \param theShapeType a shape type
68   bool isValidShape(const GeomShapePtr theShape,
69                     const TypeOfShape theShapeType) const;
70
71 };
72
73 #endif