Salome HOME
f0b5c50d4444d0b790f9460177cc066c1e69bf4b
[modules/shaper.git] / src / FeaturesPlugin / FeaturesPlugin_Validators.h
1 // Copyright (C) 2014-2023  CEA/DEN, EDF R&D
2 //
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.
7 //
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.
12 //
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
16 //
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18 //
19
20 #ifndef FeaturesPlugin_Validators_H_
21 #define FeaturesPlugin_Validators_H_
22
23 #include <ModelAPI_AttributeValidator.h>
24 #include <ModelAPI_FeatureValidator.h>
25
26 /// \class FeaturesPlugin_ValidatorPipePath
27 /// \ingroup Validators
28 /// \brief A validator for selection pipe path.
29 class FeaturesPlugin_ValidatorPipePath: public ModelAPI_AttributeValidator
30 {
31 public:
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;
39 };
40
41 /// \class FeaturesPlugin_ValidatorPipeLocations
42 /// \ingroup Validators
43 /// \brief A validator for selection pipe locations.
44 class FeaturesPlugin_ValidatorPipeLocations: public ModelAPI_AttributeValidator
45 {
46 public:
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;
54 };
55
56 /// \class FeaturesPlugin_ValidatorPipeLocationsNumber
57 /// \ingroup Validators
58 /// \brief Validator for the pipe locations.
59 class FeaturesPlugin_ValidatorPipeLocationsNumber: public ModelAPI_FeatureValidator
60 {
61  public:
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;
69 };
70
71 /// \class FeaturesPlugin_ValidatorLoftSameTypeShape
72 /// \ingroup Validators
73 /// \brief Validator for the same type of shape.
74 class FeaturesPlugin_ValidatorLoftSameTypeShape: public ModelAPI_FeatureValidator
75 {
76  public:
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;
84 };
85
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
91 {
92 public:
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;
100
101 private:
102   bool isValidAttribute(const AttributePtr& theAttribute,
103                         const std::list<std::string>& theArguments,
104                         Events_InfoMessage& theError) const;
105 };
106
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
113 {
114  public:
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;
122 };
123
124 /// \class FeaturesPlugin_ValidatorCompositeLauncher
125 /// \ingroup Validators
126 /// \brief A validator for selection at composite feature start
127 class FeaturesPlugin_ValidatorCompositeLauncher: public ModelAPI_AttributeValidator
128 {
129 public:
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;
137 };
138
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
144 {
145 public:
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;
153
154 private:
155   bool isShapesCanBeEmpty(const AttributePtr& theAttribute,
156                           Events_InfoMessage& theError) const;
157 };
158
159 /// \class FeaturesPlugin_ValidatorExtrusionBoundaryFace
160 /// \ingroup Validators
161 /// \brief A validator for extrusion from/to face attribute.
162 class FeaturesPlugin_ValidatorExtrusionBoundaryFace: public ModelAPI_AttributeValidator
163 {
164 public:
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;
172 };
173
174 /// \class FeaturesPlugin_ValidatorBooleanSelection
175 /// \ingroup Validators
176 /// \brief Validates selection for boolean operation.
177 class FeaturesPlugin_ValidatorBooleanSelection: public ModelAPI_AttributeValidator
178 {
179 public:
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;
188 };
189
190 /// \class FeaturesPlugin_ValidatorFilletSelection
191 /// \ingroup Validators
192 /// \brief Validates selection for fillet operation.
193 class FeaturesPlugin_ValidatorFilletSelection: public ModelAPI_AttributeValidator
194 {
195 public:
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;
204 };
205
206 /// \class FeaturesPlugin_ValidatorFillet1DSelection
207 /// \ingroup Validators
208 /// \brief Validates selection for 1d-fillet operation.
209 class FeaturesPlugin_ValidatorFillet1DSelection : public ModelAPI_AttributeValidator
210 {
211 public:
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;
220 };
221
222 /// \class FeaturesPlugin_ValidatorPartitionSelection
223 /// \ingroup Validators
224 /// \brief Validates selection for partition.
225 class FeaturesPlugin_ValidatorPartitionSelection: public ModelAPI_AttributeValidator
226 {
227 public:
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;
236 };
237
238 /// \class FeaturesPlugin_ValidatorRemoveSubShapesSelection
239 /// \ingroup Validators
240 /// \brief Validates selection for "Remove Sub-Shapes" feature.
241 class FeaturesPlugin_ValidatorRemoveSubShapesSelection: public ModelAPI_AttributeValidator
242 {
243 public:
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;
252 };
253
254 /// \class FeaturesPlugin_ValidatorRemoveSubShapesResult
255 /// \ingroup Validators
256 /// \brief Validator for the Remove Sub-Shapes feature.
257 class FeaturesPlugin_ValidatorRemoveSubShapesResult: public ModelAPI_FeatureValidator
258 {
259  public:
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;
267 };
268
269 /// \class FeaturesPlugin_ValidatorUnionSelection
270 /// \ingroup Validators
271 /// \brief Validates selection for "Union" feature.
272 class FeaturesPlugin_ValidatorUnionSelection: public ModelAPI_AttributeValidator
273 {
274 public:
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;
283 };
284
285 /// \class FeaturesPlugin_ValidatorUnionArguments
286 /// \ingroup Validators
287 /// \brief Validator for the "Union" feature.
288 class FeaturesPlugin_ValidatorUnionArguments: public ModelAPI_FeatureValidator
289 {
290  public:
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;
298 };
299
300 /// \class FeaturesPlugin_ValidatorConcealedResult
301 /// \ingroup Validators
302 /// \brief Validator for the "Recover" feature.
303 class FeaturesPlugin_ValidatorConcealedResult: public ModelAPI_AttributeValidator
304 {
305  public:
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;
313 };
314
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
319 {
320 public:
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;
328 };
329
330 /** \class FeaturesPlugin_ValidatorBooleanArguments
331 *  \ingroup Validators
332 *  \brief Validates that boolean operation have enough arguments.
333 */
334 class FeaturesPlugin_ValidatorBooleanArguments: public ModelAPI_FeatureValidator
335 {
336 public:
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.
342   */
343   virtual bool isValid(const std::shared_ptr<ModelAPI_Feature>& theFeature,
344                                              const std::list<std::string>& theArguments,
345                                              Events_InfoMessage& theError) const;
346
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);
349 };
350
351 /// \class FeaturesPlugin_ValidatorBooleanSmashSelection
352 /// \ingroup Validators
353 /// \brief Verifies the selected object for boolean smash feature
354 class FeaturesPlugin_ValidatorBooleanSmashSelection: public ModelAPI_AttributeValidator
355 {
356 public:
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;
364 };
365
366 /// \class FeaturesPlugin_IntersectionSelection
367 /// \ingroup Validators
368 /// \brief Verifies the selected object for intersection feature
369 class FeaturesPlugin_IntersectionSelection: public ModelAPI_AttributeValidator
370 {
371 public:
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;
379 };
380
381 /// \class FeaturesPlugin_ValidatorBooleanFuseSelection
382 /// \ingroup Validators
383 /// \brief Verifies the selected object for boolean fuse feature
384 class FeaturesPlugin_ValidatorBooleanFuseSelection: public ModelAPI_AttributeValidator
385 {
386 public:
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;
394 };
395
396 /** \class FeaturesPlugin_ValidatorBooleanFuseArguments
397 *  \ingroup Validators
398 *  \brief Validates that boolean operation have enough arguments.
399 */
400 class FeaturesPlugin_ValidatorBooleanFuseArguments: public ModelAPI_FeatureValidator
401 {
402 public:
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.
408   */
409   virtual bool isValid(const std::shared_ptr<ModelAPI_Feature>& theFeature,
410                        const std::list<std::string>& theArguments,
411                        Events_InfoMessage& theError) const;
412
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);
415 };
416
417 /// \class FeaturesPlugin_ValidatorBooleanCommonSelection
418 /// \ingroup Validators
419 /// \brief Verifies the selected object for boolean common feature
420 class FeaturesPlugin_ValidatorBooleanCommonSelection: public ModelAPI_AttributeValidator
421 {
422 public:
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;
430 };
431
432 /** \class FeaturesPlugin_ValidatorBooleanCommonArguments
433 *  \ingroup Validators
434 *  \brief Validates that boolean operation have enough arguments.
435 */
436 class FeaturesPlugin_ValidatorBooleanCommonArguments: public ModelAPI_FeatureValidator
437 {
438 public:
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.
444   */
445   virtual bool isValid(const std::shared_ptr<ModelAPI_Feature>& theFeature,
446                        const std::list<std::string>& theArguments,
447                        Events_InfoMessage& theError) const;
448
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);
451 };
452
453 /// \class FeaturesPlugin_ValidatorDefeaturingSelection
454 /// \ingroup Validators
455 /// \brief Validates selection for fillet operation.
456 class FeaturesPlugin_ValidatorDefeaturingSelection : public ModelAPI_AttributeValidator
457 {
458 public:
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;
467 };
468
469 /// \class FeaturesPlugin_ValidatorSewingSelection
470 /// \ingroup Validators
471 /// \brief Validates selection for sewing operation.
472 class FeaturesPlugin_ValidatorSewingSelection : public ModelAPI_AttributeValidator
473 {
474 public:
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;
483 };
484
485 /// \class FeaturesPlugin_ValidatorGlueFacesSelection
486 /// \ingroup Validators
487 /// \brief Validates selection for glue faces operation.
488 class FeaturesPlugin_ValidatorGlueFacesSelection : public ModelAPI_AttributeValidator
489 {
490 public:
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;
499 };
500
501 #endif