1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D -->
3 // File: SketchPlugin_Validators.h
4 // Created: 01 Aug 2014
5 // Author: Vitaly SMETANNIKOV
7 #ifndef SketchPlugin_Validators_H
8 #define SketchPlugin_Validators_H
10 #include "SketchPlugin.h"
11 #include <ModelAPI_AttributeValidator.h>
12 #include <ModelAPI_FeatureValidator.h>
14 /**\class SketchPlugin_DistanceAttrValidator
16 * \brief Validator for the distance input.
18 * It just checks that distance is greater than zero.
20 class SketchPlugin_DistanceAttrValidator : public ModelAPI_AttributeValidator
23 //! returns true if attribute is valid
24 //! \param theAttribute the checked attribute
25 //! \param theArguments arguments of the attribute
26 //! \param theError error message
27 virtual bool isValid(const AttributePtr& theAttribute,
28 const std::list<std::string>& theArguments,
29 Events_InfoMessage& theError) const;
32 /**\class SketchPlugin_TangentAttrValidator
34 * \brief Validator for the tangent constraint input.
36 * It just checks that distance is greater than zero.
38 class SketchPlugin_TangentAttrValidator : public ModelAPI_AttributeValidator
41 //! returns true if attribute is valid
42 //! \param theAttribute the checked attribute
43 //! \param theArguments arguments of the attribute
44 //! \param theError error message
45 virtual bool isValid(const AttributePtr& theAttribute,
46 const std::list<std::string>& theArguments,
47 Events_InfoMessage& theError) const;
51 /**\class SketchPlugin_NotFixedValidator
53 * \brief Validator for the rigid constraint input.
55 * It just checks there is no rigid constraint for the current feature.
57 class SketchPlugin_NotFixedValidator : public ModelAPI_AttributeValidator
60 //! returns true if attribute is not used in another rigid constraint
61 //! \param theAttribute the checked attribute
62 //! \param theArguments arguments of the attribute
63 //! \param theError error message
64 virtual bool isValid(const AttributePtr& theAttribute,
65 const std::list<std::string>& theArguments,
66 Events_InfoMessage& theError) const;
69 /**\class SketchPlugin_EqualAttrValidator
71 * \brief Validator for the equal constraint input.
73 * It checks that attributes of the Equal constraint are correct.
75 class SketchPlugin_EqualAttrValidator : public ModelAPI_AttributeValidator
78 //! returns true if attribute is valid
79 //! \param theAttribute the checked attribute
80 //! \param theArguments arguments of the attribute
81 //! \param theError error message
82 virtual bool isValid(const AttributePtr& theAttribute,
83 const std::list<std::string>& theArguments,
84 Events_InfoMessage& theError) const;
87 /**\class SketchPlugin_MirrorAttrValidator
89 * \brief Validator for the mirror constraint input.
91 * It checks that attributes of the Mirror constraint are correct.
93 class SketchPlugin_MirrorAttrValidator : public ModelAPI_AttributeValidator
96 //! returns true if attribute is valid
97 //! \param theAttribute the checked attribute
98 //! \param theArguments arguments of the attribute (not used)
99 //! \param theError error message
100 virtual bool isValid(const AttributePtr& theAttribute,
101 const std::list<std::string>& theArguments,
102 Events_InfoMessage& theError) const;
106 /**\class SketchPlugin_CoincidenceAttrValidator
107 * \ingroup Validators
108 * \brief Validator for the coincidence constraint input.
110 * It checks that attributes of the Coincidence constraint are correct.
112 class SketchPlugin_CoincidenceAttrValidator : public ModelAPI_AttributeValidator
115 //! returns true if attribute is valid
116 //! \param theAttribute the checked attribute
117 //! \param theArguments arguments of the attribute (not used)
118 //! \param theError error message
119 virtual bool isValid(const AttributePtr& theAttribute,
120 const std::list<std::string>& theArguments,
121 Events_InfoMessage& theError) const;
125 /**\class SketchPlugin_CopyValidator
126 * \ingroup Validators
127 * \brief Validator for the constraints which create features.
129 * Applicable only for features, which creates another features. It verifies the produced
130 * features of current constraint don't become into the list of initial features
132 class SketchPlugin_CopyValidator : public ModelAPI_AttributeValidator
135 //! returns true if attribute is valid
136 //! \param theAttribute the checked attribute
137 //! \param theArguments arguments of the attribute (not used)
138 //! \param theError error message
139 virtual bool isValid(const AttributePtr& theAttribute,
140 const std::list<std::string>& theArguments,
141 Events_InfoMessage& theError) const;
144 /**\class SketchPlugin_SolverErrorValidator
145 * \ingroup Validators
146 * \brief Validator for the solver error.
148 * Simply checks that solver error attribute is empty. Returns the attribute value as an error.
150 class SketchPlugin_SolverErrorValidator : public ModelAPI_FeatureValidator
153 //! returns true if there are no solver errors
154 //! \param theFeature the checked feature
155 //! \param theArguments arguments of the feature (not used)
156 //! \param theError error message
157 virtual bool isValid(const std::shared_ptr<ModelAPI_Feature>& theFeature,
158 const std::list<std::string>& theArguments,
159 Events_InfoMessage& theError) const;
161 /// Returns true if the attribute in feature is not obligatory for the feature execution
162 virtual bool isNotObligatory(std::string theFeature, std::string theAttribute);
165 /**\class SketchPlugin_FilletVertexValidator
166 * \ingroup Validators
167 * \brief Validator for the point for fillet creation.
169 * Checks that selected point have exactly two coincident lines.
171 class SketchPlugin_FilletVertexValidator : public ModelAPI_AttributeValidator
174 //! returns true if attribute is valid
175 //! \param theAttribute the checked attribute
176 //! \param theArguments arguments of the attribute (not used)
177 //! \param theError error message
178 virtual bool isValid(const AttributePtr& theAttribute,
179 const std::list<std::string>& theArguments,
180 Events_InfoMessage& theError) const;
184 /**\class SketchPlugin_MiddlePointAttrValidator
185 * \ingroup Validators
186 * \brief Validator for the middle point constraint input.
188 * It checks that attributes of the Middle point constraint are correct.
190 class SketchPlugin_MiddlePointAttrValidator : public ModelAPI_AttributeValidator
193 //! returns true if attribute is valid
194 //! \param theAttribute the checked attribute
195 //! \param theArguments arguments of the attribute (not used)
196 //! \param theError error message
197 virtual bool isValid(const AttributePtr& theAttribute,
198 const std::list<std::string>& theArguments,
199 Events_InfoMessage& theError) const;
203 /**\class SketchPlugin_ArcTangentPointValidator
204 * \ingroup Validators
205 * \brief Validator for the point where the tangent arc is building.
207 * Checks that the point is a start or end point just on line or arc.
209 class SketchPlugin_ArcTangentPointValidator : public ModelAPI_AttributeValidator
212 //! returns true if attribute is valid
213 //! \param theAttribute the checked attribute
214 //! \param theArguments arguments of the attribute
215 //! \param theError error message
216 virtual bool isValid(const AttributePtr& theAttribute,
217 const std::list<std::string>& theArguments,
218 Events_InfoMessage& theError) const;
221 /**\class SketchPlugin_SplitValidator
222 * \ingroup Validators
223 * \brief Validator for the entity of the following type:
224 * - Linear segment with point(s) coinident to this line
225 * - Arc with point(s) coincident to the arc
226 * - Circle with at least 2 split-points on this circle
228 * Checks that there are coincident point on selected feature.
230 class SketchPlugin_SplitValidator : public ModelAPI_AttributeValidator
233 //! returns true if attribute is valid
234 //! \param theAttribute the checked attribute
235 //! \param theArguments arguments of the attribute
236 //! \param theError error message
237 virtual bool isValid(const AttributePtr& theAttribute,
238 const std::list<std::string>& theArguments,
239 Events_InfoMessage& theError) const;
242 /**\class SketchPlugin_TrimValidator
243 * \ingroup Validators
244 * \brief Validator for the entity of the following type:
245 * - Linear segment with point(s) coinident to this line or intersected it
246 * - Arc with point(s) coincident to the arc or intersected it
247 * - Circle with at least 2 split-points on this circle or intersected it
249 * Checks that there are coincident point on selected feature.
251 class SketchPlugin_TrimValidator : public ModelAPI_AttributeValidator
254 //! returns true if attribute is valid
255 //! \param theAttribute the checked attribute
256 //! \param theArguments arguments of the attribute
257 //! \param theError error message
258 virtual bool isValid(const AttributePtr& theAttribute,
259 const std::list<std::string>& theArguments,
260 Events_InfoMessage& theError) const;
263 /**\class SketchPlugin_IntersectionValidator
264 * \ingroup Validators
265 * \brief Validator for the attribute to be intersected with the sketch plane.
267 class SketchPlugin_IntersectionValidator : 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 error message
274 virtual bool isValid(const AttributePtr& theAttribute,
275 const std::list<std::string>& theArguments,
276 Events_InfoMessage& theError) const;
279 /**\class SketchPlugin_ProjectionValidator
280 * \ingroup Validators
281 * \brief Validator for the attribute to be projected onto the sketch plane.
283 class SketchPlugin_ProjectionValidator : public ModelAPI_AttributeValidator
286 //! returns true if attribute is valid
287 //! \param theAttribute the checked attribute
288 //! \param theArguments arguments of the attribute
289 //! \param theError error message
290 virtual bool isValid(const AttributePtr& theAttribute,
291 const std::list<std::string>& theArguments,
292 Events_InfoMessage& theError) const;
295 /**\class SketchPlugin_DifferentReferenceValidator
296 * \ingroup Validators
297 * \brief Validator for attributes of a sketch feature.
299 * It checks that at least one of specified attributes
300 * refers to another feature in respect to each other.
302 class SketchPlugin_DifferentReferenceValidator : public ModelAPI_AttributeValidator
305 //! returns true if attribute is valid
306 //! \param theAttribute the checked attribute
307 //! \param theArguments arguments of the attribute
308 //! \param theError error message
309 virtual bool isValid(const AttributePtr& theAttribute,
310 const std::list<std::string>& theArguments,
311 Events_InfoMessage& theError) const;
314 /**\class SketchPlugin_CirclePassedPointValidator
315 * \ingroup Validators
316 * \brief Validator for passed point of MacroCircle feature.
318 * Checks that passed point does not refer to the feature, the center is coincident to.
320 class SketchPlugin_CirclePassedPointValidator : public ModelAPI_AttributeValidator
323 //! returns true if attribute is valid
324 //! \param theAttribute the checked attribute
325 //! \param theArguments arguments of the attribute
326 //! \param theError error message
327 virtual bool isValid(const AttributePtr& theAttribute,
328 const std::list<std::string>&,
329 Events_InfoMessage& theError) const;
332 /**\class SketchPlugin_ThirdPointValidator
333 * \ingroup Validators
334 * \brief Validator for the third point of MacroCircle feature.
336 * Checks that third point does not lie on a line passed through the first two points.
337 * Checks that third point does not refer to feature lying between the first two points.
339 class SketchPlugin_ThirdPointValidator : public ModelAPI_AttributeValidator
342 //! returns true if attribute is valid
343 //! \param theAttribute the checked attribute
344 //! \param theArguments arguments of the attribute
345 //! \param theError error message
346 virtual bool isValid(const AttributePtr& theAttribute,
347 const std::list<std::string>& theArguments,
348 Events_InfoMessage& theError) const;
351 //! returns true if three points have not been placed on the same line
352 bool arePointsNotOnLine(const FeaturePtr& theMacroFeature,
353 Events_InfoMessage& theError) const;
355 //! returns true if the first two points have not been separated
356 //! by a feature referred by thrid point
357 bool arePointsNotSeparated(const FeaturePtr& theMacroFeature,
358 const std::list<std::string>& theArguments,
359 Events_InfoMessage& theError) const;