X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FFeaturesPlugin%2FFeaturesPlugin_Validators.h;h=7b81dfb4708a34159a0f8ddc3a2b8c49d36e412b;hb=a55586483e5dccc5466d6ec241e2147e210d839f;hp=1ca14c03aa80458932779d84232c90550377e33c;hpb=a1047513fdbe3d6d6681e132047cbd4fb565ac33;p=modules%2Fshaper.git diff --git a/src/FeaturesPlugin/FeaturesPlugin_Validators.h b/src/FeaturesPlugin/FeaturesPlugin_Validators.h index 1ca14c03a..7b81dfb47 100644 --- a/src/FeaturesPlugin/FeaturesPlugin_Validators.h +++ b/src/FeaturesPlugin/FeaturesPlugin_Validators.h @@ -1,8 +1,22 @@ -// Copyright (C) 2014-20xx CEA/DEN, EDF R&D --> - -// File: FeaturesPlugin_Validators.h -// Created: 22 March 2016 -// Author: Dmitry Bobylev +// Copyright (C) 2014-2017 CEA/DEN, EDF R&D +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or +// email : webmaster.salome@opencascade.com +// #ifndef FeaturesPlugin_Validators_H_ #define FeaturesPlugin_Validators_H_ @@ -22,13 +36,28 @@ public: //! \param[out] theError error message. virtual bool isValid(const AttributePtr& theAttribute, const std::list& theArguments, - std::string& theError) const; + Events_InfoMessage& theError) const; }; /// \class FeaturesPlugin_ValidatorPipeLocations /// \ingroup Validators +/// \brief A validator for selection pipe locations. +class FeaturesPlugin_ValidatorPipeLocations: public ModelAPI_AttributeValidator +{ +public: + //! \return True if the attribute is valid. + //! \param[in] theAttribute the checked attribute. + //! \param[in] theArguments arguments of the attribute. + //! \param[out] theError error message. + virtual bool isValid(const AttributePtr& theAttribute, + const std::list& theArguments, + Events_InfoMessage& theError) const; +}; + +/// \class FeaturesPlugin_ValidatorPipeLocationsNumber +/// \ingroup Validators /// \brief Validator for the pipe locations. -class FeaturesPlugin_ValidatorPipeLocations: public ModelAPI_FeatureValidator +class FeaturesPlugin_ValidatorPipeLocationsNumber: public ModelAPI_FeatureValidator { public: //! \return true if number of selected locations the same as number of selected bases, or empty. @@ -37,10 +66,7 @@ class FeaturesPlugin_ValidatorPipeLocations: public ModelAPI_FeatureValidator //! \param theError error message virtual bool isValid(const std::shared_ptr& theFeature, const std::list& theArguments, - std::string& theError) const; - - /// Returns true if the attribute in feature is not obligatory for the feature execution - virtual bool isNotObligatory(std::string theFeature, std::string theAttribute); + Events_InfoMessage& theError) const; }; /// \class FeaturesPlugin_ValidatorBaseForGeneration @@ -56,12 +82,29 @@ public: //! \param[out] theError error message. virtual bool isValid(const AttributePtr& theAttribute, const std::list& theArguments, - std::string& theError) const; + Events_InfoMessage& theError) const; private: bool isValidAttribute(const AttributePtr& theAttribute, const std::list& theArguments, - std::string& theError) const; + Events_InfoMessage& theError) const; +}; + +/// \class FeaturesPlugin_ValidatorBaseForGenerationSketchOrSketchObjects +/// \ingroup Validators +/// \brief Validator for the base objects for generation. Checks that sketch and it objects +/// are not selected at the same time. +class FeaturesPlugin_ValidatorBaseForGenerationSketchOrSketchObjects: + public ModelAPI_FeatureValidator +{ + public: + //! \return true if sketch and it objects not selected at the same time. + //! \param theFeature the checked feature + //! \param theArguments arguments of the feature (not used) + //! \param theError error message + virtual bool isValid(const std::shared_ptr& theFeature, + const std::list& theArguments, + Events_InfoMessage& theError) const; }; /// \class FeaturesPlugin_ValidatorCompositeLauncher @@ -76,14 +119,14 @@ public: //! \param[out] theError error message. virtual bool isValid(const AttributePtr& theAttribute, const std::list& theArguments, - std::string& theError) const; + Events_InfoMessage& theError) const; }; -/// \class FeaturesPlugin_ValidatorCanBeEmpty +/// \class FeaturesPlugin_ValidatorExtrusionDir /// \ingroup Validators /// \brief A validator for extrusion direction attribute. Allows it to be empty if base objects are /// planar and do not contain vertices and edges. -class FeaturesPlugin_ValidatorCanBeEmpty: public ModelAPI_FeatureValidator +class FeaturesPlugin_ValidatorExtrusionDir: public ModelAPI_FeatureValidator { public: //! \return true if attribute listed in the parameter arguments are planar. @@ -92,14 +135,11 @@ public: //! \param[out] theError error message. virtual bool isValid(const std::shared_ptr& theFeature, const std::list& theArguments, - std::string& theError) const; - - /// \return true if the attribute in feature is not obligatory for the feature execution - virtual bool isNotObligatory(std::string theFeature, std::string theAttribute); + Events_InfoMessage& theError) const; private: bool isShapesCanBeEmpty(const AttributePtr& theAttribute, - std::string& theError) const; + Events_InfoMessage& theError) const; }; /// \class FeaturesPlugin_ValidatorBooleanSelection @@ -115,7 +155,23 @@ public: /// \param[out] theError error message. virtual bool isValid(const AttributePtr& theAttribute, const std::list& theArguments, - std::string& theError) const; + Events_InfoMessage& theError) const; +}; + +/// \class FeaturesPlugin_ValidatorFilletSelection +/// \ingroup Validators +/// \brief Validates selection for fillet operation. +class FeaturesPlugin_ValidatorFilletSelection: public ModelAPI_AttributeValidator +{ +public: + /// \return True if the attribute is valid. It checks whether the selection + /// is acceptable for boolean operation. + /// \param[in] theAttribute an attribute to check. + /// \param[in] theArguments a filter parameters. + /// \param[out] theError error message. + virtual bool isValid(const AttributePtr& theAttribute, + const std::list& theArguments, + Events_InfoMessage& theError) const; }; /// \class FeaturesPlugin_ValidatorPartitionSelection @@ -131,7 +187,7 @@ public: /// \param[out] theError error message. virtual bool isValid(const AttributePtr& theAttribute, const std::list& theArguments, - std::string& theError) const; + Events_InfoMessage& theError) const; }; /// \class FeaturesPlugin_ValidatorRemoveSubShapesSelection @@ -147,7 +203,7 @@ public: /// \param[out] theError error message. virtual bool isValid(const AttributePtr& theAttribute, const std::list& theArguments, - std::string& theError) const; + Events_InfoMessage& theError) const; }; /// \class FeaturesPlugin_ValidatorRemoveSubShapesResult @@ -162,10 +218,7 @@ class FeaturesPlugin_ValidatorRemoveSubShapesResult: public ModelAPI_FeatureVali //! \param theError error message virtual bool isValid(const std::shared_ptr& theFeature, const std::list& theArguments, - std::string& theError) const; - - /// \return true if the attribute in feature is not obligatory for the feature execution - virtual bool isNotObligatory(std::string theFeature, std::string theAttribute); + Events_InfoMessage& theError) const; }; /// \class FeaturesPlugin_ValidatorUnionSelection @@ -181,7 +234,7 @@ public: /// \param[out] theError error message. virtual bool isValid(const AttributePtr& theAttribute, const std::list& theArguments, - std::string& theError) const; + Events_InfoMessage& theError) const; }; /// \class FeaturesPlugin_ValidatorUnionArguments @@ -196,9 +249,159 @@ class FeaturesPlugin_ValidatorUnionArguments: public ModelAPI_FeatureValidator //! \param theError error message virtual bool isValid(const std::shared_ptr& theFeature, const std::list& theArguments, - std::string& theError) const; + Events_InfoMessage& theError) const; +}; + +/// \class FeaturesPlugin_ValidatorConcealedResult +/// \ingroup Validators +/// \brief Validator for the "Recover" feature. +class FeaturesPlugin_ValidatorConcealedResult: public ModelAPI_AttributeValidator +{ + public: + //! \return True if the attribute is valid. + //! \param[in] theAttribute the checked attribute. + //! \param[in] theArguments arguments of the attribute. + //! \param[out] theError error message. + virtual bool isValid(const AttributePtr& theAttribute, + const std::list& theArguments, + Events_InfoMessage& theError) const; +}; + +/// \class FeaturesPlugin_ValidatorCircular +/// \ingroup Validators +/// \brief Verifies the selected object is circular edge or cylindrical face +class FeaturesPlugin_ValidatorCircular : public ModelAPI_AttributeValidator +{ +public: + //! \return True if the attribute is valid. + //! \param[in] theAttribute the checked attribute. + //! \param[in] theArguments arguments of the attribute. + //! \param[out] theError error message. + virtual bool isValid(const AttributePtr& theAttribute, + const std::list& theArguments, + Events_InfoMessage& theError) const; +}; + +/** \class FeaturesPlugin_ValidatorBooleanArguments +* \ingroup Validators +* \brief Validates that boolean operation have enough arguments. +*/ +class FeaturesPlugin_ValidatorBooleanArguments: public ModelAPI_FeatureValidator +{ +public: + /** \brief Returns true if feature and/or attributes are valid. + * \param[in] theFeature the validated feature. + * \param[in] theArguments the arguments in the configuration file for this validator. + * \param[out] theError error message. + * \returns true if feature is valid. + */ + virtual bool isValid(const std::shared_ptr& theFeature, + const std::list& theArguments, + Events_InfoMessage& theError) const; + + /// \return true if the attribute in feature is not obligatory for the feature execution. + virtual bool isNotObligatory(std::string theFeature, std::string theAttribute); +}; + +/// \class FeaturesPlugin_ValidatorBooleanSmashSelection +/// \ingroup Validators +/// \brief Verifies the selected object for boolean smash feature +class FeaturesPlugin_ValidatorBooleanSmashSelection: public ModelAPI_AttributeValidator +{ +public: + //! \return True if the attribute is valid. + //! \param[in] theAttribute the checked attribute. + //! \param[in] theArguments arguments of the attribute. + //! \param[out] theError error message. + virtual bool isValid(const AttributePtr& theAttribute, + const std::list& theArguments, + Events_InfoMessage& theError) const; +}; + +/// \class FeaturesPlugin_IntersectionSelection +/// \ingroup Validators +/// \brief Verifies the selected object for intersection feature +class FeaturesPlugin_IntersectionSelection: public ModelAPI_AttributeValidator +{ +public: + //! \return True if the attribute is valid. + //! \param[in] theAttribute the checked attribute. + //! \param[in] theArguments arguments of the attribute. + //! \param[out] theError error message. + virtual bool isValid(const AttributePtr& theAttribute, + const std::list& theArguments, + Events_InfoMessage& theError) const; +}; + +/// \class FeaturesPlugin_ValidatorBooleanFuseSelection +/// \ingroup Validators +/// \brief Verifies the selected object for boolean fuse feature +class FeaturesPlugin_ValidatorBooleanFuseSelection: public ModelAPI_AttributeValidator +{ +public: + //! \return True if the attribute is valid. + //! \param[in] theAttribute the checked attribute. + //! \param[in] theArguments arguments of the attribute. + //! \param[out] theError error message. + virtual bool isValid(const AttributePtr& theAttribute, + const std::list& theArguments, + Events_InfoMessage& theError) const; +}; + +/** \class FeaturesPlugin_ValidatorBooleanFuseArguments +* \ingroup Validators +* \brief Validates that boolean operation have enough arguments. +*/ +class FeaturesPlugin_ValidatorBooleanFuseArguments: public ModelAPI_FeatureValidator +{ +public: + /** \brief Returns true if feature and/or attributes are valid. + * \param[in] theFeature the validated feature. + * \param[in] theArguments the arguments in the configuration file for this validator. + * \param[out] theError error message. + * \returns true if feature is valid. + */ + virtual bool isValid(const std::shared_ptr& theFeature, + const std::list& theArguments, + Events_InfoMessage& theError) const; + + /// \return true if the attribute in feature is not obligatory for the feature execution. + virtual bool isNotObligatory(std::string theFeature, std::string theAttribute); +}; + +/// \class FeaturesPlugin_ValidatorBooleanCommonSelection +/// \ingroup Validators +/// \brief Verifies the selected object for boolean common feature +class FeaturesPlugin_ValidatorBooleanCommonSelection: public ModelAPI_AttributeValidator +{ +public: + //! \return True if the attribute is valid. + //! \param[in] theAttribute the checked attribute. + //! \param[in] theArguments arguments of the attribute. + //! \param[out] theError error message. + virtual bool isValid(const AttributePtr& theAttribute, + const std::list& theArguments, + Events_InfoMessage& theError) const; +}; + +/** \class FeaturesPlugin_ValidatorBooleanCommonArguments +* \ingroup Validators +* \brief Validates that boolean operation have enough arguments. +*/ +class FeaturesPlugin_ValidatorBooleanCommonArguments: public ModelAPI_FeatureValidator +{ +public: + /** \brief Returns true if feature and/or attributes are valid. + * \param[in] theFeature the validated feature. + * \param[in] theArguments the arguments in the configuration file for this validator. + * \param[out] theError error message. + * \returns true if feature is valid. + */ + virtual bool isValid(const std::shared_ptr& theFeature, + const std::list& theArguments, + Events_InfoMessage& theError) const; - /// \return true if the attribute in feature is not obligatory for the feature execution + /// \return true if the attribute in feature is not obligatory for the feature execution. virtual bool isNotObligatory(std::string theFeature, std::string theAttribute); };