1 // Copyright (C) 2014-2017 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
18 // email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com>
21 #ifndef PartSet_Validators_H
22 #define PartSet_Validators_H
26 #include <ModuleBase_SelectionValidator.h>
27 #include <ModuleBase_ISelection.h>
28 #include <ModelAPI_AttributeValidator.h>
30 class GeomDataAPI_Point2D;
37 //! \ingroup Validators
38 //! A class to validate a selection for Distance constraint operation
39 class PartSet_DistanceSelection : public ModuleBase_SelectionValidator
42 PARTSET_EXPORT virtual bool isValid(const ModuleBase_ISelection* theSelection,
43 ModuleBase_Operation* theOperation) const;
46 //! \ingroup Validators
47 //! A class to validate a selection for Length constraint operation
48 class PartSet_LengthSelection : public ModuleBase_SelectionValidator
51 PARTSET_EXPORT virtual bool isValid(const ModuleBase_ISelection* theSelection,
52 ModuleBase_Operation* theOperation) const;
55 //! \ingroup Validators
56 //! A class to validate a selection for Perpendicular constraint operation
57 class PartSet_PerpendicularSelection : public ModuleBase_SelectionValidator
60 PARTSET_EXPORT virtual bool isValid(const ModuleBase_ISelection* theSelection,
61 ModuleBase_Operation* theOperation) const;
64 //! \ingroup Validators
65 //! A class to validate a selection for Parallel constraint operation
66 class PartSet_ParallelSelection : public ModuleBase_SelectionValidator
69 PARTSET_EXPORT virtual bool isValid(const ModuleBase_ISelection* theSelection,
70 ModuleBase_Operation* theOperation) const;
73 //! \ingroup Validators
74 //! A class to validate a selection for Radius constraint operation
75 class PartSet_RadiusSelection : public ModuleBase_SelectionValidator
78 PARTSET_EXPORT virtual bool isValid(const ModuleBase_ISelection* theSelection,
79 ModuleBase_Operation* theOperation) const;
82 //! \ingroup Validators
83 //! A class to validate a selection for Rigid constraint operation
84 class PartSet_RigidSelection : public ModuleBase_SelectionValidator
87 PARTSET_EXPORT virtual bool isValid(const ModuleBase_ISelection* theSelection,
88 ModuleBase_Operation* theOperation) const;
92 //! \ingroup Validators
93 //! A class to validate a selection for coincedence constraint operation
94 class PartSet_CoincidentSelection : public ModuleBase_SelectionValidator
97 PARTSET_EXPORT virtual bool isValid(const ModuleBase_ISelection* theSelection,
98 ModuleBase_Operation* theOperation) const;
101 //! \ingroup Validators
102 //! A class to validate a selection for Horizontal and Vertical constraints operation
103 class PartSet_HVDirSelection : public ModuleBase_SelectionValidator
106 PARTSET_EXPORT virtual bool isValid(const ModuleBase_ISelection* theSelection,
107 ModuleBase_Operation* theOperation) const;
110 //! \ingroup Validators
111 //! A class to validate a selection for Tangential constraints operation
112 class PartSet_TangentSelection : public ModuleBase_SelectionValidator
115 PARTSET_EXPORT virtual bool isValid(const ModuleBase_ISelection* theSelection,
116 ModuleBase_Operation* theOperation) const;
119 //! \ingroup Validators
120 //! A class to validate a selection for Fillet constraints operation
121 class PartSet_FilletSelection : public ModuleBase_SelectionValidator
124 PARTSET_EXPORT virtual bool isValid(const ModuleBase_ISelection* theSelection,
125 ModuleBase_Operation* theOperation) const;
128 //! \ingroup Validators
129 //! A class to validate a selection for Angle constraints operation
130 class PartSet_AngleSelection : public ModuleBase_SelectionValidator
133 PARTSET_EXPORT virtual bool isValid(const ModuleBase_ISelection* theSelection,
134 ModuleBase_Operation* theOperation) const;
137 //! \ingroup Validators
138 //! A class to validate a selection for Equal constraints operation
139 class PartSet_EqualSelection : public ModuleBase_SelectionValidator
142 PARTSET_EXPORT virtual bool isValid(const ModuleBase_ISelection* theSelection,
143 ModuleBase_Operation* theOperation) const;
146 //! \ingroup Validators
147 //! A class to validate a selection for Collinear constraints operation
148 class PartSet_CollinearSelection : public ModuleBase_SelectionValidator
151 PARTSET_EXPORT virtual bool isValid(const ModuleBase_ISelection* theSelection,
152 ModuleBase_Operation* theOperation) const;
155 //! \ingroup Validators
156 //! A class to validate a selection for Middle point constraints operation
157 class PartSet_MiddlePointSelection : public ModuleBase_SelectionValidator
160 PARTSET_EXPORT virtual bool isValid(const ModuleBase_ISelection* theSelection,
161 ModuleBase_Operation* theOperation) const;
164 //! \ingroup Validators
165 //! A class to validate a selection for Middle point constraints operation
166 class PartSet_MultyTranslationSelection : public ModuleBase_SelectionValidator
169 PARTSET_EXPORT virtual bool isValid(const ModuleBase_ISelection* theSelection,
170 ModuleBase_Operation* theOperation) const;
173 //! \ingroup Validators
174 //! A class to validate a selection for Middle point constraints operation
175 class PartSet_SplitSelection : public ModuleBase_SelectionValidator
178 PARTSET_EXPORT virtual bool isValid(const ModuleBase_ISelection* theSelection,
179 ModuleBase_Operation* theOperation) const;
182 //! \ingroup Validators
183 //! A class to validate a selection for Middle point constraints operation
184 class PartSet_ProjectionSelection : public ModuleBase_SelectionValidator
187 PARTSET_EXPORT virtual bool isValid(const ModuleBase_ISelection* theSelection,
188 ModuleBase_Operation* theOperation) const;
191 //! \ingroup Validators
192 //! A class to validate a selection for intersection operation
193 class PartSet_IntersectionSelection : public ModuleBase_SelectionValidator
196 PARTSET_EXPORT virtual bool isValid(const ModuleBase_ISelection* theSelection,
197 ModuleBase_Operation* theOperation) const;
200 ////////////// Attribute validators ////////////////
204 * \ingroup Validators
205 * A validator which checks that objects selected for feature attributes are different (not the same)
207 class PartSet_DifferentObjectsValidator : public ModelAPI_AttributeValidator
209 //! Validator possible error types
217 //! Returns true if the attribute is good for the feature attribute
218 //! \param theAttribute an attribute
219 //! \param theArguments a list of arguments (names of attributes to check)
220 //! \param theError an output error string
221 virtual bool isValid(const AttributePtr& theAttribute,
222 const std::list<std::string>& theArguments,
223 Events_InfoMessage& theError) const;
225 //! Returns error message for the error type
226 //! \param theType a type of error
227 //! \param thEqualObjectInfo an
228 std::string errorMessage(const PartSet_DifferentObjectsValidator::ErrorType& theType,
229 const std::string& thEqualObject, const std::string& theFirstAttribute,
230 const std::string& theSecondAttribute) const;
235 * \ingroup Validators
236 * A validator which checks that Point2D selected for feature attributes are different (not the same)
237 * It iterates by the feature ModelAPI_AttributeRefAttr attributes, finds GeomDataAPI_Point2D attribute in
238 * value or attribute of the attributes and if the point of the given attribute is geometrical equal to
239 * a point of another attribute, returns false
241 class PartSet_DifferentPointsValidator : public ModelAPI_AttributeValidator
244 //! Returns true if the attribute is good for the feature attribute
245 //! \param theAttribute an attribute
246 //! \param theArguments a list of arguments (names of attributes to check)
247 //! \param theError an output error string
248 virtual bool isValid(const AttributePtr& theAttribute,
249 const std::list<std::string>& theArguments,
250 Events_InfoMessage& theError) const;
252 //! Finds Point2D attribute by reference attribute. It might be:
253 //! - COORD_ID attribute of SketchPlugin_Point if object
254 //! - Attribute casted to point if attribute
255 //! \param theAttribute an attribute
256 //! \return point 2d attribute or NULL
257 std::shared_ptr<GeomDataAPI_Point2D> getRefPointAttribute
258 (const AttributePtr& theAttribute) const;
262 /**\class PartSet_CoincidentAttr
263 * \ingroup Validators
264 * \brief Validator to check whether there is a coincident constraint between
265 * the attribute and attribute of argument.
267 class PartSet_CoincidentAttr : public ModelAPI_AttributeValidator
270 //! returns true if attribute is valid
271 //! \param theAttribute the checked attribute
272 //! \param theArguments arguments of the attribute
273 //! \param theError an output error string
274 virtual bool isValid(const AttributePtr& theAttribute,
275 const std::list<std::string>& theArguments,
276 Events_InfoMessage& theError) const;