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 email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com>
20 #ifndef FeaturesPlugin_Validators_H_
21 #define FeaturesPlugin_Validators_H_
23 #include <ModelAPI_AttributeValidator.h>
24 #include <ModelAPI_FeatureValidator.h>
26 /// \class FeaturesPlugin_ValidatorPipePath
27 /// \ingroup Validators
28 /// \brief A validator for selection pipe path.
29 class FeaturesPlugin_ValidatorPipePath: public ModelAPI_AttributeValidator
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;
41 /// \class FeaturesPlugin_ValidatorPipeLocations
42 /// \ingroup Validators
43 /// \brief Validator for the pipe locations.
44 class FeaturesPlugin_ValidatorPipeLocations: public ModelAPI_FeatureValidator
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;
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);
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
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;
75 bool isValidAttribute(const AttributePtr& theAttribute,
76 const std::list<std::string>& theArguments,
77 Events_InfoMessage& theError) const;
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
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;
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);
100 /// \class FeaturesPlugin_ValidatorCompositeLauncher
101 /// \ingroup Validators
102 /// \brief A validator for selection at composite feature start
103 class FeaturesPlugin_ValidatorCompositeLauncher: public ModelAPI_AttributeValidator
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;
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
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;
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);
134 bool isShapesCanBeEmpty(const AttributePtr& theAttribute,
135 Events_InfoMessage& theError) const;
138 /// \class FeaturesPlugin_ValidatorBooleanSelection
139 /// \ingroup Validators
140 /// \brief Validates selection for boolean operation.
141 class FeaturesPlugin_ValidatorBooleanSelection: public ModelAPI_AttributeValidator
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;
154 /// \class FeaturesPlugin_ValidatorPartitionSelection
155 /// \ingroup Validators
156 /// \brief Validates selection for partition.
157 class FeaturesPlugin_ValidatorPartitionSelection: public ModelAPI_AttributeValidator
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;
170 /// \class FeaturesPlugin_ValidatorRemoveSubShapesSelection
171 /// \ingroup Validators
172 /// \brief Validates selection for "Remove Sub-Shapes" feature.
173 class FeaturesPlugin_ValidatorRemoveSubShapesSelection: public ModelAPI_AttributeValidator
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;
186 /// \class FeaturesPlugin_ValidatorRemoveSubShapesResult
187 /// \ingroup Validators
188 /// \brief Validator for the Remove Sub-Shapes feature.
189 class FeaturesPlugin_ValidatorRemoveSubShapesResult: public ModelAPI_FeatureValidator
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;
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);
204 /// \class FeaturesPlugin_ValidatorUnionSelection
205 /// \ingroup Validators
206 /// \brief Validates selection for "Union" feature.
207 class FeaturesPlugin_ValidatorUnionSelection: public ModelAPI_AttributeValidator
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;
220 /// \class FeaturesPlugin_ValidatorUnionArguments
221 /// \ingroup Validators
222 /// \brief Validator for the "Union" feature.
223 class FeaturesPlugin_ValidatorUnionArguments: public ModelAPI_FeatureValidator
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;
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);
238 /// \class FeaturesPlugin_ValidatorConcealedResult
239 /// \ingroup Validators
240 /// \brief Validator for the "Recover" feature.
241 class FeaturesPlugin_ValidatorConcealedResult: public ModelAPI_AttributeValidator
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;