1 // Copyright (C) 2014-2022 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 FeaturesPlugin_Validators_H_
21 #define FeaturesPlugin_Validators_H_
23 #include <ModelAPI_AttributeValidator.h>
24 #include <ModelAPI_FeatureValidator.h>
26 /// \class FeaturesPlugin_ValidatorPipePath
27 /// \ingroup Validators
28 /// \brief A validator for selection pipe path.
29 class FeaturesPlugin_ValidatorPipePath: public ModelAPI_AttributeValidator
32 //! \return True if the attribute is valid.
33 //! \param[in] theAttribute the checked attribute.
34 //! \param[in] theArguments arguments of the attribute.
35 //! \param[out] theError error message.
36 virtual bool isValid(const AttributePtr& theAttribute,
37 const std::list<std::string>& theArguments,
38 Events_InfoMessage& theError) const;
41 /// \class FeaturesPlugin_ValidatorPipeLocations
42 /// \ingroup Validators
43 /// \brief A validator for selection pipe locations.
44 class FeaturesPlugin_ValidatorPipeLocations: public ModelAPI_AttributeValidator
47 //! \return True if the attribute is valid.
48 //! \param[in] theAttribute the checked attribute.
49 //! \param[in] theArguments arguments of the attribute.
50 //! \param[out] theError error message.
51 virtual bool isValid(const AttributePtr& theAttribute,
52 const std::list<std::string>& theArguments,
53 Events_InfoMessage& theError) const;
56 /// \class FeaturesPlugin_ValidatorPipeLocationsNumber
57 /// \ingroup Validators
58 /// \brief Validator for the pipe locations.
59 class FeaturesPlugin_ValidatorPipeLocationsNumber: public ModelAPI_FeatureValidator
62 //! \return true if number of selected locations the same as number of selected bases, or empty.
63 //! \param theFeature the checked feature
64 //! \param theArguments arguments of the feature (not used)
65 //! \param theError error message
66 virtual bool isValid(const std::shared_ptr<ModelAPI_Feature>& theFeature,
67 const std::list<std::string>& theArguments,
68 Events_InfoMessage& theError) const;
71 /// \class FeaturesPlugin_ValidatorLoftSameTypeShape
72 /// \ingroup Validators
73 /// \brief Validator for the same type of shape.
74 class FeaturesPlugin_ValidatorLoftSameTypeShape: public ModelAPI_FeatureValidator
77 //! \return true if the type of selected are the same
78 //! \param theFeature the checked feature
79 //! \param theArguments arguments of the feature (not used)
80 //! \param theError error message
81 virtual bool isValid(const std::shared_ptr<ModelAPI_Feature>& theFeature,
82 const std::list<std::string>& theArguments,
83 Events_InfoMessage& theError) const;
86 /// \class FeaturesPlugin_ValidatorBaseForGeneration
87 /// \ingroup Validators
88 /// \brief A validator for selection base for generation. Allows to select faces on sketch,
89 /// whole sketch (if it has at least one face), and following objects: vertex, edge, wire, face.
90 class FeaturesPlugin_ValidatorBaseForGeneration: public ModelAPI_AttributeValidator
93 //! \return true if attribute has selection type listed in the parameter arguments.
94 //! \param[in] theAttribute the checked attribute.
95 //! \param[in] theArguments arguments of the attribute.
96 //! \param[out] theError error message.
97 virtual bool isValid(const AttributePtr& theAttribute,
98 const std::list<std::string>& theArguments,
99 Events_InfoMessage& theError) const;
102 bool isValidAttribute(const AttributePtr& theAttribute,
103 const std::list<std::string>& theArguments,
104 Events_InfoMessage& theError) const;
107 /// \class FeaturesPlugin_ValidatorBaseForGenerationSketchOrSketchObjects
108 /// \ingroup Validators
109 /// \brief Validator for the base objects for generation. Checks that sketch and it objects
110 /// are not selected at the same time.
111 class FeaturesPlugin_ValidatorBaseForGenerationSketchOrSketchObjects:
112 public ModelAPI_FeatureValidator
115 //! \return true if sketch and it objects not selected at the same time.
116 //! \param theFeature the checked feature
117 //! \param theArguments arguments of the feature (not used)
118 //! \param theError error message
119 virtual bool isValid(const std::shared_ptr<ModelAPI_Feature>& theFeature,
120 const std::list<std::string>& theArguments,
121 Events_InfoMessage& theError) const;
124 /// \class FeaturesPlugin_ValidatorCompositeLauncher
125 /// \ingroup Validators
126 /// \brief A validator for selection at composite feature start
127 class FeaturesPlugin_ValidatorCompositeLauncher: public ModelAPI_AttributeValidator
130 //! \return true if attribute has selection type listed in the parameter arguments.
131 //! \param[in] theAttribute the checked attribute.
132 //! \param[in] theArguments arguments of the attribute.
133 //! \param[out] theError error message.
134 virtual bool isValid(const AttributePtr& theAttribute,
135 const std::list<std::string>& theArguments,
136 Events_InfoMessage& theError) const;
139 /// \class FeaturesPlugin_ValidatorExtrusionDir
140 /// \ingroup Validators
141 /// \brief A validator for extrusion direction attribute. Allows it to be empty if base objects are
142 /// planar and do not contain vertices and edges.
143 class FeaturesPlugin_ValidatorExtrusionDir: public ModelAPI_FeatureValidator
146 //! \return true if attribute listed in the parameter arguments are planar.
147 //! \param[in] theFeature the checked feature.
148 //! \param[in] theArguments arguments of the attribute.
149 //! \param[out] theError error message.
150 virtual bool isValid(const std::shared_ptr<ModelAPI_Feature>& theFeature,
151 const std::list<std::string>& theArguments,
152 Events_InfoMessage& theError) const;
155 bool isShapesCanBeEmpty(const AttributePtr& theAttribute,
156 Events_InfoMessage& theError) const;
159 /// \class FeaturesPlugin_ValidatorExtrusionBoundaryFace
160 /// \ingroup Validators
161 /// \brief A validator for extrusion from/to face attribute.
162 class FeaturesPlugin_ValidatorExtrusionBoundaryFace: public ModelAPI_AttributeValidator
165 //! \return true if attribute listed in the parameter arguments are planar.
166 //! \param[in] theFeature the checked feature.
167 //! \param[in] theArguments arguments of the attribute.
168 //! \param[out] theError error message.
169 virtual bool isValid(const AttributePtr& theAttribute,
170 const std::list<std::string>& theArguments,
171 Events_InfoMessage& theError) const;
174 /// \class FeaturesPlugin_ValidatorBooleanSelection
175 /// \ingroup Validators
176 /// \brief Validates selection for boolean operation.
177 class FeaturesPlugin_ValidatorBooleanSelection: public ModelAPI_AttributeValidator
180 /// \return True if the attribute is valid. It checks whether the selection
181 /// is acceptable for boolean operation.
182 /// \param[in] theAttribute an attribute to check.
183 /// \param[in] theArguments a filter parameters.
184 /// \param[out] theError error message.
185 virtual bool isValid(const AttributePtr& theAttribute,
186 const std::list<std::string>& theArguments,
187 Events_InfoMessage& theError) const;
190 /// \class FeaturesPlugin_ValidatorFilletSelection
191 /// \ingroup Validators
192 /// \brief Validates selection for fillet operation.
193 class FeaturesPlugin_ValidatorFilletSelection: public ModelAPI_AttributeValidator
196 /// \return True if the attribute is valid. It checks whether the selection
197 /// is acceptable for boolean operation.
198 /// \param[in] theAttribute an attribute to check.
199 /// \param[in] theArguments a filter parameters.
200 /// \param[out] theError error message.
201 virtual bool isValid(const AttributePtr& theAttribute,
202 const std::list<std::string>& theArguments,
203 Events_InfoMessage& theError) const;
206 /// \class FeaturesPlugin_ValidatorFillet1DSelection
207 /// \ingroup Validators
208 /// \brief Validates selection for 1d-fillet operation.
209 class FeaturesPlugin_ValidatorFillet1DSelection : public ModelAPI_AttributeValidator
212 /// \return True if the attribute is valid. It checks whether the selection
213 /// is acceptable for fillet on wire (vertex is a sharp corner).
214 /// \param[in] theAttribute an attribute to check.
215 /// \param[in] theArguments a filter parameters.
216 /// \param[out] theError error message.
217 virtual bool isValid(const AttributePtr& theAttribute,
218 const std::list<std::string>& theArguments,
219 Events_InfoMessage& theError) const;
222 /// \class FeaturesPlugin_ValidatorPartitionSelection
223 /// \ingroup Validators
224 /// \brief Validates selection for partition.
225 class FeaturesPlugin_ValidatorPartitionSelection: public ModelAPI_AttributeValidator
228 /// \return True if the attribute is valid. It checks whether the selection
229 /// is acceptable for operation.
230 /// \param[in] theAttribute an attribute to check.
231 /// \param[in] theArguments a filter parameters.
232 /// \param[out] theError error message.
233 virtual bool isValid(const AttributePtr& theAttribute,
234 const std::list<std::string>& theArguments,
235 Events_InfoMessage& theError) const;
238 /// \class FeaturesPlugin_ValidatorRemoveSubShapesSelection
239 /// \ingroup Validators
240 /// \brief Validates selection for "Remove Sub-Shapes" feature.
241 class FeaturesPlugin_ValidatorRemoveSubShapesSelection: public ModelAPI_AttributeValidator
244 /// \return True if the attribute is valid. It checks whether the selection
245 /// is acceptable for operation.
246 /// \param[in] theAttribute an attribute to check.
247 /// \param[in] theArguments a filter parameters.
248 /// \param[out] theError error message.
249 virtual bool isValid(const AttributePtr& theAttribute,
250 const std::list<std::string>& theArguments,
251 Events_InfoMessage& theError) const;
254 /// \class FeaturesPlugin_ValidatorRemoveSubShapesResult
255 /// \ingroup Validators
256 /// \brief Validator for the Remove Sub-Shapes feature.
257 class FeaturesPlugin_ValidatorRemoveSubShapesResult: public ModelAPI_FeatureValidator
260 //! \return true if result is valid shape.
261 //! \param theFeature the checked feature
262 //! \param theArguments arguments of the feature (not used)
263 //! \param theError error message
264 virtual bool isValid(const std::shared_ptr<ModelAPI_Feature>& theFeature,
265 const std::list<std::string>& theArguments,
266 Events_InfoMessage& theError) const;
269 /// \class FeaturesPlugin_ValidatorUnionSelection
270 /// \ingroup Validators
271 /// \brief Validates selection for "Union" feature.
272 class FeaturesPlugin_ValidatorUnionSelection: public ModelAPI_AttributeValidator
275 /// \return True if the attribute is valid. It checks whether the selection
276 /// is acceptable for operation.
277 /// \param[in] theAttribute an attribute to check.
278 /// \param[in] theArguments a filter parameters.
279 /// \param[out] theError error message.
280 virtual bool isValid(const AttributePtr& theAttribute,
281 const std::list<std::string>& theArguments,
282 Events_InfoMessage& theError) const;
285 /// \class FeaturesPlugin_ValidatorUnionArguments
286 /// \ingroup Validators
287 /// \brief Validator for the "Union" feature.
288 class FeaturesPlugin_ValidatorUnionArguments: public ModelAPI_FeatureValidator
291 //! \return true if result is valid shape.
292 //! \param theFeature the checked feature
293 //! \param theArguments arguments of the feature (not used)
294 //! \param theError error message
295 virtual bool isValid(const std::shared_ptr<ModelAPI_Feature>& theFeature,
296 const std::list<std::string>& theArguments,
297 Events_InfoMessage& theError) const;
300 /// \class FeaturesPlugin_ValidatorConcealedResult
301 /// \ingroup Validators
302 /// \brief Validator for the "Recover" feature.
303 class FeaturesPlugin_ValidatorConcealedResult: public ModelAPI_AttributeValidator
306 //! \return True if the attribute is valid.
307 //! \param[in] theAttribute the checked attribute.
308 //! \param[in] theArguments arguments of the attribute.
309 //! \param[out] theError error message.
310 virtual bool isValid(const AttributePtr& theAttribute,
311 const std::list<std::string>& theArguments,
312 Events_InfoMessage& theError) const;
315 /// \class FeaturesPlugin_ValidatorCircular
316 /// \ingroup Validators
317 /// \brief Verifies the selected object is circular edge or cylindrical face
318 class FeaturesPlugin_ValidatorCircular : public ModelAPI_AttributeValidator
321 //! \return True if the attribute is valid.
322 //! \param[in] theAttribute the checked attribute.
323 //! \param[in] theArguments arguments of the attribute.
324 //! \param[out] theError error message.
325 virtual bool isValid(const AttributePtr& theAttribute,
326 const std::list<std::string>& theArguments,
327 Events_InfoMessage& theError) const;
330 /** \class FeaturesPlugin_ValidatorBooleanArguments
331 * \ingroup Validators
332 * \brief Validates that boolean operation have enough arguments.
334 class FeaturesPlugin_ValidatorBooleanArguments: public ModelAPI_FeatureValidator
337 /** \brief Returns true if feature and/or attributes are valid.
338 * \param[in] theFeature the validated feature.
339 * \param[in] theArguments the arguments in the configuration file for this validator.
340 * \param[out] theError error message.
341 * \returns true if feature is valid.
343 virtual bool isValid(const std::shared_ptr<ModelAPI_Feature>& theFeature,
344 const std::list<std::string>& theArguments,
345 Events_InfoMessage& theError) const;
347 /// \return true if the attribute in feature is not obligatory for the feature execution.
348 virtual bool isNotObligatory(std::string theFeature, std::string theAttribute);
351 /// \class FeaturesPlugin_ValidatorBooleanSmashSelection
352 /// \ingroup Validators
353 /// \brief Verifies the selected object for boolean smash feature
354 class FeaturesPlugin_ValidatorBooleanSmashSelection: public ModelAPI_AttributeValidator
357 //! \return True if the attribute is valid.
358 //! \param[in] theAttribute the checked attribute.
359 //! \param[in] theArguments arguments of the attribute.
360 //! \param[out] theError error message.
361 virtual bool isValid(const AttributePtr& theAttribute,
362 const std::list<std::string>& theArguments,
363 Events_InfoMessage& theError) const;
366 /// \class FeaturesPlugin_IntersectionSelection
367 /// \ingroup Validators
368 /// \brief Verifies the selected object for intersection feature
369 class FeaturesPlugin_IntersectionSelection: public ModelAPI_AttributeValidator
372 //! \return True if the attribute is valid.
373 //! \param[in] theAttribute the checked attribute.
374 //! \param[in] theArguments arguments of the attribute.
375 //! \param[out] theError error message.
376 virtual bool isValid(const AttributePtr& theAttribute,
377 const std::list<std::string>& theArguments,
378 Events_InfoMessage& theError) const;
381 /// \class FeaturesPlugin_ValidatorBooleanFuseSelection
382 /// \ingroup Validators
383 /// \brief Verifies the selected object for boolean fuse feature
384 class FeaturesPlugin_ValidatorBooleanFuseSelection: public ModelAPI_AttributeValidator
387 //! \return True if the attribute is valid.
388 //! \param[in] theAttribute the checked attribute.
389 //! \param[in] theArguments arguments of the attribute.
390 //! \param[out] theError error message.
391 virtual bool isValid(const AttributePtr& theAttribute,
392 const std::list<std::string>& theArguments,
393 Events_InfoMessage& theError) const;
396 /** \class FeaturesPlugin_ValidatorBooleanFuseArguments
397 * \ingroup Validators
398 * \brief Validates that boolean operation have enough arguments.
400 class FeaturesPlugin_ValidatorBooleanFuseArguments: public ModelAPI_FeatureValidator
403 /** \brief Returns true if feature and/or attributes are valid.
404 * \param[in] theFeature the validated feature.
405 * \param[in] theArguments the arguments in the configuration file for this validator.
406 * \param[out] theError error message.
407 * \returns true if feature is valid.
409 virtual bool isValid(const std::shared_ptr<ModelAPI_Feature>& theFeature,
410 const std::list<std::string>& theArguments,
411 Events_InfoMessage& theError) const;
413 /// \return true if the attribute in feature is not obligatory for the feature execution.
414 virtual bool isNotObligatory(std::string theFeature, std::string theAttribute);
417 /// \class FeaturesPlugin_ValidatorBooleanCommonSelection
418 /// \ingroup Validators
419 /// \brief Verifies the selected object for boolean common feature
420 class FeaturesPlugin_ValidatorBooleanCommonSelection: public ModelAPI_AttributeValidator
423 //! \return True if the attribute is valid.
424 //! \param[in] theAttribute the checked attribute.
425 //! \param[in] theArguments arguments of the attribute.
426 //! \param[out] theError error message.
427 virtual bool isValid(const AttributePtr& theAttribute,
428 const std::list<std::string>& theArguments,
429 Events_InfoMessage& theError) const;
432 /** \class FeaturesPlugin_ValidatorBooleanCommonArguments
433 * \ingroup Validators
434 * \brief Validates that boolean operation have enough arguments.
436 class FeaturesPlugin_ValidatorBooleanCommonArguments: public ModelAPI_FeatureValidator
439 /** \brief Returns true if feature and/or attributes are valid.
440 * \param[in] theFeature the validated feature.
441 * \param[in] theArguments the arguments in the configuration file for this validator.
442 * \param[out] theError error message.
443 * \returns true if feature is valid.
445 virtual bool isValid(const std::shared_ptr<ModelAPI_Feature>& theFeature,
446 const std::list<std::string>& theArguments,
447 Events_InfoMessage& theError) const;
449 /// \return true if the attribute in feature is not obligatory for the feature execution.
450 virtual bool isNotObligatory(std::string theFeature, std::string theAttribute);
453 /// \class FeaturesPlugin_ValidatorDefeaturingSelection
454 /// \ingroup Validators
455 /// \brief Validates selection for fillet operation.
456 class FeaturesPlugin_ValidatorDefeaturingSelection : public ModelAPI_AttributeValidator
459 /// \return True if the attribute is valid. It checks whether the selection
460 /// is acceptable for boolean operation.
461 /// \param[in] theAttribute an attribute to check.
462 /// \param[in] theArguments a filter parameters.
463 /// \param[out] theError error message.
464 virtual bool isValid(const AttributePtr& theAttribute,
465 const std::list<std::string>& theArguments,
466 Events_InfoMessage& theError) const;
469 /// \class FeaturesPlugin_ValidatorSewingSelection
470 /// \ingroup Validators
471 /// \brief Validates selection for sewing operation.
472 class FeaturesPlugin_ValidatorSewingSelection : public ModelAPI_AttributeValidator
475 /// \return True if the attribute is valid. It checks whether the selection
476 /// is acceptable for sewing operation.
477 /// \param[in] theAttribute an attribute to check.
478 /// \param[in] theArguments a filter parameters.
479 /// \param[out] theError error message.
480 virtual bool isValid(const AttributePtr& theAttribute,
481 const std::list<std::string>& theArguments,
482 Events_InfoMessage& theError) const;
485 /// \class FeaturesPlugin_ValidatorGlueFacesSelection
486 /// \ingroup Validators
487 /// \brief Validates selection for glue faces operation.
488 class FeaturesPlugin_ValidatorGlueFacesSelection : public ModelAPI_AttributeValidator
491 /// \return True if the attribute is valid. It checks whether the selection
492 /// is acceptable for glue faces operation.
493 /// \param[in] theAttribute an attribute to check.
494 /// \param[in] theArguments a filter parameters.
495 /// \param[out] theError error message.
496 virtual bool isValid(const AttributePtr& theAttribute,
497 const std::list<std::string>& theArguments,
498 Events_InfoMessage& theError) const;