Salome HOME
Issue #1343. Improvement of Extrusion and Revolution operations: sketch creator setSe...
[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_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   //! Returns 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 and bounding planes for extrusion and
85 ///        revolution. Allows them to be empty if base objects are planar and do not contain
86 ///        vertices and edges.
87 class FeaturesPlugin_ValidatorCanBeEmpty: public ModelAPI_FeatureValidator
88 {
89 public:
90   //! Returns true if attribute listed in the parameter arguments are planar.
91   //! \param[in] theFeature the checked feature.
92   //! \param[in] theArguments arguments of the attribute.
93   //! \param[out] theError error message.
94   virtual bool isValid(const std::shared_ptr<ModelAPI_Feature>& theFeature,
95                        const std::list<std::string>& theArguments,
96                        std::string& theError) const;
97
98   /// Returns true if the attribute in feature is not obligatory for the feature execution
99   virtual bool isNotObligatory(std::string theFeature, std::string theAttribute);
100
101 private:
102   bool isShapesCanBeEmpty(const AttributePtr& theAttribute,
103                           std::string& theError) const;
104 };
105
106 #endif