Salome HOME
Add copyright header according to request of CEA from 06.06.2017
[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   /// Returns true if the attribute in feature is not obligatory for the feature execution
57   virtual bool isNotObligatory(std::string theFeature, std::string theAttribute);
58 };
59
60 /// \class FeaturesPlugin_ValidatorBaseForGeneration
61 /// \ingroup Validators
62 /// \brief A validator for selection base for generation. Allows to select faces on sketch,
63 /// whole sketch(if it has at least one face), and following objects: vertex, edge, wire, face.
64 class FeaturesPlugin_ValidatorBaseForGeneration: public ModelAPI_AttributeValidator
65 {
66 public:
67   //! \return true if attribute has selection type listed in the parameter arguments.
68   //! \param[in] theAttribute the checked attribute.
69   //! \param[in] theArguments arguments of the attribute.
70   //! \param[out] theError error message.
71    virtual bool isValid(const AttributePtr& theAttribute,
72                         const std::list<std::string>& theArguments,
73                         Events_InfoMessage& theError) const;
74
75 private:
76   bool isValidAttribute(const AttributePtr& theAttribute,
77                         const std::list<std::string>& theArguments,
78                         Events_InfoMessage& theError) const;
79 };
80
81 /// \class FeaturesPlugin_ValidatorBaseForGenerationSketchOrSketchObjects
82 /// \ingroup Validators
83 /// \brief Validator for the base objects for generation. Checks that sketch and it objects
84 ///        are not selected at the same time.
85 class FeaturesPlugin_ValidatorBaseForGenerationSketchOrSketchObjects:
86   public ModelAPI_FeatureValidator
87 {
88  public:
89   //! \return true if sketch and it objects not selected at the same time.
90   //! \param theFeature the checked feature
91   //! \param theArguments arguments of the feature (not used)
92   //! \param theError error message
93   virtual bool isValid(const std::shared_ptr<ModelAPI_Feature>& theFeature,
94                        const std::list<std::string>& theArguments,
95                        Events_InfoMessage& theError) const;
96
97   /// Returns true if the attribute in feature is not obligatory for the feature execution
98   virtual bool isNotObligatory(std::string theFeature, std::string theAttribute);
99 };
100
101 /// \class FeaturesPlugin_ValidatorCompositeLauncher
102 /// \ingroup Validators
103 /// \brief A validator for selection at composite feature start
104 class FeaturesPlugin_ValidatorCompositeLauncher: public ModelAPI_AttributeValidator
105 {
106 public:
107   //! \return true if attribute has selection type listed in the parameter arguments.
108   //! \param[in] theAttribute the checked attribute.
109   //! \param[in] theArguments arguments of the attribute.
110   //! \param[out] theError error message.
111    virtual bool isValid(const AttributePtr& theAttribute,
112                         const std::list<std::string>& theArguments,
113                         Events_InfoMessage& theError) const;
114 };
115
116 /// \class FeaturesPlugin_ValidatorExtrusionDir
117 /// \ingroup Validators
118 /// \brief A validator for extrusion direction attribute. Allows it to be empty if base objects are
119 ///        planar and do not contain vertices and edges.
120 class FeaturesPlugin_ValidatorExtrusionDir: public ModelAPI_FeatureValidator
121 {
122 public:
123   //! \return true if attribute listed in the parameter arguments are planar.
124   //! \param[in] theFeature the checked feature.
125   //! \param[in] theArguments arguments of the attribute.
126   //! \param[out] theError error message.
127   virtual bool isValid(const std::shared_ptr<ModelAPI_Feature>& theFeature,
128                        const std::list<std::string>& theArguments,
129                        Events_InfoMessage& theError) const;
130
131   /// \return true if the attribute in feature is not obligatory for the feature execution
132   virtual bool isNotObligatory(std::string theFeature, std::string theAttribute);
133
134 private:
135   bool isShapesCanBeEmpty(const AttributePtr& theAttribute,
136                           Events_InfoMessage& theError) const;
137 };
138
139 /// \class FeaturesPlugin_ValidatorBooleanSelection
140 /// \ingroup Validators
141 /// \brief Validates selection for boolean operation.
142 class FeaturesPlugin_ValidatorBooleanSelection: public ModelAPI_AttributeValidator
143 {
144 public:
145   /// \return True if the attribute is valid. It checks whether the selection
146   /// is acceptable for boolean operation.
147   /// \param[in] theAttribute an attribute to check.
148   /// \param[in] theArguments a filter parameters.
149   /// \param[out] theError error message.
150   virtual bool isValid(const AttributePtr& theAttribute,
151                        const std::list<std::string>& theArguments,
152                        Events_InfoMessage& theError) const;
153 };
154
155 /// \class FeaturesPlugin_ValidatorPartitionSelection
156 /// \ingroup Validators
157 /// \brief Validates selection for partition.
158 class FeaturesPlugin_ValidatorPartitionSelection: public ModelAPI_AttributeValidator
159 {
160 public:
161   /// \return True if the attribute is valid. It checks whether the selection
162   /// is acceptable for operation.
163   /// \param[in] theAttribute an attribute to check.
164   /// \param[in] theArguments a filter parameters.
165   /// \param[out] theError error message.
166   virtual bool isValid(const AttributePtr& theAttribute,
167                        const std::list<std::string>& theArguments,
168                        Events_InfoMessage& theError) const;
169 };
170
171 /// \class FeaturesPlugin_ValidatorRemoveSubShapesSelection
172 /// \ingroup Validators
173 /// \brief Validates selection for "Remove Sub-Shapes" feature.
174 class FeaturesPlugin_ValidatorRemoveSubShapesSelection: public ModelAPI_AttributeValidator
175 {
176 public:
177   /// \return True if the attribute is valid. It checks whether the selection
178   /// is acceptable for operation.
179   /// \param[in] theAttribute an attribute to check.
180   /// \param[in] theArguments a filter parameters.
181   /// \param[out] theError error message.
182   virtual bool isValid(const AttributePtr& theAttribute,
183                        const std::list<std::string>& theArguments,
184                        Events_InfoMessage& theError) const;
185 };
186
187 /// \class FeaturesPlugin_ValidatorRemoveSubShapesResult
188 /// \ingroup Validators
189 /// \brief Validator for the Remove Sub-Shapes feature.
190 class FeaturesPlugin_ValidatorRemoveSubShapesResult: public ModelAPI_FeatureValidator
191 {
192  public:
193   //! \return true if result is valid shape.
194   //! \param theFeature the checked feature
195   //! \param theArguments arguments of the feature (not used)
196   //! \param theError error message
197   virtual bool isValid(const std::shared_ptr<ModelAPI_Feature>& theFeature,
198                        const std::list<std::string>& theArguments,
199                        Events_InfoMessage& theError) const;
200
201   /// \return true if the attribute in feature is not obligatory for the feature execution
202   virtual bool isNotObligatory(std::string theFeature, std::string theAttribute);
203 };
204
205 /// \class FeaturesPlugin_ValidatorUnionSelection
206 /// \ingroup Validators
207 /// \brief Validates selection for "Union" feature.
208 class FeaturesPlugin_ValidatorUnionSelection: public ModelAPI_AttributeValidator
209 {
210 public:
211   /// \return True if the attribute is valid. It checks whether the selection
212   /// is acceptable for operation.
213   /// \param[in] theAttribute an attribute to check.
214   /// \param[in] theArguments a filter parameters.
215   /// \param[out] theError error message.
216   virtual bool isValid(const AttributePtr& theAttribute,
217                        const std::list<std::string>& theArguments,
218                        Events_InfoMessage& theError) const;
219 };
220
221 /// \class FeaturesPlugin_ValidatorUnionArguments
222 /// \ingroup Validators
223 /// \brief Validator for the "Union" feature.
224 class FeaturesPlugin_ValidatorUnionArguments: public ModelAPI_FeatureValidator
225 {
226  public:
227   //! \return true if result is valid shape.
228   //! \param theFeature the checked feature
229   //! \param theArguments arguments of the feature (not used)
230   //! \param theError error message
231   virtual bool isValid(const std::shared_ptr<ModelAPI_Feature>& theFeature,
232                        const std::list<std::string>& theArguments,
233                        Events_InfoMessage& theError) const;
234
235   /// \return true if the attribute in feature is not obligatory for the feature execution
236   virtual bool isNotObligatory(std::string theFeature, std::string theAttribute);
237 };
238
239 /// \class FeaturesPlugin_ValidatorConcealedResult
240 /// \ingroup Validators
241 /// \brief Validator for the "Recover" feature.
242 class FeaturesPlugin_ValidatorConcealedResult: public ModelAPI_AttributeValidator
243 {
244  public:
245   //! \return True if the attribute is valid.
246   //! \param[in] theAttribute the checked attribute.
247   //! \param[in] theArguments arguments of the attribute.
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 #endif