Salome HOME
Copyright update 2022
[modules/shaper.git] / src / FeaturesPlugin / FeaturesPlugin_Validators.h
1 // Copyright (C) 2014-2022  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_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
76 {
77 public:
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;
85
86 private:
87   bool isValidAttribute(const AttributePtr& theAttribute,
88                         const std::list<std::string>& theArguments,
89                         Events_InfoMessage& theError) const;
90 };
91
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
98 {
99  public:
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;
107 };
108
109 /// \class FeaturesPlugin_ValidatorCompositeLauncher
110 /// \ingroup Validators
111 /// \brief A validator for selection at composite feature start
112 class FeaturesPlugin_ValidatorCompositeLauncher: public ModelAPI_AttributeValidator
113 {
114 public:
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;
122 };
123
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
129 {
130 public:
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;
138
139 private:
140   bool isShapesCanBeEmpty(const AttributePtr& theAttribute,
141                           Events_InfoMessage& theError) const;
142 };
143
144 /// \class FeaturesPlugin_ValidatorExtrusionBoundaryFace
145 /// \ingroup Validators
146 /// \brief A validator for extrusion from/to face attribute.
147 class FeaturesPlugin_ValidatorExtrusionBoundaryFace: public ModelAPI_AttributeValidator
148 {
149 public:
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;
157 };
158
159 /// \class FeaturesPlugin_ValidatorBooleanSelection
160 /// \ingroup Validators
161 /// \brief Validates selection for boolean operation.
162 class FeaturesPlugin_ValidatorBooleanSelection: public ModelAPI_AttributeValidator
163 {
164 public:
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;
173 };
174
175 /// \class FeaturesPlugin_ValidatorFilletSelection
176 /// \ingroup Validators
177 /// \brief Validates selection for fillet operation.
178 class FeaturesPlugin_ValidatorFilletSelection: public ModelAPI_AttributeValidator
179 {
180 public:
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;
189 };
190
191 /// \class FeaturesPlugin_ValidatorFillet1DSelection
192 /// \ingroup Validators
193 /// \brief Validates selection for 1d-fillet operation.
194 class FeaturesPlugin_ValidatorFillet1DSelection : public ModelAPI_AttributeValidator
195 {
196 public:
197   /// \return True if the attribute is valid. It checks whether the selection
198   /// is acceptable for fillet on wire (vertex is a sharp corner).
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;
205 };
206
207 /// \class FeaturesPlugin_ValidatorPartitionSelection
208 /// \ingroup Validators
209 /// \brief Validates selection for partition.
210 class FeaturesPlugin_ValidatorPartitionSelection: public ModelAPI_AttributeValidator
211 {
212 public:
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;
221 };
222
223 /// \class FeaturesPlugin_ValidatorRemoveSubShapesSelection
224 /// \ingroup Validators
225 /// \brief Validates selection for "Remove Sub-Shapes" feature.
226 class FeaturesPlugin_ValidatorRemoveSubShapesSelection: public ModelAPI_AttributeValidator
227 {
228 public:
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;
237 };
238
239 /// \class FeaturesPlugin_ValidatorRemoveSubShapesResult
240 /// \ingroup Validators
241 /// \brief Validator for the Remove Sub-Shapes feature.
242 class FeaturesPlugin_ValidatorRemoveSubShapesResult: public ModelAPI_FeatureValidator
243 {
244  public:
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;
252 };
253
254 /// \class FeaturesPlugin_ValidatorUnionSelection
255 /// \ingroup Validators
256 /// \brief Validates selection for "Union" feature.
257 class FeaturesPlugin_ValidatorUnionSelection: public ModelAPI_AttributeValidator
258 {
259 public:
260   /// \return True if the attribute is valid. It checks whether the selection
261   /// is acceptable for operation.
262   /// \param[in] theAttribute an attribute to check.
263   /// \param[in] theArguments a filter parameters.
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;
268 };
269
270 /// \class FeaturesPlugin_ValidatorUnionArguments
271 /// \ingroup Validators
272 /// \brief Validator for the "Union" feature.
273 class FeaturesPlugin_ValidatorUnionArguments: public ModelAPI_FeatureValidator
274 {
275  public:
276   //! \return true if result is valid shape.
277   //! \param theFeature the checked feature
278   //! \param theArguments arguments of the feature (not used)
279   //! \param theError error message
280   virtual bool isValid(const std::shared_ptr<ModelAPI_Feature>& theFeature,
281                        const std::list<std::string>& theArguments,
282                        Events_InfoMessage& theError) const;
283 };
284
285 /// \class FeaturesPlugin_ValidatorConcealedResult
286 /// \ingroup Validators
287 /// \brief Validator for the "Recover" feature.
288 class FeaturesPlugin_ValidatorConcealedResult: public ModelAPI_AttributeValidator
289 {
290  public:
291   //! \return True if the attribute is valid.
292   //! \param[in] theAttribute the checked attribute.
293   //! \param[in] theArguments arguments of the attribute.
294   //! \param[out] theError error message.
295    virtual bool isValid(const AttributePtr& theAttribute,
296                         const std::list<std::string>& theArguments,
297                         Events_InfoMessage& theError) const;
298 };
299
300 /// \class FeaturesPlugin_ValidatorCircular
301 /// \ingroup Validators
302 /// \brief Verifies the selected object is circular edge or cylindrical face
303 class FeaturesPlugin_ValidatorCircular : 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_ValidatorBooleanArguments
316 *  \ingroup Validators
317 *  \brief Validates that boolean operation have enough arguments.
318 */
319 class FeaturesPlugin_ValidatorBooleanArguments: public ModelAPI_FeatureValidator
320 {
321 public:
322   /** \brief Returns true if feature and/or attributes are valid.
323   *  \param[in] theFeature the validated feature.
324   *  \param[in] theArguments the arguments in the configuration file for this validator.
325   *  \param[out] theError error message.
326   *  \returns true if feature is valid.
327   */
328   virtual bool isValid(const std::shared_ptr<ModelAPI_Feature>& theFeature,
329                                              const std::list<std::string>& theArguments,
330                                              Events_InfoMessage& theError) const;
331
332   /// \return true if the attribute in feature is not obligatory for the feature execution.
333   virtual bool isNotObligatory(std::string theFeature, std::string theAttribute);
334 };
335
336 /// \class FeaturesPlugin_ValidatorBooleanSmashSelection
337 /// \ingroup Validators
338 /// \brief Verifies the selected object for boolean smash feature
339 class FeaturesPlugin_ValidatorBooleanSmashSelection: public ModelAPI_AttributeValidator
340 {
341 public:
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;
349 };
350
351 /// \class FeaturesPlugin_IntersectionSelection
352 /// \ingroup Validators
353 /// \brief Verifies the selected object for intersection feature
354 class FeaturesPlugin_IntersectionSelection: 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_ValidatorBooleanFuseSelection
367 /// \ingroup Validators
368 /// \brief Verifies the selected object for boolean fuse feature
369 class FeaturesPlugin_ValidatorBooleanFuseSelection: 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_ValidatorBooleanFuseArguments
382 *  \ingroup Validators
383 *  \brief Validates that boolean operation have enough arguments.
384 */
385 class FeaturesPlugin_ValidatorBooleanFuseArguments: public ModelAPI_FeatureValidator
386 {
387 public:
388   /** \brief Returns true if feature and/or attributes are valid.
389   *  \param[in] theFeature the validated feature.
390   *  \param[in] theArguments the arguments in the configuration file for this validator.
391   *  \param[out] theError error message.
392   *  \returns true if feature is valid.
393   */
394   virtual bool isValid(const std::shared_ptr<ModelAPI_Feature>& theFeature,
395                        const std::list<std::string>& theArguments,
396                        Events_InfoMessage& theError) const;
397
398   /// \return true if the attribute in feature is not obligatory for the feature execution.
399   virtual bool isNotObligatory(std::string theFeature, std::string theAttribute);
400 };
401
402 /// \class FeaturesPlugin_ValidatorBooleanCommonSelection
403 /// \ingroup Validators
404 /// \brief Verifies the selected object for boolean common feature
405 class FeaturesPlugin_ValidatorBooleanCommonSelection: public ModelAPI_AttributeValidator
406 {
407 public:
408   //! \return True if the attribute is valid.
409   //! \param[in] theAttribute the checked attribute.
410   //! \param[in] theArguments arguments of the attribute.
411   //! \param[out] theError error message.
412   virtual bool isValid(const AttributePtr& theAttribute,
413                        const std::list<std::string>& theArguments,
414                        Events_InfoMessage& theError) const;
415 };
416
417 /** \class FeaturesPlugin_ValidatorBooleanCommonArguments
418 *  \ingroup Validators
419 *  \brief Validates that boolean operation have enough arguments.
420 */
421 class FeaturesPlugin_ValidatorBooleanCommonArguments: public ModelAPI_FeatureValidator
422 {
423 public:
424   /** \brief Returns true if feature and/or attributes are valid.
425   *  \param[in] theFeature the validated feature.
426   *  \param[in] theArguments the arguments in the configuration file for this validator.
427   *  \param[out] theError error message.
428   *  \returns true if feature is valid.
429   */
430   virtual bool isValid(const std::shared_ptr<ModelAPI_Feature>& theFeature,
431                        const std::list<std::string>& theArguments,
432                        Events_InfoMessage& theError) const;
433
434   /// \return true if the attribute in feature is not obligatory for the feature execution.
435   virtual bool isNotObligatory(std::string theFeature, std::string theAttribute);
436 };
437
438 /// \class FeaturesPlugin_ValidatorDefeaturingSelection
439 /// \ingroup Validators
440 /// \brief Validates selection for fillet operation.
441 class FeaturesPlugin_ValidatorDefeaturingSelection : public ModelAPI_AttributeValidator
442 {
443 public:
444   /// \return True if the attribute is valid. It checks whether the selection
445   /// is acceptable for boolean operation.
446   /// \param[in] theAttribute an attribute to check.
447   /// \param[in] theArguments a filter parameters.
448   /// \param[out] theError error message.
449   virtual bool isValid(const AttributePtr& theAttribute,
450                        const std::list<std::string>& theArguments,
451                        Events_InfoMessage& theError) const;
452 };
453
454 #endif