1 // Copyright (C) 2014-2019 CEA/DEN, EDF R&D
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.
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.
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
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
20 #ifndef PartSet_Validators_H
21 #define PartSet_Validators_H
25 #include <ModuleBase_SelectionValidator.h>
26 #include <ModuleBase_ISelection.h>
27 #include <ModelAPI_AttributeValidator.h>
29 class GeomDataAPI_Point2D;
36 //! \ingroup Validators
37 //! A class to validate a selection for Distance constraint operation
38 class PartSet_DistanceSelection : public ModuleBase_SelectionValidator
41 PARTSET_EXPORT virtual bool isValid(const ModuleBase_ISelection* theSelection,
42 ModuleBase_Operation* theOperation) const;
45 //! \ingroup Validators
46 //! A class to validate a selection for Length constraint operation
47 class PartSet_LengthSelection : public ModuleBase_SelectionValidator
50 PARTSET_EXPORT virtual bool isValid(const ModuleBase_ISelection* theSelection,
51 ModuleBase_Operation* theOperation) const;
54 //! \ingroup Validators
55 //! A class to validate a selection for Perpendicular constraint operation
56 class PartSet_PerpendicularSelection : public ModuleBase_SelectionValidator
59 PARTSET_EXPORT virtual bool isValid(const ModuleBase_ISelection* theSelection,
60 ModuleBase_Operation* theOperation) const;
63 //! \ingroup Validators
64 //! A class to validate a selection for Parallel constraint operation
65 class PartSet_ParallelSelection : public ModuleBase_SelectionValidator
68 PARTSET_EXPORT virtual bool isValid(const ModuleBase_ISelection* theSelection,
69 ModuleBase_Operation* theOperation) const;
72 //! \ingroup Validators
73 //! A class to validate a selection for Radius constraint operation
74 class PartSet_RadiusSelection : public ModuleBase_SelectionValidator
77 PARTSET_EXPORT virtual bool isValid(const ModuleBase_ISelection* theSelection,
78 ModuleBase_Operation* theOperation) const;
81 //! \ingroup Validators
82 //! A class to validate a selection for Rigid constraint operation
83 class PartSet_RigidSelection : public ModuleBase_SelectionValidator
86 PARTSET_EXPORT virtual bool isValid(const ModuleBase_ISelection* theSelection,
87 ModuleBase_Operation* theOperation) const;
91 //! \ingroup Validators
92 //! A class to validate a selection for coincedence constraint operation
93 class PartSet_CoincidentSelection : public ModuleBase_SelectionValidator
96 PARTSET_EXPORT virtual bool isValid(const ModuleBase_ISelection* theSelection,
97 ModuleBase_Operation* theOperation) const;
100 //! \ingroup Validators
101 //! A class to validate a selection for Horizontal and Vertical constraints operation
102 class PartSet_HVDirSelection : public ModuleBase_SelectionValidator
105 PARTSET_EXPORT virtual bool isValid(const ModuleBase_ISelection* theSelection,
106 ModuleBase_Operation* theOperation) const;
109 //! \ingroup Validators
110 //! A class to validate a selection for Tangential constraints operation
111 class PartSet_TangentSelection : public ModuleBase_SelectionValidator
114 PARTSET_EXPORT virtual bool isValid(const ModuleBase_ISelection* theSelection,
115 ModuleBase_Operation* theOperation) const;
118 //! \ingroup Validators
119 //! A class to validate a selection for Fillet constraints operation
120 class PartSet_FilletSelection : public ModuleBase_SelectionValidator
123 PARTSET_EXPORT virtual bool isValid(const ModuleBase_ISelection* theSelection,
124 ModuleBase_Operation* theOperation) const;
127 //! \ingroup Validators
128 //! A class to validate a selection for Angle constraints operation
129 class PartSet_AngleSelection : public ModuleBase_SelectionValidator
132 PARTSET_EXPORT virtual bool isValid(const ModuleBase_ISelection* theSelection,
133 ModuleBase_Operation* theOperation) const;
136 //! \ingroup Validators
137 //! A class to validate a selection for Equal constraints operation
138 class PartSet_EqualSelection : public ModuleBase_SelectionValidator
141 PARTSET_EXPORT virtual bool isValid(const ModuleBase_ISelection* theSelection,
142 ModuleBase_Operation* theOperation) const;
145 //! \ingroup Validators
146 //! A class to validate a selection for Collinear constraints operation
147 class PartSet_CollinearSelection : public ModuleBase_SelectionValidator
150 PARTSET_EXPORT virtual bool isValid(const ModuleBase_ISelection* theSelection,
151 ModuleBase_Operation* theOperation) const;
154 //! \ingroup Validators
155 //! A class to validate a selection for Middle point constraints operation
156 class PartSet_MiddlePointSelection : public ModuleBase_SelectionValidator
159 PARTSET_EXPORT virtual bool isValid(const ModuleBase_ISelection* theSelection,
160 ModuleBase_Operation* theOperation) const;
163 //! \ingroup Validators
164 //! A class to validate a selection for Middle point constraints operation
165 class PartSet_MultyTranslationSelection : public ModuleBase_SelectionValidator
168 PARTSET_EXPORT virtual bool isValid(const ModuleBase_ISelection* theSelection,
169 ModuleBase_Operation* theOperation) const;
172 //! \ingroup Validators
173 //! A class to validate a selection for Middle point constraints operation
174 class PartSet_SplitSelection : public ModuleBase_SelectionValidator
177 PARTSET_EXPORT virtual bool isValid(const ModuleBase_ISelection* theSelection,
178 ModuleBase_Operation* theOperation) const;
181 //! \ingroup Validators
182 //! A class to validate a selection for Middle point constraints operation
183 class PartSet_ProjectionSelection : public ModuleBase_SelectionValidator
186 PARTSET_EXPORT virtual bool isValid(const ModuleBase_ISelection* theSelection,
187 ModuleBase_Operation* theOperation) const;
190 //! \ingroup Validators
191 //! A class to validate a selection for intersection operation
192 class PartSet_IntersectionSelection : public ModuleBase_SelectionValidator
195 PARTSET_EXPORT virtual bool isValid(const ModuleBase_ISelection* theSelection,
196 ModuleBase_Operation* theOperation) const;
199 ////////////// Attribute validators ////////////////
203 * \ingroup Validators
204 * A validator which checks that objects selected for feature attributes are different (not the same)
206 class PartSet_DifferentObjectsValidator : public ModelAPI_AttributeValidator
208 //! Validator possible error types
216 //! Returns true if the attribute is good for the feature attribute
217 //! \param theAttribute an attribute
218 //! \param theArguments a list of arguments (names of attributes to check)
219 //! \param theError an output error string
220 virtual bool isValid(const AttributePtr& theAttribute,
221 const std::list<std::string>& theArguments,
222 Events_InfoMessage& theError) const;
224 //! Returns error message for the error type
225 //! \param theType a type of error
226 //! \param thEqualObjectInfo an
227 std::string errorMessage(const PartSet_DifferentObjectsValidator::ErrorType& theType,
228 const std::string& thEqualObject, const std::string& theFirstAttribute,
229 const std::string& theSecondAttribute) const;
234 * \ingroup Validators
235 * A validator which checks that Point2D selected for feature attributes are different (not the same)
236 * It iterates by the feature ModelAPI_AttributeRefAttr attributes, finds GeomDataAPI_Point2D attribute in
237 * value or attribute of the attributes and if the point of the given attribute is geometrical equal to
238 * a point of another attribute, returns false
240 class PartSet_DifferentPointsValidator : public ModelAPI_AttributeValidator
243 //! Returns true if the attribute is good for the feature attribute
244 //! \param theAttribute an attribute
245 //! \param theArguments a list of arguments (names of attributes to check)
246 //! \param theError an output error string
247 virtual bool isValid(const AttributePtr& theAttribute,
248 const std::list<std::string>& theArguments,
249 Events_InfoMessage& theError) const;
251 //! Finds Point2D attribute by reference attribute. It might be:
252 //! - COORD_ID attribute of SketchPlugin_Point if object
253 //! - Attribute casted to point if attribute
254 //! \param theAttribute an attribute
255 //! \return point 2d attribute or NULL
256 std::shared_ptr<GeomDataAPI_Point2D> getRefPointAttribute
257 (const AttributePtr& theAttribute) const;
261 /**\class PartSet_CoincidentAttr
262 * \ingroup Validators
263 * \brief Validator to check whether there is a coincident constraint between
264 * the attribute and attribute of argument.
266 class PartSet_CoincidentAttr : public ModelAPI_AttributeValidator
269 //! returns true if attribute is valid
270 //! \param theAttribute the checked attribute
271 //! \param theArguments arguments of the attribute
272 //! \param theError an output error string
273 virtual bool isValid(const AttributePtr& theAttribute,
274 const std::list<std::string>& theArguments,
275 Events_InfoMessage& theError) const;