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 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_ValidatorBaseForGeneration
72 /// \ingroup Validators
73 /// \brief A validator for selection base for generation. Allows to select faces on sketch,
74 /// whole sketch(if it has at least one face), and following objects: vertex, edge, wire, face.
75 class FeaturesPlugin_ValidatorBaseForGeneration: public ModelAPI_AttributeValidator
78 //! \return true if attribute has selection type listed in the parameter arguments.
79 //! \param[in] theAttribute the checked attribute.
80 //! \param[in] theArguments arguments of the attribute.
81 //! \param[out] theError error message.
82 virtual bool isValid(const AttributePtr& theAttribute,
83 const std::list<std::string>& theArguments,
84 Events_InfoMessage& theError) const;
87 bool isValidAttribute(const AttributePtr& theAttribute,
88 const std::list<std::string>& theArguments,
89 Events_InfoMessage& theError) const;
92 /// \class FeaturesPlugin_ValidatorBaseForGenerationSketchOrSketchObjects
93 /// \ingroup Validators
94 /// \brief Validator for the base objects for generation. Checks that sketch and it objects
95 /// are not selected at the same time.
96 class FeaturesPlugin_ValidatorBaseForGenerationSketchOrSketchObjects:
97 public ModelAPI_FeatureValidator
100 //! \return true if sketch and it objects not selected at the same time.
101 //! \param theFeature the checked feature
102 //! \param theArguments arguments of the feature (not used)
103 //! \param theError error message
104 virtual bool isValid(const std::shared_ptr<ModelAPI_Feature>& theFeature,
105 const std::list<std::string>& theArguments,
106 Events_InfoMessage& theError) const;
109 /// \class FeaturesPlugin_ValidatorCompositeLauncher
110 /// \ingroup Validators
111 /// \brief A validator for selection at composite feature start
112 class FeaturesPlugin_ValidatorCompositeLauncher: public ModelAPI_AttributeValidator
115 //! \return true if attribute has selection type listed in the parameter arguments.
116 //! \param[in] theAttribute the checked attribute.
117 //! \param[in] theArguments arguments of the attribute.
118 //! \param[out] theError error message.
119 virtual bool isValid(const AttributePtr& theAttribute,
120 const std::list<std::string>& theArguments,
121 Events_InfoMessage& theError) const;
124 /// \class FeaturesPlugin_ValidatorExtrusionDir
125 /// \ingroup Validators
126 /// \brief A validator for extrusion direction attribute. Allows it to be empty if base objects are
127 /// planar and do not contain vertices and edges.
128 class FeaturesPlugin_ValidatorExtrusionDir: public ModelAPI_FeatureValidator
131 //! \return true if attribute listed in the parameter arguments are planar.
132 //! \param[in] theFeature the checked feature.
133 //! \param[in] theArguments arguments of the attribute.
134 //! \param[out] theError error message.
135 virtual bool isValid(const std::shared_ptr<ModelAPI_Feature>& theFeature,
136 const std::list<std::string>& theArguments,
137 Events_InfoMessage& theError) const;
140 bool isShapesCanBeEmpty(const AttributePtr& theAttribute,
141 Events_InfoMessage& theError) const;
144 /// \class FeaturesPlugin_ValidatorExtrusionBoundaryFace
145 /// \ingroup Validators
146 /// \brief A validator for extrusion from/to face attribute.
147 class FeaturesPlugin_ValidatorExtrusionBoundaryFace: public ModelAPI_AttributeValidator
150 //! \return true if attribute listed in the parameter arguments are planar.
151 //! \param[in] theFeature the checked feature.
152 //! \param[in] theArguments arguments of the attribute.
153 //! \param[out] theError error message.
154 virtual bool isValid(const AttributePtr& theAttribute,
155 const std::list<std::string>& theArguments,
156 Events_InfoMessage& theError) const;
159 /// \class FeaturesPlugin_ValidatorBooleanSelection
160 /// \ingroup Validators
161 /// \brief Validates selection for boolean operation.
162 class FeaturesPlugin_ValidatorBooleanSelection: public ModelAPI_AttributeValidator
165 /// \return True if the attribute is valid. It checks whether the selection
166 /// is acceptable for boolean operation.
167 /// \param[in] theAttribute an attribute to check.
168 /// \param[in] theArguments a filter parameters.
169 /// \param[out] theError error message.
170 virtual bool isValid(const AttributePtr& theAttribute,
171 const std::list<std::string>& theArguments,
172 Events_InfoMessage& theError) const;
175 /// \class FeaturesPlugin_ValidatorFilletSelection
176 /// \ingroup Validators
177 /// \brief Validates selection for fillet operation.
178 class FeaturesPlugin_ValidatorFilletSelection: public ModelAPI_AttributeValidator
181 /// \return True if the attribute is valid. It checks whether the selection
182 /// is acceptable for boolean operation.
183 /// \param[in] theAttribute an attribute to check.
184 /// \param[in] theArguments a filter parameters.
185 /// \param[out] theError error message.
186 virtual bool isValid(const AttributePtr& theAttribute,
187 const std::list<std::string>& theArguments,
188 Events_InfoMessage& theError) const;
191 /// \class FeaturesPlugin_ValidatorPartitionSelection
192 /// \ingroup Validators
193 /// \brief Validates selection for partition.
194 class FeaturesPlugin_ValidatorPartitionSelection: public ModelAPI_AttributeValidator
197 /// \return True if the attribute is valid. It checks whether the selection
198 /// is acceptable for operation.
199 /// \param[in] theAttribute an attribute to check.
200 /// \param[in] theArguments a filter parameters.
201 /// \param[out] theError error message.
202 virtual bool isValid(const AttributePtr& theAttribute,
203 const std::list<std::string>& theArguments,
204 Events_InfoMessage& theError) const;
207 /// \class FeaturesPlugin_ValidatorRemoveSubShapesSelection
208 /// \ingroup Validators
209 /// \brief Validates selection for "Remove Sub-Shapes" feature.
210 class FeaturesPlugin_ValidatorRemoveSubShapesSelection: public ModelAPI_AttributeValidator
213 /// \return True if the attribute is valid. It checks whether the selection
214 /// is acceptable for operation.
215 /// \param[in] theAttribute an attribute to check.
216 /// \param[in] theArguments a filter parameters.
217 /// \param[out] theError error message.
218 virtual bool isValid(const AttributePtr& theAttribute,
219 const std::list<std::string>& theArguments,
220 Events_InfoMessage& theError) const;
223 /// \class FeaturesPlugin_ValidatorRemoveSubShapesResult
224 /// \ingroup Validators
225 /// \brief Validator for the Remove Sub-Shapes feature.
226 class FeaturesPlugin_ValidatorRemoveSubShapesResult: public ModelAPI_FeatureValidator
229 //! \return true if result is valid shape.
230 //! \param theFeature the checked feature
231 //! \param theArguments arguments of the feature (not used)
232 //! \param theError error message
233 virtual bool isValid(const std::shared_ptr<ModelAPI_Feature>& theFeature,
234 const std::list<std::string>& theArguments,
235 Events_InfoMessage& theError) const;
238 /// \class FeaturesPlugin_ValidatorUnionSelection
239 /// \ingroup Validators
240 /// \brief Validates selection for "Union" feature.
241 class FeaturesPlugin_ValidatorUnionSelection: 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_ValidatorUnionArguments
255 /// \ingroup Validators
256 /// \brief Validator for the "Union" feature.
257 class FeaturesPlugin_ValidatorUnionArguments: 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_ValidatorConcealedResult
270 /// \ingroup Validators
271 /// \brief Validator for the "Recover" feature.
272 class FeaturesPlugin_ValidatorConcealedResult: public ModelAPI_AttributeValidator
275 //! \return True if the attribute is valid.
276 //! \param[in] theAttribute the checked attribute.
277 //! \param[in] theArguments arguments of the attribute.
278 //! \param[out] theError error message.
279 virtual bool isValid(const AttributePtr& theAttribute,
280 const std::list<std::string>& theArguments,
281 Events_InfoMessage& theError) const;
284 /// \class FeaturesPlugin_ValidatorCircular
285 /// \ingroup Validators
286 /// \brief Verifies the selected object is circular edge or cylindrical face
287 class FeaturesPlugin_ValidatorCircular : public ModelAPI_AttributeValidator
290 //! \return True if the attribute is valid.
291 //! \param[in] theAttribute the checked attribute.
292 //! \param[in] theArguments arguments of the attribute.
293 //! \param[out] theError error message.
294 virtual bool isValid(const AttributePtr& theAttribute,
295 const std::list<std::string>& theArguments,
296 Events_InfoMessage& theError) const;
299 /** \class FeaturesPlugin_ValidatorBooleanArguments
300 * \ingroup Validators
301 * \brief Validates that boolean operation have enough arguments.
303 class FeaturesPlugin_ValidatorBooleanArguments: public ModelAPI_FeatureValidator
306 /** \brief Returns true if feature and/or attributes are valid.
307 * \param[in] theFeature the validated feature.
308 * \param[in] theArguments the arguments in the configuration file for this validator.
309 * \param[out] theError error message.
310 * \returns true if feature is valid.
312 virtual bool isValid(const std::shared_ptr<ModelAPI_Feature>& theFeature,
313 const std::list<std::string>& theArguments,
314 Events_InfoMessage& theError) const;
316 /// \return true if the attribute in feature is not obligatory for the feature execution.
317 virtual bool isNotObligatory(std::string theFeature, std::string theAttribute);
320 /// \class FeaturesPlugin_ValidatorBooleanSmashSelection
321 /// \ingroup Validators
322 /// \brief Verifies the selected object for boolean smash feature
323 class FeaturesPlugin_ValidatorBooleanSmashSelection: public ModelAPI_AttributeValidator
326 //! \return True if the attribute is valid.
327 //! \param[in] theAttribute the checked attribute.
328 //! \param[in] theArguments arguments of the attribute.
329 //! \param[out] theError error message.
330 virtual bool isValid(const AttributePtr& theAttribute,
331 const std::list<std::string>& theArguments,
332 Events_InfoMessage& theError) const;
335 /// \class FeaturesPlugin_IntersectionSelection
336 /// \ingroup Validators
337 /// \brief Verifies the selected object for intersection feature
338 class FeaturesPlugin_IntersectionSelection: public ModelAPI_AttributeValidator
341 //! \return True if the attribute is valid.
342 //! \param[in] theAttribute the checked attribute.
343 //! \param[in] theArguments arguments of the attribute.
344 //! \param[out] theError error message.
345 virtual bool isValid(const AttributePtr& theAttribute,
346 const std::list<std::string>& theArguments,
347 Events_InfoMessage& theError) const;
350 /// \class FeaturesPlugin_ValidatorBooleanFuseSelection
351 /// \ingroup Validators
352 /// \brief Verifies the selected object for boolean fuse feature
353 class FeaturesPlugin_ValidatorBooleanFuseSelection: public ModelAPI_AttributeValidator
356 //! \return True if the attribute is valid.
357 //! \param[in] theAttribute the checked attribute.
358 //! \param[in] theArguments arguments of the attribute.
359 //! \param[out] theError error message.
360 virtual bool isValid(const AttributePtr& theAttribute,
361 const std::list<std::string>& theArguments,
362 Events_InfoMessage& theError) const;
365 /** \class FeaturesPlugin_ValidatorBooleanFuseArguments
366 * \ingroup Validators
367 * \brief Validates that boolean operation have enough arguments.
369 class FeaturesPlugin_ValidatorBooleanFuseArguments: public ModelAPI_FeatureValidator
372 /** \brief Returns true if feature and/or attributes are valid.
373 * \param[in] theFeature the validated feature.
374 * \param[in] theArguments the arguments in the configuration file for this validator.
375 * \param[out] theError error message.
376 * \returns true if feature is valid.
378 virtual bool isValid(const std::shared_ptr<ModelAPI_Feature>& theFeature,
379 const std::list<std::string>& theArguments,
380 Events_InfoMessage& theError) const;
382 /// \return true if the attribute in feature is not obligatory for the feature execution.
383 virtual bool isNotObligatory(std::string theFeature, std::string theAttribute);
386 /// \class FeaturesPlugin_ValidatorBooleanCommonSelection
387 /// \ingroup Validators
388 /// \brief Verifies the selected object for boolean common feature
389 class FeaturesPlugin_ValidatorBooleanCommonSelection: public ModelAPI_AttributeValidator
392 //! \return True if the attribute is valid.
393 //! \param[in] theAttribute the checked attribute.
394 //! \param[in] theArguments arguments of the attribute.
395 //! \param[out] theError error message.
396 virtual bool isValid(const AttributePtr& theAttribute,
397 const std::list<std::string>& theArguments,
398 Events_InfoMessage& theError) const;
401 /** \class FeaturesPlugin_ValidatorBooleanCommonArguments
402 * \ingroup Validators
403 * \brief Validates that boolean operation have enough arguments.
405 class FeaturesPlugin_ValidatorBooleanCommonArguments: public ModelAPI_FeatureValidator
408 /** \brief Returns true if feature and/or attributes are valid.
409 * \param[in] theFeature the validated feature.
410 * \param[in] theArguments the arguments in the configuration file for this validator.
411 * \param[out] theError error message.
412 * \returns true if feature is valid.
414 virtual bool isValid(const std::shared_ptr<ModelAPI_Feature>& theFeature,
415 const std::list<std::string>& theArguments,
416 Events_InfoMessage& theError) const;
418 /// \return true if the attribute in feature is not obligatory for the feature execution.
419 virtual bool isNotObligatory(std::string theFeature, std::string theAttribute);