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 ////////////// Attribute validators ////////////////
195 * \ingroup Validators
196 * A validator which checks that objects selected for feature attributes are different (not the same)
198 class PartSet_DifferentObjectsValidator : public ModelAPI_AttributeValidator
200 //! Validator possible error types
208 //! Returns true if the attribute is good for the feature attribute
209 //! \param theAttribute an attribute
210 //! \param theArguments a list of arguments (names of attributes to check)
211 //! \param theError an output error string
212 virtual bool isValid(const AttributePtr& theAttribute,
213 const std::list<std::string>& theArguments,
214 Events_InfoMessage& theError) const;
216 //! Returns error message for the error type
217 //! \param theType a type of error
218 //! \param thEqualObjectInfo an
219 std::string errorMessage(const PartSet_DifferentObjectsValidator::ErrorType& theType,
220 const std::string& thEqualObject, const std::string& theFirstAttribute,
221 const std::string& theSecondAttribute) const;
226 * \ingroup Validators
227 * A validator which checks that Point2D selected for feature attributes are different (not the same)
228 * It iterates by the feature ModelAPI_AttributeRefAttr attributes, finds GeomDataAPI_Point2D attribute in
229 * value or attribute of the attributes and if the point of the given attribute is geometrical equal to
230 * a point of another attribute, returns false
232 class PartSet_DifferentPointsValidator : public ModelAPI_AttributeValidator
235 //! Returns true if the attribute is good for the feature attribute
236 //! \param theAttribute an attribute
237 //! \param theArguments a list of arguments (names of attributes to check)
238 //! \param theError an output error string
239 virtual bool isValid(const AttributePtr& theAttribute,
240 const std::list<std::string>& theArguments,
241 Events_InfoMessage& theError) const;
243 //! Finds Point2D attribute by reference attribute. It might be:
244 //! - COORD_ID attribute of SketchPlugin_Point if object
245 //! - Attribute casted to point if attribute
246 //! \param theAttribute an attribute
247 //! \return point 2d attribute or NULL
248 std::shared_ptr<GeomDataAPI_Point2D> getRefPointAttribute
249 (const AttributePtr& theAttribute) const;
253 /**\class PartSet_CoincidentAttr
254 * \ingroup Validators
255 * \brief Validator to check whether there is a coincident constraint between
256 * the attribute and attribute of argument.
258 class PartSet_CoincidentAttr : public ModelAPI_AttributeValidator
261 //! returns true if attribute is valid
262 //! \param theAttribute the checked attribute
263 //! \param theArguments arguments of the attribute
264 //! \param theError an output error string
265 virtual bool isValid(const AttributePtr& theAttribute,
266 const std::list<std::string>& theArguments,
267 Events_InfoMessage& theError) const;