1 // Copyright (C) 2014-2017 CEA/DEN, EDF R&D
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.
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.
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
17 // See http://www.salome-platform.org/ or
18 // email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com>
21 #ifndef FeaturesPlugin_Validators_H_
22 #define FeaturesPlugin_Validators_H_
24 #include <ModelAPI_AttributeValidator.h>
25 #include <ModelAPI_FeatureValidator.h>
27 /// \class FeaturesPlugin_ValidatorPipePath
28 /// \ingroup Validators
29 /// \brief A validator for selection pipe path.
30 class FeaturesPlugin_ValidatorPipePath: public ModelAPI_AttributeValidator
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;
42 /// \class FeaturesPlugin_ValidatorPipeLocations
43 /// \ingroup Validators
44 /// \brief Validator for the pipe locations.
45 class FeaturesPlugin_ValidatorPipeLocations: public ModelAPI_FeatureValidator
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;
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);
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
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;
76 bool isValidAttribute(const AttributePtr& theAttribute,
77 const std::list<std::string>& theArguments,
78 Events_InfoMessage& theError) const;
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
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;
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);
101 /// \class FeaturesPlugin_ValidatorCompositeLauncher
102 /// \ingroup Validators
103 /// \brief A validator for selection at composite feature start
104 class FeaturesPlugin_ValidatorCompositeLauncher: public ModelAPI_AttributeValidator
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;
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
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;
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);
135 bool isShapesCanBeEmpty(const AttributePtr& theAttribute,
136 Events_InfoMessage& theError) const;
139 /// \class FeaturesPlugin_ValidatorBooleanSelection
140 /// \ingroup Validators
141 /// \brief Validates selection for boolean operation.
142 class FeaturesPlugin_ValidatorBooleanSelection: public ModelAPI_AttributeValidator
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;
155 /// \class FeaturesPlugin_ValidatorFilletSelection
156 /// \ingroup Validators
157 /// \brief Validates selection for fillet operation.
158 class FeaturesPlugin_ValidatorFilletSelection: public ModelAPI_AttributeValidator
161 /// \return True if the attribute is valid. It checks whether the selection
162 /// is acceptable for boolean 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;
171 /// \class FeaturesPlugin_ValidatorPartitionSelection
172 /// \ingroup Validators
173 /// \brief Validates selection for partition.
174 class FeaturesPlugin_ValidatorPartitionSelection: public ModelAPI_AttributeValidator
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;
187 /// \class FeaturesPlugin_ValidatorRemoveSubShapesSelection
188 /// \ingroup Validators
189 /// \brief Validates selection for "Remove Sub-Shapes" feature.
190 class FeaturesPlugin_ValidatorRemoveSubShapesSelection: public ModelAPI_AttributeValidator
193 /// \return True if the attribute is valid. It checks whether the selection
194 /// is acceptable for operation.
195 /// \param[in] theAttribute an attribute to check.
196 /// \param[in] theArguments a filter parameters.
197 /// \param[out] theError error message.
198 virtual bool isValid(const AttributePtr& theAttribute,
199 const std::list<std::string>& theArguments,
200 Events_InfoMessage& theError) const;
203 /// \class FeaturesPlugin_ValidatorRemoveSubShapesResult
204 /// \ingroup Validators
205 /// \brief Validator for the Remove Sub-Shapes feature.
206 class FeaturesPlugin_ValidatorRemoveSubShapesResult: public ModelAPI_FeatureValidator
209 //! \return true if result is valid shape.
210 //! \param theFeature the checked feature
211 //! \param theArguments arguments of the feature (not used)
212 //! \param theError error message
213 virtual bool isValid(const std::shared_ptr<ModelAPI_Feature>& theFeature,
214 const std::list<std::string>& theArguments,
215 Events_InfoMessage& theError) const;
217 /// \return true if the attribute in feature is not obligatory for the feature execution
218 virtual bool isNotObligatory(std::string theFeature, std::string theAttribute);
221 /// \class FeaturesPlugin_ValidatorUnionSelection
222 /// \ingroup Validators
223 /// \brief Validates selection for "Union" feature.
224 class FeaturesPlugin_ValidatorUnionSelection: public ModelAPI_AttributeValidator
227 /// \return True if the attribute is valid. It checks whether the selection
228 /// is acceptable for operation.
229 /// \param[in] theAttribute an attribute to check.
230 /// \param[in] theArguments a filter parameters.
231 /// \param[out] theError error message.
232 virtual bool isValid(const AttributePtr& theAttribute,
233 const std::list<std::string>& theArguments,
234 Events_InfoMessage& theError) const;
237 /// \class FeaturesPlugin_ValidatorUnionArguments
238 /// \ingroup Validators
239 /// \brief Validator for the "Union" feature.
240 class FeaturesPlugin_ValidatorUnionArguments: public ModelAPI_FeatureValidator
243 //! \return true if result is valid shape.
244 //! \param theFeature the checked feature
245 //! \param theArguments arguments of the feature (not used)
246 //! \param theError error message
247 virtual bool isValid(const std::shared_ptr<ModelAPI_Feature>& theFeature,
248 const std::list<std::string>& theArguments,
249 Events_InfoMessage& theError) const;
251 /// \return true if the attribute in feature is not obligatory for the feature execution
252 virtual bool isNotObligatory(std::string theFeature, std::string theAttribute);
255 /// \class FeaturesPlugin_ValidatorConcealedResult
256 /// \ingroup Validators
257 /// \brief Validator for the "Recover" feature.
258 class FeaturesPlugin_ValidatorConcealedResult: public ModelAPI_AttributeValidator
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;