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 SketchPlugin_Validators_H
22 #define SketchPlugin_Validators_H
24 #include "SketchPlugin.h"
25 #include <ModelAPI_AttributeValidator.h>
26 #include <ModelAPI_FeatureValidator.h>
28 /**\class SketchPlugin_DistanceAttrValidator
30 * \brief Validator for the distance input.
32 * It just checks that distance is greater than zero.
34 class SketchPlugin_DistanceAttrValidator : public ModelAPI_AttributeValidator
37 //! returns true if attribute is valid
38 //! \param theAttribute the checked attribute
39 //! \param theArguments arguments of the attribute
40 //! \param theError error message
41 virtual bool isValid(const AttributePtr& theAttribute,
42 const std::list<std::string>& theArguments,
43 Events_InfoMessage& theError) const;
46 /**\class SketchPlugin_TangentAttrValidator
48 * \brief Validator for the tangent constraint input.
50 * It just checks that distance is greater than zero.
52 class SketchPlugin_TangentAttrValidator : public ModelAPI_AttributeValidator
55 //! returns true if attribute is valid
56 //! \param theAttribute the checked attribute
57 //! \param theArguments arguments of the attribute
58 //! \param theError error message
59 virtual bool isValid(const AttributePtr& theAttribute,
60 const std::list<std::string>& theArguments,
61 Events_InfoMessage& theError) const;
65 /**\class SketchPlugin_NotFixedValidator
67 * \brief Validator for the rigid constraint input.
69 * It just checks there is no rigid constraint for the current feature.
71 class SketchPlugin_NotFixedValidator : public ModelAPI_AttributeValidator
74 //! returns true if attribute is not used in another rigid constraint
75 //! \param theAttribute the checked attribute
76 //! \param theArguments arguments of the attribute
77 //! \param theError error message
78 virtual bool isValid(const AttributePtr& theAttribute,
79 const std::list<std::string>& theArguments,
80 Events_InfoMessage& theError) const;
83 /**\class SketchPlugin_EqualAttrValidator
85 * \brief Validator for the equal constraint input.
87 * It checks that attributes of the Equal constraint are correct.
89 class SketchPlugin_EqualAttrValidator : public ModelAPI_AttributeValidator
92 //! returns true if attribute is valid
93 //! \param theAttribute the checked attribute
94 //! \param theArguments arguments of the attribute
95 //! \param theError error message
96 virtual bool isValid(const AttributePtr& theAttribute,
97 const std::list<std::string>& theArguments,
98 Events_InfoMessage& theError) const;
101 /**\class SketchPlugin_MirrorAttrValidator
102 * \ingroup Validators
103 * \brief Validator for the mirror constraint input.
105 * It checks that attributes of the Mirror constraint are correct.
107 class SketchPlugin_MirrorAttrValidator : public ModelAPI_AttributeValidator
110 //! returns true if attribute is valid
111 //! \param theAttribute the checked attribute
112 //! \param theArguments arguments of the attribute (not used)
113 //! \param theError error message
114 virtual bool isValid(const AttributePtr& theAttribute,
115 const std::list<std::string>& theArguments,
116 Events_InfoMessage& theError) const;
120 /**\class SketchPlugin_CoincidenceAttrValidator
121 * \ingroup Validators
122 * \brief Validator for the coincidence constraint input.
124 * It checks that attributes of the Coincidence constraint are correct.
126 class SketchPlugin_CoincidenceAttrValidator : public ModelAPI_AttributeValidator
129 //! returns true if attribute is valid
130 //! \param theAttribute the checked attribute
131 //! \param theArguments arguments of the attribute (not used)
132 //! \param theError error message
133 virtual bool isValid(const AttributePtr& theAttribute,
134 const std::list<std::string>& theArguments,
135 Events_InfoMessage& theError) const;
139 /**\class SketchPlugin_CopyValidator
140 * \ingroup Validators
141 * \brief Validator for the constraints which create features.
143 * Applicable only for features, which creates another features. It verifies the produced
144 * features of current constraint don't become into the list of initial features
146 class SketchPlugin_CopyValidator : public ModelAPI_AttributeValidator
149 //! returns true if attribute is valid
150 //! \param theAttribute the checked attribute
151 //! \param theArguments arguments of the attribute (not used)
152 //! \param theError error message
153 virtual bool isValid(const AttributePtr& theAttribute,
154 const std::list<std::string>& theArguments,
155 Events_InfoMessage& theError) const;
158 /**\class SketchPlugin_SolverErrorValidator
159 * \ingroup Validators
160 * \brief Validator for the solver error.
162 * Simply checks that solver error attribute is empty. Returns the attribute value as an error.
164 class SketchPlugin_SolverErrorValidator : public ModelAPI_FeatureValidator
167 //! returns true if there are no solver errors
168 //! \param theFeature the checked feature
169 //! \param theArguments arguments of the feature (not used)
170 //! \param theError error message
171 virtual bool isValid(const std::shared_ptr<ModelAPI_Feature>& theFeature,
172 const std::list<std::string>& theArguments,
173 Events_InfoMessage& theError) const;
175 /// Returns true if the attribute in feature is not obligatory for the feature execution
176 virtual bool isNotObligatory(std::string theFeature, std::string theAttribute);
179 /**\class SketchPlugin_FilletVertexValidator
180 * \ingroup Validators
181 * \brief Validator for the point for fillet creation.
183 * Checks that selected point have exactly two coincident lines.
185 class SketchPlugin_FilletVertexValidator : public ModelAPI_AttributeValidator
188 //! returns true if attribute is valid
189 //! \param theAttribute the checked attribute
190 //! \param theArguments arguments of the attribute (not used)
191 //! \param theError error message
192 virtual bool isValid(const AttributePtr& theAttribute,
193 const std::list<std::string>& theArguments,
194 Events_InfoMessage& theError) const;
198 /**\class SketchPlugin_MiddlePointAttrValidator
199 * \ingroup Validators
200 * \brief Validator for the middle point constraint input.
202 * It checks that attributes of the Middle point constraint are correct.
204 class SketchPlugin_MiddlePointAttrValidator : public ModelAPI_AttributeValidator
207 //! returns true if attribute is valid
208 //! \param theAttribute the checked attribute
209 //! \param theArguments arguments of the attribute (not used)
210 //! \param theError error message
211 virtual bool isValid(const AttributePtr& theAttribute,
212 const std::list<std::string>& theArguments,
213 Events_InfoMessage& theError) const;
217 /**\class SketchPlugin_ArcTangentPointValidator
218 * \ingroup Validators
219 * \brief Validator for the point where the tangent arc is building.
221 * Checks that the point is a start or end point just on line or arc.
223 class SketchPlugin_ArcTangentPointValidator : public ModelAPI_AttributeValidator
226 //! returns true if attribute is valid
227 //! \param theAttribute the checked attribute
228 //! \param theArguments arguments of the attribute
229 //! \param theError error message
230 virtual bool isValid(const AttributePtr& theAttribute,
231 const std::list<std::string>& theArguments,
232 Events_InfoMessage& theError) const;
235 /**\class SketchPlugin_SplitValidator
236 * \ingroup Validators
237 * \brief Validator for the entity of the following type:
238 * - Linear segment with point(s) coinident to this line
239 * - Arc with point(s) coincident to the arc
240 * - Circle with at least 2 split-points on this circle
242 * Checks that there are coincident point on selected feature.
244 class SketchPlugin_SplitValidator : public ModelAPI_AttributeValidator
247 //! returns true if attribute is valid
248 //! \param theAttribute the checked attribute
249 //! \param theArguments arguments of the attribute
250 //! \param theError error message
251 virtual bool isValid(const AttributePtr& theAttribute,
252 const std::list<std::string>& theArguments,
253 Events_InfoMessage& theError) const;
256 /**\class SketchPlugin_TrimValidator
257 * \ingroup Validators
258 * \brief Validator for the entity of the following type:
259 * - Linear segment with point(s) coinident to this line or intersected it
260 * - Arc with point(s) coincident to the arc or intersected it
261 * - Circle with at least 2 split-points on this circle or intersected it
263 * Checks that there are coincident point on selected feature.
265 class SketchPlugin_TrimValidator : public ModelAPI_AttributeValidator
268 //! returns true if attribute is valid
269 //! \param theAttribute the checked attribute
270 //! \param theArguments arguments of the attribute
271 //! \param theError error message
272 virtual bool isValid(const AttributePtr& theAttribute,
273 const std::list<std::string>& theArguments,
274 Events_InfoMessage& theError) const;
277 /**\class SketchPlugin_IntersectionValidator
278 * \ingroup Validators
279 * \brief Validator for the attribute to be intersected with the sketch plane.
281 class SketchPlugin_IntersectionValidator : public ModelAPI_AttributeValidator
284 //! returns true if attribute is valid
285 //! \param theAttribute the checked attribute
286 //! \param theArguments arguments of the attribute
287 //! \param theError error message
288 virtual bool isValid(const AttributePtr& theAttribute,
289 const std::list<std::string>& theArguments,
290 Events_InfoMessage& theError) const;
293 /**\class SketchPlugin_ProjectionValidator
294 * \ingroup Validators
295 * \brief Validator for the attribute to be projected onto the sketch plane.
297 class SketchPlugin_ProjectionValidator : public ModelAPI_AttributeValidator
300 //! returns true if attribute is valid
301 //! \param theAttribute the checked attribute
302 //! \param theArguments arguments of the attribute
303 //! \param theError error message
304 virtual bool isValid(const AttributePtr& theAttribute,
305 const std::list<std::string>& theArguments,
306 Events_InfoMessage& theError) const;
309 /**\class SketchPlugin_DifferentReferenceValidator
310 * \ingroup Validators
311 * \brief Validator for attributes of a sketch feature.
313 * It checks that at least one of specified attributes
314 * refers to another feature in respect to each other.
316 class SketchPlugin_DifferentReferenceValidator : public ModelAPI_AttributeValidator
319 //! returns true if attribute is valid
320 //! \param theAttribute the checked attribute
321 //! \param theArguments arguments of the attribute
322 //! \param theError error message
323 virtual bool isValid(const AttributePtr& theAttribute,
324 const std::list<std::string>& theArguments,
325 Events_InfoMessage& theError) const;
328 /**\class SketchPlugin_DifferentPointReferenceValidator
329 * \ingroup Validators
330 * \brief Validator for attributes of a sketch feature.
332 * It checks that at least two of specified attributes refer to different points.
334 class SketchPlugin_DifferentPointReferenceValidator : public ModelAPI_AttributeValidator
337 //! returns true if attribute is valid
338 //! \param theAttribute the checked attribute
339 //! \param theArguments arguments of the attribute
340 //! \param theError error message
341 virtual bool isValid(const AttributePtr& theAttribute,
342 const std::list<std::string>& theArguments,
343 Events_InfoMessage& theError) const;
346 /**\class SketchPlugin_CirclePassedPointValidator
347 * \ingroup Validators
348 * \brief Validator for passed point of MacroCircle feature.
350 * Checks that passed point does not refer to the feature, the center is coincident to.
352 class SketchPlugin_CirclePassedPointValidator : public ModelAPI_AttributeValidator
355 //! returns true if attribute is valid
356 //! \param theAttribute the checked attribute
357 //! \param theArguments arguments of the attribute
358 //! \param theError error message
359 virtual bool isValid(const AttributePtr& theAttribute,
360 const std::list<std::string>&,
361 Events_InfoMessage& theError) const;
364 /**\class SketchPlugin_ThirdPointValidator
365 * \ingroup Validators
366 * \brief Validator for the third point of MacroCircle feature.
368 * Checks that third point does not lie on a line passed through the first two points.
369 * Checks that third point does not refer to feature lying between the first two points.
371 class SketchPlugin_ThirdPointValidator : public ModelAPI_AttributeValidator
374 //! returns true if attribute is valid
375 //! \param theAttribute the checked attribute
376 //! \param theArguments arguments of the attribute
377 //! \param theError error message
378 virtual bool isValid(const AttributePtr& theAttribute,
379 const std::list<std::string>& theArguments,
380 Events_InfoMessage& theError) const;
383 //! returns true if three points have not been placed on the same line
384 bool arePointsNotOnLine(const FeaturePtr& theMacroFeature,
385 Events_InfoMessage& theError) const;
387 //! returns true if the first two points have not been separated
388 //! by a feature referred by thrid point
389 bool arePointsNotSeparated(const FeaturePtr& theMacroFeature,
390 const std::list<std::string>& theArguments,
391 Events_InfoMessage& theError) const;
394 /**\class SketchPlugin_ArcEndPointValidator
395 * \ingroup Validators
396 * \brief Validator for the end point of MacroArc feature.
398 * Checks that third point does not lie on a point.
400 class SketchPlugin_ArcEndPointValidator: public ModelAPI_AttributeValidator
403 //! returns true if attribute is valid
404 //! \param theAttribute the checked attribute
405 //! \param theArguments arguments of the attribute
406 //! \param theError error message
407 virtual bool isValid(const AttributePtr& theAttribute,
408 const std::list<std::string>& theArguments,
409 Events_InfoMessage& theError) const;
412 /**\class SketchPlugin_ArcEndPointIntersectionValidator
413 * \ingroup Validators
414 * \brief Validator for the end point of MacroArc feature.
416 * Checks that third point does lie on edge which intersects arc.
418 class SketchPlugin_ArcEndPointIntersectionValidator: public ModelAPI_AttributeValidator
421 //! returns true if attribute is valid
422 //! \param theAttribute the checked attribute
423 //! \param theArguments arguments of the attribute
424 //! \param theError error message
425 virtual bool isValid(const AttributePtr& theAttribute,
426 const std::list<std::string>& theArguments,
427 Events_InfoMessage& theError) const;
430 /**\class SketchPlugin_HasNoConstraint
431 * \ingroup Validators
432 * \brief Validator for checking whether the feature has constraint.
434 * Checks that feature of the attribute does not have constraint with some kinds.
435 * The kinds of constraints should be described in parameters of the validator
436 * Validator processes the ModelAPI_AttributeRefAttr attribute kind
438 class SketchPlugin_HasNoConstraint: public ModelAPI_AttributeValidator
441 //! returns true if attribute is valid
442 //! \param theAttribute the checked attribute
443 //! \param theArguments arguments of the attribute
444 //! \param theError error message
445 virtual bool isValid(const AttributePtr& theAttribute,
446 const std::list<std::string>& theArguments,
447 Events_InfoMessage& theError) const;
450 /**\class SketchPlugin_ReplicationReferenceValidator
451 * \ingroup Validators
452 * \brief Validator checking that the replications features (Mirror,
453 * Multi-Rotation, Mutli-Translation) do not refer to the shapes they produce.
455 class SketchPlugin_ReplicationReferenceValidator: 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_SketchFeatureValidator
468 * \ingroup Validators
469 * \brief Validator for checking whether the feature referred by attribute is a sketch feature.
471 class SketchPlugin_SketchFeatureValidator: public ModelAPI_AttributeValidator
474 //! returns true if attribute is valid
475 //! \param theAttribute the checked attribute
476 //! \param theArguments arguments of the attribute
477 //! \param theError error message
478 virtual bool isValid(const AttributePtr& theAttribute,
479 const std::list<std::string>& theArguments,
480 Events_InfoMessage& theError) const;
483 /**\class SketchPlugin_MultiRotationAngleValidator
484 * \ingroup Validators
485 * \brief Validator for checking whether the angle of MultiRotation is in range [0, 360].
487 class SketchPlugin_MultiRotationAngleValidator : public ModelAPI_AttributeValidator
489 //! returns true if attribute is valid
490 //! \param theAttribute the checked attribute
491 //! \param theArguments arguments of the attribute
492 //! \param theError error message
493 virtual bool isValid(const AttributePtr& theAttribute,
494 const std::list<std::string>& theArguments,
495 Events_InfoMessage& theError) const;