Salome HOME
36f78e031d894dddfc382d1b3f78a99abb006724
[modules/shaper.git] / src / PartSet / PartSet_Validators.h
1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D
2
3 // File:        PartSet_Validators.h
4 // Created:     09 July 2014
5 // Author:      Vitaly SMETANNIKOV
6
7 #ifndef PartSet_Validators_H
8 #define PartSet_Validators_H
9
10 #include "PartSet.h"
11
12 #include <ModuleBase_SelectionValidator.h>
13 #include <ModuleBase_ISelection.h>
14 #include <ModelAPI_AttributeValidator.h>
15
16 /*
17  * Selector validators
18  */
19
20
21 //! \ingroup Validators
22 //! A class to validate a selection for Distance constraint operation
23 class PartSet_DistanceSelection : public ModuleBase_SelectionValidator
24 {
25 public:
26   PARTSET_EXPORT virtual bool isValid(const ModuleBase_ISelection* theSelection, ModuleBase_Operation* theOperation) const;
27 };
28
29 //! \ingroup Validators
30 //! A class to validate a selection for Length constraint operation
31 class PartSet_LengthSelection : public ModuleBase_SelectionValidator
32 {
33 public:
34   PARTSET_EXPORT virtual bool isValid(const ModuleBase_ISelection* theSelection, ModuleBase_Operation* theOperation) const;
35 };
36
37 //! \ingroup Validators
38 //! A class to validate a selection for Perpendicular constraint operation
39 class PartSet_PerpendicularSelection : public ModuleBase_SelectionValidator
40 {
41 public:
42   PARTSET_EXPORT virtual bool isValid(const ModuleBase_ISelection* theSelection, ModuleBase_Operation* theOperation) const;
43 };
44
45 //! \ingroup Validators
46 //! A class to validate a selection for Parallel constraint operation
47 class PartSet_ParallelSelection : public ModuleBase_SelectionValidator
48 {
49 public:
50   PARTSET_EXPORT virtual bool isValid(const ModuleBase_ISelection* theSelection, ModuleBase_Operation* theOperation) const;
51 };
52
53 //! \ingroup Validators
54 //! A class to validate a selection for Radius constraint operation
55 class PartSet_RadiusSelection : public ModuleBase_SelectionValidator
56 {
57 public:
58   PARTSET_EXPORT virtual bool isValid(const ModuleBase_ISelection* theSelection, ModuleBase_Operation* theOperation) const;
59 };
60
61 //! \ingroup Validators
62 //! A class to validate a selection for Rigid constraint operation
63 class PartSet_RigidSelection : public ModuleBase_SelectionValidator
64 {
65 public:
66   PARTSET_EXPORT virtual bool isValid(const ModuleBase_ISelection* theSelection, ModuleBase_Operation* theOperation) const;
67 };
68
69
70 //! \ingroup Validators
71 //! A class to validate a selection for coincedence constraint operation
72 class PartSet_CoincidentSelection : public ModuleBase_SelectionValidator
73 {
74 public:
75   PARTSET_EXPORT virtual bool isValid(const ModuleBase_ISelection* theSelection, ModuleBase_Operation* theOperation) const;
76 };
77
78 //! \ingroup Validators
79 //! A class to validate a selection for Horizontal and Vertical constraints operation
80 class PartSet_HVDirSelection : public ModuleBase_SelectionValidator
81 {
82 public:
83   PARTSET_EXPORT virtual bool isValid(const ModuleBase_ISelection* theSelection, ModuleBase_Operation* theOperation) const;
84 };
85
86 //! \ingroup Validators
87 //! A class to validate a selection for Tangential constraints operation
88 class PartSet_TangentSelection : public ModuleBase_SelectionValidator
89 {
90 public:
91   PARTSET_EXPORT virtual bool isValid(const ModuleBase_ISelection* theSelection, ModuleBase_Operation* theOperation) const;
92 };
93
94 //! \ingroup Validators
95 //! A class to validate a selection for Fillet constraints operation
96 class PartSet_FilletSelection : public ModuleBase_SelectionValidator
97 {
98 public:
99   PARTSET_EXPORT virtual bool isValid(const ModuleBase_ISelection* theSelection, ModuleBase_Operation* theOperation) const;
100 };
101
102 //! \ingroup Validators
103 //! A class to validate a selection for Angle constraints operation
104 class PartSet_AngleSelection : public ModuleBase_SelectionValidator
105 {
106 public:
107   PARTSET_EXPORT virtual bool isValid(const ModuleBase_ISelection* theSelection, ModuleBase_Operation* theOperation) const;
108 };
109
110 //! \ingroup Validators
111 //! A class to validate a selection for Equal constraints operation
112 class PartSet_EqualSelection : public ModuleBase_SelectionValidator
113 {
114 public:
115   PARTSET_EXPORT virtual bool isValid(const ModuleBase_ISelection* theSelection, ModuleBase_Operation* theOperation) const;
116 };
117
118 ////////////// Attribute validators ////////////////
119
120
121 /**
122 * \ingroup Validators
123 * A validator which checks that objects selected for feature attributes are different (not the same)
124 */
125 class PartSet_DifferentObjectsValidator : public ModelAPI_AttributeValidator
126 {
127   //! Validator possible error types
128   enum ErrorType {
129     EqualObjects,
130     EqualAttributes,
131     EqualShapes,
132     EmptyShapes
133   };
134  public:
135   //! Returns true if the attribute is good for the feature attribute
136   //! \param theAttribute an attribute
137   //! \param theArguments a list of arguments (names of attributes to check)
138   //! \param theError an output error string
139   virtual bool isValid(const AttributePtr& theAttribute,
140                        const std::list<std::string>& theArguments,
141                        std::string& theError) const;
142 private:
143   //! Returns error message for the error type
144   //! \param theType a type of error
145   //! \param thEqualObjectInfo an 
146   std::string errorMessage(const PartSet_DifferentObjectsValidator::ErrorType& theType,
147                            const std::string& thEqualObject, const std::string& theFirstAttribute,
148                            const std::string& theSecondAttribute) const;
149
150 };
151
152 /**
153 * \ingroup Validators
154 * A validator which checks that objects selected for feature attributes are different (not the same)
155 */
156 class PartSet_SketchEntityValidator : public ModelAPI_AttributeValidator
157 {
158  public:
159   //! Returns true if the attribute is good for the feature attribute
160   //! \param theAttribute an attribute
161   //! \param theArguments a list of arguments (names of attributes to check)
162   //! \param theError an output error string
163   virtual bool isValid(const AttributePtr& theAttribute,
164                        const std::list<std::string>& theArguments,
165                        std::string& theError) const;
166 };
167
168 /**\class PartSet_CoincidentAttr
169  * \ingroup Validators
170  * \brief Validator to check whether there is a coincident constraint between
171  * the attribute and attribute of argument.
172  */
173 class PartSet_CoincidentAttr : public ModelAPI_AttributeValidator
174 {
175  public:
176   //! returns true if attribute is valid
177   //! \param theAttribute the checked attribute
178   //! \param theArguments arguments of the attribute
179   //! \param theError an output error string
180   virtual bool isValid(const AttributePtr& theAttribute,
181                        const std::list<std::string>& theArguments,
182                        std::string& theError) const;
183 };
184
185
186 #endif