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