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 Validator for the pipe locations.
45 class FeaturesPlugin_ValidatorPipeLocations: public ModelAPI_FeatureValidator
48 //! \return true if number of selected locations the same as number of selected bases, or empty.
49 //! \param theFeature the checked feature
50 //! \param theArguments arguments of the feature (not used)
51 //! \param theError error message
52 virtual bool isValid(const std::shared_ptr<ModelAPI_Feature>& theFeature,
53 const std::list<std::string>& theArguments,
54 Events_InfoMessage& theError) const;
57 /// \class FeaturesPlugin_ValidatorBaseForGeneration
58 /// \ingroup Validators
59 /// \brief A validator for selection base for generation. Allows to select faces on sketch,
60 /// whole sketch(if it has at least one face), and following objects: vertex, edge, wire, face.
61 class FeaturesPlugin_ValidatorBaseForGeneration: public ModelAPI_AttributeValidator
64 //! \return true if attribute has selection type listed in the parameter arguments.
65 //! \param[in] theAttribute the checked attribute.
66 //! \param[in] theArguments arguments of the attribute.
67 //! \param[out] theError error message.
68 virtual bool isValid(const AttributePtr& theAttribute,
69 const std::list<std::string>& theArguments,
70 Events_InfoMessage& theError) const;
73 bool isValidAttribute(const AttributePtr& theAttribute,
74 const std::list<std::string>& theArguments,
75 Events_InfoMessage& theError) const;
78 /// \class FeaturesPlugin_ValidatorBaseForGenerationSketchOrSketchObjects
79 /// \ingroup Validators
80 /// \brief Validator for the base objects for generation. Checks that sketch and it objects
81 /// are not selected at the same time.
82 class FeaturesPlugin_ValidatorBaseForGenerationSketchOrSketchObjects:
83 public ModelAPI_FeatureValidator
86 //! \return true if sketch and it objects not selected at the same time.
87 //! \param theFeature the checked feature
88 //! \param theArguments arguments of the feature (not used)
89 //! \param theError error message
90 virtual bool isValid(const std::shared_ptr<ModelAPI_Feature>& theFeature,
91 const std::list<std::string>& theArguments,
92 Events_InfoMessage& theError) const;
95 /// \class FeaturesPlugin_ValidatorCompositeLauncher
96 /// \ingroup Validators
97 /// \brief A validator for selection at composite feature start
98 class FeaturesPlugin_ValidatorCompositeLauncher: public ModelAPI_AttributeValidator
101 //! \return true if attribute has selection type listed in the parameter arguments.
102 //! \param[in] theAttribute the checked attribute.
103 //! \param[in] theArguments arguments of the attribute.
104 //! \param[out] theError error message.
105 virtual bool isValid(const AttributePtr& theAttribute,
106 const std::list<std::string>& theArguments,
107 Events_InfoMessage& theError) const;
110 /// \class FeaturesPlugin_ValidatorExtrusionDir
111 /// \ingroup Validators
112 /// \brief A validator for extrusion direction attribute. Allows it to be empty if base objects are
113 /// planar and do not contain vertices and edges.
114 class FeaturesPlugin_ValidatorExtrusionDir: public ModelAPI_FeatureValidator
117 //! \return true if attribute listed in the parameter arguments are planar.
118 //! \param[in] theFeature the checked feature.
119 //! \param[in] theArguments arguments of the attribute.
120 //! \param[out] theError error message.
121 virtual bool isValid(const std::shared_ptr<ModelAPI_Feature>& theFeature,
122 const std::list<std::string>& theArguments,
123 Events_InfoMessage& theError) const;
126 bool isShapesCanBeEmpty(const AttributePtr& theAttribute,
127 Events_InfoMessage& theError) const;
130 /// \class FeaturesPlugin_ValidatorBooleanSelection
131 /// \ingroup Validators
132 /// \brief Validates selection for boolean operation.
133 class FeaturesPlugin_ValidatorBooleanSelection: public ModelAPI_AttributeValidator
136 /// \return True if the attribute is valid. It checks whether the selection
137 /// is acceptable for boolean operation.
138 /// \param[in] theAttribute an attribute to check.
139 /// \param[in] theArguments a filter parameters.
140 /// \param[out] theError error message.
141 virtual bool isValid(const AttributePtr& theAttribute,
142 const std::list<std::string>& theArguments,
143 Events_InfoMessage& theError) const;
146 /// \class FeaturesPlugin_ValidatorFilletSelection
147 /// \ingroup Validators
148 /// \brief Validates selection for fillet operation.
149 class FeaturesPlugin_ValidatorFilletSelection: public ModelAPI_AttributeValidator
152 /// \return True if the attribute is valid. It checks whether the selection
153 /// is acceptable for boolean operation.
154 /// \param[in] theAttribute an attribute to check.
155 /// \param[in] theArguments a filter parameters.
156 /// \param[out] theError error message.
157 virtual bool isValid(const AttributePtr& theAttribute,
158 const std::list<std::string>& theArguments,
159 Events_InfoMessage& theError) const;
162 /// \class FeaturesPlugin_ValidatorPartitionSelection
163 /// \ingroup Validators
164 /// \brief Validates selection for partition.
165 class FeaturesPlugin_ValidatorPartitionSelection: public ModelAPI_AttributeValidator
168 /// \return True if the attribute is valid. It checks whether the selection
169 /// is acceptable for operation.
170 /// \param[in] theAttribute an attribute to check.
171 /// \param[in] theArguments a filter parameters.
172 /// \param[out] theError error message.
173 virtual bool isValid(const AttributePtr& theAttribute,
174 const std::list<std::string>& theArguments,
175 Events_InfoMessage& theError) const;
178 /// \class FeaturesPlugin_ValidatorRemoveSubShapesSelection
179 /// \ingroup Validators
180 /// \brief Validates selection for "Remove Sub-Shapes" feature.
181 class FeaturesPlugin_ValidatorRemoveSubShapesSelection: public ModelAPI_AttributeValidator
184 /// \return True if the attribute is valid. It checks whether the selection
185 /// is acceptable for operation.
186 /// \param[in] theAttribute an attribute to check.
187 /// \param[in] theArguments a filter parameters.
188 /// \param[out] theError error message.
189 virtual bool isValid(const AttributePtr& theAttribute,
190 const std::list<std::string>& theArguments,
191 Events_InfoMessage& theError) const;
194 /// \class FeaturesPlugin_ValidatorRemoveSubShapesResult
195 /// \ingroup Validators
196 /// \brief Validator for the Remove Sub-Shapes feature.
197 class FeaturesPlugin_ValidatorRemoveSubShapesResult: public ModelAPI_FeatureValidator
200 //! \return true if result is valid shape.
201 //! \param theFeature the checked feature
202 //! \param theArguments arguments of the feature (not used)
203 //! \param theError error message
204 virtual bool isValid(const std::shared_ptr<ModelAPI_Feature>& theFeature,
205 const std::list<std::string>& theArguments,
206 Events_InfoMessage& theError) const;
209 /// \class FeaturesPlugin_ValidatorUnionSelection
210 /// \ingroup Validators
211 /// \brief Validates selection for "Union" feature.
212 class FeaturesPlugin_ValidatorUnionSelection: public ModelAPI_AttributeValidator
215 /// \return True if the attribute is valid. It checks whether the selection
216 /// is acceptable for operation.
217 /// \param[in] theAttribute an attribute to check.
218 /// \param[in] theArguments a filter parameters.
219 /// \param[out] theError error message.
220 virtual bool isValid(const AttributePtr& theAttribute,
221 const std::list<std::string>& theArguments,
222 Events_InfoMessage& theError) const;
225 /// \class FeaturesPlugin_ValidatorUnionArguments
226 /// \ingroup Validators
227 /// \brief Validator for the "Union" feature.
228 class FeaturesPlugin_ValidatorUnionArguments: public ModelAPI_FeatureValidator
231 //! \return true if result is valid shape.
232 //! \param theFeature the checked feature
233 //! \param theArguments arguments of the feature (not used)
234 //! \param theError error message
235 virtual bool isValid(const std::shared_ptr<ModelAPI_Feature>& theFeature,
236 const std::list<std::string>& theArguments,
237 Events_InfoMessage& theError) const;
240 /// \class FeaturesPlugin_ValidatorConcealedResult
241 /// \ingroup Validators
242 /// \brief Validator for the "Recover" feature.
243 class FeaturesPlugin_ValidatorConcealedResult: public ModelAPI_AttributeValidator
246 //! \return True if the attribute is valid.
247 //! \param[in] theAttribute the checked attribute.
248 //! \param[in] theArguments arguments of the attribute.
249 //! \param[out] theError error message.
250 virtual bool isValid(const AttributePtr& theAttribute,
251 const std::list<std::string>& theArguments,
252 Events_InfoMessage& theError) const;
255 /// \class FeaturesPlugin_ValidatorCircular
256 /// \ingroup Validators
257 /// \brief Verifies the selected object is circular edge or cylindrical face
258 class FeaturesPlugin_ValidatorCircular : 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_ValidatorBooleanArguments
271 * \ingroup Validators
272 * \brief Validates that boolean operation have enough arguments.
274 class FeaturesPlugin_ValidatorBooleanArguments: public ModelAPI_FeatureValidator
277 /** \brief Returns true if feature and/or attributes are valid.
278 * \param[in] theFeature the validated feature.
279 * \param[in] theArguments the arguments in the configuration file for this validator.
280 * \param[out] theError error message.
281 * \returns true if feature is valid.
283 virtual bool isValid(const std::shared_ptr<ModelAPI_Feature>& theFeature,
284 const std::list<std::string>& theArguments,
285 Events_InfoMessage& theError) const;
287 /// \return true if the attribute in feature is not obligatory for the feature execution.
288 virtual bool isNotObligatory(std::string theFeature, std::string theAttribute);
291 /// \class FeaturesPlugin_ValidatorBooleanSmashSelection
292 /// \ingroup Validators
293 /// \brief Verifies the selected object for boolean smash feature
294 class FeaturesPlugin_ValidatorBooleanSmashSelection: public ModelAPI_AttributeValidator
297 //! \return True if the attribute is valid.
298 //! \param[in] theAttribute the checked attribute.
299 //! \param[in] theArguments arguments of the attribute.
300 //! \param[out] theError error message.
301 virtual bool isValid(const AttributePtr& theAttribute,
302 const std::list<std::string>& theArguments,
303 Events_InfoMessage& theError) const;
306 /// \class FeaturesPlugin_IntersectionSelection
307 /// \ingroup Validators
308 /// \brief Verifies the selected object for intersection feature
309 class FeaturesPlugin_IntersectionSelection: 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_ValidatorBooleanFuseSelection
322 /// \ingroup Validators
323 /// \brief Verifies the selected object for boolean fuse feature
324 class FeaturesPlugin_ValidatorBooleanFuseSelection: 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_ValidatorBooleanFuseArguments
337 * \ingroup Validators
338 * \brief Validates that boolean operation have enough arguments.
340 class FeaturesPlugin_ValidatorBooleanFuseArguments: public ModelAPI_FeatureValidator
343 /** \brief Returns true if feature and/or attributes are valid.
344 * \param[in] theFeature the validated feature.
345 * \param[in] theArguments the arguments in the configuration file for this validator.
346 * \param[out] theError error message.
347 * \returns true if feature is valid.
349 virtual bool isValid(const std::shared_ptr<ModelAPI_Feature>& theFeature,
350 const std::list<std::string>& theArguments,
351 Events_InfoMessage& theError) const;
353 /// \return true if the attribute in feature is not obligatory for the feature execution.
354 virtual bool isNotObligatory(std::string theFeature, std::string theAttribute);
357 /// \class FeaturesPlugin_ValidatorBooleanCommonSelection
358 /// \ingroup Validators
359 /// \brief Verifies the selected object for boolean common feature
360 class FeaturesPlugin_ValidatorBooleanCommonSelection: public ModelAPI_AttributeValidator
363 //! \return True if the attribute is valid.
364 //! \param[in] theAttribute the checked attribute.
365 //! \param[in] theArguments arguments of the attribute.
366 //! \param[out] theError error message.
367 virtual bool isValid(const AttributePtr& theAttribute,
368 const std::list<std::string>& theArguments,
369 Events_InfoMessage& theError) const;
372 /** \class FeaturesPlugin_ValidatorBooleanCommonArguments
373 * \ingroup Validators
374 * \brief Validates that boolean operation have enough arguments.
376 class FeaturesPlugin_ValidatorBooleanCommonArguments: public ModelAPI_FeatureValidator
379 /** \brief Returns true if feature and/or attributes are valid.
380 * \param[in] theFeature the validated feature.
381 * \param[in] theArguments the arguments in the configuration file for this validator.
382 * \param[out] theError error message.
383 * \returns true if feature is valid.
385 virtual bool isValid(const std::shared_ptr<ModelAPI_Feature>& theFeature,
386 const std::list<std::string>& theArguments,
387 Events_InfoMessage& theError) const;
389 /// \return true if the attribute in feature is not obligatory for the feature execution.
390 virtual bool isNotObligatory(std::string theFeature, std::string theAttribute);