]> SALOME platform Git repositories - modules/shaper.git/blob - src/FeaturesPlugin/FeaturesPlugin_Validators.h
Salome HOME
Issue #1366: "Partition" feature now modified to "Generalized Partition"
[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_ValidatorPipeLocations
14 /// \ingroup Validators
15 /// \brief Validator for the pipe locations.
16 class FeaturesPlugin_ValidatorPipeLocations: public ModelAPI_FeatureValidator
17 {
18  public:
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;
26
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);
29 };
30
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
36 {
37 public:
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;
45
46 private:
47   bool isValidAttribute(const AttributePtr& theAttribute,
48                         const std::list<std::string>& theArguments,
49                         std::string& theError) const;
50 };
51
52 /// \class FeaturesPlugin_ValidatorCompositeLauncher
53 /// \ingroup Validators
54 /// \brief A validator for selection at composite feature start
55 class FeaturesPlugin_ValidatorCompositeLauncher: public ModelAPI_AttributeValidator
56 {
57 public:
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;
65 };
66
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
72 {
73 public:
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;
81
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);
84
85 private:
86   bool isShapesCanBeEmpty(const AttributePtr& theAttribute,
87                           std::string& theError) const;
88 };
89
90 /// \class FeaturesPlugin_ValidatorBooleanSelection
91 /// \ingroup Validators
92 /// \brief Validates selection for boolean operation.
93 class FeaturesPlugin_ValidatorBooleanSelection: public ModelAPI_AttributeValidator
94 {
95 public:
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;
104 };
105
106 /// \class FeaturesPlugin_ValidatorPartitionSelection
107 /// \ingroup Validators
108 /// \brief Validates selection for partition.
109 class FeaturesPlugin_ValidatorPartitionSelection: public ModelAPI_AttributeValidator
110 {
111 public:
112   /// \return True if the attribute is valid. It checks whether the selection
113   /// is acceptable for boolean 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;
120 };
121
122 #endif