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;
64 /**\class SketchPlugin_NotFixedValidator
66 * \brief Validator for the rigid constraint input.
68 * It just checks there is no rigid constraint for the current feature.
70 class SketchPlugin_NotFixedValidator : public ModelAPI_AttributeValidator
73 //! returns true if attribute is not used in another rigid constraint
74 //! \param theAttribute the checked attribute
75 //! \param theArguments arguments of the attribute
76 //! \param theError error message
77 virtual bool isValid(const AttributePtr& theAttribute,
78 const std::list<std::string>& theArguments,
79 Events_InfoMessage& theError) const;
82 /**\class SketchPlugin_EqualAttrValidator
84 * \brief Validator for the equal constraint input.
86 * It checks that attributes of the Equal constraint are correct.
88 class SketchPlugin_EqualAttrValidator : public ModelAPI_AttributeValidator
91 //! returns true if attribute is valid
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_MirrorAttrValidator
101 * \ingroup Validators
102 * \brief Validator for the mirror constraint input.
104 * It checks that attributes of the Mirror constraint are correct.
106 class SketchPlugin_MirrorAttrValidator : public ModelAPI_AttributeValidator
109 //! returns true if attribute is valid
110 //! \param theAttribute the checked attribute
111 //! \param theArguments arguments of the attribute (not used)
112 //! \param theError error message
113 virtual bool isValid(const AttributePtr& theAttribute,
114 const std::list<std::string>& theArguments,
115 Events_InfoMessage& theError) const;
119 /**\class SketchPlugin_CoincidenceAttrValidator
120 * \ingroup Validators
121 * \brief Validator for the coincidence constraint input.
123 * It checks that attributes of the Coincidence constraint are correct.
125 class SketchPlugin_CoincidenceAttrValidator : public ModelAPI_AttributeValidator
128 //! returns true if attribute is valid
129 //! \param theAttribute the checked attribute
130 //! \param theArguments arguments of the attribute (not used)
131 //! \param theError error message
132 virtual bool isValid(const AttributePtr& theAttribute,
133 const std::list<std::string>& theArguments,
134 Events_InfoMessage& theError) const;
138 /**\class SketchPlugin_CopyValidator
139 * \ingroup Validators
140 * \brief Validator for the constraints which create features.
142 * Applicable only for features, which creates another features. It verifies the produced
143 * features of current constraint don't become into the list of initial features
145 class SketchPlugin_CopyValidator : public ModelAPI_AttributeValidator
148 //! returns true if attribute is valid
149 //! \param theAttribute the checked attribute
150 //! \param theArguments arguments of the attribute (not used)
151 //! \param theError error message
152 virtual bool isValid(const AttributePtr& theAttribute,
153 const std::list<std::string>& theArguments,
154 Events_InfoMessage& theError) const;
157 /**\class SketchPlugin_SolverErrorValidator
158 * \ingroup Validators
159 * \brief Validator for the solver error.
161 * Simply checks that solver error attribute is empty. Returns the attribute value as an error.
163 class SketchPlugin_SolverErrorValidator : public ModelAPI_FeatureValidator
166 //! returns true if there are no solver errors
167 //! \param theFeature the checked feature
168 //! \param theArguments arguments of the feature (not used)
169 //! \param theError error message
170 virtual bool isValid(const std::shared_ptr<ModelAPI_Feature>& theFeature,
171 const std::list<std::string>& theArguments,
172 Events_InfoMessage& theError) const;
174 /// Returns true if the attribute in feature is not obligatory for the feature execution
175 virtual bool isNotObligatory(std::string theFeature, std::string theAttribute);
178 /**\class SketchPlugin_FilletVertexValidator
179 * \ingroup Validators
180 * \brief Validator for the point for fillet creation.
182 * Checks that selected point have exactly two coincident lines.
184 class SketchPlugin_FilletVertexValidator : public ModelAPI_AttributeValidator
187 //! returns true if attribute is valid
188 //! \param theAttribute the checked attribute
189 //! \param theArguments arguments of the attribute (not used)
190 //! \param theError error message
191 virtual bool isValid(const AttributePtr& theAttribute,
192 const std::list<std::string>& theArguments,
193 Events_InfoMessage& theError) const;
197 /**\class SketchPlugin_MiddlePointAttrValidator
198 * \ingroup Validators
199 * \brief Validator for the middle point constraint input.
201 * It checks that attributes of the Middle point constraint are correct.
203 class SketchPlugin_MiddlePointAttrValidator : public ModelAPI_AttributeValidator
206 //! returns true if attribute is valid
207 //! \param theAttribute the checked attribute
208 //! \param theArguments arguments of the attribute (not used)
209 //! \param theError error message
210 virtual bool isValid(const AttributePtr& theAttribute,
211 const std::list<std::string>& theArguments,
212 Events_InfoMessage& theError) const;
216 /**\class SketchPlugin_ArcTangentPointValidator
217 * \ingroup Validators
218 * \brief Validator for the point where the tangent arc is building.
220 * Checks that the point is a start or end point just on line or arc.
222 class SketchPlugin_ArcTangentPointValidator : public ModelAPI_AttributeValidator
225 //! returns true if attribute is valid
226 //! \param theAttribute the checked attribute
227 //! \param theArguments arguments of the attribute
228 //! \param theError error message
229 virtual bool isValid(const AttributePtr& theAttribute,
230 const std::list<std::string>& theArguments,
231 Events_InfoMessage& theError) const;
234 /**\class SketchPlugin_SplitValidator
235 * \ingroup Validators
236 * \brief Validator for the entity of the following type:
237 * - Linear segment with point(s) coinident to this line
238 * - Arc with point(s) coincident to the arc
239 * - Circle with at least 2 split-points on this circle
241 * Checks that there are coincident point on selected feature.
243 class SketchPlugin_SplitValidator : public ModelAPI_AttributeValidator
246 //! returns true if attribute is valid
247 //! \param theAttribute the checked attribute
248 //! \param theArguments arguments of the attribute
249 //! \param theError error message
250 virtual bool isValid(const AttributePtr& theAttribute,
251 const std::list<std::string>& theArguments,
252 Events_InfoMessage& theError) const;
255 /**\class SketchPlugin_TrimValidator
256 * \ingroup Validators
257 * \brief Validator for the entity of the following type:
258 * - Linear segment with point(s) coinident to this line or intersected it
259 * - Arc with point(s) coincident to the arc or intersected it
260 * - Circle with at least 2 split-points on this circle or intersected it
262 * Checks that there are coincident point on selected feature.
264 class SketchPlugin_TrimValidator : public ModelAPI_AttributeValidator
267 //! returns true if attribute is valid
268 //! \param theAttribute the checked attribute
269 //! \param theArguments arguments of the attribute
270 //! \param theError error message
271 virtual bool isValid(const AttributePtr& theAttribute,
272 const std::list<std::string>& theArguments,
273 Events_InfoMessage& theError) const;
276 /**\class SketchPlugin_IntersectionValidator
277 * \ingroup Validators
278 * \brief Validator for the attribute to be intersected with the sketch plane.
280 class SketchPlugin_IntersectionValidator : public ModelAPI_AttributeValidator
283 //! returns true if attribute is valid
284 //! \param theAttribute the checked attribute
285 //! \param theArguments arguments of the attribute
286 //! \param theError error message
287 virtual bool isValid(const AttributePtr& theAttribute,
288 const std::list<std::string>& theArguments,
289 Events_InfoMessage& theError) const;
292 /**\class SketchPlugin_ProjectionValidator
293 * \ingroup Validators
294 * \brief Validator for the attribute to be projected onto the sketch plane.
296 class SketchPlugin_ProjectionValidator : public ModelAPI_AttributeValidator
299 //! returns true if attribute is valid
300 //! \param theAttribute the checked attribute
301 //! \param theArguments arguments of the attribute
302 //! \param theError error message
303 virtual bool isValid(const AttributePtr& theAttribute,
304 const std::list<std::string>& theArguments,
305 Events_InfoMessage& theError) const;
308 /**\class SketchPlugin_DifferentReferenceValidator
309 * \ingroup Validators
310 * \brief Validator for attributes of a sketch feature.
312 * It checks that at least one of specified attributes
313 * refers to another feature in respect to each other.
315 class SketchPlugin_DifferentReferenceValidator : public ModelAPI_AttributeValidator
318 //! returns true if attribute is valid
319 //! \param theAttribute the checked attribute
320 //! \param theArguments arguments of the attribute
321 //! \param theError error message
322 virtual bool isValid(const AttributePtr& theAttribute,
323 const std::list<std::string>& theArguments,
324 Events_InfoMessage& theError) const;
327 /**\class SketchPlugin_DifferentPointReferenceValidator
328 * \ingroup Validators
329 * \brief Validator for attributes of a sketch feature.
331 * It checks that at least two of specified attributes refer to different points.
333 class SketchPlugin_DifferentPointReferenceValidator : 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_CirclePassedPointValidator
346 * \ingroup Validators
347 * \brief Validator for passed point of MacroCircle feature.
349 * Checks that passed point does not refer to the feature, the center is coincident to.
351 class SketchPlugin_CirclePassedPointValidator : 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>&,
360 Events_InfoMessage& theError) const;
363 /**\class SketchPlugin_ThirdPointValidator
364 * \ingroup Validators
365 * \brief Validator for the third point of MacroCircle feature.
367 * Checks that third point does not lie on a line passed through the first two points.
368 * Checks that third point does not refer to feature lying between the first two points.
370 class SketchPlugin_ThirdPointValidator : public ModelAPI_AttributeValidator
373 //! returns true if attribute is valid
374 //! \param theAttribute the checked attribute
375 //! \param theArguments arguments of the attribute
376 //! \param theError error message
377 virtual bool isValid(const AttributePtr& theAttribute,
378 const std::list<std::string>& theArguments,
379 Events_InfoMessage& theError) const;
382 //! returns true if three points have not been placed on the same line
383 bool arePointsNotOnLine(const FeaturePtr& theMacroFeature,
384 Events_InfoMessage& theError) const;
386 //! returns true if the first two points have not been separated
387 //! by a feature referred by thrid point
388 bool arePointsNotSeparated(const FeaturePtr& theMacroFeature,
389 const std::list<std::string>& theArguments,
390 Events_InfoMessage& theError) const;
393 /**\class SketchPlugin_ArcEndPointValidator
394 * \ingroup Validators
395 * \brief Validator for the end point of MacroArc feature.
397 * Checks that third point does not lie on a point.
399 class SketchPlugin_ArcEndPointValidator: public ModelAPI_AttributeValidator
402 //! returns true if attribute is valid
403 //! \param theAttribute the checked attribute
404 //! \param theArguments arguments of the attribute
405 //! \param theError error message
406 virtual bool isValid(const AttributePtr& theAttribute,
407 const std::list<std::string>& theArguments,
408 Events_InfoMessage& theError) const;
411 /**\class SketchPlugin_ArcEndPointIntersectionValidator
412 * \ingroup Validators
413 * \brief Validator for the end point of MacroArc feature.
415 * Checks that third point does lie on edge which intersects arc.
417 class SketchPlugin_ArcEndPointIntersectionValidator: 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_HasNoConstraint
430 * \ingroup Validators
431 * \brief Validator for checking whether the feature has constraint.
433 * Checks that feature of the attribute does not have constraint with some kinds.
434 * The kinds of constraints should be described in parameters of the validator
435 * Validator processes the ModelAPI_AttributeRefAttr attribute kind
437 class SketchPlugin_HasNoConstraint: public ModelAPI_AttributeValidator
440 //! returns true if attribute is valid
441 //! \param theAttribute the checked attribute
442 //! \param theArguments arguments of the attribute
443 //! \param theError error message
444 virtual bool isValid(const AttributePtr& theAttribute,
445 const std::list<std::string>& theArguments,
446 Events_InfoMessage& theError) const;
449 /**\class SketchPlugin_ReplicationReferenceValidator
450 * \ingroup Validators
451 * \brief Validator checking that the replications features (Mirror,
452 * Multi-Rotation, Mutli-Translation) do not refer to the shapes they produce.
454 class SketchPlugin_ReplicationReferenceValidator: public ModelAPI_AttributeValidator
457 //! returns true if attribute is valid
458 //! \param theAttribute the checked attribute
459 //! \param theArguments arguments of the attribute
460 //! \param theError error message
461 virtual bool isValid(const AttributePtr& theAttribute,
462 const std::list<std::string>& theArguments,
463 Events_InfoMessage& theError) const;
466 /**\class SketchPlugin_SketchFeatureValidator
467 * \ingroup Validators
468 * \brief Validator for checking whether the feature referred by attribute is a sketch feature.
470 class SketchPlugin_SketchFeatureValidator: public ModelAPI_AttributeValidator
473 //! returns true if attribute is valid
474 //! \param theAttribute the checked attribute
475 //! \param theArguments arguments of the attribute
476 //! \param theError error message
477 virtual bool isValid(const AttributePtr& theAttribute,
478 const std::list<std::string>& theArguments,
479 Events_InfoMessage& theError) const;
482 /**\class SketchPlugin_MultiRotationAngleValidator
483 * \ingroup Validators
484 * \brief Validator for checking whether the angle of MultiRotation is in range [0, 360].
486 class SketchPlugin_MultiRotationAngleValidator : public ModelAPI_AttributeValidator
488 //! returns true if attribute is valid
489 //! \param theAttribute the checked attribute
490 //! \param theArguments arguments of the attribute
491 //! \param theError error message
492 virtual bool isValid(const AttributePtr& theAttribute,
493 const std::list<std::string>& theArguments,
494 Events_InfoMessage& theError) const;