X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FPartSet%2FPartSet_Validators.h;h=e4b083bc0388eb9e465a0607dc2d8f8aaa85e13b;hb=b240d1def415f30a9569bd71f6715c72c0a92291;hp=02f7d21e6c53b1f8c7e8cd88385dc044a62c63dd;hpb=8dc74f82810d5f597b78633b457efb0ef4f89f9f;p=modules%2Fshaper.git diff --git a/src/PartSet/PartSet_Validators.h b/src/PartSet/PartSet_Validators.h index 02f7d21e6..e4b083bc0 100644 --- a/src/PartSet/PartSet_Validators.h +++ b/src/PartSet/PartSet_Validators.h @@ -1,6 +1,21 @@ -// File: PartSet_Validators.h -// Created: 09 July 2014 -// Author: Vitaly SMETANNIKOV +// Copyright (C) 2014-2019 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 PartSet_Validators_H #define PartSet_Validators_H @@ -9,44 +24,256 @@ #include #include +#include + +class GeomDataAPI_Point2D; /* * Selector validators */ + +//! \ingroup Validators //! A class to validate a selection for Distance constraint operation -class PartSet_DistanceValidator : public ModuleBase_SelectionValidator +class PartSet_DistanceSelection : public ModuleBase_SelectionValidator { - public: - PARTSET_EXPORT virtual bool isValid(const ModuleBase_ISelection* theSelection) const; +public: + PARTSET_EXPORT virtual bool isValid(const ModuleBase_ISelection* theSelection, + ModuleBase_Operation* theOperation) const; }; +//! \ingroup Validators //! A class to validate a selection for Length constraint operation -class PartSet_LengthValidator : public ModuleBase_SelectionValidator +class PartSet_LengthSelection : public ModuleBase_SelectionValidator { - public: - PARTSET_EXPORT virtual bool isValid(const ModuleBase_ISelection* theSelection) const; +public: + PARTSET_EXPORT virtual bool isValid(const ModuleBase_ISelection* theSelection, + ModuleBase_Operation* theOperation) const; }; +//! \ingroup Validators //! A class to validate a selection for Perpendicular constraint operation -class PartSet_PerpendicularValidator : public ModuleBase_SelectionValidator +class PartSet_PerpendicularSelection : public ModuleBase_SelectionValidator +{ +public: + PARTSET_EXPORT virtual bool isValid(const ModuleBase_ISelection* theSelection, + ModuleBase_Operation* theOperation) const; +}; + +//! \ingroup Validators +//! A class to validate a selection for Parallel constraint operation +class PartSet_ParallelSelection : public ModuleBase_SelectionValidator +{ +public: + PARTSET_EXPORT virtual bool isValid(const ModuleBase_ISelection* theSelection, + ModuleBase_Operation* theOperation) const; +}; + +//! \ingroup Validators +//! A class to validate a selection for Radius constraint operation +class PartSet_RadiusSelection : public ModuleBase_SelectionValidator +{ +public: + PARTSET_EXPORT virtual bool isValid(const ModuleBase_ISelection* theSelection, + ModuleBase_Operation* theOperation) const; +}; + +//! \ingroup Validators +//! A class to validate a selection for Rigid constraint operation +class PartSet_RigidSelection : public ModuleBase_SelectionValidator { +public: + PARTSET_EXPORT virtual bool isValid(const ModuleBase_ISelection* theSelection, + ModuleBase_Operation* theOperation) const; +}; + + +//! \ingroup Validators +//! A class to validate a selection for coincedence constraint operation +class PartSet_CoincidentSelection : public ModuleBase_SelectionValidator +{ +public: + PARTSET_EXPORT virtual bool isValid(const ModuleBase_ISelection* theSelection, + ModuleBase_Operation* theOperation) const; +}; + +//! \ingroup Validators +//! A class to validate a selection for Horizontal and Vertical constraints operation +class PartSet_HVDirSelection : public ModuleBase_SelectionValidator +{ +public: + PARTSET_EXPORT virtual bool isValid(const ModuleBase_ISelection* theSelection, + ModuleBase_Operation* theOperation) const; +}; + +//! \ingroup Validators +//! A class to validate a selection for Tangential constraints operation +class PartSet_TangentSelection : public ModuleBase_SelectionValidator +{ +public: + PARTSET_EXPORT virtual bool isValid(const ModuleBase_ISelection* theSelection, + ModuleBase_Operation* theOperation) const; +}; + +//! \ingroup Validators +//! A class to validate a selection for Fillet constraints operation +class PartSet_FilletSelection : public ModuleBase_SelectionValidator +{ +public: + PARTSET_EXPORT virtual bool isValid(const ModuleBase_ISelection* theSelection, + ModuleBase_Operation* theOperation) const; +}; + +//! \ingroup Validators +//! A class to validate a selection for Angle constraints operation +class PartSet_AngleSelection : public ModuleBase_SelectionValidator +{ +public: + PARTSET_EXPORT virtual bool isValid(const ModuleBase_ISelection* theSelection, + ModuleBase_Operation* theOperation) const; +}; + +//! \ingroup Validators +//! A class to validate a selection for Equal constraints operation +class PartSet_EqualSelection : public ModuleBase_SelectionValidator +{ +public: + PARTSET_EXPORT virtual bool isValid(const ModuleBase_ISelection* theSelection, + ModuleBase_Operation* theOperation) const; +}; + +//! \ingroup Validators +//! A class to validate a selection for Collinear constraints operation +class PartSet_CollinearSelection : public ModuleBase_SelectionValidator +{ +public: + PARTSET_EXPORT virtual bool isValid(const ModuleBase_ISelection* theSelection, + ModuleBase_Operation* theOperation) const; +}; + +//! \ingroup Validators +//! A class to validate a selection for Middle point constraints operation +class PartSet_MiddlePointSelection : public ModuleBase_SelectionValidator +{ +public: + PARTSET_EXPORT virtual bool isValid(const ModuleBase_ISelection* theSelection, + ModuleBase_Operation* theOperation) const; +}; + +//! \ingroup Validators +//! A class to validate a selection for Middle point constraints operation +class PartSet_MultyTranslationSelection : public ModuleBase_SelectionValidator +{ +public: + PARTSET_EXPORT virtual bool isValid(const ModuleBase_ISelection* theSelection, + ModuleBase_Operation* theOperation) const; +}; + +//! \ingroup Validators +//! A class to validate a selection for Middle point constraints operation +class PartSet_SplitSelection : public ModuleBase_SelectionValidator +{ +public: + PARTSET_EXPORT virtual bool isValid(const ModuleBase_ISelection* theSelection, + ModuleBase_Operation* theOperation) const; +}; + +//! \ingroup Validators +//! A class to validate a selection for Middle point constraints operation +class PartSet_ProjectionSelection : public ModuleBase_SelectionValidator +{ +public: + PARTSET_EXPORT virtual bool isValid(const ModuleBase_ISelection* theSelection, + ModuleBase_Operation* theOperation) const; +}; + +//! \ingroup Validators +//! A class to validate a selection for intersection operation +class PartSet_IntersectionSelection : public ModuleBase_SelectionValidator +{ +public: + PARTSET_EXPORT virtual bool isValid(const ModuleBase_ISelection* theSelection, + ModuleBase_Operation* theOperation) const; +}; + +////////////// Attribute validators //////////////// + + +/** +* \ingroup Validators +* A validator which checks that objects selected for feature attributes are different (not the same) +*/ +class PartSet_DifferentObjectsValidator : public ModelAPI_AttributeValidator +{ + //! Validator possible error types + enum ErrorType { + EqualObjects, + EqualAttributes, + EqualShapes, + EmptyShapes + }; public: - PARTSET_EXPORT virtual bool isValid(const ModuleBase_ISelection* theSelection) const; + //! Returns true if the attribute is good for the feature attribute + //! \param theAttribute an attribute + //! \param theArguments a list of arguments (names of attributes to check) + //! \param theError an output error string + virtual bool isValid(const AttributePtr& theAttribute, + const std::list& theArguments, + Events_InfoMessage& theError) const; +private: + //! Returns error message for the error type + //! \param theType a type of error + //! \param thEqualObjectInfo an + std::string errorMessage(const PartSet_DifferentObjectsValidator::ErrorType& theType, + const std::string& thEqualObject, const std::string& theFirstAttribute, + const std::string& theSecondAttribute) const; + }; -//! A class to validate a selection for Perpendicular constraint operation -class PartSet_ParallelValidator : public ModuleBase_SelectionValidator +/** +* \ingroup Validators +* A validator which checks that Point2D selected for feature attributes are different (not the same) +* It iterates by the feature ModelAPI_AttributeRefAttr attributes, finds GeomDataAPI_Point2D attribute in +* value or attribute of the attributes and if the point of the given attribute is geometrical equal to +* a point of another attribute, returns false +*/ +class PartSet_DifferentPointsValidator : public ModelAPI_AttributeValidator { public: - PARTSET_EXPORT virtual bool isValid(const ModuleBase_ISelection* theSelection) const; + //! Returns true if the attribute is good for the feature attribute + //! \param theAttribute an attribute + //! \param theArguments a list of arguments (names of attributes to check) + //! \param theError an output error string + virtual bool isValid(const AttributePtr& theAttribute, + const std::list& theArguments, + Events_InfoMessage& theError) const; +private: + //! Finds Point2D attribute by reference attribute. It might be: + //! - COORD_ID attribute of SketchPlugin_Point if object + //! - Attribute casted to point if attribute + //! \param theAttribute an attribute + //! \return point 2d attribute or NULL + std::shared_ptr getRefPointAttribute + (const AttributePtr& theAttribute) const; }; -//! A class to validate a selection for Perpendicular constraint operation -class PartSet_RadiusValidator : public ModuleBase_SelectionValidator + +/**\class PartSet_CoincidentAttr + * \ingroup Validators + * \brief Validator to check whether there is a coincident constraint between + * the attribute and attribute of argument. + */ +class PartSet_CoincidentAttr : public ModelAPI_AttributeValidator { public: - PARTSET_EXPORT virtual bool isValid(const ModuleBase_ISelection* theSelection) const; + //! returns true if attribute is valid + //! \param theAttribute the checked attribute + //! \param theArguments arguments of the attribute + //! \param theError an output error string + virtual bool isValid(const AttributePtr& theAttribute, + const std::list& theArguments, + Events_InfoMessage& theError) const; }; + #endif