1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D -->
3 // File: FeaturesPlugin_Validators.h
4 // Created: 22 March 2016
5 // Author: Dmitry Bobylev
7 #ifndef FeaturesPlugin_Validators_H_
8 #define FeaturesPlugin_Validators_H_
10 #include <ModelAPI_AttributeValidator.h>
11 #include <ModelAPI_FeatureValidator.h>
13 /// \class FeaturesPlugin_ValidatorPipeLocations
14 /// \ingroup Validators
15 /// \brief Validator for the pipe locations.
16 class FeaturesPlugin_ValidatorPipeLocations: public ModelAPI_FeatureValidator
19 //! \return true if number of selected locations the same as number of selected bases, or empty.
20 //! \param theFeature the checked feature
21 //! \param theArguments arguments of the feature (not used)
22 //! \param theError error message
23 virtual bool isValid(const std::shared_ptr<ModelAPI_Feature>& theFeature,
24 const std::list<std::string>& theArguments,
25 std::string& theError) const;
27 /// Returns true if the attribute in feature is not obligatory for the feature execution
28 virtual bool isNotObligatory(std::string theFeature, std::string theAttribute);
31 /// \class FeaturesPlugin_ValidatorBaseForGeneration
32 /// \ingroup Validators
33 /// \brief A validator for selection base for generation. Allows to select faces on sketch,
34 /// whole sketch(if it has at least one face), and following objects: vertex, edge, wire, face.
35 class FeaturesPlugin_ValidatorBaseForGeneration: public ModelAPI_AttributeValidator
38 //! Returns true if attribute has selection type listed in the parameter arguments.
39 //! \param[in] theAttribute the checked attribute.
40 //! \param[in] theArguments arguments of the attribute.
41 //! \param[out] theError error message.
42 virtual bool isValid(const AttributePtr& theAttribute,
43 const std::list<std::string>& theArguments,
44 std::string& theError) const;
47 bool isValidAttribute(const AttributePtr& theAttribute,
48 const std::list<std::string>& theArguments,
49 std::string& theError) const;
52 /// \class FeaturesPlugin_ValidatorCompositeLauncher
53 /// \ingroup Validators
54 /// \brief A validator for selection at composite feature start
55 class FeaturesPlugin_ValidatorCompositeLauncher: public ModelAPI_AttributeValidator
58 //! Returns true if attribute has selection type listed in the parameter arguments.
59 //! \param[in] theAttribute the checked attribute.
60 //! \param[in] theArguments arguments of the attribute.
61 //! \param[out] theError error message.
62 virtual bool isValid(const AttributePtr& theAttribute,
63 const std::list<std::string>& theArguments,
64 std::string& theError) const;
67 /// \class FeaturesPlugin_ValidatorCanBeEmpty
68 /// \ingroup Validators
69 /// \brief A validator for extrusion direction attribute. Allows it to be empty if base objects are
70 /// planar and do not contain vertices and edges.
71 class FeaturesPlugin_ValidatorCanBeEmpty: public ModelAPI_FeatureValidator
74 //! Returns true if attribute listed in the parameter arguments are planar.
75 //! \param[in] theFeature the checked feature.
76 //! \param[in] theArguments arguments of the attribute.
77 //! \param[out] theError error message.
78 virtual bool isValid(const std::shared_ptr<ModelAPI_Feature>& theFeature,
79 const std::list<std::string>& theArguments,
80 std::string& theError) const;
82 /// Returns true if the attribute in feature is not obligatory for the feature execution
83 virtual bool isNotObligatory(std::string theFeature, std::string theAttribute);
86 bool isShapesCanBeEmpty(const AttributePtr& theAttribute,
87 std::string& theError) const;
90 /// \class FeaturesPlugin_ValidatorBooleanSelection
91 /// \ingroup Validators
92 /// \brief Validates selection for boolean operation.
93 class FeaturesPlugin_ValidatorBooleanSelection: public ModelAPI_AttributeValidator
96 /// \return True if the attribute is valid. It checks whether the selection
97 /// is acceptable for boolean operation.
98 /// \param[in] theAttribute an attribute to check.
99 /// \param[in] theArguments a filter parameters.
100 /// \param[out] theError error message.
101 virtual bool isValid(const AttributePtr& theAttribute,
102 const std::list<std::string>& theArguments,
103 std::string& theError) const;
106 /// \class FeaturesPlugin_ValidatorPartitionSelection
107 /// \ingroup Validators
108 /// \brief Validates selection for partition.
109 class FeaturesPlugin_ValidatorPartitionSelection: public ModelAPI_AttributeValidator
112 /// \return True if the attribute is valid. It checks whether the selection
113 /// is acceptable for operation.
114 /// \param[in] theAttribute an attribute to check.
115 /// \param[in] theArguments a filter parameters.
116 /// \param[out] theError error message.
117 virtual bool isValid(const AttributePtr& theAttribute,
118 const std::list<std::string>& theArguments,
119 std::string& theError) const;
122 /// \class FeaturesPlugin_ValidatorRemoveSubShapesSelection
123 /// \ingroup Validators
124 /// \brief Validates selection for "Remove Sub-Shapes" feature.
125 class FeaturesPlugin_ValidatorRemoveSubShapesSelection: public ModelAPI_AttributeValidator
128 /// \return True if the attribute is valid. It checks whether the selection
129 /// is acceptable for operation.
130 /// \param[in] theAttribute an attribute to check.
131 /// \param[in] theArguments a filter parameters.
132 /// \param[out] theError error message.
133 virtual bool isValid(const AttributePtr& theAttribute,
134 const std::list<std::string>& theArguments,
135 std::string& theError) const;
138 /// \class FeaturesPlugin_ValidatorRemoveSubShapesResult
139 /// \ingroup Validators
140 /// \brief Validator for the Remove Sub-Shapes feature.
141 class FeaturesPlugin_ValidatorRemoveSubShapesResult: public ModelAPI_FeatureValidator
144 //! \return true if result is valid shape.
145 //! \param theFeature the checked feature
146 //! \param theArguments arguments of the feature (not used)
147 //! \param theError error message
148 virtual bool isValid(const std::shared_ptr<ModelAPI_Feature>& theFeature,
149 const std::list<std::string>& theArguments,
150 std::string& theError) const;
152 /// Returns true if the attribute in feature is not obligatory for the feature execution
153 virtual bool isNotObligatory(std::string theFeature, std::string theAttribute);