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_ValidatorBooleanSelection
145 /// \ingroup Validators
146 /// \brief Validates selection for boolean operation.
147 class FeaturesPlugin_ValidatorBooleanSelection: public ModelAPI_AttributeValidator
150 /// \return True if the attribute is valid. It checks whether the selection
151 /// is acceptable for boolean operation.
152 /// \param[in] theAttribute an attribute to check.
153 /// \param[in] theArguments a filter parameters.
154 /// \param[out] theError error message.
155 virtual bool isValid(const AttributePtr& theAttribute,
156 const std::list<std::string>& theArguments,
157 Events_InfoMessage& theError) const;
160 /// \class FeaturesPlugin_ValidatorFilletSelection
161 /// \ingroup Validators
162 /// \brief Validates selection for fillet operation.
163 class FeaturesPlugin_ValidatorFilletSelection: public ModelAPI_AttributeValidator
166 /// \return True if the attribute is valid. It checks whether the selection
167 /// is acceptable for boolean operation.
168 /// \param[in] theAttribute an attribute to check.
169 /// \param[in] theArguments a filter parameters.
170 /// \param[out] theError error message.
171 virtual bool isValid(const AttributePtr& theAttribute,
172 const std::list<std::string>& theArguments,
173 Events_InfoMessage& theError) const;
176 /// \class FeaturesPlugin_ValidatorPartitionSelection
177 /// \ingroup Validators
178 /// \brief Validates selection for partition.
179 class FeaturesPlugin_ValidatorPartitionSelection: public ModelAPI_AttributeValidator
182 /// \return True if the attribute is valid. It checks whether the selection
183 /// is acceptable for operation.
184 /// \param[in] theAttribute an attribute to check.
185 /// \param[in] theArguments a filter parameters.
186 /// \param[out] theError error message.
187 virtual bool isValid(const AttributePtr& theAttribute,
188 const std::list<std::string>& theArguments,
189 Events_InfoMessage& theError) const;
192 /// \class FeaturesPlugin_ValidatorRemoveSubShapesSelection
193 /// \ingroup Validators
194 /// \brief Validates selection for "Remove Sub-Shapes" feature.
195 class FeaturesPlugin_ValidatorRemoveSubShapesSelection: public ModelAPI_AttributeValidator
198 /// \return True if the attribute is valid. It checks whether the selection
199 /// is acceptable for operation.
200 /// \param[in] theAttribute an attribute to check.
201 /// \param[in] theArguments a filter parameters.
202 /// \param[out] theError error message.
203 virtual bool isValid(const AttributePtr& theAttribute,
204 const std::list<std::string>& theArguments,
205 Events_InfoMessage& theError) const;
208 /// \class FeaturesPlugin_ValidatorRemoveSubShapesResult
209 /// \ingroup Validators
210 /// \brief Validator for the Remove Sub-Shapes feature.
211 class FeaturesPlugin_ValidatorRemoveSubShapesResult: public ModelAPI_FeatureValidator
214 //! \return true if result is valid shape.
215 //! \param theFeature the checked feature
216 //! \param theArguments arguments of the feature (not used)
217 //! \param theError error message
218 virtual bool isValid(const std::shared_ptr<ModelAPI_Feature>& theFeature,
219 const std::list<std::string>& theArguments,
220 Events_InfoMessage& theError) const;
223 /// \class FeaturesPlugin_ValidatorUnionSelection
224 /// \ingroup Validators
225 /// \brief Validates selection for "Union" feature.
226 class FeaturesPlugin_ValidatorUnionSelection: public ModelAPI_AttributeValidator
229 /// \return True if the attribute is valid. It checks whether the selection
230 /// is acceptable for operation.
231 /// \param[in] theAttribute an attribute to check.
232 /// \param[in] theArguments a filter parameters.
233 /// \param[out] theError error message.
234 virtual bool isValid(const AttributePtr& theAttribute,
235 const std::list<std::string>& theArguments,
236 Events_InfoMessage& theError) const;
239 /// \class FeaturesPlugin_ValidatorUnionArguments
240 /// \ingroup Validators
241 /// \brief Validator for the "Union" feature.
242 class FeaturesPlugin_ValidatorUnionArguments: public ModelAPI_FeatureValidator
245 //! \return true if result is valid shape.
246 //! \param theFeature the checked feature
247 //! \param theArguments arguments of the feature (not used)
248 //! \param theError error message
249 virtual bool isValid(const std::shared_ptr<ModelAPI_Feature>& theFeature,
250 const std::list<std::string>& theArguments,
251 Events_InfoMessage& theError) const;
254 /// \class FeaturesPlugin_ValidatorConcealedResult
255 /// \ingroup Validators
256 /// \brief Validator for the "Recover" feature.
257 class FeaturesPlugin_ValidatorConcealedResult: public ModelAPI_AttributeValidator
260 //! \return True if the attribute is valid.
261 //! \param[in] theAttribute the checked attribute.
262 //! \param[in] theArguments arguments of the attribute.
263 //! \param[out] theError error message.
264 virtual bool isValid(const AttributePtr& theAttribute,
265 const std::list<std::string>& theArguments,
266 Events_InfoMessage& theError) const;
269 /// \class FeaturesPlugin_ValidatorCircular
270 /// \ingroup Validators
271 /// \brief Verifies the selected object is circular edge or cylindrical face
272 class FeaturesPlugin_ValidatorCircular : 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_ValidatorBooleanArguments
285 * \ingroup Validators
286 * \brief Validates that boolean operation have enough arguments.
288 class FeaturesPlugin_ValidatorBooleanArguments: public ModelAPI_FeatureValidator
291 /** \brief Returns true if feature and/or attributes are valid.
292 * \param[in] theFeature the validated feature.
293 * \param[in] theArguments the arguments in the configuration file for this validator.
294 * \param[out] theError error message.
295 * \returns true if feature is valid.
297 virtual bool isValid(const std::shared_ptr<ModelAPI_Feature>& theFeature,
298 const std::list<std::string>& theArguments,
299 Events_InfoMessage& theError) const;
301 /// \return true if the attribute in feature is not obligatory for the feature execution.
302 virtual bool isNotObligatory(std::string theFeature, std::string theAttribute);
305 /// \class FeaturesPlugin_ValidatorBooleanSmashSelection
306 /// \ingroup Validators
307 /// \brief Verifies the selected object for boolean smash feature
308 class FeaturesPlugin_ValidatorBooleanSmashSelection: public ModelAPI_AttributeValidator
311 //! \return True if the attribute is valid.
312 //! \param[in] theAttribute the checked attribute.
313 //! \param[in] theArguments arguments of the attribute.
314 //! \param[out] theError error message.
315 virtual bool isValid(const AttributePtr& theAttribute,
316 const std::list<std::string>& theArguments,
317 Events_InfoMessage& theError) const;
320 /// \class FeaturesPlugin_IntersectionSelection
321 /// \ingroup Validators
322 /// \brief Verifies the selected object for intersection feature
323 class FeaturesPlugin_IntersectionSelection: 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_ValidatorBooleanFuseSelection
336 /// \ingroup Validators
337 /// \brief Verifies the selected object for boolean fuse feature
338 class FeaturesPlugin_ValidatorBooleanFuseSelection: 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_ValidatorBooleanFuseArguments
351 * \ingroup Validators
352 * \brief Validates that boolean operation have enough arguments.
354 class FeaturesPlugin_ValidatorBooleanFuseArguments: public ModelAPI_FeatureValidator
357 /** \brief Returns true if feature and/or attributes are valid.
358 * \param[in] theFeature the validated feature.
359 * \param[in] theArguments the arguments in the configuration file for this validator.
360 * \param[out] theError error message.
361 * \returns true if feature is valid.
363 virtual bool isValid(const std::shared_ptr<ModelAPI_Feature>& theFeature,
364 const std::list<std::string>& theArguments,
365 Events_InfoMessage& theError) const;
367 /// \return true if the attribute in feature is not obligatory for the feature execution.
368 virtual bool isNotObligatory(std::string theFeature, std::string theAttribute);
371 /// \class FeaturesPlugin_ValidatorBooleanCommonSelection
372 /// \ingroup Validators
373 /// \brief Verifies the selected object for boolean common feature
374 class FeaturesPlugin_ValidatorBooleanCommonSelection: public ModelAPI_AttributeValidator
377 //! \return True if the attribute is valid.
378 //! \param[in] theAttribute the checked attribute.
379 //! \param[in] theArguments arguments of the attribute.
380 //! \param[out] theError error message.
381 virtual bool isValid(const AttributePtr& theAttribute,
382 const std::list<std::string>& theArguments,
383 Events_InfoMessage& theError) const;
386 /** \class FeaturesPlugin_ValidatorBooleanCommonArguments
387 * \ingroup Validators
388 * \brief Validates that boolean operation have enough arguments.
390 class FeaturesPlugin_ValidatorBooleanCommonArguments: public ModelAPI_FeatureValidator
393 /** \brief Returns true if feature and/or attributes are valid.
394 * \param[in] theFeature the validated feature.
395 * \param[in] theArguments the arguments in the configuration file for this validator.
396 * \param[out] theError error message.
397 * \returns true if feature is valid.
399 virtual bool isValid(const std::shared_ptr<ModelAPI_Feature>& theFeature,
400 const std::list<std::string>& theArguments,
401 Events_InfoMessage& theError) const;
403 /// \return true if the attribute in feature is not obligatory for the feature execution.
404 virtual bool isNotObligatory(std::string theFeature, std::string theAttribute);