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 FeaturesPlugin_Validators_H_
22 #define FeaturesPlugin_Validators_H_
24 #include <ModelAPI_AttributeValidator.h>
25 #include <ModelAPI_FeatureValidator.h>
27 /// \class FeaturesPlugin_ValidatorPipePath
28 /// \ingroup Validators
29 /// \brief A validator for selection pipe path.
30 class FeaturesPlugin_ValidatorPipePath: public ModelAPI_AttributeValidator
33 //! \return True if the attribute is valid.
34 //! \param[in] theAttribute the checked attribute.
35 //! \param[in] theArguments arguments of the attribute.
36 //! \param[out] theError error message.
37 virtual bool isValid(const AttributePtr& theAttribute,
38 const std::list<std::string>& theArguments,
39 Events_InfoMessage& theError) const;
42 /// \class FeaturesPlugin_ValidatorPipeLocations
43 /// \ingroup Validators
44 /// \brief A validator for selection pipe locations.
45 class FeaturesPlugin_ValidatorPipeLocations: public ModelAPI_AttributeValidator
48 //! \return True if the attribute is valid.
49 //! \param[in] theAttribute the checked attribute.
50 //! \param[in] theArguments arguments of the attribute.
51 //! \param[out] theError error message.
52 virtual bool isValid(const AttributePtr& theAttribute,
53 const std::list<std::string>& theArguments,
54 Events_InfoMessage& theError) const;
57 /// \class FeaturesPlugin_ValidatorPipeLocationsNumber
58 /// \ingroup Validators
59 /// \brief Validator for the pipe locations.
60 class FeaturesPlugin_ValidatorPipeLocationsNumber: public ModelAPI_FeatureValidator
63 //! \return true if number of selected locations the same as number of selected bases, or empty.
64 //! \param theFeature the checked feature
65 //! \param theArguments arguments of the feature (not used)
66 //! \param theError error message
67 virtual bool isValid(const std::shared_ptr<ModelAPI_Feature>& theFeature,
68 const std::list<std::string>& theArguments,
69 Events_InfoMessage& theError) const;
72 /// \class FeaturesPlugin_ValidatorBaseForGeneration
73 /// \ingroup Validators
74 /// \brief A validator for selection base for generation. Allows to select faces on sketch,
75 /// whole sketch(if it has at least one face), and following objects: vertex, edge, wire, face.
76 class FeaturesPlugin_ValidatorBaseForGeneration: public ModelAPI_AttributeValidator
79 //! \return true if attribute has selection type listed in the parameter arguments.
80 //! \param[in] theAttribute the checked attribute.
81 //! \param[in] theArguments arguments of the attribute.
82 //! \param[out] theError error message.
83 virtual bool isValid(const AttributePtr& theAttribute,
84 const std::list<std::string>& theArguments,
85 Events_InfoMessage& theError) const;
88 bool isValidAttribute(const AttributePtr& theAttribute,
89 const std::list<std::string>& theArguments,
90 Events_InfoMessage& theError) const;
93 /// \class FeaturesPlugin_ValidatorBaseForGenerationSketchOrSketchObjects
94 /// \ingroup Validators
95 /// \brief Validator for the base objects for generation. Checks that sketch and it objects
96 /// are not selected at the same time.
97 class FeaturesPlugin_ValidatorBaseForGenerationSketchOrSketchObjects:
98 public ModelAPI_FeatureValidator
101 //! \return true if sketch and it objects not selected at the same time.
102 //! \param theFeature the checked feature
103 //! \param theArguments arguments of the feature (not used)
104 //! \param theError error message
105 virtual bool isValid(const std::shared_ptr<ModelAPI_Feature>& theFeature,
106 const std::list<std::string>& theArguments,
107 Events_InfoMessage& theError) const;
110 /// \class FeaturesPlugin_ValidatorCompositeLauncher
111 /// \ingroup Validators
112 /// \brief A validator for selection at composite feature start
113 class FeaturesPlugin_ValidatorCompositeLauncher: public ModelAPI_AttributeValidator
116 //! \return true if attribute has selection type listed in the parameter arguments.
117 //! \param[in] theAttribute the checked attribute.
118 //! \param[in] theArguments arguments of the attribute.
119 //! \param[out] theError error message.
120 virtual bool isValid(const AttributePtr& theAttribute,
121 const std::list<std::string>& theArguments,
122 Events_InfoMessage& theError) const;
125 /// \class FeaturesPlugin_ValidatorExtrusionDir
126 /// \ingroup Validators
127 /// \brief A validator for extrusion direction attribute. Allows it to be empty if base objects are
128 /// planar and do not contain vertices and edges.
129 class FeaturesPlugin_ValidatorExtrusionDir: public ModelAPI_FeatureValidator
132 //! \return true if attribute listed in the parameter arguments are planar.
133 //! \param[in] theFeature the checked feature.
134 //! \param[in] theArguments arguments of the attribute.
135 //! \param[out] theError error message.
136 virtual bool isValid(const std::shared_ptr<ModelAPI_Feature>& theFeature,
137 const std::list<std::string>& theArguments,
138 Events_InfoMessage& theError) const;
141 bool isShapesCanBeEmpty(const AttributePtr& theAttribute,
142 Events_InfoMessage& theError) const;
145 /// \class FeaturesPlugin_ValidatorBooleanSelection
146 /// \ingroup Validators
147 /// \brief Validates selection for boolean operation.
148 class FeaturesPlugin_ValidatorBooleanSelection: public ModelAPI_AttributeValidator
151 /// \return True if the attribute is valid. It checks whether the selection
152 /// is acceptable for boolean operation.
153 /// \param[in] theAttribute an attribute to check.
154 /// \param[in] theArguments a filter parameters.
155 /// \param[out] theError error message.
156 virtual bool isValid(const AttributePtr& theAttribute,
157 const std::list<std::string>& theArguments,
158 Events_InfoMessage& theError) const;
161 /// \class FeaturesPlugin_ValidatorFilletSelection
162 /// \ingroup Validators
163 /// \brief Validates selection for fillet operation.
164 class FeaturesPlugin_ValidatorFilletSelection: public ModelAPI_AttributeValidator
167 /// \return True if the attribute is valid. It checks whether the selection
168 /// is acceptable for boolean operation.
169 /// \param[in] theAttribute an attribute to check.
170 /// \param[in] theArguments a filter parameters.
171 /// \param[out] theError error message.
172 virtual bool isValid(const AttributePtr& theAttribute,
173 const std::list<std::string>& theArguments,
174 Events_InfoMessage& theError) const;
177 /// \class FeaturesPlugin_ValidatorPartitionSelection
178 /// \ingroup Validators
179 /// \brief Validates selection for partition.
180 class FeaturesPlugin_ValidatorPartitionSelection: public ModelAPI_AttributeValidator
183 /// \return True if the attribute is valid. It checks whether the selection
184 /// is acceptable for operation.
185 /// \param[in] theAttribute an attribute to check.
186 /// \param[in] theArguments a filter parameters.
187 /// \param[out] theError error message.
188 virtual bool isValid(const AttributePtr& theAttribute,
189 const std::list<std::string>& theArguments,
190 Events_InfoMessage& theError) const;
193 /// \class FeaturesPlugin_ValidatorRemoveSubShapesSelection
194 /// \ingroup Validators
195 /// \brief Validates selection for "Remove Sub-Shapes" feature.
196 class FeaturesPlugin_ValidatorRemoveSubShapesSelection: public ModelAPI_AttributeValidator
199 /// \return True if the attribute is valid. It checks whether the selection
200 /// is acceptable for operation.
201 /// \param[in] theAttribute an attribute to check.
202 /// \param[in] theArguments a filter parameters.
203 /// \param[out] theError error message.
204 virtual bool isValid(const AttributePtr& theAttribute,
205 const std::list<std::string>& theArguments,
206 Events_InfoMessage& theError) const;
209 /// \class FeaturesPlugin_ValidatorRemoveSubShapesResult
210 /// \ingroup Validators
211 /// \brief Validator for the Remove Sub-Shapes feature.
212 class FeaturesPlugin_ValidatorRemoveSubShapesResult: public ModelAPI_FeatureValidator
215 //! \return true if result is valid shape.
216 //! \param theFeature the checked feature
217 //! \param theArguments arguments of the feature (not used)
218 //! \param theError error message
219 virtual bool isValid(const std::shared_ptr<ModelAPI_Feature>& theFeature,
220 const std::list<std::string>& theArguments,
221 Events_InfoMessage& theError) const;
224 /// \class FeaturesPlugin_ValidatorUnionSelection
225 /// \ingroup Validators
226 /// \brief Validates selection for "Union" feature.
227 class FeaturesPlugin_ValidatorUnionSelection: public ModelAPI_AttributeValidator
230 /// \return True if the attribute is valid. It checks whether the selection
231 /// is acceptable for operation.
232 /// \param[in] theAttribute an attribute to check.
233 /// \param[in] theArguments a filter parameters.
234 /// \param[out] theError error message.
235 virtual bool isValid(const AttributePtr& theAttribute,
236 const std::list<std::string>& theArguments,
237 Events_InfoMessage& theError) const;
240 /// \class FeaturesPlugin_ValidatorUnionArguments
241 /// \ingroup Validators
242 /// \brief Validator for the "Union" feature.
243 class FeaturesPlugin_ValidatorUnionArguments: public ModelAPI_FeatureValidator
246 //! \return true if result is valid shape.
247 //! \param theFeature the checked feature
248 //! \param theArguments arguments of the feature (not used)
249 //! \param theError error message
250 virtual bool isValid(const std::shared_ptr<ModelAPI_Feature>& theFeature,
251 const std::list<std::string>& theArguments,
252 Events_InfoMessage& theError) const;
255 /// \class FeaturesPlugin_ValidatorConcealedResult
256 /// \ingroup Validators
257 /// \brief Validator for the "Recover" feature.
258 class FeaturesPlugin_ValidatorConcealedResult: public ModelAPI_AttributeValidator
261 //! \return True if the attribute is valid.
262 //! \param[in] theAttribute the checked attribute.
263 //! \param[in] theArguments arguments of the attribute.
264 //! \param[out] theError error message.
265 virtual bool isValid(const AttributePtr& theAttribute,
266 const std::list<std::string>& theArguments,
267 Events_InfoMessage& theError) const;
270 /// \class FeaturesPlugin_ValidatorCircular
271 /// \ingroup Validators
272 /// \brief Verifies the selected object is circular edge or cylindrical face
273 class FeaturesPlugin_ValidatorCircular : public ModelAPI_AttributeValidator
276 //! \return True if the attribute is valid.
277 //! \param[in] theAttribute the checked attribute.
278 //! \param[in] theArguments arguments of the attribute.
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_ValidatorBooleanArguments
286 * \ingroup Validators
287 * \brief Validates that boolean operation have enough arguments.
289 class FeaturesPlugin_ValidatorBooleanArguments: public ModelAPI_FeatureValidator
292 /** \brief Returns true if feature and/or attributes are valid.
293 * \param[in] theFeature the validated feature.
294 * \param[in] theArguments the arguments in the configuration file for this validator.
295 * \param[out] theError error message.
296 * \returns true if feature is valid.
298 virtual bool isValid(const std::shared_ptr<ModelAPI_Feature>& theFeature,
299 const std::list<std::string>& theArguments,
300 Events_InfoMessage& theError) const;
302 /// \return true if the attribute in feature is not obligatory for the feature execution.
303 virtual bool isNotObligatory(std::string theFeature, std::string theAttribute);
306 /// \class FeaturesPlugin_ValidatorBooleanSmashSelection
307 /// \ingroup Validators
308 /// \brief Verifies the selected object for boolean smash feature
309 class FeaturesPlugin_ValidatorBooleanSmashSelection: public ModelAPI_AttributeValidator
312 //! \return True if the attribute is valid.
313 //! \param[in] theAttribute the checked attribute.
314 //! \param[in] theArguments arguments of the attribute.
315 //! \param[out] theError error message.
316 virtual bool isValid(const AttributePtr& theAttribute,
317 const std::list<std::string>& theArguments,
318 Events_InfoMessage& theError) const;
321 /// \class FeaturesPlugin_IntersectionSelection
322 /// \ingroup Validators
323 /// \brief Verifies the selected object for intersection feature
324 class FeaturesPlugin_IntersectionSelection: public ModelAPI_AttributeValidator
327 //! \return True if the attribute is valid.
328 //! \param[in] theAttribute the checked attribute.
329 //! \param[in] theArguments arguments of the attribute.
330 //! \param[out] theError error message.
331 virtual bool isValid(const AttributePtr& theAttribute,
332 const std::list<std::string>& theArguments,
333 Events_InfoMessage& theError) const;
336 /// \class FeaturesPlugin_ValidatorBooleanFuseSelection
337 /// \ingroup Validators
338 /// \brief Verifies the selected object for boolean fuse feature
339 class FeaturesPlugin_ValidatorBooleanFuseSelection: public ModelAPI_AttributeValidator
342 //! \return True if the attribute is valid.
343 //! \param[in] theAttribute the checked attribute.
344 //! \param[in] theArguments arguments of the attribute.
345 //! \param[out] theError error message.
346 virtual bool isValid(const AttributePtr& theAttribute,
347 const std::list<std::string>& theArguments,
348 Events_InfoMessage& theError) const;
351 /** \class FeaturesPlugin_ValidatorBooleanFuseArguments
352 * \ingroup Validators
353 * \brief Validates that boolean operation have enough arguments.
355 class FeaturesPlugin_ValidatorBooleanFuseArguments: public ModelAPI_FeatureValidator
358 /** \brief Returns true if feature and/or attributes are valid.
359 * \param[in] theFeature the validated feature.
360 * \param[in] theArguments the arguments in the configuration file for this validator.
361 * \param[out] theError error message.
362 * \returns true if feature is valid.
364 virtual bool isValid(const std::shared_ptr<ModelAPI_Feature>& theFeature,
365 const std::list<std::string>& theArguments,
366 Events_InfoMessage& theError) const;
368 /// \return true if the attribute in feature is not obligatory for the feature execution.
369 virtual bool isNotObligatory(std::string theFeature, std::string theAttribute);
372 /// \class FeaturesPlugin_ValidatorBooleanCommonSelection
373 /// \ingroup Validators
374 /// \brief Verifies the selected object for boolean common feature
375 class FeaturesPlugin_ValidatorBooleanCommonSelection: public ModelAPI_AttributeValidator
378 //! \return True if the attribute is valid.
379 //! \param[in] theAttribute the checked attribute.
380 //! \param[in] theArguments arguments of the attribute.
381 //! \param[out] theError error message.
382 virtual bool isValid(const AttributePtr& theAttribute,
383 const std::list<std::string>& theArguments,
384 Events_InfoMessage& theError) const;
387 /** \class FeaturesPlugin_ValidatorBooleanCommonArguments
388 * \ingroup Validators
389 * \brief Validates that boolean operation have enough arguments.
391 class FeaturesPlugin_ValidatorBooleanCommonArguments: public ModelAPI_FeatureValidator
394 /** \brief Returns true if feature and/or attributes are valid.
395 * \param[in] theFeature the validated feature.
396 * \param[in] theArguments the arguments in the configuration file for this validator.
397 * \param[out] theError error message.
398 * \returns true if feature is valid.
400 virtual bool isValid(const std::shared_ptr<ModelAPI_Feature>& theFeature,
401 const std::list<std::string>& theArguments,
402 Events_InfoMessage& theError) const;
404 /// \return true if the attribute in feature is not obligatory for the feature execution.
405 virtual bool isNotObligatory(std::string theFeature, std::string theAttribute);