Salome HOME
Merge branch 'master' into cgt/devCEA
[modules/shaper.git] / src / GeomValidators / GeomValidators_ShapeType.h
1 // Copyright (C) 2014-2017  CEA/DEN, EDF R&D
2 //
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License, or (at your option) any later version.
7 //
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11 // Lesser General Public License for more details.
12 //
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16 //
17 // See http://www.salome-platform.org/ or
18 // email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com>
19 //
20
21 #ifndef GeomValidators_ShapeType_H
22 #define GeomValidators_ShapeType_H
23
24 #include "GeomValidators.h"
25 #include "ModelAPI_AttributeValidator.h"
26
27 #include <GeomAPI_Shape.h>
28
29 #include <string>
30
31 /**
32 * \ingroup Validators
33 * A validator for shape types, such as vertex, line, circe or arc.
34 * If there are some argument parameters, this validator returns true if the attribute satisfied
35 * at least one argument (OR combination of arguments).
36 */
37 class GeomValidators_ShapeType : public ModelAPI_AttributeValidator
38 {
39  public:
40   /// Type of shape
41   enum TypeOfShape
42   {
43     Empty,
44     Vertex,
45     Edge,
46     Line,
47     Circle,
48     Wire,
49     Face,
50     Plane,
51     Shell,
52     Solid,
53     CompSolid,
54     Compound,
55     AnyShape
56   };
57
58  public:
59    GEOMVALIDATORS_EXPORT GeomValidators_ShapeType() {}
60   //! Returns true if attribute has shape type listed in the parameter arguments
61   //! \param[in] theAttribute the checked attribute
62   //! \param[in] theArguments arguments of the attribute
63   //! \param[out] theError error message.
64   GEOMVALIDATORS_EXPORT virtual bool isValid(const AttributePtr& theAttribute,
65                                              const std::list<std::string>& theArguments,
66                                              Events_InfoMessage& theError) const;
67 protected:
68   /// Convert string to TypeOfShape value
69   /// \param theType a string value
70   static TypeOfShape shapeType(const std::string& theType);
71
72   /// Returns true if the attibute's object type satisfies the argument value
73   /// \param[in] theAttribute a checked attribute
74   /// \param[in] theShapeType a type of shape
75   /// \param[out] theError error message.
76   bool isValidAttribute(const AttributePtr& theAttribute,
77                         const TypeOfShape theShapeType,
78                         Events_InfoMessage& theError) const;
79
80   /// Returns true if the attibute's object type satisfies the argument value
81   /// \param[in] theObject a checked object
82   /// \param[in] theShapeType a shape type
83   /// \param[out] theError error message.
84   bool isValidObject(const ObjectPtr& theObject,
85                      const TypeOfShape theShapeType,
86                      Events_InfoMessage& theError) const;
87
88   /// Returns true if the attibute's object type satisfies the argument value
89   /// \param[in] theShape a checked shape
90   /// \param[in] theShapeType a shape type
91   /// \param[out] theError error message.
92   bool isValidShape(const GeomShapePtr theShape,
93                     const TypeOfShape theShapeType,
94                     Events_InfoMessage& theError) const;
95
96 };
97
98 #endif