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 SketchPlugin_Validators_H
21 #define SketchPlugin_Validators_H
23 #include "SketchPlugin.h"
24 #include <ModelAPI_AttributeValidator.h>
25 #include <ModelAPI_FeatureValidator.h>
27 /**\class SketchPlugin_DistanceAttrValidator
29 * \brief Validator for the distance input.
31 * It just checks that distance is greater than zero.
33 class SketchPlugin_DistanceAttrValidator : public ModelAPI_AttributeValidator
36 //! returns true if attribute is valid
37 //! \param theAttribute the checked attribute
38 //! \param theArguments arguments of the attribute
39 //! \param theError error message
40 virtual bool isValid(const AttributePtr& theAttribute,
41 const std::list<std::string>& theArguments,
42 Events_InfoMessage& theError) const;
45 /**\class SketchPlugin_TangentAttrValidator
47 * \brief Validator for the tangent constraint input.
49 * It just checks that distance is greater than zero.
51 class SketchPlugin_TangentAttrValidator : public ModelAPI_AttributeValidator
54 //! returns true if attribute is valid
55 //! \param theAttribute the checked attribute
56 //! \param theArguments arguments of the attribute
57 //! \param theError error message
58 virtual bool isValid(const AttributePtr& theAttribute,
59 const std::list<std::string>& theArguments,
60 Events_InfoMessage& theError) const;
63 /**\class SketchPlugin_PerpendicularAttrValidator
65 * \brief Validator for the perpendicular constraint input.
67 * Checks that two arcs are not selected for perpendicular.
69 class SketchPlugin_PerpendicularAttrValidator : public ModelAPI_AttributeValidator
72 //! returns true if attribute is valid
73 //! \param theAttribute the checked attribute
74 //! \param theArguments arguments of the attribute
75 //! \param theError error message
76 virtual bool isValid(const AttributePtr& theAttribute,
77 const std::list<std::string>& theArguments,
78 Events_InfoMessage& theError) const;
82 /**\class SketchPlugin_NotFixedValidator
84 * \brief Validator for the rigid constraint input.
86 * It just checks there is no rigid constraint for the current feature.
88 class SketchPlugin_NotFixedValidator : public ModelAPI_AttributeValidator
91 //! returns true if attribute is not used in another rigid constraint
92 //! \param theAttribute the checked attribute
93 //! \param theArguments arguments of the attribute
94 //! \param theError error message
95 virtual bool isValid(const AttributePtr& theAttribute,
96 const std::list<std::string>& theArguments,
97 Events_InfoMessage& theError) const;
100 /**\class SketchPlugin_EqualAttrValidator
101 * \ingroup Validators
102 * \brief Validator for the equal constraint input.
104 * It checks that attributes of the Equal constraint are correct.
106 class SketchPlugin_EqualAttrValidator : public ModelAPI_AttributeValidator
109 //! returns true if attribute is valid
110 //! \param theAttribute the checked attribute
111 //! \param theArguments arguments of the attribute
112 //! \param theError error message
113 virtual bool isValid(const AttributePtr& theAttribute,
114 const std::list<std::string>& theArguments,
115 Events_InfoMessage& theError) const;
118 /**\class SketchPlugin_MirrorAttrValidator
119 * \ingroup Validators
120 * \brief Validator for the mirror constraint input.
122 * It checks that attributes of the Mirror constraint are correct.
124 class SketchPlugin_MirrorAttrValidator : public ModelAPI_AttributeValidator
127 //! returns true if attribute is valid
128 //! \param theAttribute the checked attribute
129 //! \param theArguments arguments of the attribute (not used)
130 //! \param theError error message
131 virtual bool isValid(const AttributePtr& theAttribute,
132 const std::list<std::string>& theArguments,
133 Events_InfoMessage& theError) const;
137 /**\class SketchPlugin_CoincidenceAttrValidator
138 * \ingroup Validators
139 * \brief Validator for the coincidence constraint input.
141 * It checks that attributes of the Coincidence constraint are correct.
143 class SketchPlugin_CoincidenceAttrValidator : public ModelAPI_AttributeValidator
146 //! returns true if attribute is valid
147 //! \param theAttribute the checked attribute
148 //! \param theArguments arguments of the attribute (not used)
149 //! \param theError error message
150 virtual bool isValid(const AttributePtr& theAttribute,
151 const std::list<std::string>& theArguments,
152 Events_InfoMessage& theError) const;
156 /**\class SketchPlugin_CopyValidator
157 * \ingroup Validators
158 * \brief Validator for the constraints which create features.
160 * Applicable only for features, which creates another features. It verifies the produced
161 * features of current constraint don't become into the list of initial features
163 class SketchPlugin_CopyValidator : public ModelAPI_AttributeValidator
166 //! returns true if attribute is valid
167 //! \param theAttribute the checked attribute
168 //! \param theArguments arguments of the attribute (not used)
169 //! \param theError error message
170 virtual bool isValid(const AttributePtr& theAttribute,
171 const std::list<std::string>& theArguments,
172 Events_InfoMessage& theError) const;
175 /**\class SketchPlugin_SolverErrorValidator
176 * \ingroup Validators
177 * \brief Validator for the solver error.
179 * Simply checks that solver error attribute is empty. Returns the attribute value as an error.
181 class SketchPlugin_SolverErrorValidator : public ModelAPI_FeatureValidator
184 //! returns true if there are no solver errors
185 //! \param theFeature the checked feature
186 //! \param theArguments arguments of the feature (not used)
187 //! \param theError error message
188 virtual bool isValid(const std::shared_ptr<ModelAPI_Feature>& theFeature,
189 const std::list<std::string>& theArguments,
190 Events_InfoMessage& theError) const;
192 /// Returns true if the attribute in feature is not obligatory for the feature execution
193 virtual bool isNotObligatory(std::string theFeature, std::string theAttribute);
196 /**\class SketchPlugin_FilletVertexValidator
197 * \ingroup Validators
198 * \brief Validator for the point for fillet creation.
200 * Checks that selected point have exactly two coincident lines.
202 class SketchPlugin_FilletVertexValidator : public ModelAPI_AttributeValidator
205 //! returns true if attribute is valid
206 //! \param theAttribute the checked attribute
207 //! \param theArguments arguments of the attribute (not used)
208 //! \param theError error message
209 virtual bool isValid(const AttributePtr& theAttribute,
210 const std::list<std::string>& theArguments,
211 Events_InfoMessage& theError) const;
215 /**\class SketchPlugin_MiddlePointAttrValidator
216 * \ingroup Validators
217 * \brief Validator for the middle point constraint input.
219 * It checks that attributes of the Middle point constraint are correct.
221 class SketchPlugin_MiddlePointAttrValidator : public ModelAPI_AttributeValidator
224 //! returns true if attribute is valid
225 //! \param theAttribute the checked attribute
226 //! \param theArguments arguments of the attribute (not used)
227 //! \param theError error message
228 virtual bool isValid(const AttributePtr& theAttribute,
229 const std::list<std::string>& theArguments,
230 Events_InfoMessage& theError) const;
234 /**\class SketchPlugin_ArcTangentPointValidator
235 * \ingroup Validators
236 * \brief Validator for the point where the tangent arc is building.
238 * Checks that the point is a start or end point just on line or arc.
240 class SketchPlugin_ArcTangentPointValidator : public ModelAPI_AttributeValidator
243 //! returns true if attribute is valid
244 //! \param theAttribute the checked attribute
245 //! \param theArguments arguments of the attribute
246 //! \param theError error message
247 virtual bool isValid(const AttributePtr& theAttribute,
248 const std::list<std::string>& theArguments,
249 Events_InfoMessage& theError) const;
252 /**\class SketchPlugin_SplitValidator
253 * \ingroup Validators
254 * \brief Validator for the entity of the following type:
255 * - Linear segment with point(s) coinident to this line
256 * - Arc with point(s) coincident to the arc
257 * - Circle with at least 2 split-points on this circle
259 * Checks that there are coincident point on selected feature.
261 class SketchPlugin_SplitValidator : public ModelAPI_AttributeValidator
264 //! returns true if attribute is valid
265 //! \param theAttribute the checked attribute
266 //! \param theArguments arguments of the attribute
267 //! \param theError error message
268 virtual bool isValid(const AttributePtr& theAttribute,
269 const std::list<std::string>& theArguments,
270 Events_InfoMessage& theError) const;
273 /**\class SketchPlugin_TrimValidator
274 * \ingroup Validators
275 * \brief Validator for the entity of the following type:
276 * - Linear segment with point(s) coinident to this line or intersected it
277 * - Arc with point(s) coincident to the arc or intersected it
278 * - Circle with at least 2 split-points on this circle or intersected it
280 * Checks that there are coincident point on selected feature.
282 class SketchPlugin_TrimValidator : public ModelAPI_AttributeValidator
285 //! returns true if attribute is valid
286 //! \param theAttribute the checked attribute
287 //! \param theArguments arguments of the attribute
288 //! \param theError error message
289 virtual bool isValid(const AttributePtr& theAttribute,
290 const std::list<std::string>& theArguments,
291 Events_InfoMessage& theError) const;
294 /**\class SketchPlugin_IntersectionValidator
295 * \ingroup Validators
296 * \brief Validator for the attribute to be intersected with the sketch plane.
298 class SketchPlugin_IntersectionValidator : public ModelAPI_AttributeValidator
301 //! returns true if attribute is valid
302 //! \param theAttribute the checked attribute
303 //! \param theArguments arguments of the attribute
304 //! \param theError error message
305 virtual bool isValid(const AttributePtr& theAttribute,
306 const std::list<std::string>& theArguments,
307 Events_InfoMessage& theError) const;
310 /**\class SketchPlugin_ProjectionValidator
311 * \ingroup Validators
312 * \brief Validator for the attribute to be projected onto the sketch plane.
314 class SketchPlugin_ProjectionValidator : public ModelAPI_AttributeValidator
317 //! returns true if attribute is valid
318 //! \param theAttribute the checked attribute
319 //! \param theArguments arguments of the attribute
320 //! \param theError error message
321 virtual bool isValid(const AttributePtr& theAttribute,
322 const std::list<std::string>& theArguments,
323 Events_InfoMessage& theError) const;
326 /**\class SketchPlugin_DifferentReferenceValidator
327 * \ingroup Validators
328 * \brief Validator for attributes of a sketch feature.
330 * It checks that at least one of specified attributes
331 * refers to another feature in respect to each other.
333 class SketchPlugin_DifferentReferenceValidator : public ModelAPI_AttributeValidator
336 //! returns true if attribute is valid
337 //! \param theAttribute the checked attribute
338 //! \param theArguments arguments of the attribute
339 //! \param theError error message
340 virtual bool isValid(const AttributePtr& theAttribute,
341 const std::list<std::string>& theArguments,
342 Events_InfoMessage& theError) const;
345 /**\class SketchPlugin_DifferentPointReferenceValidator
346 * \ingroup Validators
347 * \brief Validator for attributes of a sketch feature.
349 * It checks that at least two of specified attributes refer to different points.
351 class SketchPlugin_DifferentPointReferenceValidator : public ModelAPI_AttributeValidator
354 //! returns true if attribute is valid
355 //! \param theAttribute the checked attribute
356 //! \param theArguments arguments of the attribute
357 //! \param theError error message
358 virtual bool isValid(const AttributePtr& theAttribute,
359 const std::list<std::string>& theArguments,
360 Events_InfoMessage& theError) const;
363 /**\class SketchPlugin_CirclePassedPointValidator
364 * \ingroup Validators
365 * \brief Validator for passed point of MacroCircle feature.
367 * Checks that passed point does not refer to the feature, the center is coincident to.
369 class SketchPlugin_CirclePassedPointValidator : public ModelAPI_AttributeValidator
372 //! returns true if attribute is valid
373 //! \param theAttribute the checked attribute
374 //! \param theArguments arguments of the attribute
375 //! \param theError error message
376 virtual bool isValid(const AttributePtr& theAttribute,
377 const std::list<std::string>&,
378 Events_InfoMessage& theError) const;
381 /**\class SketchPlugin_ThirdPointValidator
382 * \ingroup Validators
383 * \brief Validator for the third point of MacroCircle feature.
385 * Checks that third point does not lie on a line passed through the first two points.
386 * Checks that third point does not refer to feature lying between the first two points.
388 class SketchPlugin_ThirdPointValidator : public ModelAPI_AttributeValidator
391 //! returns true if attribute is valid
392 //! \param theAttribute the checked attribute
393 //! \param theArguments arguments of the attribute
394 //! \param theError error message
395 virtual bool isValid(const AttributePtr& theAttribute,
396 const std::list<std::string>& theArguments,
397 Events_InfoMessage& theError) const;
400 //! returns true if three points have not been placed on the same line
401 bool arePointsNotOnLine(const FeaturePtr& theMacroFeature,
402 Events_InfoMessage& theError) const;
404 //! returns true if the first two points have not been separated
405 //! by a feature referred by thrid point
406 bool arePointsNotSeparated(const FeaturePtr& theMacroFeature,
407 const std::list<std::string>& theArguments,
408 Events_InfoMessage& theError) const;
411 /**\class SketchPlugin_ArcEndPointValidator
412 * \ingroup Validators
413 * \brief Validator for the end point of MacroArc feature.
415 * Checks that third point does not lie on a point.
417 class SketchPlugin_ArcEndPointValidator: public ModelAPI_AttributeValidator
420 //! returns true if attribute is valid
421 //! \param theAttribute the checked attribute
422 //! \param theArguments arguments of the attribute
423 //! \param theError error message
424 virtual bool isValid(const AttributePtr& theAttribute,
425 const std::list<std::string>& theArguments,
426 Events_InfoMessage& theError) const;
429 /**\class SketchPlugin_ArcEndPointIntersectionValidator
430 * \ingroup Validators
431 * \brief Validator for the end point of MacroArc feature.
433 * Checks that third point does lie on edge which intersects arc.
435 class SketchPlugin_ArcEndPointIntersectionValidator: public ModelAPI_AttributeValidator
438 //! returns true if attribute is valid
439 //! \param theAttribute the checked attribute
440 //! \param theArguments arguments of the attribute
441 //! \param theError error message
442 virtual bool isValid(const AttributePtr& theAttribute,
443 const std::list<std::string>& theArguments,
444 Events_InfoMessage& theError) const;
447 /**\class SketchPlugin_HasNoConstraint
448 * \ingroup Validators
449 * \brief Validator for checking whether the feature has constraint.
451 * Checks that feature of the attribute does not have constraint with some kinds.
452 * The kinds of constraints should be described in parameters of the validator
453 * Validator processes the ModelAPI_AttributeRefAttr attribute kind
455 class SketchPlugin_HasNoConstraint: public ModelAPI_AttributeValidator
458 //! returns true if attribute is valid
459 //! \param theAttribute the checked attribute
460 //! \param theArguments arguments of the attribute
461 //! \param theError error message
462 virtual bool isValid(const AttributePtr& theAttribute,
463 const std::list<std::string>& theArguments,
464 Events_InfoMessage& theError) const;
467 /**\class SketchPlugin_ReplicationReferenceValidator
468 * \ingroup Validators
469 * \brief Validator checking that the replications features (Mirror,
470 * Multi-Rotation, Mutli-Translation) do not refer to the shapes they produce.
472 class SketchPlugin_ReplicationReferenceValidator: public ModelAPI_AttributeValidator
475 //! returns true if attribute is valid
476 //! \param theAttribute the checked attribute
477 //! \param theArguments arguments of the attribute
478 //! \param theError error message
479 virtual bool isValid(const AttributePtr& theAttribute,
480 const std::list<std::string>& theArguments,
481 Events_InfoMessage& theError) const;
484 /**\class SketchPlugin_SketchFeatureValidator
485 * \ingroup Validators
486 * \brief Validator for checking whether the feature referred by attribute is a sketch feature.
488 class SketchPlugin_SketchFeatureValidator: public ModelAPI_AttributeValidator
491 //! returns true if attribute is valid
492 //! \param theAttribute the checked attribute
493 //! \param theArguments arguments of the attribute
494 //! \param theError error message
495 virtual bool isValid(const AttributePtr& theAttribute,
496 const std::list<std::string>& theArguments,
497 Events_InfoMessage& theError) const;
500 /**\class SketchPlugin_MultiRotationAngleValidator
501 * \ingroup Validators
502 * \brief Validator for checking whether the angle of MultiRotation is in range [0, 360].
504 class SketchPlugin_MultiRotationAngleValidator : public ModelAPI_AttributeValidator
506 //! returns true if attribute is valid
507 //! \param theAttribute the checked attribute
508 //! \param theArguments arguments of the attribute
509 //! \param theError error message
510 virtual bool isValid(const AttributePtr& theAttribute,
511 const std::list<std::string>& theArguments,
512 Events_InfoMessage& theError) const;