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_ValidatorCanBeEmpty
68 /// \ingroup Validators
69 /// \brief A validator for extrusion direction attribute and bounding planes for extrusion and
70 ///        revolution. Allows them to be empty if base objects are planar and do not contain
71 ///        vertices and edges.
72 class FeaturesPlugin_ValidatorCanBeEmpty: public ModelAPI_FeatureValidator
73 {
74 public:
75   //! Returns true if attribute listed in the parameter arguments are planar.
76   //! \param[in] theFeature the checked feature.
77   //! \param[in] theArguments arguments of the attribute.
78   //! \param[out] theError error message.
79   virtual bool isValid(const std::shared_ptr<ModelAPI_Feature>& theFeature,
80                        const std::list<std::string>& theArguments,
81                        std::string& theError) const;
82
83   /// Returns true if the attribute in feature is not obligatory for the feature execution
84   virtual bool isNotObligatory(std::string theFeature, std::string theAttribute);
85
86 private:
87   bool isShapesCanBeEmpty(const AttributePtr& theAttribute,
88                           std::string& theError) const;
89 };
90
91 #endif