Salome HOME
Task 3.8. Extrusion to any face
[modules/shaper.git] / src / FeaturesPlugin / FeaturesPlugin_Validators.h
1 // Copyright (C) 2014-2019  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_ValidatorPartitionSelection
192 /// \ingroup Validators
193 /// \brief Validates selection for partition.
194 class FeaturesPlugin_ValidatorPartitionSelection: public ModelAPI_AttributeValidator
195 {
196 public:
197   /// \return True if the attribute is valid. It checks whether the selection
198   /// is acceptable for operation.
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_ValidatorRemoveSubShapesSelection
208 /// \ingroup Validators
209 /// \brief Validates selection for "Remove Sub-Shapes" feature.
210 class FeaturesPlugin_ValidatorRemoveSubShapesSelection: 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_ValidatorRemoveSubShapesResult
224 /// \ingroup Validators
225 /// \brief Validator for the Remove Sub-Shapes feature.
226 class FeaturesPlugin_ValidatorRemoveSubShapesResult: public ModelAPI_FeatureValidator
227 {
228  public:
229   //! \return true if result is valid shape.
230   //! \param theFeature the checked feature
231   //! \param theArguments arguments of the feature (not used)
232   //! \param theError error message
233   virtual bool isValid(const std::shared_ptr<ModelAPI_Feature>& theFeature,
234                        const std::list<std::string>& theArguments,
235                        Events_InfoMessage& theError) const;
236 };
237
238 /// \class FeaturesPlugin_ValidatorUnionSelection
239 /// \ingroup Validators
240 /// \brief Validates selection for "Union" feature.
241 class FeaturesPlugin_ValidatorUnionSelection: 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_ValidatorUnionArguments
255 /// \ingroup Validators
256 /// \brief Validator for the "Union" feature.
257 class FeaturesPlugin_ValidatorUnionArguments: 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_ValidatorConcealedResult
270 /// \ingroup Validators
271 /// \brief Validator for the "Recover" feature.
272 class FeaturesPlugin_ValidatorConcealedResult: public ModelAPI_AttributeValidator
273 {
274  public:
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;
282 };
283
284 /// \class FeaturesPlugin_ValidatorCircular
285 /// \ingroup Validators
286 /// \brief Verifies the selected object is circular edge or cylindrical face
287 class FeaturesPlugin_ValidatorCircular : public ModelAPI_AttributeValidator
288 {
289 public:
290   //! \return True if the attribute is valid.
291   //! \param[in] theAttribute the checked attribute.
292   //! \param[in] theArguments arguments of the attribute.
293   //! \param[out] theError error message.
294   virtual bool isValid(const AttributePtr& theAttribute,
295                        const std::list<std::string>& theArguments,
296                        Events_InfoMessage& theError) const;
297 };
298
299 /** \class FeaturesPlugin_ValidatorBooleanArguments
300 *  \ingroup Validators
301 *  \brief Validates that boolean operation have enough arguments.
302 */
303 class FeaturesPlugin_ValidatorBooleanArguments: public ModelAPI_FeatureValidator
304 {
305 public:
306   /** \brief Returns true if feature and/or attributes are valid.
307   *  \param[in] theFeature the validated feature.
308   *  \param[in] theArguments the arguments in the configuration file for this validator.
309   *  \param[out] theError error message.
310   *  \returns true if feature is valid.
311   */
312   virtual bool isValid(const std::shared_ptr<ModelAPI_Feature>& theFeature,
313                                              const std::list<std::string>& theArguments,
314                                              Events_InfoMessage& theError) const;
315
316   /// \return true if the attribute in feature is not obligatory for the feature execution.
317   virtual bool isNotObligatory(std::string theFeature, std::string theAttribute);
318 };
319
320 /// \class FeaturesPlugin_ValidatorBooleanSmashSelection
321 /// \ingroup Validators
322 /// \brief Verifies the selected object for boolean smash feature
323 class FeaturesPlugin_ValidatorBooleanSmashSelection: public ModelAPI_AttributeValidator
324 {
325 public:
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;
333 };
334
335 /// \class FeaturesPlugin_IntersectionSelection
336 /// \ingroup Validators
337 /// \brief Verifies the selected object for intersection feature
338 class FeaturesPlugin_IntersectionSelection: public ModelAPI_AttributeValidator
339 {
340 public:
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;
348 };
349
350 /// \class FeaturesPlugin_ValidatorBooleanFuseSelection
351 /// \ingroup Validators
352 /// \brief Verifies the selected object for boolean fuse feature
353 class FeaturesPlugin_ValidatorBooleanFuseSelection: public ModelAPI_AttributeValidator
354 {
355 public:
356   //! \return True if the attribute is valid.
357   //! \param[in] theAttribute the checked attribute.
358   //! \param[in] theArguments arguments of the attribute.
359   //! \param[out] theError error message.
360   virtual bool isValid(const AttributePtr& theAttribute,
361                        const std::list<std::string>& theArguments,
362                        Events_InfoMessage& theError) const;
363 };
364
365 /** \class FeaturesPlugin_ValidatorBooleanFuseArguments
366 *  \ingroup Validators
367 *  \brief Validates that boolean operation have enough arguments.
368 */
369 class FeaturesPlugin_ValidatorBooleanFuseArguments: public ModelAPI_FeatureValidator
370 {
371 public:
372   /** \brief Returns true if feature and/or attributes are valid.
373   *  \param[in] theFeature the validated feature.
374   *  \param[in] theArguments the arguments in the configuration file for this validator.
375   *  \param[out] theError error message.
376   *  \returns true if feature is valid.
377   */
378   virtual bool isValid(const std::shared_ptr<ModelAPI_Feature>& theFeature,
379                        const std::list<std::string>& theArguments,
380                        Events_InfoMessage& theError) const;
381
382   /// \return true if the attribute in feature is not obligatory for the feature execution.
383   virtual bool isNotObligatory(std::string theFeature, std::string theAttribute);
384 };
385
386 /// \class FeaturesPlugin_ValidatorBooleanCommonSelection
387 /// \ingroup Validators
388 /// \brief Verifies the selected object for boolean common feature
389 class FeaturesPlugin_ValidatorBooleanCommonSelection: public ModelAPI_AttributeValidator
390 {
391 public:
392   //! \return True if the attribute is valid.
393   //! \param[in] theAttribute the checked attribute.
394   //! \param[in] theArguments arguments of the attribute.
395   //! \param[out] theError error message.
396   virtual bool isValid(const AttributePtr& theAttribute,
397                        const std::list<std::string>& theArguments,
398                        Events_InfoMessage& theError) const;
399 };
400
401 /** \class FeaturesPlugin_ValidatorBooleanCommonArguments
402 *  \ingroup Validators
403 *  \brief Validates that boolean operation have enough arguments.
404 */
405 class FeaturesPlugin_ValidatorBooleanCommonArguments: public ModelAPI_FeatureValidator
406 {
407 public:
408   /** \brief Returns true if feature and/or attributes are valid.
409   *  \param[in] theFeature the validated feature.
410   *  \param[in] theArguments the arguments in the configuration file for this validator.
411   *  \param[out] theError error message.
412   *  \returns true if feature is valid.
413   */
414   virtual bool isValid(const std::shared_ptr<ModelAPI_Feature>& theFeature,
415                        const std::list<std::string>& theArguments,
416                        Events_InfoMessage& theError) const;
417
418   /// \return true if the attribute in feature is not obligatory for the feature execution.
419   virtual bool isNotObligatory(std::string theFeature, std::string theAttribute);
420 };
421
422 #endif