From: spo Date: Wed, 29 Jul 2015 10:54:09 +0000 (+0300) Subject: Error management -- Attribute validator returns an error. X-Git-Tag: V_1.4.0_beta4~434 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=4ca3fd41634c37f840d0cbb3f896fa97c2d3c457;p=modules%2Fshaper.git Error management -- Attribute validator returns an error. --- diff --git a/src/ExchangePlugin/ExchangePlugin_Validators.cpp b/src/ExchangePlugin/ExchangePlugin_Validators.cpp index 052140b81..d13b2c478 100644 --- a/src/ExchangePlugin/ExchangePlugin_Validators.cpp +++ b/src/ExchangePlugin/ExchangePlugin_Validators.cpp @@ -38,7 +38,8 @@ bool ExchangePlugin_FormatValidator::parseFormats(const std::list& } bool ExchangePlugin_FormatValidator::isValid(const AttributePtr& theAttribute, - const std::list& theArguments) const + const std::list& theArguments, + std::string& theError) const { if (!theAttribute->isInitialized()) return false; diff --git a/src/ExchangePlugin/ExchangePlugin_Validators.h b/src/ExchangePlugin/ExchangePlugin_Validators.h index 36fa3ea2f..cf7851e7a 100644 --- a/src/ExchangePlugin/ExchangePlugin_Validators.h +++ b/src/ExchangePlugin/ExchangePlugin_Validators.h @@ -33,7 +33,8 @@ public: * allowed formats. */ virtual bool isValid(const AttributePtr& theAttribute, - const std::list& theArguments) const; + const std::list& theArguments, + std::string& theError) const; }; class ExchangePlugin_ImportFormatValidator : public ExchangePlugin_FormatValidator diff --git a/src/GeomValidators/GeomValidators_ConstructionComposite.cpp b/src/GeomValidators/GeomValidators_ConstructionComposite.cpp index 16fd4a2e9..afd84190e 100644 --- a/src/GeomValidators/GeomValidators_ConstructionComposite.cpp +++ b/src/GeomValidators/GeomValidators_ConstructionComposite.cpp @@ -7,7 +7,8 @@ #include "ModelAPI_CompositeFeature.h" bool GeomValidators_ConstructionComposite::isValid(const AttributePtr& theAttribute, - const std::list& theArguments) const + const std::list& theArguments, + std::string& theError) const { bool aValid = false; AttributeSelectionPtr aSelectionAttr = std::dynamic_pointer_cast diff --git a/src/GeomValidators/GeomValidators_ConstructionComposite.h b/src/GeomValidators/GeomValidators_ConstructionComposite.h index abe123fe5..c9f316321 100644 --- a/src/GeomValidators/GeomValidators_ConstructionComposite.h +++ b/src/GeomValidators/GeomValidators_ConstructionComposite.h @@ -22,7 +22,8 @@ class GeomValidators_ConstructionComposite : public ModelAPI_AttributeValidator //! \param theAttribute the checked attribute //! \param theArguments arguments of the attribute GEOMVALIDATORS_EXPORT virtual bool isValid(const AttributePtr& theAttribute, - const std::list& theArguments) const; + const std::list& theArguments, + std::string& theError) const; }; #endif diff --git a/src/GeomValidators/GeomValidators_Face.cpp b/src/GeomValidators/GeomValidators_Face.cpp index c8797278b..90eb2aac3 100644 --- a/src/GeomValidators/GeomValidators_Face.cpp +++ b/src/GeomValidators/GeomValidators_Face.cpp @@ -31,7 +31,8 @@ GeomAbs_SurfaceType GeomValidators_Face::faceType(const std::string& theType) } bool GeomValidators_Face::isValid(const AttributePtr& theAttribute, - const std::list& theArguments) const + const std::list& theArguments, + std::string& theError) const { bool aValid = false; diff --git a/src/GeomValidators/GeomValidators_Face.h b/src/GeomValidators/GeomValidators_Face.h index 2ff49551c..c66d4b315 100644 --- a/src/GeomValidators/GeomValidators_Face.h +++ b/src/GeomValidators/GeomValidators_Face.h @@ -24,7 +24,8 @@ class GeomValidators_Face : public ModelAPI_AttributeValidator //! \param theAttribute the checked attribute //! \param theArguments arguments of the attribute GEOMVALIDATORS_EXPORT virtual bool isValid(const AttributePtr& theAttribute, - const std::list& theArguments) const; + const std::list& theArguments, + std::string& theError) const; protected: /// Convert string to TypeOfFace value /// \param theType a string value diff --git a/src/GeomValidators/GeomValidators_Positive.cpp b/src/GeomValidators/GeomValidators_Positive.cpp index 9d3fbf983..cd7dcc68c 100644 --- a/src/GeomValidators/GeomValidators_Positive.cpp +++ b/src/GeomValidators/GeomValidators_Positive.cpp @@ -21,8 +21,9 @@ GeomValidators_Positive::GeomValidators_Positive() aFactory->registerValidator("GeomValidators_Positive", this); } -bool GeomValidators_Positive::isValid( - const AttributePtr& theAttribute, const std::list& theArguments) const +bool GeomValidators_Positive::isValid(const AttributePtr& theAttribute, + const std::list& theArguments, + std::string& theError) const { AttributeDoublePtr aDouble = std::dynamic_pointer_cast(theAttribute); diff --git a/src/GeomValidators/GeomValidators_Positive.h b/src/GeomValidators/GeomValidators_Positive.h index abfbe948b..8c88ab08d 100644 --- a/src/GeomValidators/GeomValidators_Positive.h +++ b/src/GeomValidators/GeomValidators_Positive.h @@ -22,7 +22,8 @@ public: //! \param theAttribute the checked attribute //! \param theArguments arguments of the attribute GEOMVALIDATORS_EXPORT virtual bool isValid(const AttributePtr& theAttribute, - const std::list& theArguments) const; + const std::list& theArguments, + std::string& theError) const; }; diff --git a/src/GeomValidators/GeomValidators_ShapeType.cpp b/src/GeomValidators/GeomValidators_ShapeType.cpp index 85d21a0ad..cefd7a592 100644 --- a/src/GeomValidators/GeomValidators_ShapeType.cpp +++ b/src/GeomValidators/GeomValidators_ShapeType.cpp @@ -42,7 +42,8 @@ GeomValidators_ShapeType::TypeOfShape GeomValidators_ShapeType::shapeType(const } bool GeomValidators_ShapeType::isValid(const AttributePtr& theAttribute, - const std::list& theArguments) const + const std::list& theArguments, + std::string& theError) const { bool aValid = false; diff --git a/src/GeomValidators/GeomValidators_ShapeType.h b/src/GeomValidators/GeomValidators_ShapeType.h index 782d9eaeb..daefb1e22 100644 --- a/src/GeomValidators/GeomValidators_ShapeType.h +++ b/src/GeomValidators/GeomValidators_ShapeType.h @@ -43,7 +43,8 @@ class GeomValidators_ShapeType : public ModelAPI_AttributeValidator //! \param theAttribute the checked attribute //! \param theArguments arguments of the attribute GEOMVALIDATORS_EXPORT virtual bool isValid(const AttributePtr& theAttribute, - const std::list& theArguments) const; + const std::list& theArguments, + std::string& theError) const; protected: /// Convert string to TypeOfShape value /// \param theType a string value diff --git a/src/ModelAPI/ModelAPI_AttributeValidator.h b/src/ModelAPI/ModelAPI_AttributeValidator.h index 151c793c2..9ec8cb934 100644 --- a/src/ModelAPI/ModelAPI_AttributeValidator.h +++ b/src/ModelAPI/ModelAPI_AttributeValidator.h @@ -21,7 +21,8 @@ public: //! \param theAttribute the checked attribute //! \param theArguments arguments of the attribute virtual bool isValid(const AttributePtr& theAttribute, - const std::list& theArguments) const = 0; + const std::list& theArguments, + std::string& theError = std::string()) const = 0; MODELAPI_EXPORT ~ModelAPI_AttributeValidator(); }; diff --git a/src/ModelAPI/ModelAPI_ShapeValidator.cpp b/src/ModelAPI/ModelAPI_ShapeValidator.cpp index fb03f459f..1bd2e50c5 100644 --- a/src/ModelAPI/ModelAPI_ShapeValidator.cpp +++ b/src/ModelAPI/ModelAPI_ShapeValidator.cpp @@ -10,7 +10,8 @@ #include "ModelAPI_Object.h" bool ModelAPI_ShapeValidator::isValid(const AttributePtr& theAttribute, - const std::list& theArguments) const + const std::list& theArguments, + std::string& theError) const { FeaturePtr aFeature = std::dynamic_pointer_cast(theAttribute->owner()); AttributeSelectionPtr aSelectionAttribute = diff --git a/src/ModelAPI/ModelAPI_ShapeValidator.h b/src/ModelAPI/ModelAPI_ShapeValidator.h index beac5e2c9..878ad80e6 100644 --- a/src/ModelAPI/ModelAPI_ShapeValidator.h +++ b/src/ModelAPI/ModelAPI_ShapeValidator.h @@ -23,7 +23,8 @@ public: /// \param theAttribute an attribute to check /// \param theArguments a filter parameters MODELAPI_EXPORT virtual bool isValid(const AttributePtr& theAttribute, - const std::list& theArguments) const; + const std::list& theArguments, + std::string& theError) const; }; #endif diff --git a/src/ParametersPlugin/ParametersPlugin_Validators.cpp b/src/ParametersPlugin/ParametersPlugin_Validators.cpp index 90ded6031..8242713d8 100644 --- a/src/ParametersPlugin/ParametersPlugin_Validators.cpp +++ b/src/ParametersPlugin/ParametersPlugin_Validators.cpp @@ -21,7 +21,8 @@ ParametersPlugin_VariableValidator::~ParametersPlugin_VariableValidator() } bool ParametersPlugin_VariableValidator::isValid(const AttributePtr& theAttribute, - const std::list& theArguments) const + const std::list& theArguments, + std::string& theError) const { AttributeStringPtr aStrAttr = std::dynamic_pointer_cast(theAttribute); bool result = isVariable(aStrAttr->value()) && isUnique(theAttribute, aStrAttr->value()); @@ -75,7 +76,8 @@ ParametersPlugin_ExpressionValidator::~ParametersPlugin_ExpressionValidator() } bool ParametersPlugin_ExpressionValidator::isValid(const AttributePtr& theAttribute, - const std::list& theArguments) const + const std::list& theArguments, + std::string& theError) const { FeaturePtr aFeature = std::dynamic_pointer_cast(theAttribute->owner()); ResultParameterPtr aParam = diff --git a/src/ParametersPlugin/ParametersPlugin_Validators.h b/src/ParametersPlugin/ParametersPlugin_Validators.h index 8b4626ead..b81b1c92c 100644 --- a/src/ParametersPlugin/ParametersPlugin_Validators.h +++ b/src/ParametersPlugin/ParametersPlugin_Validators.h @@ -25,7 +25,8 @@ class ParametersPlugin_VariableValidator : public ModelAPI_AttributeValidator //! \param theAttribute the checked attribute //! \param theArguments arguments of the attribute PARAMETERSPLUGIN_EXPORT virtual bool isValid(const AttributePtr& theAttribute, - const std::list& theArguments) const; + const std::list& theArguments, + std::string& theError) const; protected: PARAMETERSPLUGIN_EXPORT bool isVariable(const std::string& theString) const; @@ -43,7 +44,8 @@ class ParametersPlugin_ExpressionValidator: public ModelAPI_AttributeValidator //! \param theAttribute the checked attribute //! \param theArguments arguments of the attribute PARAMETERSPLUGIN_EXPORT virtual bool isValid(const AttributePtr& theAttribute, - const std::list& theArguments) const; + const std::list& theArguments, + std::string& theError) const; }; diff --git a/src/PartSet/PartSet_Validators.cpp b/src/PartSet/PartSet_Validators.cpp index 29afcf8d0..b6be3e0e3 100644 --- a/src/PartSet/PartSet_Validators.cpp +++ b/src/PartSet/PartSet_Validators.cpp @@ -184,7 +184,8 @@ bool PartSet_TangentSelection::isValid(const ModuleBase_ISelection* theSelection bool PartSet_DifferentObjectsValidator::isValid(const AttributePtr& theAttribute, - const std::list& theArguments) const + const std::list& theArguments, + std::string& theError) const { FeaturePtr aFeature = std::dynamic_pointer_cast(theAttribute->owner()); @@ -322,7 +323,8 @@ bool PartSet_DifferentObjectsValidator::featureHasReferences(const AttributePtr& } bool PartSet_SketchEntityValidator::isValid(const AttributePtr& theAttribute, - const std::list& theArguments) const + const std::list& theArguments, + std::string& theError) const { bool isSketchEntities = true; std::set anEntityKinds; @@ -373,8 +375,9 @@ bool PartSet_SketchEntityValidator::isValid(const AttributePtr& theAttribute, -bool PartSet_SameTypeAttrValidator::isValid( - const AttributePtr& theAttribute, const std::list& theArguments ) const +bool PartSet_SameTypeAttrValidator::isValid(const AttributePtr& theAttribute, + const std::list& theArguments, + std::string& theError ) const { // there is a check whether the feature contains a point and a linear edge or two point values std::string aParamA = theArguments.front(); @@ -399,8 +402,9 @@ bool PartSet_SameTypeAttrValidator::isValid( return false; } -bool PartSet_CoincidentAttr::isValid( - const AttributePtr& theAttribute, const std::list& theArguments ) const +bool PartSet_CoincidentAttr::isValid(const AttributePtr& theAttribute, + const std::list& theArguments, + std::string& theError) const { // there is a check whether the feature contains a point and a linear edge or two point values std::string aParamA = theArguments.front(); diff --git a/src/PartSet/PartSet_Validators.h b/src/PartSet/PartSet_Validators.h index 38d693db9..048680613 100644 --- a/src/PartSet/PartSet_Validators.h +++ b/src/PartSet/PartSet_Validators.h @@ -112,7 +112,8 @@ class PartSet_DifferentObjectsValidator : public ModelAPI_AttributeValidator //! \param theAttribute an attribute //! \param theArguments a list of arguments (names of attributes to check) virtual bool isValid(const AttributePtr& theAttribute, - const std::list& theArguments) const; + const std::list& theArguments, + std::string& theError) const; protected: //! Checks whethe other feature attributes has a reference to the given attribute @@ -132,7 +133,8 @@ class PartSet_SketchEntityValidator : public ModelAPI_AttributeValidator //! \param theAttribute an attribute //! \param theArguments a list of arguments (names of attributes to check) virtual bool isValid(const AttributePtr& theAttribute, - const std::list& theArguments) const; + const std::list& theArguments, + std::string& theError) const; }; /**\class PartSet_SameTypeAttrValidator @@ -148,7 +150,8 @@ class PartSet_SameTypeAttrValidator : public ModelAPI_AttributeValidator //! \param theAttribute the checked attribute //! \param theArguments arguments of the attribute virtual bool isValid(const AttributePtr& theAttribute, - const std::list& theArguments) const; + const std::list& theArguments, + std::string& theError) const; }; /**\class PartSet_CoincidentAttr @@ -163,7 +166,8 @@ class PartSet_CoincidentAttr : public ModelAPI_AttributeValidator //! \param theAttribute the checked attribute //! \param theArguments arguments of the attribute virtual bool isValid(const AttributePtr& theAttribute, - const std::list& theArguments) const; + const std::list& theArguments, + std::string& theError) const; }; diff --git a/src/SketchPlugin/SketchPlugin_ExternalValidator.cpp b/src/SketchPlugin/SketchPlugin_ExternalValidator.cpp index 7b8587188..3302e4c1e 100644 --- a/src/SketchPlugin/SketchPlugin_ExternalValidator.cpp +++ b/src/SketchPlugin/SketchPlugin_ExternalValidator.cpp @@ -13,7 +13,8 @@ #include bool SketchPlugin_ExternalValidator::isValid(const AttributePtr& theAttribute, - const std::list& theArguments) const + const std::list& theArguments, + std::string& theError) const { if (theArguments.size() != 1) return true; diff --git a/src/SketchPlugin/SketchPlugin_ExternalValidator.h b/src/SketchPlugin/SketchPlugin_ExternalValidator.h index 62d95bfe0..c2773d23a 100644 --- a/src/SketchPlugin/SketchPlugin_ExternalValidator.h +++ b/src/SketchPlugin/SketchPlugin_ExternalValidator.h @@ -24,7 +24,8 @@ public: /// \param theAttribute an attribute to check /// \param theArguments a filter parameters SKETCHPLUGIN_EXPORT virtual bool isValid(const AttributePtr& theAttribute, - const std::list& theArguments) const; + const std::list& theArguments, + std::string& theError) const; protected: /// returns true if the feature of the attribute is external diff --git a/src/SketchPlugin/SketchPlugin_Validators.cpp b/src/SketchPlugin/SketchPlugin_Validators.cpp index 2af4de2e1..b8b2fa53e 100644 --- a/src/SketchPlugin/SketchPlugin_Validators.cpp +++ b/src/SketchPlugin/SketchPlugin_Validators.cpp @@ -28,8 +28,9 @@ #include -bool SketchPlugin_DistanceAttrValidator::isValid( - const AttributePtr& theAttribute, const std::list& theArguments ) const +bool SketchPlugin_DistanceAttrValidator::isValid(const AttributePtr& theAttribute, + const std::list& theArguments, + std::string& theError) const { // there is a check whether the feature contains a point and a linear edge or two point values std::string aParamA = theArguments.front(); @@ -78,8 +79,9 @@ bool SketchPlugin_DistanceAttrValidator::isValid( return false; } -bool SketchPlugin_TangentAttrValidator::isValid( - const AttributePtr& theAttribute, const std::list& theArguments ) const +bool SketchPlugin_TangentAttrValidator::isValid(const AttributePtr& theAttribute, + const std::list& theArguments, + std::string& theError) const { // there is a check whether the feature contains a point and a linear edge or two point values std::string aParamA = theArguments.front(); @@ -115,8 +117,9 @@ bool SketchPlugin_TangentAttrValidator::isValid( return false; } -bool SketchPlugin_NotFixedValidator::isValid( - const AttributePtr& theAttribute, const std::list& theArguments) const +bool SketchPlugin_NotFixedValidator::isValid(const AttributePtr& theAttribute, + const std::list& theArguments, + std::string& theError) const { std::shared_ptr aFeature = std::dynamic_pointer_cast(theAttribute->owner()); @@ -144,8 +147,9 @@ bool SketchPlugin_NotFixedValidator::isValid( return true; } -bool SketchPlugin_EqualAttrValidator::isValid( - const AttributePtr& theAttribute, const std::list& theArguments ) const +bool SketchPlugin_EqualAttrValidator::isValid(const AttributePtr& theAttribute, + const std::list& theArguments, + std::string& theError) const { std::string aParamA = theArguments.front(); FeaturePtr aFeature = std::dynamic_pointer_cast(theAttribute->owner()); @@ -188,8 +192,9 @@ bool SketchPlugin_EqualAttrValidator::isValid( return true; } -bool SketchPlugin_MirrorAttrValidator::isValid( - const AttributePtr& theAttribute, const std::list& theArguments ) const +bool SketchPlugin_MirrorAttrValidator::isValid(const AttributePtr& theAttribute, + const std::list& theArguments, + std::string& theError) const { FeaturePtr aFeature = std::dynamic_pointer_cast(theAttribute->owner()); AttributeSelectionListPtr aSelAttr = @@ -212,8 +217,9 @@ bool SketchPlugin_MirrorAttrValidator::isValid( } -bool SketchPlugin_CoincidenceAttrValidator::isValid( - const AttributePtr& theAttribute, const std::list& theArguments ) const +bool SketchPlugin_CoincidenceAttrValidator::isValid(const AttributePtr& theAttribute, + const std::list& theArguments, + std::string& theError) const { // there is a check whether the feature contains a point and a linear edge or two point values std::string aParamA = theArguments.front(); @@ -255,8 +261,9 @@ bool SketchPlugin_CoincidenceAttrValidator::isValid( } -bool SketchPlugin_CopyValidator::isValid( - const AttributePtr& theAttribute, const std::list& theArguments ) const +bool SketchPlugin_CopyValidator::isValid(const AttributePtr& theAttribute, + const std::list& theArguments, + std::string& theError) const { FeaturePtr aFeature = std::dynamic_pointer_cast(theAttribute->owner()); AttributeSelectionListPtr aSelAttr = diff --git a/src/SketchPlugin/SketchPlugin_Validators.h b/src/SketchPlugin/SketchPlugin_Validators.h index 24d79c1b4..f9f45506f 100644 --- a/src/SketchPlugin/SketchPlugin_Validators.h +++ b/src/SketchPlugin/SketchPlugin_Validators.h @@ -23,7 +23,8 @@ class SketchPlugin_DistanceAttrValidator : public ModelAPI_AttributeValidator //! \param theAttribute the checked attribute //! \param theArguments arguments of the attribute virtual bool isValid(const AttributePtr& theAttribute, - const std::list& theArguments) const; + const std::list& theArguments, + std::string& theError) const; }; /**\class SketchPlugin_TangentAttrValidator @@ -39,7 +40,8 @@ class SketchPlugin_TangentAttrValidator : public ModelAPI_AttributeValidator //! \param theAttribute the checked attribute //! \param theArguments arguments of the attribute virtual bool isValid(const AttributePtr& theAttribute, - const std::list& theArguments) const; + const std::list& theArguments, + std::string& theError) const; }; @@ -56,7 +58,8 @@ class SketchPlugin_NotFixedValidator : public ModelAPI_AttributeValidator //! \param theAttribute the checked attribute //! \param theArguments arguments of the attribute virtual bool isValid(const AttributePtr& theAttribute, - const std::list& theArguments) const; + const std::list& theArguments, + std::string& theError) const; }; /**\class SketchPlugin_EqualAttrValidator @@ -72,7 +75,8 @@ class SketchPlugin_EqualAttrValidator : public ModelAPI_AttributeValidator //! \param theAttribute the checked attribute //! \param theArguments arguments of the attribute virtual bool isValid(const AttributePtr& theAttribute, - const std::list& theArguments) const; + const std::list& theArguments, + std::string& theError) const; }; /**\class SketchPlugin_MirrorAttrValidator @@ -88,7 +92,8 @@ class SketchPlugin_MirrorAttrValidator : public ModelAPI_AttributeValidator //! \param theAttribute the checked attribute //! \param theArguments arguments of the attribute (not used) virtual bool isValid(const AttributePtr& theAttribute, - const std::list& theArguments) const; + const std::list& theArguments, + std::string& theError) const; }; @@ -105,7 +110,8 @@ class SketchPlugin_CoincidenceAttrValidator : public ModelAPI_AttributeValidator //! \param theAttribute the checked attribute //! \param theArguments arguments of the attribute (not used) virtual bool isValid(const AttributePtr& theAttribute, - const std::list& theArguments) const; + const std::list& theArguments, + std::string& theError) const; }; @@ -123,7 +129,8 @@ class SketchPlugin_CopyValidator : public ModelAPI_AttributeValidator //! \param theAttribute the checked attribute //! \param theArguments arguments of the attribute (not used) virtual bool isValid(const AttributePtr& theAttribute, - const std::list& theArguments) const; + const std::list& theArguments, + std::string& theError) const; }; #endif