Salome HOME
ca731ef0e7de141a8a9d8c88f2bb5e732dc0041d
[modules/shaper.git] / src / FeaturesPlugin / FeaturesPlugin_Validators.h
1 // Copyright (C) 2014-2017  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
18 // email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com>
19 //
20
21 #ifndef FeaturesPlugin_Validators_H_
22 #define FeaturesPlugin_Validators_H_
23
24 #include <ModelAPI_AttributeValidator.h>
25 #include <ModelAPI_FeatureValidator.h>
26
27 /// \class FeaturesPlugin_ValidatorPipePath
28 /// \ingroup Validators
29 /// \brief A validator for selection pipe path.
30 class FeaturesPlugin_ValidatorPipePath: public ModelAPI_AttributeValidator
31 {
32 public:
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;
40 };
41
42 /// \class FeaturesPlugin_ValidatorPipeLocations
43 /// \ingroup Validators
44 /// \brief Validator for the pipe locations.
45 class FeaturesPlugin_ValidatorPipeLocations: public ModelAPI_FeatureValidator
46 {
47  public:
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;
55 };
56
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
62 {
63 public:
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;
71
72 private:
73   bool isValidAttribute(const AttributePtr& theAttribute,
74                         const std::list<std::string>& theArguments,
75                         Events_InfoMessage& theError) const;
76 };
77
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
84 {
85  public:
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;
93 };
94
95 /// \class FeaturesPlugin_ValidatorCompositeLauncher
96 /// \ingroup Validators
97 /// \brief A validator for selection at composite feature start
98 class FeaturesPlugin_ValidatorCompositeLauncher: public ModelAPI_AttributeValidator
99 {
100 public:
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;
108 };
109
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
115 {
116 public:
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;
124
125 private:
126   bool isShapesCanBeEmpty(const AttributePtr& theAttribute,
127                           Events_InfoMessage& theError) const;
128 };
129
130 /// \class FeaturesPlugin_ValidatorBooleanSelection
131 /// \ingroup Validators
132 /// \brief Validates selection for boolean operation.
133 class FeaturesPlugin_ValidatorBooleanSelection: public ModelAPI_AttributeValidator
134 {
135 public:
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;
144 };
145
146 /// \class FeaturesPlugin_ValidatorFilletSelection
147 /// \ingroup Validators
148 /// \brief Validates selection for fillet operation.
149 class FeaturesPlugin_ValidatorFilletSelection: public ModelAPI_AttributeValidator
150 {
151 public:
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;
160 };
161
162 /// \class FeaturesPlugin_ValidatorPartitionSelection
163 /// \ingroup Validators
164 /// \brief Validates selection for partition.
165 class FeaturesPlugin_ValidatorPartitionSelection: public ModelAPI_AttributeValidator
166 {
167 public:
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;
176 };
177
178 /// \class FeaturesPlugin_ValidatorRemoveSubShapesSelection
179 /// \ingroup Validators
180 /// \brief Validates selection for "Remove Sub-Shapes" feature.
181 class FeaturesPlugin_ValidatorRemoveSubShapesSelection: public ModelAPI_AttributeValidator
182 {
183 public:
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;
192 };
193
194 /// \class FeaturesPlugin_ValidatorRemoveSubShapesResult
195 /// \ingroup Validators
196 /// \brief Validator for the Remove Sub-Shapes feature.
197 class FeaturesPlugin_ValidatorRemoveSubShapesResult: public ModelAPI_FeatureValidator
198 {
199  public:
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;
207 };
208
209 /// \class FeaturesPlugin_ValidatorUnionSelection
210 /// \ingroup Validators
211 /// \brief Validates selection for "Union" feature.
212 class FeaturesPlugin_ValidatorUnionSelection: public ModelAPI_AttributeValidator
213 {
214 public:
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;
223 };
224
225 /// \class FeaturesPlugin_ValidatorUnionArguments
226 /// \ingroup Validators
227 /// \brief Validator for the "Union" feature.
228 class FeaturesPlugin_ValidatorUnionArguments: public ModelAPI_FeatureValidator
229 {
230  public:
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;
238 };
239
240 /// \class FeaturesPlugin_ValidatorConcealedResult
241 /// \ingroup Validators
242 /// \brief Validator for the "Recover" feature.
243 class FeaturesPlugin_ValidatorConcealedResult: public ModelAPI_AttributeValidator
244 {
245  public:
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;
253 };
254
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
259 {
260 public:
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;
268 };
269
270 /** \class FeaturesPlugin_ValidatorBooleanArguments
271 *  \ingroup Validators
272 *  \brief Validates that boolean operation have enough arguments.
273 */
274 class FeaturesPlugin_ValidatorBooleanArguments: public ModelAPI_FeatureValidator
275 {
276 public:
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.
282   */
283   virtual bool isValid(const std::shared_ptr<ModelAPI_Feature>& theFeature,
284                                              const std::list<std::string>& theArguments,
285                                              Events_InfoMessage& theError) const;
286
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);
289 };
290
291 /// \class FeaturesPlugin_ValidatorBooleanSmashSelection
292 /// \ingroup Validators
293 /// \brief Verifies the selected object for boolean smash feature
294 class FeaturesPlugin_ValidatorBooleanSmashSelection: public ModelAPI_AttributeValidator
295 {
296 public:
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;
304 };
305
306 #endif