Salome HOME
"2.11 Constraint with a point from the intersection between an outer edge and plane...
[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 //! \ingroup Validators
119 //! A class to validate a selection for Collinear constraints operation
120 class PartSet_CollinearSelection : public ModuleBase_SelectionValidator
121 {
122 public:
123   PARTSET_EXPORT virtual bool isValid(const ModuleBase_ISelection* theSelection, ModuleBase_Operation* theOperation) const;
124 };
125
126 //! \ingroup Validators
127 //! A class to validate a selection for Middle point constraints operation
128 class PartSet_MiddlePointSelection : public ModuleBase_SelectionValidator
129 {
130 public:
131   PARTSET_EXPORT virtual bool isValid(const ModuleBase_ISelection* theSelection, ModuleBase_Operation* theOperation) const;
132 };
133
134 ////////////// Attribute validators ////////////////
135
136
137 /**
138 * \ingroup Validators
139 * A validator which checks that objects selected for feature attributes are different (not the same)
140 */
141 class PartSet_DifferentObjectsValidator : public ModelAPI_AttributeValidator
142 {
143   //! Validator possible error types
144   enum ErrorType {
145     EqualObjects,
146     EqualAttributes,
147     EqualShapes,
148     EmptyShapes
149   };
150  public:
151   //! Returns true if the attribute is good for the feature attribute
152   //! \param theAttribute an attribute
153   //! \param theArguments a list of arguments (names of attributes to check)
154   //! \param theError an output error string
155   virtual bool isValid(const AttributePtr& theAttribute,
156                        const std::list<std::string>& theArguments,
157                        std::string& theError) const;
158 private:
159   //! Returns error message for the error type
160   //! \param theType a type of error
161   //! \param thEqualObjectInfo an 
162   std::string errorMessage(const PartSet_DifferentObjectsValidator::ErrorType& theType,
163                            const std::string& thEqualObject, const std::string& theFirstAttribute,
164                            const std::string& theSecondAttribute) const;
165
166 };
167
168 /**
169 * \ingroup Validators
170 * A validator which checks that objects selected for feature attributes are different (not the same)
171 */
172 class PartSet_SketchEntityValidator : public ModelAPI_AttributeValidator
173 {
174  public:
175   //! Returns true if the attribute is good for the feature attribute
176   //! \param theAttribute an attribute
177   //! \param theArguments a list of arguments (names of attributes to check)
178   //! \param theError an output error string
179   virtual bool isValid(const AttributePtr& theAttribute,
180                        const std::list<std::string>& theArguments,
181                        std::string& theError) const;
182 };
183
184 /**\class PartSet_CoincidentAttr
185  * \ingroup Validators
186  * \brief Validator to check whether there is a coincident constraint between
187  * the attribute and attribute of argument.
188  */
189 class PartSet_CoincidentAttr : public ModelAPI_AttributeValidator
190 {
191  public:
192   //! returns true if attribute is valid
193   //! \param theAttribute the checked attribute
194   //! \param theArguments arguments of the attribute
195   //! \param theError an output error string
196   virtual bool isValid(const AttributePtr& theAttribute,
197                        const std::list<std::string>& theArguments,
198                        std::string& theError) const;
199 };
200
201
202 #endif