Salome HOME
Validator for Pipe path selection which disables local selection of wires.
[modules/shaper.git] / src / FeaturesPlugin / FeaturesPlugin_Validators.h
1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D -->
2
3 // File:        FeaturesPlugin_Validators.h
4 // Created:     22 March 2016
5 // Author:      Dmitry Bobylev
6
7 #ifndef FeaturesPlugin_Validators_H_
8 #define FeaturesPlugin_Validators_H_
9
10 #include <ModelAPI_AttributeValidator.h>
11 #include <ModelAPI_FeatureValidator.h>
12
13 /// \class FeaturesPlugin_ValidatorPipePath
14 /// \ingroup Validators
15 /// \brief A validator for selection pipe path.
16 class FeaturesPlugin_ValidatorPipePath: public ModelAPI_AttributeValidator
17 {
18 public:
19   //! \return True if the attribute is valid.
20   //! \param[in] theAttribute the checked attribute.
21   //! \param[in] theArguments arguments of the attribute.
22   //! \param[out] theError error message.
23    virtual bool isValid(const AttributePtr& theAttribute,
24                         const std::list<std::string>& theArguments,
25                         std::string& theError) const;
26 };
27
28 /// \class FeaturesPlugin_ValidatorPipeLocations
29 /// \ingroup Validators
30 /// \brief Validator for the pipe locations.
31 class FeaturesPlugin_ValidatorPipeLocations: public ModelAPI_FeatureValidator
32 {
33  public:
34   //! \return true if number of selected locations the same as number of selected bases, or empty.
35   //! \param theFeature the checked feature
36   //! \param theArguments arguments of the feature (not used)
37   //! \param theError error message
38   virtual bool isValid(const std::shared_ptr<ModelAPI_Feature>& theFeature,
39                        const std::list<std::string>& theArguments,
40                        std::string& theError) const;
41
42   /// Returns true if the attribute in feature is not obligatory for the feature execution
43   virtual bool isNotObligatory(std::string theFeature, std::string theAttribute);
44 };
45
46 /// \class FeaturesPlugin_ValidatorBaseForGeneration
47 /// \ingroup Validators
48 /// \brief A validator for selection base for generation. Allows to select faces on sketch,
49 /// whole sketch(if it has at least one face), and following objects: vertex, edge, wire, face.
50 class FeaturesPlugin_ValidatorBaseForGeneration: public ModelAPI_AttributeValidator
51 {
52 public:
53   //! \return true if attribute has selection type listed in the parameter arguments.
54   //! \param[in] theAttribute the checked attribute.
55   //! \param[in] theArguments arguments of the attribute.
56   //! \param[out] theError error message.
57    virtual bool isValid(const AttributePtr& theAttribute,
58                         const std::list<std::string>& theArguments,
59                         std::string& theError) const;
60
61 private:
62   bool isValidAttribute(const AttributePtr& theAttribute,
63                         const std::list<std::string>& theArguments,
64                         std::string& theError) const;
65 };
66
67 /// \class FeaturesPlugin_ValidatorCompositeLauncher
68 /// \ingroup Validators
69 /// \brief A validator for selection at composite feature start
70 class FeaturesPlugin_ValidatorCompositeLauncher: public ModelAPI_AttributeValidator
71 {
72 public:
73   //! \return true if attribute has selection type listed in the parameter arguments.
74   //! \param[in] theAttribute the checked attribute.
75   //! \param[in] theArguments arguments of the attribute.
76   //! \param[out] theError error message.
77    virtual bool isValid(const AttributePtr& theAttribute,
78                         const std::list<std::string>& theArguments,
79                         std::string& theError) const;
80 };
81
82 /// \class FeaturesPlugin_ValidatorCanBeEmpty
83 /// \ingroup Validators
84 /// \brief A validator for extrusion direction attribute. Allows it to be empty if base objects are
85 ///        planar and do not contain vertices and edges.
86 class FeaturesPlugin_ValidatorCanBeEmpty: public ModelAPI_FeatureValidator
87 {
88 public:
89   //! \return true if attribute listed in the parameter arguments are planar.
90   //! \param[in] theFeature the checked feature.
91   //! \param[in] theArguments arguments of the attribute.
92   //! \param[out] theError error message.
93   virtual bool isValid(const std::shared_ptr<ModelAPI_Feature>& theFeature,
94                        const std::list<std::string>& theArguments,
95                        std::string& theError) const;
96
97   /// \return 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 private:
101   bool isShapesCanBeEmpty(const AttributePtr& theAttribute,
102                           std::string& theError) const;
103 };
104
105 /// \class FeaturesPlugin_ValidatorBooleanSelection
106 /// \ingroup Validators
107 /// \brief Validates selection for boolean operation.
108 class FeaturesPlugin_ValidatorBooleanSelection: public ModelAPI_AttributeValidator
109 {
110 public:
111   /// \return True if the attribute is valid. It checks whether the selection
112   /// is acceptable for boolean operation.
113   /// \param[in] theAttribute an attribute to check.
114   /// \param[in] theArguments a filter parameters.
115   /// \param[out] theError error message.
116   virtual bool isValid(const AttributePtr& theAttribute,
117                        const std::list<std::string>& theArguments,
118                        std::string& theError) const;
119 };
120
121 /// \class FeaturesPlugin_ValidatorPartitionSelection
122 /// \ingroup Validators
123 /// \brief Validates selection for partition.
124 class FeaturesPlugin_ValidatorPartitionSelection: public ModelAPI_AttributeValidator
125 {
126 public:
127   /// \return True if the attribute is valid. It checks whether the selection
128   /// is acceptable for operation.
129   /// \param[in] theAttribute an attribute to check.
130   /// \param[in] theArguments a filter parameters.
131   /// \param[out] theError error message.
132   virtual bool isValid(const AttributePtr& theAttribute,
133                        const std::list<std::string>& theArguments,
134                        std::string& theError) const;
135 };
136
137 /// \class FeaturesPlugin_ValidatorRemoveSubShapesSelection
138 /// \ingroup Validators
139 /// \brief Validates selection for "Remove Sub-Shapes" feature.
140 class FeaturesPlugin_ValidatorRemoveSubShapesSelection: public ModelAPI_AttributeValidator
141 {
142 public:
143   /// \return True if the attribute is valid. It checks whether the selection
144   /// is acceptable for operation.
145   /// \param[in] theAttribute an attribute to check.
146   /// \param[in] theArguments a filter parameters.
147   /// \param[out] theError error message.
148   virtual bool isValid(const AttributePtr& theAttribute,
149                        const std::list<std::string>& theArguments,
150                        std::string& theError) const;
151 };
152
153 /// \class FeaturesPlugin_ValidatorRemoveSubShapesResult
154 /// \ingroup Validators
155 /// \brief Validator for the Remove Sub-Shapes feature.
156 class FeaturesPlugin_ValidatorRemoveSubShapesResult: public ModelAPI_FeatureValidator
157 {
158  public:
159   //! \return true if result is valid shape.
160   //! \param theFeature the checked feature
161   //! \param theArguments arguments of the feature (not used)
162   //! \param theError error message
163   virtual bool isValid(const std::shared_ptr<ModelAPI_Feature>& theFeature,
164                        const std::list<std::string>& theArguments,
165                        std::string& theError) const;
166
167   /// \return true if the attribute in feature is not obligatory for the feature execution
168   virtual bool isNotObligatory(std::string theFeature, std::string theAttribute);
169 };
170
171 #endif