From: vsv Date: Thu, 5 Mar 2015 14:52:36 +0000 (+0300) Subject: Avoid duplication of validators X-Git-Tag: V_1.1.0~145^2~4 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=5f1d05c7cfb0765c1577944534678ac173f0bea2;p=modules%2Fshaper.git Avoid duplication of validators --- diff --git a/src/SketchPlugin/SketchPlugin_Plugin.cpp b/src/SketchPlugin/SketchPlugin_Plugin.cpp index aeaba71c8..88f062b69 100644 --- a/src/SketchPlugin/SketchPlugin_Plugin.cpp +++ b/src/SketchPlugin/SketchPlugin_Plugin.cpp @@ -46,8 +46,8 @@ SketchPlugin_Plugin::SketchPlugin_Plugin() ModelAPI_ValidatorsFactory* aFactory = aMgr->validators(); aFactory->registerValidator("SketchPlugin_DistanceAttr", new SketchPlugin_DistanceAttrValidator); - aFactory->registerValidator("SketchPlugin_DifferentObjects", - new SketchPlugin_DifferentObjectsValidator); + //aFactory->registerValidator("SketchPlugin_DifferentObjects", + // new SketchPlugin_DifferentObjectsValidator); aFactory->registerValidator("SketchPlugin_ResultPoint", new SketchPlugin_ResultPointValidator); aFactory->registerValidator("SketchPlugin_ResultLine", new SketchPlugin_ResultLineValidator); aFactory->registerValidator("SketchPlugin_ResultArc", new SketchPlugin_ResultArcValidator); diff --git a/src/SketchPlugin/SketchPlugin_Validators.cpp b/src/SketchPlugin/SketchPlugin_Validators.cpp index 29bdf3c27..1fcac300d 100644 --- a/src/SketchPlugin/SketchPlugin_Validators.cpp +++ b/src/SketchPlugin/SketchPlugin_Validators.cpp @@ -57,64 +57,64 @@ bool SketchPlugin_DistanceAttrValidator::isValid(const FeaturePtr& theFeature, return isValid(theAttribute, theArguments); } -bool SketchPlugin_DifferentObjectsValidator::isValid(const FeaturePtr& theFeature, - const std::list& theArguments, - const ObjectPtr& theObject) const -{ - std::list > anAttrs = - theFeature->data()->attributes(ModelAPI_AttributeRefAttr::type()); - std::list >::iterator anAttr = anAttrs.begin(); - for(; anAttr != anAttrs.end(); anAttr++) { - if (*anAttr) { - std::shared_ptr aRef = - std::dynamic_pointer_cast(*anAttr); - // check the object is already presented - if (aRef->isObject() && aRef->object() == theObject) - return false; - } - } - return true; -} +//bool SketchPlugin_DifferentObjectsValidator::isValid(const FeaturePtr& theFeature, +// const std::list& theArguments, +// const ObjectPtr& theObject) const +//{ +// std::list > anAttrs = +// theFeature->data()->attributes(ModelAPI_AttributeRefAttr::type()); +// std::list >::iterator anAttr = anAttrs.begin(); +// for(; anAttr != anAttrs.end(); anAttr++) { +// if (*anAttr) { +// std::shared_ptr aRef = +// std::dynamic_pointer_cast(*anAttr); +// // check the object is already presented +// if (aRef->isObject() && aRef->object() == theObject) +// return false; +// } +// } +// return true; +//} -bool SketchPlugin_DifferentObjectsValidator::isValid( - const AttributePtr& theAttribute, const std::list& theArguments ) const -{ - std::shared_ptr anOrigAttr = - std::dynamic_pointer_cast(theAttribute); - if (anOrigAttr && anOrigAttr->isObject()) { - const ObjectPtr& anObj = theAttribute->owner(); - const FeaturePtr aFeature = std::dynamic_pointer_cast(anObj); +//bool SketchPlugin_DifferentObjectsValidator::isValid( +// const AttributePtr& theAttribute, const std::list& theArguments ) const +//{ +// std::shared_ptr anOrigAttr = +// std::dynamic_pointer_cast(theAttribute); +// if (anOrigAttr && anOrigAttr->isObject()) { +// const ObjectPtr& anObj = theAttribute->owner(); +// const FeaturePtr aFeature = std::dynamic_pointer_cast(anObj); +// +// std::list > anAttrs = +// aFeature->data()->attributes(ModelAPI_AttributeRefAttr::type()); +// std::list >::iterator anAttr = anAttrs.begin(); +// for(; anAttr != anAttrs.end(); anAttr++) { +// if (*anAttr && *anAttr != theAttribute) { +// std::shared_ptr aRef = +// std::dynamic_pointer_cast(*anAttr); +// // check the object is already presented +// if (aRef->isObject() && aRef->object() == anOrigAttr->object()) +// return false; +// } +// } +// } +// return true; +//} - std::list > anAttrs = - aFeature->data()->attributes(ModelAPI_AttributeRefAttr::type()); - std::list >::iterator anAttr = anAttrs.begin(); - for(; anAttr != anAttrs.end(); anAttr++) { - if (*anAttr && *anAttr != theAttribute) { - std::shared_ptr aRef = - std::dynamic_pointer_cast(*anAttr); - // check the object is already presented - if (aRef->isObject() && aRef->object() == anOrigAttr->object()) - return false; - } - } - } - return true; -} - -bool SketchPlugin_DifferentObjectsValidator::isValid(const FeaturePtr& theFeature, - const std::list& theArguments, const AttributePtr& theAttribute) const -{ - std::list > anAttrs = - theFeature->data()->attributes(ModelAPI_AttributeRefAttr::type()); - std::list >::iterator anAttr = anAttrs.begin(); - for(; anAttr != anAttrs.end(); anAttr++) { - if (*anAttr) { - std::shared_ptr aRef = - std::dynamic_pointer_cast(*anAttr); - // check the object is already presented - if (!aRef->isObject() && aRef->attr() == theAttribute) - return false; - } - } - return true; -} +//bool SketchPlugin_DifferentObjectsValidator::isValid(const FeaturePtr& theFeature, +// const std::list& theArguments, const AttributePtr& theAttribute) const +//{ +// std::list > anAttrs = +// theFeature->data()->attributes(ModelAPI_AttributeRefAttr::type()); +// std::list >::iterator anAttr = anAttrs.begin(); +// for(; anAttr != anAttrs.end(); anAttr++) { +// if (*anAttr) { +// std::shared_ptr aRef = +// std::dynamic_pointer_cast(*anAttr); +// // check the object is already presented +// if (!aRef->isObject() && aRef->attr() == theAttribute) +// return false; +// } +// } +// return true; +//} diff --git a/src/SketchPlugin/SketchPlugin_Validators.h b/src/SketchPlugin/SketchPlugin_Validators.h index d6368a1eb..61553fea8 100644 --- a/src/SketchPlugin/SketchPlugin_Validators.h +++ b/src/SketchPlugin/SketchPlugin_Validators.h @@ -39,20 +39,21 @@ class SketchPlugin_DistanceAttrValidator : public ModelAPI_RefAttrValidator * Check that there is no same object was already selected in the feature. * For an example: to avoid perpendicularity on line and the same line. */ -class SketchPlugin_DifferentObjectsValidator : public ModelAPI_RefAttrValidator -{ - public: - //! returns true if attribute is valid - //! \param theAttribute the checked attribute - //! \param theArguments arguments of the attribute - virtual bool isValid( - const AttributePtr& theAttribute, const std::list& theArguments) const; - //! Returns true if object is good for the feature attribute - virtual bool isValid(const FeaturePtr& theFeature, const std::list& theArguments, - const ObjectPtr& theObject) const; - //! Returns true if the attribute is good for the feature attribute - virtual bool isValid(const FeaturePtr& theFeature, const std::list& theArguments, - const AttributePtr& theAttribute) const; -}; +// Use PartSet_DifferentObjectsValidator +//class SketchPlugin_DifferentObjectsValidator : public ModelAPI_RefAttrValidator +//{ +// public: +// //! returns true if attribute is valid +// //! \param theAttribute the checked attribute +// //! \param theArguments arguments of the attribute +// virtual bool isValid( +// const AttributePtr& theAttribute, const std::list& theArguments) const; +// //! Returns true if object is good for the feature attribute +// virtual bool isValid(const FeaturePtr& theFeature, const std::list& theArguments, +// const ObjectPtr& theObject) const; +// //! Returns true if the attribute is good for the feature attribute +// virtual bool isValid(const FeaturePtr& theFeature, const std::list& theArguments, +// const AttributePtr& theAttribute) const; +//}; #endif diff --git a/src/SketchPlugin/plugin-Sketch.xml b/src/SketchPlugin/plugin-Sketch.xml index ff6c30559..9eb94b38f 100644 --- a/src/SketchPlugin/plugin-Sketch.xml +++ b/src/SketchPlugin/plugin-Sketch.xml @@ -60,7 +60,7 @@ label="Last object" tooltip="Select point, line end point, line, center of circle or arc." shape_types="edge vertex"> - + @@ -112,7 +112,7 @@ - + @@ -131,7 +131,7 @@ - +